def create_resolution(self,
                          body):
        """Does a POST request to /public/alertResolutions.

        Create an Alert Resolution and apply it to one or more Alerts.
        Mark the Alerts as resolved.

        Args:
            body (CreateAlertResolutionRequest): Request to create an Alert
                Resolution and apply it to the specified Alerts.

        Returns:
            AlertResolution1: 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_resolution called.')

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

            # Prepare query URL
            self.logger.info('Preparing query URL for create_resolution.')
            _url_path = '/public/alertResolutions'
            _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_resolution.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'application/json; charset=utf-8'
            }

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

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for create_resolution.')
            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, AlertResolution1.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info = True)
            raise
    def get_alert_by_id(self,
                        id):
        """Does a GET request to /public/alerts/{id}.

        Returns the Alert object corresponding to the specified id.

        Args:
            id (string): Unique id of the Alert to return.

        Returns:
            Alert: 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('get_alert_by_id called.')

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

            # Prepare query URL
            self.logger.info('Preparing query URL for get_alert_by_id.')
            _url_path = '/public/alerts/{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 get_alert_by_id.')
            _headers = {
                'accept': 'application/json'
            }

            # Prepare and execute request
            self.logger.info('Preparing and executing request for get_alert_by_id.')
            _request = self.http_client.get(_query_url, headers=_headers)
            AuthManager.apply(_request)
            _context = self.execute_request(_request, name = 'get_alert_by_id')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for get_alert_by_id.')
            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, Alert.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info = True)
            raise
예제 #3
0
    def create_cancel_protection_job_run(self,
                                         id,
                                         body=None):
        """Does a POST request to /public/protectionRuns/cancel/{id}.

        Cancel a Protection Job run.

        Args:
            id (long|int): Specifies a unique id of the Protection Job.
            body (CancelAProtectionJobRun, 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('create_cancel_protection_job_run called.')
    
            # Validate required parameters
            self.logger.info('Validating required parameters for create_cancel_protection_job_run.')
            self.validate_parameters(id=id)
    
            # Prepare query URL
            self.logger.info('Preparing query URL for create_cancel_protection_job_run.')
            _url_path = '/public/protectionRuns/cancel/{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 create_cancel_protection_job_run.')
            _headers = {
                'content-type': 'application/json; charset=utf-8'
            }
    
            # Prepare and execute request
            self.logger.info('Preparing and executing request for create_cancel_protection_job_run.')
            _request = self.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request)
            _context = self.execute_request(_request, name = 'create_cancel_protection_job_run')

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

        except Exception as e:
            self.logger.error(e, exc_info = True)
예제 #4
0
    def get_kms_config(self, server_ip=None):
        """Does a GET request to /public/kmsConfig.

        List KMS configurations in the cluster.

        Args:
            server_ip (string, optional): Specifies IP address of the KMS for
                which KMS configuration is requested. If server IP is not
                specified, all KMS configurations will be fetched.

        Returns:
            list of GetKMSConfigurationResponseParameters: Response from the
                API. Specifies a list of KMS configurations.

        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('get_kms_config called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for get_kms_config.')
            _url_path = '/public/kmsConfig'
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_parameters = {'serverIp': server_ip}
            _query_builder = APIHelper.append_url_with_query_parameters(
                _query_builder, _query_parameters,
                Configuration.array_serialization)
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for get_kms_config.')
            _headers = {'accept': 'application/json'}

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for get_kms_config.')
            _request = self.http_client.get(_query_url, headers=_headers)
            AuthManager.apply(_request)
            _context = self.execute_request(_request, name='get_kms_config')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for get_kms_config.')
            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,
                GetKMSConfigurationResponseParameters.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
