Example #1
0
    def delete_users(self, body=None):
        """Does a DELETE request to /public/users.

        Only users from the same domain can be deleted by a single request.
        If the Cohesity user was created for an Active Directory user, the
        referenced
        principal user on the Active Directory domain is NOT deleted.
        Only the user on the Cohesity Cluster is deleted.
        Returns Success if the specified users are deleted.

        Args:
            body (UserDeleteParameters, optional): Request to delete one or
                more users on the Cohesity Cluster.

        Returns:
            void: Response from the API. No Content

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('delete_users called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for delete_users.')
            _url_path = '/public/users'
            _query_builder = self.config.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for delete_users.')
            _headers = {'content-type': 'application/json; charset=utf-8'}

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for delete_users.')
            _request = self.http_client.delete(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request, self.config)
            _context = self.execute_request(_request, name='delete_users')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for delete_users.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
Example #2
0
    def delete_scheduler_jobs(self, ids=None):
        """Does a DELETE request to /public/scheduler.

        Specify a list of email report schedule job ids to unschedule and
        delete.

        Args:
            ids (list<object, int|long>): Array of ids

        Returns:
            void: Response from the API. No Content

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('delete_scheduler_jobs called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for delete_scheduler_jobs.')
            _url_path = '/public/scheduler'
            _query_builder = self.config.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for delete_scheduler_jobs.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for delete_scheduler_jobs.')
            _request = self.http_client.delete(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(ids))
            AuthManager.apply(_request, self.config)
            _context = self.execute_request(_request,
                                            name='delete_scheduler_jobs')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for delete_scheduler_jobs.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
