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 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
Esempio n. 3
0
    def retire(self, server_id):
        """This method retires a server

        Args:
            server_id (str): ID of server to be retired

        Returns:
            True if successful, throws exception on failure

        """

        sanity.validate_object_id(server_id)
        endpoint = "/v1/servers/%s" % server_id
        body = {"server": {"retire": True}}
        request = HttpHelper(self.session)
        request.put(endpoint, body)
        # Exceptions fire deeper if this fails.  Otherwise, return True.
        return True
    def assign_group(self, server_id, group_id):
        """Moves server to another group.

        Args:
            server_id (str): Target server's ID
            group_id (str): ID of group to move server to.

        Returns:
            True if successful, throws exceptions if it fails.

        """

        sanity.validate_object_id(server_id)
        endpoint = "/v1/servers/%s" % server_id
        request_body = {"server": {"group_id": group_id}}
        request = HttpHelper(self.session)
        request.put(endpoint, request_body)
        # Exception will throw if the prior line fails.
        return True
    def retire(self, server_id):
        """This method retires a server

        Args:
            server_id (str): ID of server to be retired

        Returns:
            True if successful, throws exception on failure

        """

        sanity.validate_object_id(server_id)
        endpoint = "/v1/servers/%s" % server_id
        body = {"server":
                {"retire": True}}
        request = HttpHelper(self.session)
        request.put(endpoint, body)
        # Exceptions fire deeper if this fails.  Otherwise, return True.
        return True
Esempio n. 6
0
    def assign_group(self, server_id, group_id):
        """Moves server to another group.

        Args:
            server_id (str): Target server's ID
            group_id (str): ID of group to move server to.

        Returns:
            True if successful, throws exceptions if it fails.

        """

        sanity.validate_object_id(server_id)
        endpoint = "/v1/servers/%s" % server_id
        request_body = {"server": {"group_id": group_id}}
        request = HttpHelper(self.session)
        request.put(endpoint, request_body)
        # Exception will throw if the prior line fails.
        return True
    def update(self, fim_policy_id, fim_baseline_id, server_id):
        """Update a FIM policy baseline.

        Args:
            fim_policy_id (str): ID of fim policy
            fim_baseline_id (str): ID of baseline to be updated
            server_id (str): ID of server to use when generating new baseline

        Returns:
            None if successful, exceptions throw otherwise.

        """

        sanity.validate_object_id([fim_policy_id, fim_baseline_id, server_id])
        request = HttpHelper(self.session)
        endpoint = "/v1/fim_policies/%s/baselines/%s" % (fim_policy_id,
                                                         fim_baseline_id)
        request_body = {"baseline": {"server_id": server_id}}
        request.put(endpoint, request_body)
        return None
Esempio n. 8
0
    def update(self, fim_policy_id, fim_baseline_id, server_id):
        """Update a FIM policy baseline.

        Args:
            fim_policy_id (str): ID of fim policy
            fim_baseline_id (str): ID of baseline to be updated
            server_id (str): ID of server to use when generating new baseline

        Returns:
            None if successful, exceptions throw otherwise.

        """

        sanity.validate_object_id([fim_policy_id, fim_baseline_id, server_id])
        request = HttpHelper(self.session)
        endpoint = "/v1/fim_policies/%s/baselines/%s" % (fim_policy_id,
                                                         fim_baseline_id)
        request_body = {"baseline": {"server_id": server_id}}
        request.put(endpoint, request_body)
        return None