예제 #5
0
    def get_tenants_proxies(self, ids=None):
        """Does a GET request to /public/tenants/proxies.

        Returns the list of proxies.

        Args:
            ids (list of string, optional): TODO: type description here.
                Example: 

        Returns:
            list of TenantProxy: Response from the API. Get Tenants Proxies
                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('get_tenants_proxies called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for get_tenants_proxies.')
            _url_path = '/public/tenants/proxies'
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_parameters = {'ids': ids}
            _query_builder = APIHelper.append_url_with_query_parameters(
                _query_builder, _query_parameters,
                Configuration.array_serialization)
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for get_tenants_proxies.')
            _headers = {'accept': 'application/json'}

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for get_tenants_proxies.')
            _request = self.http_client.get(_query_url, headers=_headers)
            AuthManager.apply(_request)
            _context = self.execute_request(_request,
                                            name='get_tenants_proxies')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for get_tenants_proxies.')
            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,
                                              TenantProxy.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
예제 #6
0
    def delete_tenant(self, tenant_id=None):
        """Does a DELETE request to /public/tenants.

        Returns success if the specified tenant is deleted.

        Args:
            tenant_id (string, optional): TODO: type description here.
                Example: 

        Returns:
            list of TenantDetails: Response from the API. Get 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('delete_tenant called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for delete_tenant.')
            _url_path = '/public/tenants'
            _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_tenant.')
            _headers = {
                'accept': 'application/json',
                'content-type': 'text/plain; charset=utf-8'
            }

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

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for delete_tenant.')
            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,
                                              TenantDetails.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
