def get_icap_connection_status(self, icap_uris=None): """Does a GET request to /public/icapConnectionStatus. Returns the list of succeeded and failed connection statuses of Icap servers. Args: icap_uris (list of string, optional): Specifies the list of icap uri. Returns: IcapConnectionStatusResponse: 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_icap_connection_status called.') # Prepare query URL self.logger.info('Preparing query URL for get_icap_connection_status.') _url_path = '/public/icapConnectionStatus' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'icapUris': icap_uris } _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_icap_connection_status.') _headers = { 'accept': 'application/json' } # Prepare and execute request self.logger.info('Preparing and executing request for get_icap_connection_status.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name = 'get_icap_connection_status') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_icap_connection_status.') 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, IcapConnectionStatusResponse.from_dictionary) except Exception as e: self.logger.error(e, exc_info = True) raise
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
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 = self.config.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, self.config) _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 RequestErrorErrorException('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
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 RequestErrorErrorException('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_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 add_query_parameter(self, name, value): """ Add a query parameter to the HttpRequest. Args: name (string): The name of the query parameter. value (string): The value of the query parameter. """ self.query_url = APIHelper.append_url_with_query_parameters(self.query_url, {name:value}) self.query_url = APIHelper.clean_url(self.query_url)
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)
def get_run_objects_details(self, job_type, job_id, job_run_id): """Does a GET request to /public/monitoring/objectDetails. Returns the objects details for the job run. Args: job_type (string): Specifies the job type of the needed run. job_id (long|int): Specifies the job id of the needed run. job_run_id (long|int): Specifies the job run id of the needed run. Returns: list of GetObjectsDetailsResult: 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_run_objects_details called.') # Validate required parameters self.logger.info( 'Validating required parameters for get_run_objects_details.') self.validate_parameters(job_type=job_type, job_id=job_id, job_run_id=job_run_id) # Prepare query URL self.logger.info( 'Preparing query URL for get_run_objects_details.') _url_path = '/public/monitoring/objectDetails' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_parameters = { 'jobType': job_type, 'jobId': job_id, 'jobRunId': job_run_id } _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_run_objects_details.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_run_objects_details.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request, self.config) _context = self.execute_request(_request, name='get_run_objects_details') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for get_run_objects_details.') 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, GetObjectsDetailsResult.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_alerts(self, max_alerts, alert_id_list=None, alert_type_list=None, alert_category_list=None, property_key=None, property_value=None, start_date_usecs=None, end_date_usecs=None, alert_state_list=None, alert_severity_list=None, alert_type_bucket_list=None, resolution_id_list=None, tenant_ids=None, all_under_hierarchy=None): """Does a GET request to /public/alerts. Returns all Alert objects found on the Cohesity Cluster that match the filter criteria specified using parameters. The Cohesity Cluster creates an Alert when a potential problem is found or when a threshold has been exceeded on the Cohesity Cluster. If no filter parameters are specified, all Alert objects are returned. Each object provides details about the Alert such as the Status and Severity. Args: max_alerts (int): Specifies the number of returned Alerts to be returned. The newest Alerts are returned. alert_id_list (list of string, optional): Specifies list of Alert ids to filter alerts by. alert_type_list (list of int, optional): Specifies list of Alert Types to filter alerts by. alert_category_list (list of AlertCategoryListGetAlertsEnum, optional): Specifies list of Alert Categories. property_key (string, optional): Specifies name of the property to filter alerts by. property_value (string, optional): Specifies value of the property to filter alerts by. start_date_usecs (long|int, optional): Specifies start time Unix epoch time in microseconds to filter alerts by. end_date_usecs (long|int, optional): Specifies end time Unix epoch time in microseconds to filter alerts by. alert_state_list (list of AlertStateListEnum, optional): Specifies list of Alert States to filter alerts by. alert_severity_list (list of AlertSeverityListEnum, optional): Specifies list of Alert severity to filter alerts by. alert_type_bucket_list (list of AlertTypeBucketListEnum, optional): Specifies the list of Alert type bucket. Specifies the Alert type bucket. resolution_id_list (list of long|int, optional): Specifies alert resolution ids to filter alerts by. 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 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_alerts called.') # Validate required parameters self.logger.info('Validating required parameters for get_alerts.') self.validate_parameters(max_alerts=max_alerts) # Prepare query URL self.logger.info('Preparing query URL for get_alerts.') _url_path = '/public/alerts' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_parameters = { 'maxAlerts': max_alerts, 'alertIdList': alert_id_list, 'alertTypeList': alert_type_list, 'alertCategoryList': alert_category_list, 'propertyKey': property_key, 'propertyValue': property_value, 'startDateUsecs': start_date_usecs, 'endDateUsecs': end_date_usecs, 'alertStateList': alert_state_list, 'alertSeverityList': alert_severity_list, 'alertTypeBucketList': alert_type_bucket_list, 'resolutionIdList': resolution_id_list, '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_alerts.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info('Preparing and executing request for get_alerts.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request, self.config) _context = self.execute_request(_request, name='get_alerts') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_alerts.') 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, Alert.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_protection_policies(self, tenant_ids=None, all_under_hierarchy=None, ids=None, names=None, environments=None, vault_ids=None): """Does a GET request to /public/protectionPolicies. If no parameters are specified, all Protection Policies 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 string, optional): Filter by a list of Protection Policy ids. names (list of string, optional): Filter by a list of Protection Policy names. environments (list of EnvironmentGetProtectionPoliciesEnum, optional): Filter by Environment type such as 'kVMware', 'kView', etc. Only Policies protecting the specified environment type are returned. NOTE: 'kPuppeteer' refers to Cohesity's Remote Adapter. vault_ids (list of long|int, optional): Filter by a list of Vault ids. Policies archiving to any of the specified vaults will be returned. Returns: list of ProtectionPolicy: Response from the API. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ try: self.logger.info('get_protection_policies called.') # Prepare query URL self.logger.info( 'Preparing query URL for get_protection_policies.') _url_path = '/public/protectionPolicies' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'tenantIds': tenant_ids, 'allUnderHierarchy': all_under_hierarchy, 'ids': ids, 'names': names, 'environments': environments, 'vaultIds': vault_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_protection_policies.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_protection_policies.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_protection_policies') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for get_protection_policies.') if _context.response.status_code == 0: raise RequestErrorErrorException('Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, ProtectionPolicy.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_service_gflag(self, service_name=None, gflags_name_list=None): """Does a GET request to /public/clusters/gflag. Sends a request to get the gflags of the current Cluster. Args: service_name (ServiceNameGetServiceGflagEnum, optional): Specifies the service name. If specified, only gflags matching the service name will be returned. 'kApollo' is a service for reclaiming freed disk sectors on Nodes in the SnapFS distributed file system. 'kBridge' is a service for managing the SnapFS distributed file system. 'kGenie' is a service that is responsible for monitoring hardware health on the Cluster. 'kGenieGofer' is a service that links the Genie service to other services on the Cluster. 'kMagneto' is the data protection service of the Cohesity Data Platform. 'kIris' is the service which serves REST API calls to the UI, CLI, and any scripts written by customers. 'kIrisProxy' is a service that links the Iris service to other services on the Cluster. 'kScribe' is the service responsible for storing filesystem metadata. 'kStats' is the service that is responsible for retrieving and aggregating disk metrics across the Cluster. 'kYoda' is an elastic search indexing service. 'kAlerts' is a publisher and subscribing service for alerts. 'kKeychain' is a service for managing disk encryption keys. 'kLogWatcher' is a service that scans the log directory and reduces the number of logs if required. 'kStatsCollector' is a service that periodically logs system stats. 'kGandalf' is a distributed lock service and coordination manager. 'kNexus' indicates the Nexus service. This is the service that is responsible for creation of Clusters and configuration of Nodes and networking. 'kNexusProxy' is a service that links the Nexus service to other services on the Cluster. 'kStorageProxy' is a service for accessing data on external entities. 'kTricorder' is a diagnostic health testing service for Clusters. 'kRtClient' is a reverse tunneling client service. 'kVaultProxy' is a service for managing external targets that Clusters can be backed up to. 'kSmbProxy' is an SMB protocol service. 'kBridgeProxy' is the service that links the Bridge service to other services on the Cluster. 'kLibrarian' is an elastic search indexing service. 'kGroot' is a service for managing replication of SQL databases across multiple nodes in a Cluster. 'kEagleAgent' is a service that is responsible for retrieving information on Cluster health. 'kAthena' is a service for running distributed containerized applications on the Cohesity Data Platform. 'kBifrostBroker' is a service for communicating with the Cohesity proxies for multitenancy. 'kSmb2Proxy' is a new SMB protocol service. 'kOs' can be specified in order to do a full reboot. gflags_name_list (list of string, optional): Specifies a list of gflag names. If specified, only gflags matching the gflag name list will be returned. Returns: list of ServiceGflags: 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_service_gflag called.') # Prepare query URL self.logger.info('Preparing query URL for get_service_gflag.') _url_path = '/public/clusters/gflag' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'serviceName': service_name, 'gflagsNameList': gflags_name_list } _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_service_gflag.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_service_gflag.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_service_gflag') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_service_gflag.') 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, ServiceGflags.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_view_stats(self, metric=None, num_top_views=None): """Does a GET request to /public/stats/views. Compute the statistics on Views. Args: metric (MetricEnum, optional): Specifies the metric to which stats has to be sorted. num_top_views (long|int, optional): Specifies the number of views for which stats has to be computed. Specifying this field will return the Views sorted in the descending order on the metric specified. If specified, minimum value is 1. If not specified, all views will be returned. If metric is not specified, this parameter must also not be specified. Returns: ViewStatsSnapshot: 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_stats called.') # Prepare query URL self.logger.info('Preparing query URL for get_view_stats.') _url_path = '/public/stats/views' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'metric': metric, 'numTopViews': num_top_views } _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_stats.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_view_stats.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_view_stats') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_view_stats.') 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, ViewStatsSnapshot.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def search_principals(self, domain=None, object_class=None, search=None, sids=None, include_computers=None): """Does a GET request to /public/principals/searchPrincipals. Optionally limit the search results by specifying security identifiers (SIDs), an object class (user or group) or a substring. You can specify SIDs or a substring but not both. Args: domain (string, optional): Specifies the domain name of the principals to search. If specified the principals in that domain are searched. Domain could be an Active Directory domain joined by the Cluster or any one of the trusted domains of the Active Directory domain or the LOCAL domain. If not specified, all the domains are searched. object_class (ObjectClassSearchPrincipalsEnum, optional): Optionally filter by a principal object class such as 'kGroup' or 'kUser'. If 'kGroup' is specified, only group principals are returned. If 'kUser' is specified, only user principals are returned. If not specified, both group and user principals are returned. 'kUser' specifies a user object class. 'kGroup' specifies a group object class. 'kComputer' specifies a computer object class. search (string, optional): Optionally filter by matching a substring. Only principals in the with a name or sAMAccountName that matches part or all of the specified substring are returned. If specified, a 'sids' parameter should not be specified. sids (list of string, optional): Optionally filter by a list of security identifiers (SIDs) found in the specified domain. Only principals matching the specified SIDs are returned. If specified, a 'search' parameter should not be specified. include_computers (bool, optional): Specifies if Computer/GMSA accounts need to be included in this search. Returns: list of Principal: 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_principals called.') # Prepare query URL self.logger.info('Preparing query URL for search_principals.') _url_path = '/public/principals/searchPrincipals' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'domain': domain, 'objectClass': object_class, 'search': search, 'sids': sids, 'includeComputers': include_computers } _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_principals.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for search_principals.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='search_principals') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for search_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, Principal.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 = self.config.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, self.config) _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_view_box_by_id(self, id, fetch_stats=None): """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) fetch_stats (bool, optional): Specifies whether to include usage and performance statistics. 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 = self.config.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_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, self.config) _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_vault_run_stats(self, run_type, start_time_usecs, end_time_usecs, interval): """Does a GET request to /public/stats/vaults/runs. Compute the statistics on protection runs to or from a vault and return a trend line of the result. Args: run_type (RunTypeGetVaultRunStatsEnum): Specifies the type of the run. start_time_usecs (long|int): Specifies the start time Unix time epoch in microseconds from which the vault run stats are computed. end_time_usecs (long|int): Specifies the end time Unix time epoch in microseconds to which the vault run stats are computed. interval (IntervalEnum): Specifies the interval by which runs will be grouped together in the returned trend line. Returns: VaultRunStatsSummary: 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_run_stats called.') # Validate required parameters self.logger.info( 'Validating required parameters for get_vault_run_stats.') self.validate_parameters(run_type=run_type, start_time_usecs=start_time_usecs, end_time_usecs=end_time_usecs, interval=interval) # Prepare query URL self.logger.info('Preparing query URL for get_vault_run_stats.') _url_path = '/public/stats/vaults/runs' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'runType': run_type, 'startTimeUsecs': start_time_usecs, 'endTimeUsecs': end_time_usecs, 'interval': interval } _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_vault_run_stats.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_vault_run_stats.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_vault_run_stats') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_vault_run_stats.') 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, VaultRunStatsSummary.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_view_box_stats(self, view_boxes_id_list=None, organizations_id_list=None): """Does a GET request to /public/stats/viewBoxes. Gets the statistics of view boxes (storage domain). Args: view_boxes_id_list (list of long|int, optional): Specifies a list of view boxes (storage domain) id. organizations_id_list (list of string, optional): Specifies a list of organizations (tenant) id. Returns: GetViewBoxStatsResult: 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_stats called.') # Prepare query URL self.logger.info('Preparing query URL for get_view_box_stats.') _url_path = '/public/stats/viewBoxes' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'viewBoxesIdList': view_boxes_id_list, 'organizationsIdList': organizations_id_list } _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_box_stats.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_view_box_stats.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_view_box_stats') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_view_box_stats.') 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, GetViewBoxStatsResult.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def list_sources_for_principals(self, sids=None): """Does a GET request to /public/principals/protectionSources. From the passed in list principals (specified by SIDs), return the list of Protection Sources objects and View names that each principal has permission to access. Args: sids (list of string, optional): Specifies a list of security identifiers (SIDs) that specify user or group principals. Returns: list of SourcesForSid: 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_sources_for_principals called.') # Prepare query URL self.logger.info( 'Preparing query URL for list_sources_for_principals.') _url_path = '/public/principals/protectionSources' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = {'sids': sids} _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_sources_for_principals.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for list_sources_for_principals.' ) _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='list_sources_for_principals') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for list_sources_for_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, SourcesForSid.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def search_cluster_audit_logs(self, user_names=None, domains=None, entity_types=None, actions=None, search=None, start_time_usecs=None, end_time_usecs=None, start_index=None, page_count=None, output_format=None, tenant_id=None, all_under_hierarchy=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: user_names (list of string, optional): Filter by user names who cause the actions that generate Cluster Audit Logs. domains (list of string, optional): Filter by domains of users who cause the actions that trigger 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. search (string, optional): Filter by matching a substring in entity name or details of the Cluster audit log. 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. 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. page_count (long|int, optional): Limit the number of items to return in the response for pagination purposes. Default value is 1000. 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. all_under_hierarchy (bool, optional): AllUnderHierarchy specifies if logs of all the tenants under the hierarchy of tenant with id TenantId should be returned. Returns: ClusterAuditLogsSearchResult: 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 = self.config.get_base_uri() _query_builder += _url_path _query_parameters = { 'userNames': user_names, 'domains': domains, 'entityTypes': entity_types, 'actions': actions, 'search': search, 'startTimeUsecs': start_time_usecs, 'endTimeUsecs': end_time_usecs, 'startIndex': start_index, 'pageCount': page_count, 'outputFormat': output_format, 'tenantId': tenant_id, '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 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, self.config) _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 RequestErrorErrorException('Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize( _context.response.raw_body, ClusterAuditLogsSearchResult.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_idps(self, tenant_ids=None, all_under_hierarchy=None, names=None, 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: 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. 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. 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 = self.config.get_base_uri() _query_builder += _url_path _query_parameters = { 'tenantIds': tenant_ids, 'allUnderHierarchy': all_under_hierarchy, 'names': names, 'ids': 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, self.config) _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 get_groups(self, name=None, domain=None, tenant_ids=None, all_under_hierarchy=None): """Does a GET request to /public/groups. If no parameters are specified, all groups currently on the Cohesity Cluster are returned. Specifying parameters filters the results that are returned. Args: name (string, optional): Optionally specify a group name to filter by. All groups containing name will be returned. domain (string, optional): If no domain is specified, all groups on the Cohesity Cluster are searched. If a domain is specified, only groups on the Cohesity Cluster associated with that domain are searched. 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 Group: Response from the API. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ try: self.logger.info('get_groups called.') # Prepare query URL self.logger.info('Preparing query URL for get_groups.') _url_path = '/public/groups' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'name': name, 'domain': domain, '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_groups.') _headers = { 'accept': 'application/json' } # Prepare and execute request self.logger.info('Preparing and executing request for get_groups.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name = 'get_groups') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_groups.') if _context.response.status_code == 0: raise RequestErrorErrorException('Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, Group.from_dictionary) except Exception as e: self.logger.error(e, exc_info = True) raise
def get_file_distribution_stats(self, entity_type): """Does a GET request to /public/stats/files. Compute the file distribution statistics on a given entity like cluster or storage domain. Args: entity_type (EntityTypeGetFileDistributionStatsEnum): Specifies the entity type on which file distribution stats are computed. Returns: list of FileDistributionStats: 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_file_distribution_stats called.') # Validate required parameters self.logger.info( 'Validating required parameters for get_file_distribution_stats.' ) self.validate_parameters(entity_type=entity_type) # Prepare query URL self.logger.info( 'Preparing query URL for get_file_distribution_stats.') _url_path = '/public/stats/files' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = {'entityType': entity_type} _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_file_distribution_stats.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_file_distribution_stats.' ) _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_file_distribution_stats') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for get_file_distribution_stats.') 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, FileDistributionStats.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_protection_policy_summary(self, id, include_aggregated_last_run_summary=None, include_aggregated_runs_summary=None, start_time_usecs=None, end_time_usecs=None, page_count=None, pagination_cookie=None): """Does a GET request to /public/protectionPolicySummary. List Protection Policy Summary. Args: id (string): Specifies the id of the policy whose summary should be retrieved. If this is not set, the API will return error. include_aggregated_last_run_summary (bool, optional): Specifies whether to include summary of the last Protection Run of each Protection Source. include_aggregated_runs_summary (bool, optional): Specifies whether to include summary of all Protection Runs of the Protection Source or Protection Jobs. If this is set to true, then only the Protection Runs from the provided 'startTimeUsecs' and 'endTimeUsecs' are processed. start_time_usecs (long|int, optional): Filter by a start time specified as a Unix epoch Timestamp (in microseconds). Only Job Runs that started after the specified time are included in the aggregated runs summary result. end_time_usecs (long|int, optional): Filter by a end time specified as a Unix epoch Timestamp (in microseconds). Only Job Runs that completed before the specified end time are included int he aggregated runs summary result. page_count (long|int, optional): Specifies the limit of the number of Protection Sources or Protection Jobs to be returned as a part of the Protection Policy Summary. pagination_cookie (string, optional): If set, i.e. there are more results to display, use this value to get the next set of results, by using this value in paginationCookie param for the next request to GetProtectionPolicySummary. Returns: ProtectionPolicySummary: 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_policy_summary called.') # Validate required parameters self.logger.info( 'Validating required parameters for get_protection_policy_summary.' ) self.validate_parameters(id=id) # Prepare query URL self.logger.info( 'Preparing query URL for get_protection_policy_summary.') _url_path = '/public/protectionPolicySummary' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'id': id, 'includeAggregatedLastRunSummary': include_aggregated_last_run_summary, 'includeAggregatedRunsSummary': include_aggregated_runs_summary, 'startTimeUsecs': start_time_usecs, 'endTimeUsecs': end_time_usecs, '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_protection_policy_summary.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_protection_policy_summary.' ) _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request( _request, name='get_protection_policy_summary') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for get_protection_policy_summary.') 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, ProtectionPolicySummary.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_protected_objects_summary(self, exclude_types=None): """Does a GET request to /public/stats/protectionSummary. Computes the protected objects summary on the cluster. Args: exclude_types (list of ExcludeTypeGetProtectedObjectsSummaryEnum, optional): Specifies the environment types to exclude. Returns: ProtectedObjectsSummary: 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_summary called.') # Prepare query URL self.logger.info( 'Preparing query URL for get_protected_objects_summary.') _url_path = '/public/stats/protectionSummary' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = {'excludeTypes': exclude_types} _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_summary.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_protected_objects_summary.' ) _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request( _request, name='get_protected_objects_summary') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for get_protected_objects_summary.') 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, ProtectedObjectsSummary.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_alert_types(self, alert_category_list=None): """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. Args: alert_category_list (list of AlertCategoryListEnum, optional): Specifies a list of Alert Categories to filter alert types by. Specifies the category of an Alert. 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 = self.config.get_base_uri() _query_builder += _url_path _query_parameters = {'alertCategoryList': alert_category_list} _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_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, self.config) _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 RequestErrorErrorException('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
def get_restore_stats(self, start_time_usecs, end_time_usecs): """Does a GET request to /public/stats/restores. Compute the statistics on the Restore tasks on the cluster based on the provided time interval. Args: start_time_usecs (long|int): Specifies the start time Unix time epoch in microseconds from which the restore stats are computed. end_time_usecs (long|int): Specifies the end time Unix time epoch in microseconds to which the restore stats are computed. Returns: RestoreStats: 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_restore_stats called.') # Validate required parameters self.logger.info( 'Validating required parameters for get_restore_stats.') self.validate_parameters(start_time_usecs=start_time_usecs, end_time_usecs=end_time_usecs) # Prepare query URL self.logger.info('Preparing query URL for get_restore_stats.') _url_path = '/public/stats/restores' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { '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_restore_stats.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_restore_stats.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_restore_stats') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_restore_stats.') 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, RestoreStats.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_cluster_partitions(self, ids=None, names=None): """Does a GET request to /public/clusterPartitions. If no parameters are specified, all Cluster Partitions currently on the Cohesity Cluster are returned. Specifying parameters filters the results that are returned. Args: ids (list of long|int, optional): Array of Cluster Partition Ids. Filter by a list of Cluster Partition ids. If empty, the Cluster Partitions are not filtered by id. names (list of string, optional): Array of Cluster Partition Names. Filter by a list of Cluster Partition Names. If empty, the Cluster Partitions are not filtered by names. Returns: list of ClusterPartition: 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_cluster_partitions called.') # Prepare query URL self.logger.info('Preparing query URL for get_cluster_partitions.') _url_path = '/public/clusterPartitions' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = {'ids': ids, 'names': 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_cluster_partitions.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_cluster_partitions.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_cluster_partitions') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_cluster_partitions.') 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, ClusterPartition.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_tenant_stats(self, consumer_type=None, max_count=None, cookie=None, view_boxes_id_list=None, organizations_id_list=None): """Does a GET request to /public/stats/tenants. Gets the statistics of organizations (tenant). Args: consumer_type (ConsumerTypeGetTenantStatsEnum, optional): Specifies the consumer type. Type of the consumer can be one of the following three, 'kViews', indicates the stats info of Views used per organization (tenant) per view box (storage domain). 'kProtectionRuns', indicates the stats info of Protection Runs used per organization (tenant) per view box (storage domain). 'kReplicationRuns', indicates the stats info of Replication In used per organization (tenant) per view box (storage domain). max_count (long|int, optional): Specifies a limit on the number of stats groups returned. cookie (string, optional): Specifies the opaque string returned in the previous response. If this is set, next set of active opens just after the previous response are returned. If this is not set, first set of active opens are returned. view_boxes_id_list (list of long|int, optional): Specifies a list of view boxes (storage domain) id. organizations_id_list (list of string, optional): Specifies a list of organizations (tenant) id. Returns: GetTenantStatsResult: 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_tenant_stats called.') # Prepare query URL self.logger.info('Preparing query URL for get_tenant_stats.') _url_path = '/public/stats/tenants' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'consumerType': consumer_type, 'maxCount': max_count, 'cookie': cookie, 'viewBoxesIdList': view_boxes_id_list, 'organizationsIdList': organizations_id_list } _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_tenant_stats.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_tenant_stats.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_tenant_stats') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_tenant_stats.') 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, GetTenantStatsResult.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_all_job_runs(self, start_time_msecs, end_time_msecs, job_types=None, env_types=None, page=None, page_size=None): """Does a GET request to /public/monitoring/jobs. Returns the job runs for the filters. Specifying parameters can alter the results that are returned. Args: start_time_msecs (long|int): Specifies the start time of the time range of interest. end_time_msecs (long|int): Specifies the end time of the time range of interest. job_types (list of string, optional): Specifies the job types for which runs are needed. env_types (list of EnvTypeGetAllJobRunsEnum, optional): Specifies the environment types of the job. 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. page (int, optional): Specifies the page number in case of pagination of response. page_size (int, optional): Specifies the size of the page in case of pagination of response. Returns: list of GetAllJobRunsResult: 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_all_job_runs called.') # Validate required parameters self.logger.info( 'Validating required parameters for get_all_job_runs.') self.validate_parameters(start_time_msecs=start_time_msecs, end_time_msecs=end_time_msecs) # Prepare query URL self.logger.info('Preparing query URL for get_all_job_runs.') _url_path = '/public/monitoring/jobs' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_parameters = { 'startTimeMsecs': start_time_msecs, 'endTimeMsecs': end_time_msecs, 'jobTypes': job_types, 'envTypes': env_types, 'page': page, 'pageSize': page_size } _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_all_job_runs.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_all_job_runs.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request, self.config) _context = self.execute_request(_request, name='get_all_job_runs') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_all_job_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, GetAllJobRunsResult.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_vault_provider_stats(self, run_type): """Does a GET request to /public/stats/vaults/providers. Compute the size and count of entities on vaults. Args: run_type (RunTypeGetVaultProviderStatsEnum): Specifies the type of the runs. Returns: list of VaultProviderStatsInfo: 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_provider_stats called.') # Validate required parameters self.logger.info( 'Validating required parameters for get_vault_provider_stats.') self.validate_parameters(run_type=run_type) # Prepare query URL self.logger.info( 'Preparing query URL for get_vault_provider_stats.') _url_path = '/public/stats/vaults/providers' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = {'runType': run_type} _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_vault_provider_stats.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_vault_provider_stats.' ) _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_vault_provider_stats') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for get_vault_provider_stats.') 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, VaultProviderStatsInfo.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise