Exemplo n.º 1
0
    def create(self, policy_body):
        """Creates a policy from JSON document.

        Returns the ID of the new policy
        """

        request = HttpHelper(self.session)
        request_body = utility.policy_to_dict(policy_body)
        return request.post(self.endpoint(), request_body)["id"]
    def update(self, policy_body):
        """Update a policy.  Success returns None"""

        request = HttpHelper(self.session)
        request_body = utility.policy_to_dict(policy_body)
        policy_id = request_body[self.policy_key()]["id"]
        sanity.validate_object_id(policy_id)
        update_endpoint = "%s/%s" % (self.endpoint(), policy_id)
        request.put(update_endpoint, request_body)
        return None
    def create(self, policy_body):
        """Creates a policy from JSON document.

        Returns the ID of the new policy
        """

        request = HttpHelper(self.session)
        request_body = utility.policy_to_dict(policy_body)
        return request.post(self.endpoint(),
                            request_body)["id"]
    def update(self, policy_body):
        """Update a policy.  Success returns None"""

        request = HttpHelper(self.session)
        request_body = utility.policy_to_dict(policy_body)
        policy_id = request_body[self.policy_key()]["id"]
        sanity.validate_object_id(policy_id)
        update_endpoint = "%s/%s" % (self.endpoint(), policy_id)
        request.put(update_endpoint, request_body)
        return None