예제 #7
0
    def update_tenant(self, body=None):
        """Does a PUT request to /public/tenants.

        Returns the tenant that was updated on the Cohesity Cluster.

        Args:
            body (TenantUpdateDetails, optional): Request to update existing
                tenant.

        Returns:
            TenantDetails: Response from the API. Update 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('update_tenant called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for update_tenant.')
            _url_path = '/public/tenants'
            _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_tenant.')
            _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.')
            _request = self.http_client.put(
                _query_url,
                headers=_headers,
                parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request)
            _context = self.execute_request(_request, name='update_tenant')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for update_tenant.')
            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,
                                              TenantDetails.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
예제 #8
0
    def create_export_config(self, body):
        """Does a POST request to /public/export/config.

        Export metadata into Json files

        Args:
            body (ExportParameters): Request to open an exported config file
                to prepare for importing.

        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_export_config called.')

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

            # Prepare query URL
            self.logger.info('Preparing query URL for create_export_config.')
            _url_path = '/public/export/config'
            _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_export_config.')
            _headers = {'content-type': 'application/json; charset=utf-8'}

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

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

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
예제 #9
0
    def delete_stop_remote_vault_search_job(self,
                                            body):
        """Does a DELETE request to /public/remoteVaults/searchJobs.

        This is part of the CloudRetrieve functionality for finding and
        restoring
        archived data from remote Vaults to an alternative (non-original)
        Cluster.

        Args:
            body (SearchJobStopRequest): Request to stop a Remote Vault Search
                Job.

        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_stop_remote_vault_search_job called.')

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

            # Prepare query URL
            self.logger.info('Preparing query URL for delete_stop_remote_vault_search_job.')
            _url_path = '/public/remoteVaults/searchJobs'
            _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_stop_remote_vault_search_job.')
            _headers = {
                'content-type': 'application/json; charset=utf-8'
            }

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

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

        except Exception as e:
            self.logger.error(e, exc_info = True)
            raise
    def list_centrify_zones(self, domain_name=None):
        """Does a GET request to /public/activeDirectory/centrifyZones.

        Fetches the list centrify zones of an active directory domain.

        Args:
            domain_name (string, optional): Specifies the fully qualified
                domain name (FQDN) of an Active Directory.

        Returns:
            list of ListCentrifyZone: 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('list_centrify_zones called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for list_centrify_zones.')
            _url_path = '/public/activeDirectory/centrifyZones'
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_parameters = {'domainName': domain_name}
            _query_builder = APIHelper.append_url_with_query_parameters(
                _query_builder, _query_parameters,
                Configuration.array_serialization)
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for list_centrify_zones.')
            _headers = {'accept': 'application/json'}

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for list_centrify_zones.')
            _request = self.http_client.get(_query_url, headers=_headers)
            AuthManager.apply(_request)
            _context = self.execute_request(_request,
                                            name='list_centrify_zones')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for list_centrify_zones.')
            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,
                                              ListCentrifyZone.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
    def get_external_client_subnets(self):
        """Does a GET request to /public/externalClientSubnets.

        Returns the external Client Subnets for the cluster.

        Returns:
            SpecifiesTheExternalClientSubnetsThatCanCommunicateWithThisCluster:
                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('get_external_client_subnets called.')

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for get_external_client_subnets.')
            _url_path = '/public/externalClientSubnets'
            _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 get_external_client_subnets.')
            _headers = {'accept': 'application/json'}

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for get_external_client_subnets.'
            )
            _request = self.http_client.get(_query_url, headers=_headers)
            AuthManager.apply(_request)
            _context = self.execute_request(_request,
                                            name='get_external_client_subnets')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info(
                'Validating response for get_external_client_subnets.')
            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,
                SpecifiesTheExternalClientSubnetsThatCanCommunicateWithThisCluster
                .from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
    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 (RoleCreate, optional): Request to create a new custom Role.

        Returns:
            RoleInformation: 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 = Configuration.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)
            _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 ErrorErrorException('Error', _context)
            self.validate_response(_context)

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

        except Exception as e:
            self.logger.error(e, exc_info = True)
            raise
    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 (DeleteUsersRequest, 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 = Configuration.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)
            _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 ErrorErrorException('Error', _context)
            self.validate_response(_context)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
예제 #14
0
    def get_cluster(self, fetch_stats=None):
        """Does a GET request to /public/cluster.

        Returns information about this Cohesity Cluster.

        Args:
            fetch_stats (bool, optional): If 'true', also get statistics about
                the Cohesity Cluster.

        Returns:
            CohesityCluster: Response from the API. Successful 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('get_cluster called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for get_cluster.')
            _url_path = '/public/cluster'
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_parameters = {'fetchStats': fetch_stats}
            _query_builder = APIHelper.append_url_with_query_parameters(
                _query_builder, _query_parameters,
                Configuration.array_serialization)
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare headers
            self.logger.info('Preparing headers for get_cluster.')
            _headers = {'accept': 'application/json'}

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for get_cluster.')
            _request = self.http_client.get(_query_url, headers=_headers)
            AuthManager.apply(_request)
            _context = self.execute_request(_request, name='get_cluster')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for get_cluster.')
            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,
                                              CohesityCluster.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
    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 = Configuration.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)
            _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 ErrorErrorException('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
예제 #16
0
    def delete_protection_policy(self, id):
        """Does a DELETE request to /public/protectionPolicies/{id}.

        Returns Success if the Protection Policy is deleted.

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

        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_protection_policy called.')

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

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for delete_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 and execute request
            self.logger.info(
                'Preparing and executing request for delete_protection_policy.'
            )
            _request = self.http_client.delete(_query_url)
            AuthManager.apply(_request)
            _context = self.execute_request(_request,
                                            name='delete_protection_policy')

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

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
예제 #17
0
    def get_basic_cluster_info(self):
        """Does a GET request to /public/basicClusterInfo.

        All Active Directory domains that are currently joined to the
        Cohesity
        Cluster are returned. In addition, the default LOCAL domain on the
        Cohesity Cluster is returned as the first element of the domains array
        in
        the response.

        Returns:
            BasicCohesityClusterInformation: 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('get_basic_cluster_info called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for get_basic_cluster_info.')
            _url_path = '/public/basicClusterInfo'
            _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 get_basic_cluster_info.')
            _headers = {'accept': 'application/json'}

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for get_basic_cluster_info.')
            _request = self.http_client.get(_query_url, headers=_headers)
            AuthManager.apply(_request)
            _context = self.execute_request(_request,
                                            name='get_basic_cluster_info')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for get_basic_cluster_info.')
            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,
                BasicCohesityClusterInformation.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
예제 #18
0
    def delete_uninstall_app(self, app_uid, version):
        """Does a DELETE request to /public/apps/{appUid}/versions/{version}.

        App must already been installed for this api to work.

        Args:
            app_uid (long|int): Specifies the app Id.
            version (long|int): Specifies the app version.

        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_uninstall_app called.')

            # Validate required parameters
            self.logger.info(
                'Validating required parameters for delete_uninstall_app.')
            self.validate_parameters(app_uid=app_uid, version=version)

            # Prepare query URL
            self.logger.info('Preparing query URL for delete_uninstall_app.')
            _url_path = '/public/apps/{appUid}/versions/{version}'
            _url_path = APIHelper.append_url_with_template_parameters(
                _url_path, {
                    'appUid': app_uid,
                    'version': version
                })
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_url = APIHelper.clean_url(_query_builder)

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for delete_uninstall_app.')
            _request = self.http_client.delete(_query_url)
            AuthManager.apply(_request)
            _context = self.execute_request(_request,
                                            name='delete_uninstall_app')

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

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
예제 #19
0
    def list_remote_vault_restore_tasks(self):
        """Does a GET request to /public/remoteVaults/restoreTasks.

        A remote Vault restore task can restore archived data from a Vault
        (External Target) to this local Cluster.
        This is part of the CloudRetrieve functionality for finding and
        restoring
        archived data from remote Vaults to an alternative (non-original)
        Cluster.

        Returns:
            list of RemoteVaultRestoreTaskStatus: 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('list_remote_vault_restore_tasks called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for list_remote_vault_restore_tasks.')
            _url_path = '/public/remoteVaults/restoreTasks'
            _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 list_remote_vault_restore_tasks.')
            _headers = {
                'accept': 'application/json'
            }

            # Prepare and execute request
            self.logger.info('Preparing and executing request for list_remote_vault_restore_tasks.')
            _request = self.http_client.get(_query_url, headers=_headers)
            AuthManager.apply(_request)
            _context = self.execute_request(_request, name = 'list_remote_vault_restore_tasks')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for list_remote_vault_restore_tasks.')
            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, RemoteVaultRestoreTaskStatus.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info = True)
            raise
예제 #20
0
    def delete_notification_rule(self, rule_id):
        """Does a DELETE request to /public/alertNotificationRules/{ruleId}.

        Deletes an existing alert notification rule matching the rule id.

        Args:
            rule_id (long|int): Specifies the rule id.

        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_notification_rule called.')

            # Validate required parameters
            self.logger.info(
                'Validating required parameters for delete_notification_rule.')
            self.validate_parameters(rule_id=rule_id)

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

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for delete_notification_rule.'
            )
            _request = self.http_client.delete(_query_url)
            AuthManager.apply(_request)
            _context = self.execute_request(_request,
                                            name='delete_notification_rule')

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

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
    def get_ldap_provider_status(self, id):
        """Does a GET request to /public/ldapProvider/{id}/status.

        Get the connection status of an LDAP provider.

        Args:
            id (long|int): Specifies the LDAP Id.

        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('get_ldap_provider_status called.')

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

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for get_ldap_provider_status.')
            _url_path = '/public/ldapProvider/{id}/status'
            _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 and execute request
            self.logger.info(
                'Preparing and executing request for get_ldap_provider_status.'
            )
            _request = self.http_client.get(_query_url)
            AuthManager.apply(_request)
            _context = self.execute_request(_request,
                                            name='get_ldap_provider_status')

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

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
예제 #22
0
    def create_interface_group(self,
                               body=None):
        """Does a POST request to /public/interfaceGroups.

        Returns the create status upon completion.

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

        Returns:
            InterfaceGroup: 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_interface_group called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for create_interface_group.')
            _url_path = '/public/interfaceGroups'
            _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_interface_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_interface_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_interface_group')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for create_interface_group.')
            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, InterfaceGroup.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info = True)
            raise
예제 #23
0
    def get_tenants_proxy_config_request(self):
        """Does a GET request to /public/tenants/proxy/config.

        Returns the config for tenants proxy.

        Returns:
            list of int: Response from the API. Get Tenants Proxy Config
                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('get_tenants_proxy_config_request called.')

            # Prepare query URL
            self.logger.info(
                'Preparing query URL for get_tenants_proxy_config_request.')
            _url_path = '/public/tenants/proxy/config'
            _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 get_tenants_proxy_config_request.')
            _headers = {'accept': 'application/json'}

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for get_tenants_proxy_config_request.'
            )
            _request = self.http_client.get(_query_url, headers=_headers)
            AuthManager.apply(_request)
            _context = self.execute_request(
                _request, name='get_tenants_proxy_config_request')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info(
                'Validating response for get_tenants_proxy_config_request.')
            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)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