Esempio n. 9
0
    def update(self, firewall_policy_id, firewall_rule_id, firewall_rule_body):
        """Update a firewall policy rule.

        Args:
            firewall_policy_id (str): ID of firewall policy containing the\
            rule to be modified.
            firewall_rule_id (str): ID of firewall policy rule to modify.
            firewall_rule_body (dict or str): String- or dictionary-type \
            object containing the fields to be updated within the firewall \
            rule.

        Returns:
            None if successful.  Errors will throw exceptions.

        Example:

        ::

          {
            "firewall_rule" : {
              "chain": "INPUT",
              "active": true,
              "firewall_interface": "7b881ca072b1012ec681404096c01709",
              "firewall_service": "7b6409a072b1012ec681404096c01709",
              "connection_states": "NEW, ESTABLISHED",
              "action": "ACCEPT",
              "log": true,
              "log_prefix": "East-3 input-accept",
              "comment": "All servers in group East-3 must include this rule",
              "position": 4
              }
          }

        """

        sanity.validate_object_id([firewall_policy_id, firewall_rule_id])
        request = HttpHelper(self.session)
        endpoint = ("/v1/firewall_policies/%s/firewall_rules/%s" %
                    (firewall_policy_id, firewall_rule_id))
        request.put(endpoint, firewall_rule_body)
        return None
Esempio n. 10
0
    def resolve(self, issue_id):
        """Resolves an Issue.

        Args: issue_id (str): ID of issue to be altered

        Returns:
            True if successful, throws exception otherwise.

        """

        sanity.validate_object_id(issue_id)
        endpoint = "/v1/issues/%s" % issue_id
        response = None
        body = {"status": "resolved"}
        request = HttpHelper(self.session)
        response = request.put(endpoint, body)
        return response
    def update(self, group_id, **kwargs):
        """Updates a ServerGroup.

        Args:
            group_id (str): ID of group to be altered

        Keyword Args:
            name (str): Override name for group
            linux_firewall_policy_id (str): Override Linux firewall policy ID.
            windows_firewall_policy_id (str): Override Windows firewall \
            policy ID.
            policy_ids (list): Override Linux configuration policies
            windows_policy_ids (list): Override Windows firewall policies
            linux_fim_policy_ids (list): Override Linux firewall policies
            windows_fim_policy_ids (list): Override Windows FIM policies
            lids_policy_ids (list): Override LIDS policy IDs
            tag (str): Override server group tag
            special_events_policy (str): Override server events policy.  Note\
            the difference in naming from the \
            :meth:`cloudpassage.ServerGroup.create()` \
            method
            alert_profiles (list): List of alert profiles

        Returns:
            True if successful, throws exception otherwise.

        """

        sanity.validate_object_id(group_id)
        endpoint = "/v1/groups/%s" % group_id
        response = None
        group_data = {}
        try:
            sanity.validate_servergroup_update(kwargs)
        except TypeError as exc:
            raise CloudPassageValidation(exc)
        body = {"group": utility.merge_dicts(group_data, kwargs)}
        request = HttpHelper(self.session)
        response = request.put(endpoint, body)
        return response
    def update(self, group_id, **kwargs):
        """Updates a ServerGroup.

        Args:
            group_id (str): ID of group to be altered

        Keyword Args:
            name (str): Override name for group
            linux_firewall_policy_id (str): Override Linux firewall policy ID.
            windows_firewall_policy_id (str): Override Windows firewall \
            policy ID.
            policy_ids (list): Override Linux configuration policies
            windows_policy_ids (list): Override Windows firewall policies
            linux_fim_policy_ids (list): Override Linux firewall policies
            windows_fim_policy_ids (list): Override Windows FIM policies
            lids_policy_ids (list): Override LIDS policy IDs
            tag (str): Override server group tag
            special_events_policy (str): Override server events policy.  Note\
            the difference in naming from the \
            :meth:`cloudpassage.ServerGroup.create()` \
            method
            alert_profiles (list): List of alert profiles

        Returns:
            True if successful, throws exception otherwise.

        """

        sanity.validate_object_id(group_id)
        endpoint = "/v1/groups/%s" % group_id
        response = None
        group_data = {}
        body = {"group": utility.merge_dicts(group_data, kwargs)}
        request = HttpHelper(self.session)
        response = request.put(endpoint, body)
        return response