def get_protection_jobs(self, ids=None, names=None, policy_ids=None, environments=None, is_active=None, is_deleted=None, only_return_basic_summary=None, include_last_run_and_stats=None, include_rpo_snapshots=None, is_last_run_sla_violated=None, only_return_data_migration_jobs=None, tenant_ids=None, all_under_hierarchy=None): """Does a GET request to /public/protectionJobs. If no parameters are specified, all Protection Jobs currently on the Cohesity Cluster are returned. Specifying parameters filters the results that are returned. Args: ids (list of long|int, optional): Filter by a list of Protection Job ids. names (list of string, optional): Filter by a list of Protection Job names. policy_ids (list of string, optional): Filter by Policy ids that are associated with Protection Jobs. Only Jobs associated with the specified Policy ids, are returned. environments (list of EnvironmentGetProtectionJobsEnum, optional): Filter by environment types such as 'kVMware', 'kView', etc. Only Jobs protecting the specified environment types are returned. NOTE: 'kPuppeteer' refers to Cohesity's Remote Adapter. is_active (bool, optional): Filter by Inactive or Active Jobs. If not set, all Inactive and Active Jobs are returned. If true, only Active Jobs are returned. If false, only Inactive Jobs are returned. When you create a Protection Job on a Primary Cluster with a replication schedule, the Cluster creates an Inactive copy of the Job on the Remote Cluster. In addition, when an Active and running Job is deactivated, the Job becomes Inactive. is_deleted (bool, optional): If true, return only Protection Jobs that have been deleted but still have Snapshots associated with them. If false, return all Protection Jobs except those Jobs that have been deleted and still have Snapshots associated with them. A Job that is deleted with all its Snapshots is not returned for either of these cases. only_return_basic_summary (bool, optional): if true then only job descriptions and the most recent run of the job will be returned. include_last_run_and_stats (bool, optional): If true, return the last Protection Run of the Job and the summary stats. include_rpo_snapshots (bool, optional): If true, then the Protected Objects protected by RPO policies will also be returned. is_last_run_sla_violated (bool, optional): IsLastRunSlaViolated is the parameter to filter the Protection Jobs based on the SLA violation status of the last Protection Run. only_return_data_migration_jobs (bool, optional): OnlyReturnDataMigrationJobs specifies if only data migration jobs should be returned. If not set, no data migration job will be returned. tenant_ids (list of string, optional): TenantIds contains ids of the tenants for which objects are to be returned. all_under_hierarchy (bool, optional): AllUnderHierarchy specifies if objects of all the tenants under the hierarchy of the logged in user's organization should be returned. Returns: list of ProtectionJob: 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_protection_jobs called.') # Prepare query URL self.logger.info('Preparing query URL for get_protection_jobs.') _url_path = '/public/protectionJobs' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'ids': ids, 'names': names, 'policyIds': policy_ids, 'environments': environments, 'isActive': is_active, 'isDeleted': is_deleted, 'onlyReturnBasicSummary': only_return_basic_summary, 'includeLastRunAndStats': include_last_run_and_stats, 'includeRpoSnapshots': include_rpo_snapshots, 'isLastRunSlaViolated': is_last_run_sla_violated, 'onlyReturnDataMigrationJobs': only_return_data_migration_jobs, 'tenantIds': tenant_ids, 'allUnderHierarchy': all_under_hierarchy } _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_protection_jobs.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_protection_jobs.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_protection_jobs') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_protection_jobs.') 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, ProtectionJob.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_remote_clusters(self, purpose_replication=None, purpose_remote_access=None, cluster_ids=None, cluster_names=None): """Does a GET request to /public/remoteClusters. Cohesity Clusters involved in replication, must be registered to each other. For example, if Cluster A is replicating Snapshots to Cluster B, Cluster B must be registered on Cluster A and Cluster B must be registered on Cluster A. Args: purpose_replication (bool, optional): Filter for purpose as Replication. purpose_remote_access (bool, optional): Filter for purpose as Remote Access. cluster_ids (list of long|int, optional): Filter by a list of Cluster ids. cluster_names (list of string, optional): Filter by a list of Cluster names. Returns: list of RemoteCluster: 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_remote_clusters called.') # Prepare query URL self.logger.info('Preparing query URL for get_remote_clusters.') _url_path = '/public/remoteClusters' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'purposeReplication': purpose_replication, 'purposeRemoteAccess': purpose_remote_access, 'clusterIds': cluster_ids, 'clusterNames': cluster_names } _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_remote_clusters.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_remote_clusters.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_remote_clusters') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_remote_clusters.') 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, RemoteCluster.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def create_remote_cluster(self, body): """Does a POST request to /public/remoteClusters. For a Protection Job to replicate Snapshots from one Cluster to another Cluster, the Clusters must be paired together by registering each Cluster on the other Cluster. For example, Cluster A must be registered on Cluster B and Cluster B must be registered on Cluster A. Args: body (RegisterRemoteCluster): Request to register a remote Cluster. Returns: RemoteCluster: 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_remote_cluster called.') # Validate required parameters self.logger.info( 'Validating required parameters for create_remote_cluster.') self.validate_parameters(body=body) # Prepare query URL self.logger.info('Preparing query URL for create_remote_cluster.') _url_path = '/public/remoteClusters' _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_remote_cluster.') _headers = { 'accept': 'application/json', 'content-type': 'application/json; charset=utf-8' } # Prepare and execute request self.logger.info( 'Preparing and executing request for create_remote_cluster.') _request = self.http_client.post( _query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) AuthManager.apply(_request) _context = self.execute_request(_request, name='create_remote_cluster') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for create_remote_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, RemoteCluster.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_gdpr_report(self, id=None, accessible_users=None, parent_source_id=None, output_format=None, actions=None, search=None, start_time_usecs=None, end_time_usecs=None): """Does a GET request to /public/reports/gdpr. Returns the GDPR report information. Args: id (list of int|long): Specifies the objects for which to get the gdpr information. accessible_users (list of string, optional): Specifies the users for which to get the accessible objects. parent_source_id (list of int|long, optional): Specifies the parent sources of objects for which to get info for. output_format (string, optional): Specifies the format for the output such as 'csv' or 'json'. If not specified, the json format is returned. If 'csv' is specified, a comma-separated list with a heading row is returned. actions (list of string, optional): Specifies the action for the audit logs. search (string, optional): Specifies the search string for the audit logs. start_time_usecs (long|int, optional): Specifies the start time for the audit logs as a Unix epoch Timestamp (in microseconds). end_time_usecs (long|int, optional): Specifies the end time for the audit logsas a Unix epoch Timestamp (in microseconds). Returns: list of ObjectInformation: 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_gdpr_report called.') # Prepare query URL self.logger.info('Preparing query URL for get_gdpr_report.') _url_path = '/public/reports/gdpr' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_parameters = { 'id': id, 'accessibleUsers': accessible_users, 'parentSourceId': parent_source_id, 'outputFormat': output_format, 'actions': actions, 'search': search, 'startTimeUsecs': start_time_usecs, 'endTimeUsecs': end_time_usecs } _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_gdpr_report.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_gdpr_report.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request, self.config) _context = self.execute_request(_request, name='get_gdpr_report') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_gdpr_report.') 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, ObjectInformation.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_protection_sources_job_runs_report_request( self, tenant_ids=None, all_under_hierarchy=None, job_ids=None, start_time_usecs=None, end_time_usecs=None, environments=None, protection_source_ids=None, output_format=None, page_count=None, run_status=None): """Does a GET request to /public/reports/protectionSourcesJobRuns. Returns the Snapshots that contain backups of the specified Protection Source Objects and match the specified filter criteria. Args: tenant_ids (list of string, optional): TenantIds contains ids of the tenants for which objects are to be returned. all_under_hierarchy (bool, optional): AllUnderHierarchy specifies if objects of all the tenants under the hierarchy of the logged in user's organization should be returned. job_ids (list of int|long, optional): Filter by a list of Job ids. Snapshots for the specified Protection Jobs are listed. start_time_usecs (int|long, optional): Filter by a start time. Snapshots that started after the specified time are returned. Specify the end time as a Unix epoch Timestamp (in microseconds). end_time_usecs (int|long, optional): Filter by a end time. Snapshots that ended before the specified time are returned. Specify the end time as a Unix epoch Timestamp (in microseconds). environments (EnvironmentEnum, optional): Filter by a list of environment types such as 'kVMware', 'kView', etc. protection_source_ids (int|long, required): Filter by a list of leaf Protection Sources Objects (such as VMs). Snapshots of the specified Protection Source Objects are returned. output_format (string, optional): Specifies the format for the output such as 'cvs' or 'json'. If not specified, the json format is returned. If 'csv' is specified, a comma-separated list with a heading row is returned. page_count (int, optional): Specifies the number of Snapshots to return in the response for pagination purposes. Used in combination with the paginationCookie in the response to return multiple sets of Snapshots. run_status (RunStatusEnum, optional): Filter by a list of run statuses such as 'kRunning', 'kSuccess', 'kFailure' etc. Snapshots of Job Runs with the specified run statuses are reported. 'kSuccess' indicates that the Job Run was successful. 'kRunning' indicates that the Job Run is currently running. 'kWarning' indicates that the Job Run was successful but warnings were issued. 'kCancelled' indicates that the Job Run was canceled. 'kError' indicates the Job Run encountered an error and did not run to completion. Returns: list of ProtectionSourcesJobRunsReportElement: 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_protection_sources_job_runs_report_request called.') # Prepare query URL self.logger.info( 'Preparing query URL for get_protection_sources_job_runs_report_request.' ) _url_path = '/public/reports/protectionSourcesJobRuns' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_parameters = { 'tenantIds': tenant_ids, 'allUnderHierarchy': all_under_hierarchy, 'jobIds': job_ids, 'startTimeUsecs': start_time_usecs, 'endTimeUsecs': end_time_usecs, 'environments': environments, 'protectionSourceIds': protection_source_ids, 'outputFormat': output_format, 'pageCount': page_count, 'runStatus': run_status } _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_protection_sources_job_runs_report_request.' ) _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_protection_sources_job_runs_report_request.' ) _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request, self.config) _context = self.execute_request( _request, name='get_protection_sources_job_runs_report_request') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for get_protection_sources_job_runs_report_request.' ) 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, ProtectionSourcesJobRunsReportElement.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_view_box_by_id(self, id): """Does a GET request to /public/viewBoxes/{id}. Returns the Domain (View Box) corresponding to the specified Domain (View Box) Id. Args: id (long|int): Id of the Storage Domain (View Box) Returns: ViewBox: 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_view_box_by_id called.') # Validate required parameters self.logger.info( 'Validating required parameters for get_view_box_by_id.') self.validate_parameters(id=id) # Prepare query URL self.logger.info('Preparing query URL for get_view_box_by_id.') _url_path = '/public/viewBoxes/{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_view_box_by_id.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_view_box_by_id.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_view_box_by_id') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_view_box_by_id.') if _context.response.status_code == 404: raise APIException('Not Found', _context) elif (_context.response.status_code < 200) or (_context.response.status_code > 208): raise RequestErrorErrorException('Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, ViewBox.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_data_transfer_to_vaults_report_request(self, start_time_msecs=None, end_time_msecs=None, vault_ids=None, output_format=None, group_by=None): """Does a GET request to /public/reports/dataTransferToVaults. A Vault can provide an additional Cloud Tier where cold data of the Cohesity Cluster can be 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: start_time_msecs (int|long, optional): Filter by a start time. Specify the start time as a Unix epoch Timestamp (in milliseconds). If startTimeMsecs and endTimeMsecs are not specified, the time period is the last 7 days. end_time_msecs (int|long, optional): Filter by end time. Specify the end time as a Unix epoch Timestamp (in milliseconds). If startTimeMsecs and endTimeMsecs are not specified, the time period is the last 7 days. vault_ids (list of int, required): Filter by a list of Vault ids. output_format (string, optional): Specifies the format for the output such as 'csv' or 'json'. If not specified, the json format is returned. If 'csv' is specified, a comma-separated list with a heading row is returned. group_by (string, optional): Specifies wheather the report should be grouped by target when scheduled or downloaded. If not set or set to false, report is grouped by protection jobs. It is ignored if outformat is not "csv" and response contains whole report. Returns: list of DataTransferToVaultsSummaryResponse: 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_data_transfer_to_vaults_report_request called.') # Validate required parameters self.logger.info( 'Validating required parameters for get_data_transfer_to_vaults_report_request.' ) self.validate_parameters(vault_ids=vault_ids) # Prepare query URL self.logger.info( 'Preparing query URL for get_data_transfer_to_vaults_report_request.' ) _url_path = '/public/reports/dataTransferToVaults' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_parameters = { 'startTimeMsecs': start_time_msecs, 'endTimeMsecs': end_time_msecs, 'vaultIds': vault_ids, 'outputFormat': output_format, 'groupBy': group_by } _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_data_transfer_to_vaults_report_request.' ) _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_data_transfer_to_vaults_report_request.' ) _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request, self.config) _context = self.execute_request( _request, name='get_data_transfer_to_vaults_report_request') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for get_data_transfer_to_vaults_report_request.' ) 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, DataTransferToVaultsSummaryResponse.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_ldap_provider(self, tenant_ids=None, all_under_hierarchy=None, ids=None): """Does a GET request to /public/ldapProvider. Lists the LDAP providers. Args: tenant_ids (list of string, optional): TenantIds contains ids of the tenants for which objects are to be returned. all_under_hierarchy (bool, optional): AllUnderHierarchy specifies if objects of all the tenants under the hierarchy of the logged in user's organization should be returned. ids (list of long|int, optional): Specifies the ids of the LDAP providers to fetch. Returns: list of LDAPProviderResponse: 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_ldap_provider called.') # Prepare query URL self.logger.info('Preparing query URL for get_ldap_provider.') _url_path = '/public/ldapProvider' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'tenantIds': tenant_ids, 'allUnderHierarchy': all_under_hierarchy, '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_ldap_provider.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_ldap_provider.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_ldap_provider') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_ldap_provider.') 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, LDAPProviderResponse.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 (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 = 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 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 get_archive_media_info(self, cluster_incarnation_id, qstar_archive_job_id, cluster_id, qstar_restore_task_id=None, entity_ids=None): """Does a GET request to /public/vaults/archiveMediaInfo. Returns the media information about the specified archive service uid (such as a QStar tape archive service). An archive service uid is uniquely identified using a combination of the following fields: clusterIncarnationId, entityIds and clusterId. These are all required fields. Args: cluster_incarnation_id (long|int): Specifies the incarnation id of the Cohesity Cluster that archived to a QStar media Vault. qstar_archive_job_id (long|int): Specifies the id of the Job that archived to a QStar media Vault. cluster_id (long|int): Specifies the id of the Cohesity Cluster that archived to a QStar media Vault. qstar_restore_task_id (long|int, optional): Specifies the id of the restore task to optionally filter by. The restore task that is restoring data from the specified media Vault. entity_ids (list of long|int, optional): Specifies an array of entityIds to optionally filter by. An entityId is a unique id for a VM assigned by the Cohesity Cluster. Returns: list of TapeMediaInformation: 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_archive_media_info called.') # Validate required parameters self.logger.info( 'Validating required parameters for get_archive_media_info.') self.validate_parameters( cluster_incarnation_id=cluster_incarnation_id, qstar_archive_job_id=qstar_archive_job_id, cluster_id=cluster_id) # Prepare query URL self.logger.info('Preparing query URL for get_archive_media_info.') _url_path = '/public/vaults/archiveMediaInfo' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'clusterIncarnationId': cluster_incarnation_id, 'qstarArchiveJobId': qstar_archive_job_id, 'clusterId': cluster_id, 'qstarRestoreTaskId': qstar_restore_task_id, 'entityIds': entity_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_archive_media_info.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_archive_media_info.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_archive_media_info') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_archive_media_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, TapeMediaInformation.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_vaults(self, include_marked_for_removal=None, id=None, name=None): """Does a GET request to /public/vaults. If no parameters are specified, all Vaults (External Targets) currently registered on the Cohesity Cluster are returned. Specifying parameters filters the results that are returned. A Vault is equivalent to an External Target in the Cohesity Dashboard. Args: include_marked_for_removal (bool, optional): Specifies if Vaults that are marked for removal should be returned. id (long|int, optional): Specifies the id of Vault to return. If empty, all Vaults are returned. name (string, optional): Specifies the name of the Vault to return. If empty, all Vaults are returned. Returns: list of Vault: 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_vaults called.') # Prepare query URL self.logger.info('Preparing query URL for get_vaults.') _url_path = '/public/vaults' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'includeMarkedForRemoval': include_marked_for_removal, 'id': id, 'name': 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 get_vaults.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info('Preparing and executing request for get_vaults.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_vaults') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_vaults.') 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, Vault.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_vault_encryption_key(self, id): """Does a GET request to /public/vaults/encryptionKey/{id}. Get encryption information (such as the encryption key) for the specified Vault (External Target). To restore data to a remote Cluster (for example to support a disaster recovery scenario), you must get the encryption key of the Vault and store it outside the local source Cluster, before disaster strikes. If you have the encryption key and the local source Cluster goes down, you can restore the data to a remote Cluster from the Vault. The local source Cluster is the Cluster that archived the data on the Vault. Args: id (long|int): Specifies a unique id of the Vault. Returns: VaultEncryptionKey: 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_vault_encryption_key called.') # Validate required parameters self.logger.info( 'Validating required parameters for get_vault_encryption_key.') self.validate_parameters(id=id) # Prepare query URL self.logger.info( 'Preparing query URL for get_vault_encryption_key.') _url_path = '/public/vaults/encryptionKey/{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_vault_encryption_key.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_vault_encryption_key.' ) _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_vault_encryption_key') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for get_vault_encryption_key.') 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, VaultEncryptionKey.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def search_cluster_audit_logs(self, all_under_hierarchy=None, domains=None, search=None, start_index=None, output_format=None, tenant_id=None, user_names=None, entity_types=None, actions=None, start_time_usecs=None, end_time_usecs=None, page_count=None): """Does a GET request to /public/auditLogs/cluster. When actions (such as a login or a Job being paused) occur on the Cohesity Cluster, the Cluster generates Audit Logs. If no parameters are specified, all logs currently on the Cohesity Cluster are returned. Specifying parameters filters the results that are returned. Args: all_under_hierarchy (bool, optional): AllUnderHierarchy specifies if logs of all the tenants under the hierarchy of tenant with id TenantId should be returned. domains (list of string, optional): Filter by domains of users who cause the actions that trigger Cluster audit logs. search (string, optional): Filter by matching a substring in entity name or details of the Cluster audit log. start_index (long|int, optional): Specifies an index number that can be used to return subsets of items in multiple requests. Break up the items to return into multiple requests by setting pageCount and startIndex to return a subsets of items in the search result. For example, set startIndex to 0 to get the first set of pageCount items for the first request. Increment startIndex by pageCount to get the next set of pageCount items for a next request. Continue until all items are returned and therefore the total number of returned items is equal to totalCount. Default value is 0. output_format (string, optional): Specifies the format of the output such as csv and json. If not specified, the json format is returned. If csv is specified, a comma-separated list with a heading row is returned. tenant_id (string, optional): TenantId specifies the tenant whose action resulted in the audit log. user_names (list of string, optional): Filter by user names who cause the actions that generate Cluster Audit Logs. entity_types (list of string, optional): Filter by entity types involved in the actions that generate the Cluster audit logs, such as User, Protection Job, View, etc. For a complete list, see the Category drop-down in the Admin > Audit Logs page of the Cohesity Dashboard. actions (list of string, optional): Filter by the actions that generate Cluster audit logs such as Activate, Cancel, Clone, Create, etc. For a complete list, see the Actions drop-down in the Admin > Audit Logs page of the Cohesity Dashboard. start_time_usecs (long|int, optional): Filter by a start time. Only Cluster audit logs that were generated after the specified time are returned. Specify the start time as a Unix epoch Timestamp (in microseconds). end_time_usecs (long|int, optional): Filter by a end time specified as a Unix epoch Timestamp (in microseconds). Only Cluster audit logs that were generated before the specified end time are returned. page_count (long|int, optional): Limit the number of items to return in the response for pagination purposes. Default value is 1000. Returns: ClusterAuditLogFilterResult: 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('search_cluster_audit_logs called.') # Prepare query URL self.logger.info( 'Preparing query URL for search_cluster_audit_logs.') _url_path = '/public/auditLogs/cluster' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'allUnderHierarchy': all_under_hierarchy, 'domains': domains, 'search': search, 'startIndex': start_index, 'outputFormat': output_format, 'tenantId': tenant_id, 'userNames': user_names, 'entityTypes': entity_types, 'actions': actions, 'startTimeUsecs': start_time_usecs, 'endTimeUsecs': end_time_usecs, 'pageCount': page_count } _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 search_cluster_audit_logs.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for search_cluster_audit_logs.' ) _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='search_cluster_audit_logs') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for search_cluster_audit_logs.') 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, ClusterAuditLogFilterResult.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def create_clone_refresh_task(self, body): """Does a POST request to /public/restore/applicationsClone/refresh. Returns the created Clone Refresh Task which refreshes the clone with specified data. Args: body (CloneRefreshRequest): Request to create a Clone Refresh Task. Returns: RestoreTaskWrapper: 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_clone_refresh_task called.') # Validate required parameters self.logger.info( 'Validating required parameters for create_clone_refresh_task.' ) self.validate_parameters(body=body) # Prepare query URL self.logger.info( 'Preparing query URL for create_clone_refresh_task.') _url_path = '/public/restore/applicationsClone/refresh' _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_clone_refresh_task.') _headers = { 'accept': 'application/json', 'content-type': 'application/json; charset=utf-8' } # Prepare and execute request self.logger.info( 'Preparing and executing request for create_clone_refresh_task.' ) _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_clone_refresh_task') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for create_clone_refresh_task.') 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, RestoreTaskWrapper.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_idps(self, names=None, ids=None, tenant_ids=None, domains=None): """Does a GET request to /public/idps. Returns the Idps configured on the Cohesity Cluster corresponding to the filter parameters. If no filter is given, all Idp configurations are returned. Args: names (list of string, optional): Specifies the names of the IdP vendors like Okta. If specified, returns IdP configurations of the vendors matching the names in the parameters. ids (list of long|int, optional): Specifies the Ids of the IdP configuration. If specified, returns IdP configurations of the matching Ids in the IdP configuration. tenant_ids (list of string, optional): Specifies the Tenant Ids having IdP configurations. If specified, returns IdP configurations used by the tenants matching the Tenant Ids in the parameters. domains (list of string, optional): Specifies the domains of the IdP configurations. If specified, returns IdP configurations matching the domains in the parameters. Returns: list of 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('get_idps called.') # Prepare query URL self.logger.info('Preparing query URL for get_idps.') _url_path = '/public/idps' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'names': names, 'ids': ids, 'tenantIds': tenant_ids, 'domains': domains } _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_idps.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info('Preparing and executing request for get_idps.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_idps') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_idps.') 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 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 = Configuration.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) _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
def create_view_box(self, body): """Does a POST request to /public/viewBoxes. Returns the created Domain (View Box). Args: body (CreateViewBoxParams): Request to create a Storage Domain (View Box) configuration. Returns: ViewBox: 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_view_box called.') # Validate required parameters self.logger.info( 'Validating required parameters for create_view_box.') self.validate_parameters(body=body) # Prepare query URL self.logger.info('Preparing query URL for create_view_box.') _url_path = '/public/viewBoxes' _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_view_box.') _headers = { 'accept': 'application/json', 'content-type': 'application/json; charset=utf-8' } # Prepare and execute request self.logger.info( 'Preparing and executing request for create_view_box.') _request = self.http_client.post( _query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) AuthManager.apply(_request) _context = self.execute_request(_request, name='create_view_box') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for create_view_box.') 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, ViewBox.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_roles(self, name=None, tenant_ids=None, all_under_hierarchy=None): """Does a GET request to /public/roles. If the 'name' parameter is not specified, all roles defined on the Cohesity Cluster are returned. In addition, information about each role is returned such as the name, description, assigned privileges, etc. If an exact role name (such as COHESITY_VIEWER) is specified in the 'name' parameter, only information about that single role is returned. Args: name (string, optional): Specifies the name of the role. tenant_ids (list of string, optional): TenantIds contains ids of the tenants for which objects are to be returned. all_under_hierarchy (bool, optional): AllUnderHierarchy specifies if objects of all the tenants under the hierarchy of the logged in user's organization should be returned. Returns: list of 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('get_roles called.') # Prepare query URL self.logger.info('Preparing query URL for get_roles.') _url_path = '/public/roles' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'name': name, 'tenantIds': tenant_ids, 'allUnderHierarchy': all_under_hierarchy } _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_roles.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info('Preparing and executing request for get_roles.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_roles') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_roles.') 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 get_view_boxes(self, tenant_ids=None, all_under_hierarchy=None, ids=None, names=None, cluster_partition_ids=None, fetch_stats=None): """Does a GET request to /public/viewBoxes. If no parameters are specified, all Domains (View Boxes) currently on the Cohesity Cluster are returned. Specifying parameters filters the results that are returned. Args: tenant_ids (list of string, optional): TenantIds contains ids of the tenants for which objects are to be returned. all_under_hierarchy (bool, optional): AllUnderHierarchy specifies if objects of all the tenants under the hierarchy of the logged in user's organization should be returned. ids (list of long|int, optional): Filter by a list of Storage Domain (View Box) ids. If empty, View Boxes are not filtered by id. names (list of string, optional): Filter by a list of Storage Domain (View Box) Names. If empty, Storage Domains (View Boxes) are not filtered by Name. cluster_partition_ids (list of long|int, optional): Filter by a list of Cluster Partition Ids. fetch_stats (bool, optional): Specifies whether to include usage and performance statistics. Returns: list of ViewBox: 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_view_boxes called.') # Prepare query URL self.logger.info('Preparing query URL for get_view_boxes.') _url_path = '/public/viewBoxes' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'tenantIds': tenant_ids, 'allUnderHierarchy': all_under_hierarchy, 'ids': ids, 'names': names, 'clusterPartitionIds': cluster_partition_ids, '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_view_boxes.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_view_boxes.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_view_boxes') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_view_boxes.') 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, ViewBox.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_infected_files(self, view_names=None, include_quarantined_files=None, include_unquarantined_files=None, file_path=None, page_count=None, pagination_cookie=None): """Does a GET request to /public/infectedFiles. Returns all the infected files matching with query parameters. Args: view_names (list of string, optional): Filter by a list of View names. include_quarantined_files (bool, optional): Specifies whether to include quarantined files in the result. include_unquarantined_files (bool, optional): Specifies whether to include unquarantined files in the result. file_path (string, optional): Specifies the path of a file. If this is provided, infected file list would contain the scan and infection state of the file and pagination cookie will be ignored. page_count (long|int, optional): Specifies the number of items to return in the response for pagination purposes. Default value is 1000. pagination_cookie (string, optional): Pagination cookie should be used from previous call to list infected files. It resumes (or gives the next set of values) from the result of the previous call. Returns: InfectedFiles: 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_infected_files called.') # Prepare query URL self.logger.info('Preparing query URL for get_infected_files.') _url_path = '/public/infectedFiles' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'viewNames': view_names, 'includeQuarantinedFiles': include_quarantined_files, 'includeUnquarantinedFiles': include_unquarantined_files, 'filePath': file_path, 'pageCount': page_count, 'paginationCookie': pagination_cookie } _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_infected_files.') _headers = { 'accept': 'application/json' } # Prepare and execute request self.logger.info('Preparing and executing request for get_infected_files.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name = 'get_infected_files') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_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, InfectedFiles.from_dictionary) except Exception as e: self.logger.error(e, exc_info = True) raise
def get_agent_deployment_report(self, host_os_type=None, compact_version=None, output_format=None, health_status=None): """Does a GET request to /public/reports/agents. Get the list of all the installed agents which includes the health status and upgradability of the agent. Args: host_os_type (HostOsTypeEnum, optional): Specifies the host type on which the Cohesity agent is installed. compact_version (string, optional): Specifies the compact version of Cohesity agent. For example, 6.0.1. Setting this parameter will filter the response based on installed agent version. output_format (string): Specifies the format for the output such as 'csv' or 'json'. If not specified, the json format is returned. If 'csv' is specified, a comma-separated list with a heading row is returned. health_status (HealthStatusEnum): Specifies the health status of the Cohesity agent. Returns: list of AgentDeploymentStatusResponse: 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_agent_deployment_report called.') # Prepare query URL self.logger.info( 'Preparing query URL for get_agent_deployment_report.') _url_path = '/public/reports/agents' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_parameters = { 'hostOsType': host_os_type, 'compactVersion': compact_version, 'outputFormat': output_format, 'healthStatus': health_status } _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_agent_deployment_report.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_agent_deployment_report.' ) _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request, self.config) _context = self.execute_request(_request, name='get_agent_deployment_report') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for get_agent_deployment_report.') 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, AgentDeploymentStatusResponse.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def search_protection_runs(self, uuid): """Does a GET request to /public/search/protectionRuns. Returns the information of latest snapshot of a particular object across all snapshot target locations. Args: uuid (string): Specifies the unique id of the Protection Source. Returns: ProtectionRunResponse: 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('search_protection_runs called.') # Validate required parameters self.logger.info( 'Validating required parameters for search_protection_runs.') self.validate_parameters(uuid=uuid) # Prepare query URL self.logger.info('Preparing query URL for search_protection_runs.') _url_path = '/public/search/protectionRuns' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_parameters = {'uuid': uuid} _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 search_protection_runs.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for search_protection_runs.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request, self.config) _context = self.execute_request(_request, name='search_protection_runs') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for search_protection_runs.') 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, ProtectionRunResponse.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_protected_objects_trends_report_request(self, job_ids=None, start_time_usecs=None, timezone=None, end_time_usecs=None, environments=None, protected_object_ids=None, registered_source_id=None, rollup=None, tenant_ids=None, all_under_hierarchy=None): """Does a GET request to /public/reports/protectedObjectsTrends. This gives a summary of protection trend for protected resources during the given time range. If no roll up is specified, then the trends will be grouped by days. Args: job_ids (list of int|long, optional): Filter by a list of Job ids. Snapshots summary statistics for the specified Protection Jobs are reported. start_time_usecs (int|long, optional): Filter by a start time. Snapshot summary statistics for Job Runs that started after the specified time are reported. Specify the start time as a Unix epoch Timestamp (in microseconds). timezone (string, required): Specifies the timezone to use when calculating day/week/month Specify the timezone in the following format: "Area/Location", for example:"America/New_York". end_time_usecs (int|long, optional): Filter by end time. Snapshot summary statistics environments (EnvironmentEnum, optional): Filter by a list of environment types suchas 'kVMware', 'kView', etc. Supported environment types such as 'kView', 'kSQL', 'kVMware', etc. NOTE: 'kPuppeteer' refers to Cohesity's Remote Adapter. 'kVMware' indicates the VMware Protection Source environment. 'kHyperV' indicates the HyperV Protection Source environment. 'kSQL' indicates the SQL Protection Source environment. 'kView' indicates the View Protection Source environment. 'kPuppeteer' indicates the Cohesity's Remote Adapter. 'kPhysical' indicates the physical Protection Source environment. 'kPure' indicates the Pure Storage Protection Source environment. 'Nimble' indicates the Nimble Storage Protection Source environment. 'kAzure' indicates the Microsoft's Azure Protection Source environment. 'kNetapp' indicates the Netapp Protection Source environment. 'kAgent' indicates the Agent Protection Source environment. 'kGenericNas' indicates the Generic Network Attached Storage Protection Source environment. 'kAcropolis' indicates the Acropolis Protection Source environment. 'kPhsicalFiles' indicates the Physical Files Protection Source environment. 'kIsilon' indicates the Dell EMC's Isilon Protection Source environment. 'kGPFS' indicates IBM's GPFS Protection Source environment. 'kKVM' indicates the KVM Protection Source environment. 'kAWS' indicates the AWS Protection Source environment. 'kExchange' indicates the Exchange Protection Source environment. 'kHyperVVSS' indicates the HyperV VSS Protection Source environment. 'kOracle' indicates the Oracle Protection Source environment. 'kGCP' indicates the Google Cloud Platform Protection Source environment. 'kFlashBlade' indicates the Flash Blade Protection Source environment. 'kAWSNative' indicates the AWS Native Protection Source environment. 'kO365' indicates the Office 365 Protection Source environment. 'kO365Outlook' indicates Office 365 outlook Protection Source environment. 'kHyperFlex' indicates the Hyper Flex Protection Source environment. 'kGCPNative' indicates the GCP Native Protection Source environment. 'kAzureNative' indicates the Azure Native Protection Source environment. 'kKubernetes' indicates a Kubernetes Protection Source environment. 'kElastifile' indicates Elastifile Protection Source environment. 'kAD' indicates Active Directory Protection Source environment. 'kRDSSnapshotManager' indicates AWS RDS Protection Source environment. 'kCassandra' indicates Cassandra Protection Source environment. 'kMongoDB' indicates MongoDB Protection Source environment. 'kCouchbase' indicates Couchbase Protection Source environment. 'kHdfs' indicates Hdfs Protection Source environment. 'kHive' indicates Hive Protection Source environment. 'kHBase' indicates HBase Protection Source environment. protected_object_ids (list of int|long, optional): Filter by a list of leaf Protection Sources Objects (such as VMs). registered_source_id (int|long, optional): Specifies an id of a top level Registered Source such as a vCenter Server. If specified, Snapshot summary statistics for all the leaf Protection Sources (such as VMs) that are children of this Registered Source are reported. NOTE: If specified, filtering by other fields is not supported. rollup (string, optional): Roll up type for grouping. Valid values are day, week, month tenant_ids (list of string, optional): TenantIds contains ids of the tenants for which objects are to be returned. all_under_hierarchy (bool, optional): AllUnderHierarchy specifies if objects of all the tenants under the hierarchy of the logged in user's organization should be returned. Returns: list of ProtectionTrend: 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_protected_objects_trends_report_request called.') # Prepare query URL self.logger.info( 'Preparing query URL for get_protected_objects_trends_report_request.' ) _url_path = '/public/reports/protectedObjectsTrends' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_parameters = { 'jobIds': job_ids, 'startTimeUsecs': start_time_usecs, 'timezone': timezone, 'endTimeUsecs': end_time_usecs, 'environments': environments, 'protectedObjectIds': protected_object_ids, 'registeredSourceId': registered_source_id, 'rollup': rollup, 'tenantIds': tenant_ids, 'allUnderHierarchy': all_under_hierarchy } _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_protected_objects_trends_report_request.' ) _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_protected_objects_trends_report_request.' ) _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request, self.config) _context = self.execute_request( _request, name='get_protected_objects_trends_report_request') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for get_protected_objects_trends_report_request.' ) 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, ProtectionTrend.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def search_protection_sources(self, office_365_protection_source_types=None, department_list=None, title_list=None, country_list=None, search_string=None, protection_status=None, environments=None, last_protection_job_run_status=None, physical_server_host_types=None, registered_source_uuids=None, start_index=None, page_count=None): """Does a GET request to /public/search/protectionSources. Returns list of all the objects along with the protection status information. Args: office_365_protection_source_types ( Office365ProtectionSourceTypesEnum, optional): Specifies the Array of Office365 source types. Specifies the type of Office 365 entity department_list (list of string, optional): Specifies the list of departments to which an Office365 user may belong. title_list (list of string, optional): Specifies the list of titles/desgination applicable to Office365 users. country_list (list of string, optional): Specifies the list of countries to which Office365 user belongs. search_string (string, optional): Specifies the search string to query the name of the Protection Source or the name of the job protecting a Protection Source. protection_status (list of string, optional): Specifies the protection status of the object. If specified, the objects are filtered based on current protection status of that object on the cluster. Possible values that can be passed are "protected", "unprotected" or both. If not specified, all the objects are returned irrespective of protection status of the object. environments (list of EnvironmentSearchProtectionSourcesEnum, optional): Specifies the environment type by which Protection Sources will be filtered. Supported environment types such as 'kView', 'kSQL', 'kVMware', etc. NOTE: 'kPuppeteer' refers to Cohesity's Remote Adapter. 'kVMware' indicates the VMware Protection Source environment. 'kHyperV' indicates the HyperV Protection Source environment. 'kSQL' indicates the SQL Protection Source environment. 'kView' indicates the View Protection Source environment. 'kPuppeteer' indicates the Cohesity's Remote Adapter. 'kPhysical' indicates the physical Protection Source environment. 'kPure' indicates the Pure Storage Protection Source environment. 'Nimble' indicates the Nimble Storage Protection Source environment. 'kAzure' indicates the Microsoft's Azure Protection Source environment. 'kNetapp' indicates the Netapp Protection Source environment. 'kAgent' indicates the Agent Protection Source environment. 'kGenericNas' indicates the Generic Network Attached Storage Protection Source environment. 'kAcropolis' indicates the Acropolis Protection Source environment. 'kPhsicalFiles' indicates the Physical Files Protection Source environment. 'kIsilon' indicates the Dell EMC's Isilon Protection Source environment. 'kGPFS' indicates IBM's GPFS Protection Source environment. 'kKVM' indicates the KVM Protection Source environment. 'kAWS' indicates the AWS Protection Source environment. 'kExchange' indicates the Exchange Protection Source environment. 'kHyperVVSS' indicates the HyperV VSS Protection Source environment. 'kOracle' indicates the Oracle Protection Source environment. 'kGCP' indicates the Google Cloud Platform Protection Source environment. 'kFlashBlade' indicates the Flash Blade Protection Source environment. 'kAWSNative' indicates the AWS Native Protection Source environment. 'kO365' indicates the Office 365 Protection Source environment. 'kO365Outlook' indicates Office 365 outlook Protection Source environment. 'kHyperFlex' indicates the Hyper Flex Protection Source environment. 'kGCPNative' indicates the GCP Native Protection Source environment. 'kAzureNative' indicates the Azure Native Protection Source environment. 'kKubernetes' indicates a Kubernetes Protection Source environment. 'kElastifile' indicates Elastifile Protection Source environment. 'kAD' indicates Active Directory Protection Source environment. 'kRDSSnapshotManager' indicates AWS RDS Protection Source environment. 'kCassandra' indicates Cassandra Protection Source environment. 'kMongoDB' indicates MongoDB Protection Source environment. 'kCouchbase' indicates Couchbase Protection Source environment. 'kHdfs' indicates Hdfs Protection Source environment. 'kHive' indicates Hive Protection Source environment. 'kHBase' indicates HBase Protection Source environment. last_protection_job_run_status (list of int, optional): Specifies the last Protection Job run status of the object. If specified, objects will be filtered based on last job run status. physical_server_host_types (list of PhysicalServerHostTypeEnum, optional): Specifies physical server host OS type. If specified, the physical server objects will be filtered based on OS type of the server. 'kLinux' indicates the Linux operating system. 'kWindows' indicates the Microsoft Windows operating system. 'kAix' indicates the IBM AIX operating system. 'kSolaris' indicates the Oracle Solaris operating system. 'kSapHana' indicates the Sap Hana database system developed by SAP SE. 'kOther' indicates the other types of operating system. registered_source_uuids (list of string, optional): Specifies the list of Registered Sources Uuids. Only items from the listed Registered Sources are returned. start_index (int, optional): Specifies an index number that can be used to return subsets of items in multiple requests. Break up the items to return into multiple requests by setting pageCount and using startIndex to return a subsets of items. For example, set startIndex to 0 to get the first set of items for the first request. Increment startIndex by pageCount to get the next set of items for a next request. page_count (int, optional): Specifies the number of items to return in the response for pagination purposes. Default the pageCount to MaxSearchResponseSize if this is unspecified. Returns: list of ProtectionSourceResponse: 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('search_protection_sources called.') # Prepare query URL self.logger.info( 'Preparing query URL for search_protection_sources.') _url_path = '/public/search/protectionSources' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_parameters = { 'office365ProtectionSourceTypes': office_365_protection_source_types, 'departmentList': department_list, 'titleList': title_list, 'countryList': country_list, 'searchString': search_string, 'protectionStatus': protection_status, 'environments': environments, 'lastProtectionJobRunStatus': last_protection_job_run_status, 'physicalServerHostTypes': physical_server_host_types, 'registeredSourceUuids': registered_source_uuids, 'startIndex': start_index, 'pageCount': page_count } _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 search_protection_sources.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for search_protection_sources.' ) _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request, self.config) _context = self.execute_request(_request, name='search_protection_sources') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for search_protection_sources.') 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, ProtectionSourceResponse.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_protection_sources_jobs_summary_report_request( self, job_ids=None, start_time_usecs=None, end_time_usecs=None, environments=None, protection_source_ids=None, statuses=None, output_format=None, registered_source_id=None, consecutive_failures=None, report_name=None, report_type=None, tenant_ids=None, all_under_hierarchy=None): """Does a GET request to /public/reports/protectionSourcesJobsSummary. For example, if two Job ids are passed in, Snapshot summary statistics about all the leaf Objects that have been protected by the two specified Jobs are reported. For example, if a top level registered Source id is passed in, summary statistics about all the Snapshots backing up leaf Objects in the specified Source are reported. Args: job_ids (list of int|long, optional): Filter by a list of Job ids. Snapshots summary statistics for the specified Protection Jobs are reported. start_time_usecs (int|long, optional): Filter by a start time. Snapshot summary statistics for Job Runs that started after the specified time are reported. Specify the start time as a Unix epoch Timestamp (in microseconds). end_time_usecs (int|long, optional): Filter by end time. Snapshot summary statistics for Job Runs that ended before the specified time are returned. Specify the end time as a Unix epoch Timestamp (in microseconds). environments (EnvironmentEnum, optional): Filter by a list of environment types such as 'kVMware', 'kView', etc. NOTE: 'kPuppeteer' refers to Cohesity's Remote Adapter. protection_source_ids (list of long|int, optional): Filter by a list of leaf Protection Sources Objects (such as VMs). Snapshot summary statistics for the listed Protection Source Objects are reported. statuses (RunStatusEnum, optional): Filter by a list of run statuses. 'kSuccess' indicates that the Job Run was successful. 'kRunning' indicates that the Job Run is currently running. 'kWarning' indicates that the Job Run was successful but warnings were issued. 'kCancelled' indicates that the Job Run was canceled. 'kError' indicates the Job Run encountered an error and did not run to completion. output_format (string, optional): Specifies the format for the output such as 'csv' or 'json'. If not specified, the json format is returned. If 'csv' is specified, a comma-separated list with a heading row is returned. registered_source_id (int, optional): Specifies an id of a top level Registered Source such as a vCenter Server. If specified, Snapshot summary statistics for allthe leaf Protection Sources (such as VMs) that are children of this Registered Source are reported. NOTE: If specified, filtering by other fields is not supported. consecutive_failures (int, optional): Filters out those jobs which have number of consecutive run failures less than consecutiveFailures. report_name (string, optional): Specifies the custom report name the user wants to set for this report. report_type (int, optional): Specifies the report type that will be used to set the right label & subject line for the report when downloaded or emailed because same API is used for 3 reports currently 1. kAvailableLocalSnapshotsReport 2. kFailedObjectsReport 3. kProtectionSummaryByObjectTypeReport tenant_ids (list of string, optional): TenantIds contains ids of the tenants for which objects are to be returned. all_under_hierarchy (bool, optional): AllUnderHierarchy specifies if objects of all the tenants under the hierarchy of the logged in user's organization should be returned. Returns: ProtectionSourcesJobsSummaryReportResponseWrapper: 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_protection_sources_jobs_summary_report_request called.') # Prepare query URL self.logger.info( 'Preparing query URL for get_protection_sources_jobs_summary_report_request.' ) _url_path = '/public/reports/protectionSourcesJobsSummary' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_parameters = { 'jobIds': job_ids, 'startTimeUsecs': start_time_usecs, 'endTimeUsecs': end_time_usecs, 'environments': environments, 'protectionSourceIds': protection_source_ids, 'statuses': statuses, 'outputFormat': output_format, 'registeredSourceId': registered_source_id, 'consecutiveFailures': consecutive_failures, 'reportName': report_name, 'reportType': report_type, 'tenantIds': tenant_ids, 'allUnderHierarchy': all_under_hierarchy } _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_protection_sources_jobs_summary_report_request.' ) _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_protection_sources_jobs_summary_report_request.' ) _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request, self.config) _context = self.execute_request( _request, name='get_protection_sources_jobs_summary_report_request') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for get_protection_sources_jobs_summary_report_request.' ) 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, ProtectionSourcesJobsSummaryReportResponseWrapper. from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def list_interface(self, node_id=None, cache=None, bond_interface_only=None, iface_group_assigned_only=None): """Does a GET request to /public/interface. Show network interfaces. Args: node_id (int, optional): Specifies the id of the node. cache (bool, optional): Specifies if interface is cached info. bond_interface_only (bool, optional): Specifies if only show bond interface info. iface_group_assigned_only (bool, optional): Specifies if only show interface group assigned interface info. Returns: Interface: 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_interface called.') # Prepare query URL self.logger.info('Preparing query URL for list_interface.') _url_path = '/public/interface' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_parameters = { 'nodeId': node_id, 'cache': cache, 'bondInterfaceOnly': bond_interface_only, 'ifaceGroupAssignedOnly': iface_group_assigned_only } _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_interface.') _headers = { 'accept': 'application/json', 'content-type': 'application/json; charset=utf-8' } # Prepare and execute request self.logger.info( 'Preparing and executing request for list_interface.') _request = self.http_client.put(_query_url, headers=_headers) AuthManager.apply(_request, self.config) _context = self.execute_request(_request, name='list_interface') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for list_interface.') 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, Interface.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def update_remote_cluster(self, id, body): """Does a PUT request to /public/remoteClusters/{id}. Update the connection settings of the specified remote Cluster that is registered on this Cluster. Args: id (long|int): id of the remote Cluster body (RegisterRemoteCluster): Request to update a remote Cluster. Returns: RemoteCluster: 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_remote_cluster called.') # Validate required parameters self.logger.info( 'Validating required parameters for update_remote_cluster.') self.validate_parameters(id=id, body=body) # Prepare query URL self.logger.info('Preparing query URL for update_remote_cluster.') _url_path = '/public/remoteClusters/{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_remote_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_remote_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_remote_cluster') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for update_remote_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, RemoteCluster.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def add_active_idp_principals(self): """Does a POST request to /public/idp/principals. After a group or user has been added to a Cohesity Cluster, the referenced Idp 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 Idp 'management' principal group and is associated with the Cohesity 'View' role, all users in the referenced Idp '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 Idp principals and are created directly in the default LOCAL domain. Returns: list of AddedIdpPrincipal: 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_idp_principals called.') # Prepare query URL self.logger.info( 'Preparing query URL for add_active_idp_principals.') _url_path = '/public/idp/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_idp_principals.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for add_active_idp_principals.' ) _request = self.http_client.post(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='add_active_idp_principals') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for add_active_idp_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, AddedIdpPrincipal.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def update_kms_config(self, body=None): """Does a PUT request to /public/kmsConfig. Update KMS configurations in the cluster. Args: body (KmsUpdateRequestParameters, optional): TODO: type description here. Example: Returns: KmsConfigurationResponse: Response from the API. Response after KMS has been updated. 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_kms_config called.') # Prepare query URL self.logger.info('Preparing query URL for update_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 update_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 update_kms_config.') _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_kms_config') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for update_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 get_protection_job_audit(self, id): """Does a GET request to /public/protectionJobs/{id}/auditTrail. Returns the audit of specific protection job edit history. Args: id (long|int): Specifies a unique id of the Protection Job. Returns: list of ProtectionJobAuditTrail: 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_protection_job_audit called.') # Validate required parameters self.logger.info( 'Validating required parameters for get_protection_job_audit.') self.validate_parameters(id=id) # Prepare query URL self.logger.info( 'Preparing query URL for get_protection_job_audit.') _url_path = '/public/protectionJobs/{id}/auditTrail' _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_protection_job_audit.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_protection_job_audit.' ) _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_protection_job_audit') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for get_protection_job_audit.') 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, ProtectionJobAuditTrail.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise