Beispiel #1
0
    def create_association_set(self, association, input_data=None,
                               args=None, wait_time=3, retries=10):
        """Creates a new association set.

        """
        association_id = None
        resource_type = get_resource_type(association)
        if resource_type == ASSOCIATION_PATH:
            association_id = get_association_id(association)
            check_resource(association_id,
                           query_string=TINY_RESOURCE,
                           wait_time=wait_time, retries=retries,
                           raise_on_error=True, api=self)
        else:
            raise Exception("A association id is needed to create an"
                            " association set. %s found." % resource_type)

        if input_data is None:
            input_data = {}
        create_args = {}
        if args is not None:
            create_args.update(args)
        create_args.update({
            "input_data": input_data})
        create_args.update({
            "association": association_id})

        body = json.dumps(create_args)
        return self._create(self.association_set_url, body,
                            verify=self.verify)
Beispiel #2
0
    def delete_association(self, association):
        """Deletes an association.

        """
        check_resource_type(association, ASSOCIATION_PATH, message="An association id is needed.")
        association_id = get_association_id(association)
        if association_id:
            return self._delete("%s%s" % (self.url, association_id))
    def delete_association(self, association):
        """Deletes an association.

        """
        check_resource_type(association, ASSOCIATION_PATH,
                            message="An association id is needed.")
        association_id = get_association_id(association)
        if association_id:
            return self._delete("%s%s" % (self.url, association_id))
Beispiel #4
0
    def update_association(self, association, changes):
        """Updates a association.

        """
        check_resource_type(association, ASSOCIATION_PATH, message="An association id is needed.")
        association_id = get_association_id(association)
        if association_id:
            body = json.dumps(changes)
            return self._update("%s%s" % (self.url, association_id), body)
    def update_association(self, association, changes):
        """Updates a association.

        """
        check_resource_type(association, ASSOCIATION_PATH,
                            message="An association id is needed.")
        association_id = get_association_id(association)
        if association_id:
            body = json.dumps(changes)
            return self._update("%s%s" % (self.url, association_id), body)
Beispiel #6
0
    def get_association(self, association, query_string=""):
        """Retrieves an association.

           The association parameter should be a string containing the
           association id or the dict returned by create_association.
           As association is an evolving object that is processed
           until it reaches the FINISHED or FAULTY state, the function will
           return a dict that encloses the association values and state info
           available at the time it is called.
        """
        check_resource_type(association, ASSOCIATION_PATH, message="An association id is needed.")
        association_id = get_association_id(association)
        if association_id:
            return self._get("%s%s" % (self.url, association_id), query_string=query_string)
    def get_association(self, association, query_string=''):
        """Retrieves an association.

           The association parameter should be a string containing the
           association id or the dict returned by create_association.
           As association is an evolving object that is processed
           until it reaches the FINISHED or FAULTY state, the function will
           return a dict that encloses the association values and state info
           available at the time it is called.
        """
        check_resource_type(association, ASSOCIATION_PATH,
                            message="An association id is needed.")
        association_id = get_association_id(association)
        if association_id:
            return self._get("%s%s" % (self.url, association_id),
                             query_string=query_string)