Example #3
0
    def update_user_preferences(self,
                                body=None):
        """Does a PUT request to /public/sessionUser/preferences.

        Returns the updated user preferences.

        Args:
            body (list of UserPreferencesProtoUserPreferencesPreference,
                optional): Request to create or update User Preferences

        Returns:
            list of UserPreferencesProtoUserPreferencesPreference: Response
                from the API. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('update_user_preferences called.')
    
            # Prepare query URL
            self.logger.info('Preparing query URL for update_user_preferences.')
            _url_path = '/public/sessionUser/preferences'
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)
    
            # Prepare headers
            self.logger.info('Preparing headers for update_user_preferences.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }
    
            # Prepare and execute request
            self.logger.info('Preparing and executing request for update_user_preferences.')
            _request = self.http_client.put(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request)
            _context = self.execute_request(_request, name = 'update_user_preferences')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for update_user_preferences.')
            if _context.response.status_code == 0:
                raise ErrorErrorException('Error', _context)
            self.validate_response(_context)
    
            # Return appropriate type
            return APIHelper.json_deserialize(_context.response.raw_body, UserPreferencesProtoUserPreferencesPreference.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info = True)
Example #4
0
    def delete_unprotect_object(self, body=None):
        """Does a DELETE request to /public/protectionObjects.

        Unprotect a Protected Object.

        Args:
            body (UnprotectObjectParams, optional): TODO: type description
                here. Example:

        Returns:
            void: Response from the API. No Content

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('delete_unprotect_object called.')

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for delete_unprotect_object.')
            _url_path = '/public/protectionObjects'
            _query_builder = self.config.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for delete_unprotect_object.')
            _headers = {'content-type': 'application/json; charset=utf-8'}

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for delete_unprotect_object.')
            _request = self.http_client.delete(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request, self.config)
            _context = self.execute_request(_request,
                                            name='delete_unprotect_object')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info(
                'Validating response for delete_unprotect_object.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
    def update_antivirus_service_group_state(self,
                                             body=None):
        """Does a PUT request to /public/antivirusGroups/states.

        Returns the state of an antivirus service group upon completion.

        Args:
            body (AntivirusServiceGroupStateParams, optional): TODO: type
                description here. Example:

        Returns:
            AntivirusServiceGroupStateParams: Response from the API. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('update_antivirus_service_group_state called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for update_antivirus_service_group_state.')
            _url_path = '/public/antivirusGroups/states'
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for update_antivirus_service_group_state.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info('Preparing and executing request for update_antivirus_service_group_state.')
            _request = self.http_client.put(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request)
            _context = self.execute_request(_request, name = 'update_antivirus_service_group_state')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for update_antivirus_service_group_state.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(_context.response.raw_body, AntivirusServiceGroupStateParams.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info = True)
            raise
Example #6
0
    def update_resolution(self, id, body):
        """Does a PUT request to /public/alertResolutions/{id}.

        Apply an existing Alert Resolution to one or more additional Alerts.
        Mark those additional Alerts as resolved.

        Args:
            id (long|int): Unique id of the Alert Resolution to return.
            body (UpdateResolutionParams): Request to apply an existing
                resolution to the specified Alerts.

        Returns:
            AlertResolution: Response from the API. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('update_resolution called.')

            # Validate required parameters
            self.logger.info(
                'Validating required parameters for update_resolution.')
            self.validate_parameters(id=id, body=body)

            # Prepare query URL
            self.logger.info('Preparing query URL for update_resolution.')
            _url_path = '/public/alertResolutions/{id}'
            _url_path = APIHelper.append_url_with_template_parameters(
                _url_path, {'id': id})
            _query_builder = self.config.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for update_resolution.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for update_resolution.')
            _request = self.http_client.put(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request, self.config)
            _context = self.execute_request(_request, name='update_resolution')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for update_resolution.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(_context.response.raw_body,
                                              AlertResolution.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
    def update_protection_policy(self, body, id):
        """Does a PUT request to /public/protectionPolicies/{id}.

        Returns the updated Protection Policy.

        Args:
            body (ProtectionPolicyRequest): Request to update a Protection
                Policy.
            id (string): Specifies a unique id of the Protection Policy to
                return.

        Returns:
            ProtectionPolicy: Response from the API. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('update_protection_policy called.')

            # Validate required parameters
            self.logger.info(
                'Validating required parameters for update_protection_policy.')
            self.validate_parameters(body=body, id=id)

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for update_protection_policy.')
            _url_path = '/public/protectionPolicies/{id}'
            _url_path = APIHelper.append_url_with_template_parameters(
                _url_path, {'id': id})
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for update_protection_policy.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for update_protection_policy.'
            )
            _request = self.http_client.put(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request)
            _context = self.execute_request(_request,
                                            name='update_protection_policy')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info(
                'Validating response for update_protection_policy.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(_context.response.raw_body,
                                              ProtectionPolicy.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
    def update_upgrade_cluster(self, body):
        """Does a PUT request to /public/clusters/software.

        Sends a request to upgrade the software version of a Cohesity Cluster
        and returns a message specifying the result. Before using this, you
        need to
        use the /public/packages endpoint to upload a new package to the
        Cluster.

        Args:
            body (UpgradeClusterParameters): TODO: type description here.
                Example:

        Returns:
            UpgradeClusterResult: Response from the API. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('update_upgrade_cluster called.')

            # Validate required parameters
            self.logger.info(
                'Validating required parameters for update_upgrade_cluster.')
            self.validate_parameters(body=body)

            # Prepare query URL
            self.logger.info('Preparing query URL for update_upgrade_cluster.')
            _url_path = '/public/clusters/software'
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for update_upgrade_cluster.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for update_upgrade_cluster.')
            _request = self.http_client.put(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request)
            _context = self.execute_request(_request,
                                            name='update_upgrade_cluster')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for update_upgrade_cluster.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(
                _context.response.raw_body,
                UpgradeClusterResult.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
    def put_io_preferential_tier(self, body):
        """Does a PUT request to /public/clusters/ioPreferentialTier.

        Update the IO preferential tiers of the cluster.

        Args:
            body (IoPreferentialTier): TODO: type description here. Example:

        Returns:
            IoPreferentialTier: Response from the API. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('put_io_preferential_tier called.')

            # Validate required parameters
            self.logger.info(
                'Validating required parameters for put_io_preferential_tier.')
            self.validate_parameters(body=body)

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for put_io_preferential_tier.')
            _url_path = '/public/clusters/ioPreferentialTier'
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for put_io_preferential_tier.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for put_io_preferential_tier.'
            )
            _request = self.http_client.put(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request)
            _context = self.execute_request(_request,
                                            name='put_io_preferential_tier')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info(
                'Validating response for put_io_preferential_tier.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException(Error, _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(
                _context.response.raw_body, IoPreferentialTier.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
Example #10
0
    def update_idp(self, id, body=None):
        """Does a PUT request to /public/idps/{id}.

        Returns the updated IdP configuration.

        Args:
            id (long|int): Specifies the Id assigned for the IdP Service by
                the Cluster.
            body (UpdateIdpConfigurationRequest, optional): Request to update
                an Idp Configuration.

        Returns:
            IdpServiceConfiguration: Response from the API. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('update_idp called.')

            # Validate required parameters
            self.logger.info('Validating required parameters for update_idp.')
            self.validate_parameters(id=id)

            # Prepare query URL
            self.logger.info('Preparing query URL for update_idp.')
            _url_path = '/public/idps/{id}'
            _url_path = APIHelper.append_url_with_template_parameters(
                _url_path, {'id': id})
            _query_builder = self.config.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for update_idp.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info('Preparing and executing request for update_idp.')
            _request = self.http_client.put(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request, self.config)
            _context = self.execute_request(_request, name='update_idp')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for update_idp.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(
                _context.response.raw_body,
                IdpServiceConfiguration.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
    def create_reset_s_3_secret_key(self, body=None):
        """Does a POST request to /public/users/s3SecretKey.

        Returns the new key that was generated.

        Args:
            body (ResetS3SecretKeyParameters, optional): Request to reset the
                S3 secret access key for the specified Cohesity user.

        Returns:
            NewS3SecretAccessKey: Response from the API. New S3 Secret Access
                Key.

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('create_reset_s_3_secret_key called.')

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for create_reset_s_3_secret_key.')
            _url_path = '/public/users/s3SecretKey'
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info(
                'Preparing headers for create_reset_s_3_secret_key.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for create_reset_s_3_secret_key.'
            )
            _request = self.http_client.post(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request)
            _context = self.execute_request(_request,
                                            name='create_reset_s_3_secret_key')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info(
                'Validating response for create_reset_s_3_secret_key.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(
                _context.response.raw_body,
                NewS3SecretAccessKey.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
Example #12
0
    def create_tenant(self, body=None):
        """Does a POST request to /public/tenants.

        A Vault can provide an additional Cloud Tier where cold data of the
        Cohesity Cluster is stored in the Cloud.
        A Vault can also provide archive storage for backup data.
        This archive data is stored on Tapes and in Cloud Vaults.

        Args:
            body (TenantCreateParameters, optional): Request to add or create
                a new tenant.

        Returns:
            Tenant: Response from the API. Create Tenants response

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('create_tenant called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for create_tenant.')
            _url_path = '/public/tenants'
            _query_builder = self.config.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for create_tenant.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for create_tenant.')
            _request = self.http_client.post(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request, self.config)
            _context = self.execute_request(_request, name='create_tenant')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for create_tenant.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(_context.response.raw_body,
                                              Tenant.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
Example #13
0
    def update_role(self, name, body=None):
        """Does a PUT request to /public/roles/{name}.

        For example, you could update the privileges assigned to a Role.
        Returns the updated role.

        Args:
            name (string): Specifies the name of the role to update.
            body (RoleUpdateParameters, optional): Request to update a custom
                role.

        Returns:
            Role: Response from the API. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('update_role called.')

            # Validate required parameters
            self.logger.info('Validating required parameters for update_role.')
            self.validate_parameters(name=name)

            # Prepare query URL
            self.logger.info('Preparing query URL for update_role.')
            _url_path = '/public/roles/{name}'
            _url_path = APIHelper.append_url_with_template_parameters(
                _url_path, {'name': name})
            _query_builder = self.config.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for update_role.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for update_role.')
            _request = self.http_client.put(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request, self.config)
            _context = self.execute_request(_request, name='update_role')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for update_role.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(_context.response.raw_body,
                                              Role.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
Example #14
0
    def create_role(self, body=None):
        """Does a POST request to /public/roles.

        Returns the new custom role that was created.
        A custom role is a user-defined role that is created using the REST
        API,
        the Cohesity Cluster or the CLI.

        Args:
            body (RoleCreateParameters, optional): Request to create a new
                custom Role.

        Returns:
            Role: Response from the API. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('create_role called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for create_role.')
            _url_path = '/public/roles'
            _query_builder = self.config.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for create_role.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for create_role.')
            _request = self.http_client.post(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request, self.config)
            _context = self.execute_request(_request, name='create_role')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for create_role.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(_context.response.raw_body,
                                              Role.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
    def delete_vault(self, id, body):
        """Does a DELETE request to /public/vaults/{id}.

        Returns delete status upon completion.
        A Vault is equivalent to an External Target in the Cohesity Dashboard.

        Args:
            id (long|int): Specifies a unique id of the Vault.
            body (VaultDeleteParams): Request to delete vault.

        Returns:
            void: Response from the API. No Content

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('delete_vault called.')

            # Validate required parameters
            self.logger.info(
                'Validating required parameters for delete_vault.')
            self.validate_parameters(id=id, body=body)

            # Prepare query URL
            self.logger.info('Preparing query URL for delete_vault.')
            _url_path = '/public/vaults/{id}'
            _url_path = APIHelper.append_url_with_template_parameters(
                _url_path, {'id': id})
            _query_builder = self.config.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for create_vault.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for delete_vault.')
            _request = self.http_client.delete(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request, self.config)
            _context = self.execute_request(_request, name='delete_vault')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for delete_vault.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
    def delete_infected_files(self, body):
        """Does a DELETE request to /public/infectedFiles.

        Returns the list of delete succeeded and delete failed infected
        files.

        Args:
            body (DeleteInfectedFileParams): Request to delete the list of
                infected files.

        Returns:
            DeleteInfectedFileResponse: Response from the API. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('delete_infected_files called.')

            # Validate required parameters
            self.logger.info(
                'Validating required parameters for delete_infected_files.')
            self.validate_parameters(body=body)

            # Prepare query URL
            self.logger.info('Preparing query URL for delete_infected_files.')
            _url_path = '/public/infectedFiles'
            _query_builder = self.config.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for delete_infected_files.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for delete_infected_files.')
            _request = self.http_client.delete(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request, self.config)
            _context = self.execute_request(_request,
                                            name='delete_infected_files')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for delete_infected_files.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(
                _context.response.raw_body,
                DeleteInfectedFileResponse.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
    def create_antivirus_service_group(self, body):
        """Does a POST request to /public/antivirusGroups.

        Returns the created Antivirus service group.

        Args:
            body (AntivirusServiceGroupParams): Request to create an Antivirus
                Service Group.

        Returns:
            AntivirusServiceGroup: Response from the API. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('create_antivirus_service_group called.')

            # Validate required parameters
            self.logger.info(
                'Validating required parameters for create_antivirus_service_group.'
            )
            self.validate_parameters(body=body)

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for create_antivirus_service_group.')
            _url_path = '/public/antivirusGroups'
            _query_builder = self.config.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info(
                'Preparing headers for create_antivirus_service_group.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for create_antivirus_service_group.'
            )
            _request = self.http_client.post(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request, self.config)
            _context = self.execute_request(
                _request, name='create_antivirus_service_group')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info(
                'Validating response for create_antivirus_service_group.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(
                _context.response.raw_body,
                AntivirusServiceGroup.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
Example #18
0
    def update_tenant_view(self, body=None):
        """Does a PUT request to /public/tenants/view.

        Returns success if the update for views permission data is successful
        for
        specified tenant.

        Args:
            body (TenantViewUpdateParameters, optional): Request to update
                existing views.

        Returns:
            TenantViewUpdate: Response from the API. Tenant View Mapping
                Response.

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('update_tenant_view called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for update_tenant_view.')
            _url_path = '/public/tenants/view'
            _query_builder = self.config.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for update_tenant_view.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for update_tenant_view.')
            _request = self.http_client.put(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request, self.config)
            _context = self.execute_request(_request,
                                            name='update_tenant_view')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for update_tenant_view.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(_context.response.raw_body,
                                              TenantViewUpdate.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
    def update_sources_for_principals(self, body):
        """Does a PUT request to /public/principals/protectionSources.

        Specify the security identifier (SID) of the principal to grant
        access
        permissions for.

        Args:
            body (UpdateSourcesForPrincipalsParams): Request to set access
                permissions to Protection Sources and Views for a principal.

        Returns:
            void: Response from the API. No Content

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('update_sources_for_principals called.')

            # Validate required parameters
            self.logger.info(
                'Validating required parameters for update_sources_for_principals.'
            )
            self.validate_parameters(body=body)

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for update_sources_for_principals.')
            _url_path = '/public/principals/protectionSources'
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info(
                'Preparing headers for update_sources_for_principals.')
            _headers = {'content-type': 'application/json; charset=utf-8'}

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for update_sources_for_principals.'
            )
            _request = self.http_client.put(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request)
            _context = self.execute_request(
                _request, name='update_sources_for_principals')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info(
                'Validating response for update_sources_for_principals.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
Example #20
0
    def create_close_smb_file_open(self, body):
        """Does a POST request to /public/smbFileOpens.

        Returns nothing upon success.

        Args:
            body (CloseSmbFileOpenParameters): Request to close an active SMB
                file open.

        Returns:
            void: Response from the API. No Content

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('create_close_smb_file_open called.')

            # Validate required parameters
            self.logger.info(
                'Validating required parameters for create_close_smb_file_open.'
            )
            self.validate_parameters(body=body)

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for create_close_smb_file_open.')
            _url_path = '/public/smbFileOpens'
            _query_builder = self.config.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info(
                'Preparing headers for create_close_smb_file_open.')
            _headers = {'content-type': 'application/json; charset=utf-8'}

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for create_close_smb_file_open.'
            )
            _request = self.http_client.post(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request, self.config)
            _context = self.execute_request(_request,
                                            name='create_close_smb_file_open')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info(
                'Validating response for create_close_smb_file_open.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
    def update_banner(self, body=None):
        """Does a PUT request to /public/banners.

        Returns the banner that was updated on the Cohesity Cluster.

        Args:
            body (BannerUpdateParameters): Request to update a View.

        Returns:
            Banner: Response from the API. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('update_banner called.')

            # Validate required parameters
            self.logger.info(
                'Validating required parameters for update_banner.')

            # Prepare query URL
            self.logger.info('Preparing query URL for update_banner.')
            _url_path = '/public/banners'
            _query_builder = self.config.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for update_banner.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for update_banner.')
            _request = self.http_client.put(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request, self.config)
            _context = self.execute_request(_request, name='update_banner')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for update_banner.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)

            self.validate_response(_context)
            # Return appropriate type
            return APIHelper.json_deserialize(_context.response.raw_body,
                                              Banner.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
Example #22
0
    def update_static_route(self,
                            ip,
                            body=None):
        """Does a PUT request to /public/staticRoutes/{ip}.

        Returns the created or updated Static Route on the Cohesity Cluster.

        Args:
            ip (string): Specifies the subnet IP of the route destination
                network.
            body (StaticRoute, optional): TODO: type description here.
                Example:

        Returns:
            StaticRoute: Response from the API. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('update_static_route called.')

            # Validate required parameters
            self.logger.info('Validating required parameters for update_static_route.')
            self.validate_parameters(ip=ip)

            # Prepare query URL
            self.logger.info('Preparing query URL for update_static_route.')
            _url_path = '/public/staticRoutes/{ip}'
            _url_path = APIHelper.append_url_with_template_parameters(_url_path, {
                'ip': ip
            })
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for update_static_route.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info('Preparing and executing request for update_static_route.')
            _request = self.http_client.put(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request)
            _context = self.execute_request(_request, name = 'update_static_route')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for update_static_route.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(_context.response.raw_body, StaticRoute.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info = True)
            raise
    def change_service_state(self, body):
        """Does a POST request to /public/clusters/services/states.

        Sends a request to either stop, start, or restart one or more of the
        services
        on a Cohesity Cluster and returns a message describing the result.

        Args:
            body (ChangeServiceStateParameters): TODO: type description here.
                Example:

        Returns:
            ChangeServiceStateResult: Response from the API. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('change_service_state called.')

            # Validate required parameters
            self.logger.info(
                'Validating required parameters for change_service_state.')
            self.validate_parameters(body=body)

            # Prepare query URL
            self.logger.info('Preparing query URL for change_service_state.')
            _url_path = '/public/clusters/services/states'
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for change_service_state.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for change_service_state.')
            _request = self.http_client.post(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request)
            _context = self.execute_request(_request,
                                            name='change_service_state')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for change_service_state.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(
                _context.response.raw_body,
                ChangeServiceStateResult.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
    def create_active_directory_entry(self, body):
        """Does a POST request to /public/activeDirectory.

        After a Cohesity Cluster has been joined to an Active Directory
        domain,
        the users and groups in the domain can be authenticated on the
        Cohesity Cluster
        using their Active Directory credentials.

        Args:
            body (CreateActiveDirectoryEntryParams): Request to join an Active
                Directory.

        Returns:
            ActiveDirectoryEntry: Response from the API. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('create_active_directory_entry called.')

            # Validate required parameters
            self.logger.info(
                'Validating required parameters for create_active_directory_entry.'
            )
            self.validate_parameters(body=body)

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for create_active_directory_entry.')
            _url_path = '/public/activeDirectory'
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info(
                'Preparing headers for create_active_directory_entry.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for create_active_directory_entry.'
            )
            _request = self.http_client.post(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request)
            _context = self.execute_request(
                _request, name='create_active_directory_entry')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info(
                'Validating response for create_active_directory_entry.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(
                _context.response.raw_body,
                ActiveDirectoryEntry.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
Example #25
0
    def create_group(self,
                     body=None):
        """Does a POST request to /public/groups.

        If an Active Directory domain is specified, a new group is added to
        the
        Cohesity Cluster for the specified Active Directory group principal.
        If the LOCAL domain is specified, a new group is created directly in
        the default LOCAL domain on the Cohesity Cluster.
        Returns the created or added group.

        Args:
            body (GroupParameters, optional): Request to add or create a
                Group.

        Returns:
            Group: Response from the API. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('create_group called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for create_group.')
            _url_path = '/public/groups'
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for create_group.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info('Preparing and executing request for create_group.')
            _request = self.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request)
            _context = self.execute_request(_request, name = 'create_group')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for create_group.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(_context.response.raw_body, Group.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info = True)
            raise
    def delete_active_directory_entry(self, body):
        """Does a DELETE request to /public/activeDirectory.

        Deletes the join of the Cohesity Cluster to the specified
        Active Directory domain. After the deletion, the Cohesity Cluster
        no longer has access to the principals on the Active Directory.
        For example, you can no longer log in to the Cohesity Cluster
        with a user defined in a principal group of the Active Directory
        domain.

        Args:
            body (ActiveDirectoryEntry): Request to delete a join with an
                Active Directory.

        Returns:
            void: Response from the API. No Content

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('delete_active_directory_entry called.')

            # Validate required parameters
            self.logger.info(
                'Validating required parameters for delete_active_directory_entry.'
            )
            self.validate_parameters(body=body)

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for delete_active_directory_entry.')
            _url_path = '/public/activeDirectory'
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info(
                'Preparing headers for delete_active_directory_entry.')
            _headers = {'content-type': 'application/json; charset=utf-8'}

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for delete_active_directory_entry.'
            )
            _request = self.http_client.delete(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request)
            _context = self.execute_request(
                _request, name='delete_active_directory_entry')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info(
                'Validating response for delete_active_directory_entry.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
Example #27
0
    def create_notification_rule(self, body=None):
        """Does a POST request to /public/alertNotificationRules.

        Creates a new notification rule with provided delivery targets such as
        email
        addresses and external apis.

        Args:
            body (NotificationRule, optional): Create Notification Rule
                argument.

        Returns:
            NotificationRule: Response from the API. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('create_notification_rule called.')

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for create_notification_rule.')
            _url_path = '/public/alertNotificationRules'
            _query_builder = self.config.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for create_notification_rule.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for create_notification_rule.'
            )
            _request = self.http_client.post(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request, self.config)
            _context = self.execute_request(_request,
                                            name='create_notification_rule')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info(
                'Validating response for create_notification_rule.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(_context.response.raw_body,
                                              NotificationRule.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
    def add_active_directory_principals(self, body=None):
        """Does a POST request to /public/activeDirectory/principals.

        After a group or user has been added to a Cohesity Cluster,
        the referenced Active Directory principal can be used by the Cohesity
        Cluster.
        In addition, this operation maps Cohesity roles with a group or user
        and
        this mapping defines the privileges allowed on the Cohesity Cluster
        for the
        group or user.
        For example if an 'management' group is created on the Cohesity
        Cluster
        for the Active Directory 'management' principal group and is
        associated with the Cohesity 'View' role, all users in the
        referenced Active Directory 'management' principal group can log in to
        the
        Cohesity Dashboard but will only have view-only privileges.
        These users cannot create new Protection Jobs, Policies, Views, etc.
        NOTE: Local Cohesity users and groups cannot be created by this
        operation.
        Local Cohesity users or groups do not have an associated Active
        Directory
        principals and are created directly in the default LOCAL domain.

        Args:
            body (list of ActiveDirectoryPrincipalsAddParameters, optional):
                Request to add groups or users to the Cohesity Cluster.

        Returns:
            list of AddedActiveDirectoryPrincipal: Response from the API.
                Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('add_active_directory_principals called.')

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for add_active_directory_principals.')
            _url_path = '/public/activeDirectory/principals'
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info(
                'Preparing headers for add_active_directory_principals.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for add_active_directory_principals.'
            )
            _request = self.http_client.post(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request)
            _context = self.execute_request(
                _request, name='add_active_directory_principals')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info(
                'Validating response for add_active_directory_principals.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(
                _context.response.raw_body,
                AddedActiveDirectoryPrincipal.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
Example #29
0
    def create_kms_config(self, body=None):
        """Does a POST request to /public/kmsConfig.

        Returns the created KMS config.

        Args:
            body (KmsCreateRequestParameters, optional): TODO: type description here.
                Example:

        Returns:
            KmsConfigurationResponse: Response from the API. Response after
                KMS has been created.

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('create_kms_config called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for create_kms_config.')
            _url_path = '/public/kmsConfig'
            _query_builder = self.config.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for create_kms_config.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for create_kms_config.')
            _request = self.http_client.post(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request, self.config)
            _context = self.execute_request(_request, name='create_kms_config')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for create_kms_config.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(
                _context.response.raw_body,
                KmsConfigurationResponse.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
    def update_preferred_domain_controllers(self, body, name):
        """Does a PUT request to /public/activeDirectory/{name}/preferredDomainControllers.

        Updates the preferred domain controllers of an Active Directory

        Args:
            body (list of PreferredDomainController): Request to update
                preferred domain controllers of an Active Directory.
            name (string): Specifies the Active Directory Domain Name.

        Returns:
            ActiveDirectoryEntry: Response from the API. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """
        try:
            self.logger.info('update_preferred_domain_controllers called.')

            # Validate required parameters
            self.logger.info(
                'Validating required parameters for update_preferred_domain_controllers.'
            )
            self.validate_parameters(body=body, name=name)

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for update_preferred_domain_controllers.')
            _url_path = '/public/activeDirectory/{name}/preferredDomainControllers'
            _url_path = APIHelper.append_url_with_template_parameters(
                _url_path, {'name': name})
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info(
                'Preparing headers for update_preferred_domain_controllers.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for update_preferred_domain_controllers.'
            )
            _request = self.http_client.put(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request)
            _context = self.execute_request(
                _request, name='update_preferred_domain_controllers')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info(
                'Validating response for update_preferred_domain_controllers.')
            if _context.response.status_code == 0:
                raise RequestErrorErrorException('Error', _context)
            self.validate_response(_context)

            # Return appropriate type
            return APIHelper.json_deserialize(
                _context.response.raw_body,
                ActiveDirectoryEntry.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise