コード例 #1
0
    def create(self, group_name, **kwargs):
        """Creates a ServerGroup.

        Args:
            group_name (str): Name for the new group

        Keyword Args:
            firewall_policy_id (str): ID of firewall policy to be assigned to \
            the group (deprecated- use linux_firewall_policy_id)
            linux_firewall_policy_id (str): ID of linux firewall policy to \
            associate with the new group
            windows_firewall_policy_id (str): ID of Windows firewall policy \
            to associate with the new group
            policy_ids (list): List of Linux configuration policy IDs
            windows_policy_ids (list): List of Windows configuration policy IDs
            fim_policy_ids (list): List of Linux FIM policies
            linux_fim_policy_ids (list): List of Linux FIM policies
            windows_fim_policy_ids (list): List of Windows FIM policies
            lids_policy_ids (list): List of LIDS policy IDs
            tag (str): Server group tag-used for auto-assignment of group.
            server_events_policy (str): Special events policy IDs
            alert_profiles (list): List of alert profile IDs

        Returns:
            str: ID of newly-created group.

        """

        endpoint = "/v1/groups"
        group_data = {"name": group_name, "policy_ids": [], "tag": None}
        body = {"group": utility.merge_dicts(group_data, kwargs)}
        request = HttpHelper(self.session)
        response = request.post(endpoint, body)
        return response["group"]["id"]
コード例 #2
0
    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
コード例 #3
0
    def create(self, group_name, **kwargs):
        """Creates a ServerGroup.

        Args:
            group_name (str): Name for the new group

        Keyword Args:
            firewall_policy_id (str): ID of firewall policy to be assigned to \
            the group (deprecated- use linux_firewall_policy_id)
            linux_firewall_policy_id (str): ID of linux firewall policy to \
            associate with the new group
            windows_firewall_policy_id (str): ID of Windows firewall policy \
            to associate with the new group
            policy_ids (list): List of Linux configuration policy IDs
            windows_policy_ids (list): List of Windows configuration policy IDs
            fim_policy_ids (list): List of Linux FIM policies
            linux_fim_policy_ids (list): List of Linux FIM policies
            windows_fim_policy_ids (list): List of Windows FIM policies
            linux_lids_policy_ids (list): List of Linux LIDS policy IDs
            windows_lids_policy_ids (list): List of Windows LIDS policy IDs
            tag (str): Server group tag-used for auto-assignment of group.
            server_events_policy (str): Special events policy IDs
            alert_profiles (list): List of alert profile IDs

        Returns:
            str: ID of newly-created group.

        """

        endpoint = "/v1/groups"
        group_data = {"name": group_name, "policy_ids": [], "tag": None}
        try:
            sanity.validate_servergroup_create(kwargs)
        except TypeError as exc:
            raise CloudPassageValidation(exc)
        body = {"group": utility.merge_dicts(group_data, kwargs)}
        request = HttpHelper(self.session)
        response = request.post(endpoint, body)
        return response["group"]["id"]
コード例 #4
0
    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