예제 #24
0
    def get_notification_rules(self):
        """Does a GET request to /public/alertNotificationRules.

        Gets all alert notification rules containing criteria to deliver
        notification
        to delivery targets such as email addresses, invoking external apis
        etc.

        Returns:
            list of 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('get_notification_rules called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for get_notification_rules.')
            _url_path = '/public/alertNotificationRules'
            _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 get_notification_rules.')
            _headers = {'accept': 'application/json'}

            # Prepare and execute request
            self.logger.info(
                'Preparing and executing request for get_notification_rules.')
            _request = self.http_client.get(_query_url, headers=_headers)
            AuthManager.apply(_request)
            _context = self.execute_request(_request,
                                            name='get_notification_rules')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for get_notification_rules.')
            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,
                                              NotificationRule.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
예제 #25
0
    def get_apps(self):
        """Does a GET request to /public/apps.

        Api provides the list of the apps which are available for the user to
        install
        or are already installed. App object provides basic app information
        along with
        app metadata.

        Returns:
            list of AppInformation: Response from the API. GetAppsResponse
                specifies response for getting apps

        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('get_apps called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for get_apps.')
            _url_path = '/public/apps'
            _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 get_apps.')
            _headers = {'accept': 'application/json'}

            # Prepare and execute request
            self.logger.info('Preparing and executing request for get_apps.')
            _request = self.http_client.get(_query_url, headers=_headers)
            AuthManager.apply(_request)
            _context = self.execute_request(_request, name='get_apps')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for get_apps.')
            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,
                                              AppInformation.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
    def remove_static_route(self, ip):
        """Does a DELETE request to /public/staticRoutes/{ip}.

        Returns the delete status upon completion.

        Args:
            ip (string): Specifies the subnet IP of the route destination
                network.

        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('remove_static_route called.')

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

            # Prepare query URL
            self.logger.info('Preparing query URL for remove_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 and execute request
            self.logger.info(
                'Preparing and executing request for remove_static_route.')
            _request = self.http_client.delete(_query_url)
            AuthManager.apply(_request)
            _context = self.execute_request(_request,
                                            name='remove_static_route')

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

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
    def get_alert_types(self):
        """Does a GET request to /public/alertTypes.

        Returns registered alerts in the Cohesity cluster that match the
        filter
        criteria specified using parameters. If no filter parameters are
        specified,
        all registered alerts in the Cohesity cluster are returned.

        Returns:
            list of AlertMetadata: 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('get_alert_types called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for get_alert_types.')
            _url_path = '/public/alertTypes'
            _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 get_alert_types.')
            _headers = {
                'accept': 'application/json'
            }

            # Prepare and execute request
            self.logger.info('Preparing and executing request for get_alert_types.')
            _request = self.http_client.get(_query_url, headers=_headers)
            AuthManager.apply(_request)
            _context = self.execute_request(_request, name = 'get_alert_types')

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for get_alert_types.')
            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, AlertMetadata.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info = True)
            raise
예제 #28
0
    def update_tenant_groups(self):
        """Does a PUT request to /public/tenants/groups.

        Returns success if the update for groups is successful for specified
        tenant.

        Returns:
            list of GroupDetails: Response from the API. Tenant Group 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_groups called.')

            # Prepare query URL
            self.logger.info('Preparing query URL for update_tenant_groups.')
            _url_path = '/public/tenants/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 update_tenant_groups.')
            _headers = {'accept': 'application/json'}

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

            # Endpoint and global error handling using HTTP status codes.
            self.logger.info('Validating response for update_tenant_groups.')
            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,
                                              GroupDetails.from_dictionary)

        except Exception as e:
            self.logger.error(e, exc_info=True)
            raise
예제 #29
0
    def get_idp_login(self,
                      tenant_id=None):
        """Does a GET request to /public/idps/login.

        Redirects the client to the IdP site with the URI to login.

        Args:
            tenant_id (string, optional): Specifies an optional tenantId for
                which the SSO login should be done. If this is not specified,
                Cluster SSO login is done.

        Returns:
            void: Response from the API. 

        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('get_idp_login called.')
    
            # Prepare query URL
            self.logger.info('Preparing query URL for get_idp_login.')
            _url_path = '/public/idps/login'
            _query_builder = Configuration.get_base_uri()
            _query_builder += _url_path
            _query_parameters = {
                'tenantId': tenant_id
            }
            _query_builder = APIHelper.append_url_with_query_parameters(_query_builder,
                _query_parameters, Configuration.array_serialization)
            _query_url = APIHelper.clean_url(_query_builder)
    
            # Prepare and execute request
            self.logger.info('Preparing and executing request for get_idp_login.')
            _request = self.http_client.get(_query_url)
            AuthManager.apply(_request)
            _context = self.execute_request(_request, name = 'get_idp_login')

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

        except Exception as e:
            self.logger.error(e, exc_info = True)
예제 #30
0
    def delete_route(self,
                     body=None):
        """Does a DELETE request to /public/routes.

        Returns the delete status upon completion.

        Args:
            body (DeleteRouteParameters, 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_route called.')
    
            # Prepare query URL
            self.logger.info('Preparing query URL for delete_route.')
            _url_path = '/public/routes'
            _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_route.')
            _headers = {
                'content-type': 'application/json; charset=utf-8'
            }
    
            # Prepare and execute request
            self.logger.info('Preparing and executing request for delete_route.')
            _request = self.http_client.delete(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body))
            AuthManager.apply(_request)
            _context = self.execute_request(_request, name = 'delete_route')

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

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