def get_last_protection_run_stats(self): """Does a GET request to /public/stats/protectionRuns/lastRun. Compute stats on last Protection Run for every job. Returns: LastProtectionRunStats: 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_last_protection_run_stats called.') # Prepare query URL self.logger.info( 'Preparing query URL for get_last_protection_run_stats.') _url_path = '/public/stats/protectionRuns/lastRun' _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_last_protection_run_stats.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_last_protection_run_stats.' ) _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request( _request, name='get_last_protection_run_stats') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for get_last_protection_run_stats.') if _context.response.status_code == 0: raise ErrorException('Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize( _context.response.raw_body, LastProtectionRunStats.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 ErrorException('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 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 ErrorException('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_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 ErrorException('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
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 ErrorException('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_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 ErrorException('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_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 ErrorException('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