def get_active_directory_domain_controllers(self, domain_name=None): """Does a GET request to /public/activeDirectory/domainControllers. List the domain controllers for a domain. Args: domain_name (string, optional): Specifies the domain name Returns: DomainControllers: 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_active_directory_domain_controllers called.') # Prepare query URL self.logger.info( 'Preparing query URL for get_active_directory_domain_controllers.' ) _url_path = '/public/activeDirectory/domainControllers' _query_builder = self.config.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 get_active_directory_domain_controllers.' ) _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_active_directory_domain_controllers.' ) _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request, self.config) _context = self.execute_request( _request, name='get_active_directory_domain_controllers') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for get_active_directory_domain_controllers.' ) if _context.response.status_code == 0: raise RequestErrorErrorException('Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize( _context.response.raw_body, DomainControllers.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def create_kms_config(self, body=None): """Does a POST request to /public/kmsConfig. Returns the created KMS config. Args: body (KmsConfiguration, optional): TODO: type description here. Example: Returns: KmsConfigurationResponse: Response from the API. Response after KMS has been created. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ try: self.logger.info('create_kms_config called.') # Prepare query URL self.logger.info('Preparing query URL for create_kms_config.') _url_path = '/public/kmsConfig' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers self.logger.info('Preparing headers for create_kms_config.') _headers = { 'accept': 'application/json', 'content-type': 'application/json; charset=utf-8' } # Prepare and execute request self.logger.info( 'Preparing and executing request for create_kms_config.') _request = self.http_client.post( _query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) AuthManager.apply(_request) _context = self.execute_request(_request, name='create_kms_config') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for create_kms_config.') if _context.response.status_code == 0: raise RequestErrorErrorException('Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize( _context.response.raw_body, KmsConfigurationResponse.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_vlan_by_id(self, id): """Does a GET request to /public/vlans/{id}. Returns the VLAN corresponding to the specified VLAN ID or a specified vlan interface group name. Example: /public/vlans/intf_group1.20 Args: id (int): Specifies the id of the VLAN. Returns: Vlan: 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_vlan_by_id called.') # Validate required parameters self.logger.info( 'Validating required parameters for get_vlan_by_id.') self.validate_parameters(id=id) # Prepare query URL self.logger.info('Preparing query URL for get_vlan_by_id.') _url_path = '/public/vlans/{id}' _url_path = APIHelper.append_url_with_template_parameters( _url_path, {'id': id}) _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers self.logger.info('Preparing headers for get_vlan_by_id.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_vlan_by_id.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_vlan_by_id') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_vlan_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, Vlan.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def update_app_settings(self, body=None): """Does a PUT request to /public/cluster/appSettings. Returns the updated app settings. Args: body (AppsConfig): Update App Settings Parameter. Returns: AppsConfig: Response from the API. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ try: self.logger.info('update_app_settings called.') # Prepare query URL self.logger.info( 'Preparing query URL for update_app_settings.') _url_path = '/public/cluster/appSettings' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers self.logger.info( 'Preparing headers for update_app_settings.') _headers = { 'accept': 'application/json', 'content-type': 'application/json; charset=utf-8' } # Prepare and execute request self.logger.info( 'Preparing and executing request for update_app_settings.' ) _request = self.http_client.put( _query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) AuthManager.apply(_request, self.config) _context = self.execute_request(_request, name='update_app_settings') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for update_app_settings.') 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, AppsConfig.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def update_role(self, name, body=None): """Does a PUT request to /public/roles/{name}. For example, you could update the privileges assigned to a Role. Returns the updated role. Args: name (string): Specifies the name of the role to update. body (RoleUpdate, optional): Request to update a custom role. Returns: RoleInformation: Response from the API. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ try: self.logger.info('update_role called.') # Validate required parameters self.logger.info('Validating required parameters for update_role.') self.validate_parameters(name=name) # Prepare query URL self.logger.info('Preparing query URL for update_role.') _url_path = '/public/roles/{name}' _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 'name': name }) _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers self.logger.info('Preparing headers for update_role.') _headers = { 'accept': 'application/json', 'content-type': 'application/json; charset=utf-8' } # Prepare and execute request self.logger.info('Preparing and executing request for update_role.') _request = self.http_client.put(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) AuthManager.apply(_request) _context = self.execute_request(_request, name = 'update_role') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for update_role.') if _context.response.status_code == 0: raise ErrorErrorException('Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, RoleInformation.from_dictionary) except Exception as e: self.logger.error(e, exc_info = True) raise
def create_tenant(self, body=None): """Does a POST request to /public/tenants. A Vault can provide an additional Cloud Tier where cold data of the Cohesity Cluster is stored in the Cloud. A Vault can also provide archive storage for backup data. This archive data is stored on Tapes and in Cloud Vaults. Args: body (TenantCreateParameters, optional): Request to add or create a new tenant. Returns: Tenant: Response from the API. Create Tenants response Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ try: self.logger.info('create_tenant called.') # Prepare query URL self.logger.info('Preparing query URL for create_tenant.') _url_path = '/public/tenants' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers self.logger.info('Preparing headers for create_tenant.') _headers = { 'accept': 'application/json', 'content-type': 'application/json; charset=utf-8' } # Prepare and execute request self.logger.info( 'Preparing and executing request for create_tenant.') _request = self.http_client.post( _query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) AuthManager.apply(_request, self.config) _context = self.execute_request(_request, name='create_tenant') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for create_tenant.') if _context.response.status_code == 0: raise RequestErrorErrorException('Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, Tenant.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_tenants_proxy_config(self, id=None, validate_only=None): """Does a GET request to /public/tenants/proxy/config. Returns the config for tenants proxy. Args: id (string, optional): Specifies the id of the tenant. validate_only (bool, optional): Specifies whether to only validate the config request. Returns: list of int: Response from the API. Get Tenants Proxy Config Response. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ try: self.logger.info('get_tenants_proxy_config called.') # Prepare query URL self.logger.info( 'Preparing query URL for get_tenants_proxy_config.') _url_path = '/public/tenants/proxy/config' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_parameters = {'id': id, 'validateOnly': validate_only} _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare headers self.logger.info('Preparing headers for get_tenants_proxy_config.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_tenants_proxy_config.' ) _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request, self.config) _context = self.execute_request(_request, name='get_tenants_proxy_config') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for get_tenants_proxy_config.') if _context.response.status_code == 0: raise RequestErrorErrorException('Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body) except Exception as e: self.logger.error(e, exc_info=True) raise
def update_view_box(self, id, body): """Does a PUT request to /public/viewBoxes/{id}. Returns the updated Domain (View Box). Args: id (long|int): Id of the Storage Domain (View Box) body (StorageDomainViewBoxRequest): Request to update a Storage Domain (View Box) configuration. Returns: DomainViewBox: Response from the API. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ try: self.logger.info('update_view_box called.') # Validate required parameters self.logger.info( 'Validating required parameters for update_view_box.') self.validate_parameters(id=id, body=body) # Prepare query URL self.logger.info('Preparing query URL for update_view_box.') _url_path = '/public/viewBoxes/{id}' _url_path = APIHelper.append_url_with_template_parameters( _url_path, {'id': id}) _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers self.logger.info('Preparing headers for update_view_box.') _headers = { 'accept': 'application/json', 'content-type': 'application/json; charset=utf-8' } # Prepare and execute request self.logger.info( 'Preparing and executing request for update_view_box.') _request = self.http_client.put( _query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) AuthManager.apply(_request) _context = self.execute_request(_request, name='update_view_box') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for update_view_box.') 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, DomainViewBox.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 = self.config.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, self.config) _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 update_preferred_domain_controllers(self, body, name): """Does a PUT request to /public/activeDirectory/{name}/preferredDomainControllers. Updates the preferred domain controllers of an Active Directory Args: body (list of PreferredDomainController): Request to update preferred domain controllers of an Active Directory. name (string): Specifies the Active Directory Domain Name. Returns: ActiveDirectoryEntry: Response from the API. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ try: self.logger.info('update_preferred_domain_controllers called.') # Validate required parameters self.logger.info( 'Validating required parameters for update_preferred_domain_controllers.' ) self.validate_parameters(body=body, name=name) # Prepare query URL self.logger.info( 'Preparing query URL for update_preferred_domain_controllers.') _url_path = '/public/activeDirectory/{name}/preferredDomainControllers' _url_path = APIHelper.append_url_with_template_parameters( _url_path, {'name': name}) _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers self.logger.info( 'Preparing headers for update_preferred_domain_controllers.') _headers = { 'accept': 'application/json', 'content-type': 'application/json; charset=utf-8' } # Prepare and execute request self.logger.info( 'Preparing and executing request for update_preferred_domain_controllers.' ) _request = self.http_client.put( _query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) AuthManager.apply(_request, self.config) _context = self.execute_request( _request, name='update_preferred_domain_controllers') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for update_preferred_domain_controllers.') if _context.response.status_code == 0: raise RequestErrorErrorException('Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize( _context.response.raw_body, ActiveDirectoryEntry.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_view_boxes(self, fetch_stats=None, tenant_ids=None, all_under_hierarchy=None, ids=None, names=None, cluster_partition_ids=None): """Does a GET request to /public/viewBoxes. If no parameters are specified, all Domains (View Boxes) currently on the Cohesity Cluster are returned. Specifying parameters filters the results that are returned. Args: fetch_stats (bool, optional): Specifies whether to include usage and performance statistics. tenant_ids (list of string, optional): TenantIds contains ids of the tenants for which objects are to be returned. all_under_hierarchy (bool, optional): AllUnderHierarchy specifies if objects of all the tenants under the hierarchy of the logged in user's organization should be returned. ids (list of long|int, optional): Filter by a list of Storage Domain (View Box) ids. If empty, View Boxes are not filtered by id. names (list of string, optional): Filter by a list of Storage Domain (View Box) Names. If empty, Storage Domains (View Boxes) are not filtered by Name. cluster_partition_ids (list of long|int, optional): Filter by a list of Cluster Partition Ids. Returns: list of DomainViewBox: Response from the API. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ try: self.logger.info('get_view_boxes called.') # Prepare query URL self.logger.info('Preparing query URL for get_view_boxes.') _url_path = '/public/viewBoxes' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'fetchStats': fetch_stats, 'tenantIds': tenant_ids, 'allUnderHierarchy': all_under_hierarchy, 'ids': ids, 'names': names, 'clusterPartitionIds': cluster_partition_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_view_boxes.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_view_boxes.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_view_boxes') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_view_boxes.') if _context.response.status_code == 0: raise ErrorErrorException('Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, DomainViewBox.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_active_directory_entry(self, domains=None, tenant_ids=None, all_under_hierarchy=None): """Does a GET request to /public/activeDirectory. After a Cohesity Cluster has been joined to an Active Directory domain, the users and groups in the domain can be authenticated on the Cohesity Cluster using their Active Directory credentials. NOTE: The userName and password fields are not populated by this operation. Args: domains (list of string, optional): Specifies the domains to fetch active directory entries. 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 ActiveDirectoryEntry: Response from the API. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ try: self.logger.info('get_active_directory_entry called.') # Prepare query URL self.logger.info( 'Preparing query URL for get_active_directory_entry.') _url_path = '/public/activeDirectory' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_parameters = { 'domains': domains, '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_active_directory_entry.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_active_directory_entry.' ) _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request, self.config) _context = self.execute_request(_request, name='get_active_directory_entry') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for get_active_directory_entry.') if _context.response.status_code == 0: raise RequestErrorErrorException('Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize( _context.response.raw_body, ActiveDirectoryEntry.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def add_active_directory_principals(self, body=None): """Does a POST request to /public/activeDirectory/principals. After a group or user has been added to a Cohesity Cluster, the referenced Active Directory principal can be used by the Cohesity Cluster. In addition, this operation maps Cohesity roles with a group or user and this mapping defines the privileges allowed on the Cohesity Cluster for the group or user. For example if an 'management' group is created on the Cohesity Cluster for the Active Directory 'management' principal group and is associated with the Cohesity 'View' role, all users in the referenced Active Directory 'management' principal group can log in to the Cohesity Dashboard but will only have view-only privileges. These users cannot create new Protection Jobs, Policies, Views, etc. NOTE: Local Cohesity users and groups cannot be created by this operation. Local Cohesity users or groups do not have an associated Active Directory principals and are created directly in the default LOCAL domain. Args: body (list of ActiveDirectoryPrincipalsAddParameters, optional): Request to add groups or users to the Cohesity Cluster. Returns: list of AddedActiveDirectoryPrincipal: Response from the API. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ try: self.logger.info('add_active_directory_principals called.') # Prepare query URL self.logger.info( 'Preparing query URL for add_active_directory_principals.') _url_path = '/public/activeDirectory/principals' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers self.logger.info( 'Preparing headers for add_active_directory_principals.') _headers = { 'accept': 'application/json', 'content-type': 'application/json; charset=utf-8' } # Prepare and execute request self.logger.info( 'Preparing and executing request for add_active_directory_principals.' ) _request = self.http_client.post( _query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) AuthManager.apply(_request, self.config) _context = self.execute_request( _request, name='add_active_directory_principals') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for add_active_directory_principals.') if _context.response.status_code == 0: raise RequestErrorErrorException('Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize( _context.response.raw_body, AddedActiveDirectoryPrincipal.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def search_active_directory_principals(self, domain=None, object_class=None, search=None, sids=None, include_computers=None): """Does a GET request to /public/activeDirectory/principals. 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 (ObjectClassSearchActiveDirectoryPrincipalsEnum, 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. 'kWellKnownPrincipal' specifies a well known principal. 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 ActiveDirectoryPrincipal: 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_active_directory_principals called.') # Prepare query URL self.logger.info( 'Preparing query URL for search_active_directory_principals.') _url_path = '/public/activeDirectory/principals' _query_builder = self.config.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_active_directory_principals.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for search_active_directory_principals.' ) _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request, self.config) _context = self.execute_request( _request, name='search_active_directory_principals') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for search_active_directory_principals.') if _context.response.status_code == 0: raise RequestErrorErrorException('Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize( _context.response.raw_body, ActiveDirectoryPrincipal.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, tenant_ids=None, include_service_provider=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. tenant_ids (list of string, optional): Specifies a list of organizations (tenant) id. This field is added to allow tenantIds json tag. This list will be concatenated with TenantsIdList to form full list of tenantsIdList. include_service_provider(bool, optional): Specifies whether to fetch the consumption of external service providers. These information will be listed as a unique organization (tenant) in response. By default it is false. 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 = self.config.get_base_uri() _query_builder += _url_path _query_parameters = { 'viewBoxesIdList': view_boxes_id_list, 'organizationsIdList': organizations_id_list, 'tenantIds': tenant_ids, 'includeServiceProvider': include_service_provider } _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, self.config) _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 get_consumer_stats(self, consumer_type=None, max_count=None, cookie=None, consumer_id_list=None, consumer_entity_id_list=None, fetch_view_box_name=None, fetch_tenant_name=None, fetch_protection_policy=None, fetch_protection_environment=None, view_boxes_id_list=None, organizations_id_list=None, tenant_ids=None, include_service_provider=None): """Does a GET request to /public/stats/consumers. Gets the statistics of consumers. Args: consumer_type (ConsumerTypeGetConsumerStatsEnum, 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. consumer_id_list (list of long|int, optional): Specifies a list of consumer ids. consumer_entity_id_list (list of string, optional): Specifies a list of consumer entity ids. If this field is specified, each entity id must corresponds to the id in 'ConsumerIdList' in the same index, and the length of 'ConsumerEntityIdList' and 'ConsumerIdList' must be the same. fetch_view_box_name (bool, optional): Specifies whether to fetch view box (storage domain) name for each consumer. fetch_tenant_name (bool, optional): Specifies whether to fetch tenant (organization) name for each consumer. fetch_protection_policy (bool, optional): Specifies whether to fetch protection policy for each consumer. This field is applicable only if 'consumerType' is 'kProtectionRuns' or 'kReplicationRuns'. fetch_protection_environment(bool, optional): Specifies whether to fetch protection environment for each consumer. This field is applicable only if 'consumerType' is 'kProtectionRuns' or 'kReplicationRuns'. 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. tenant_ids (list of string, optional): Specifies a list of organizations (tenant) id. This field is added to allow tenantIds json tag. This list will be concatenated with TenantsIdList to form full list of tenantsIdList. include_service_provider(bool, optional): Specifies whether to fetch the consumption of external service providers. These information will be listed as a unique organization (tenant) in response. By default it is false. Returns: GetConsumerStatsResult: 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_consumer_stats called.') # Prepare query URL self.logger.info('Preparing query URL for get_consumer_stats.') _url_path = '/public/stats/consumers' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_parameters = { 'consumerType': consumer_type, 'maxCount': max_count, 'cookie': cookie, 'consumerIdList': consumer_id_list, 'consumerEntityIdList': consumer_entity_id_list, 'fetchViewBoxName': fetch_view_box_name, 'fetchTenantName': fetch_tenant_name, 'fetchProtectionPolicy': fetch_protection_policy, 'fetchProtectionEnvironment': fetch_protection_environment, 'viewBoxesIdList': view_boxes_id_list, 'organizationsIdList': organizations_id_list, 'tenantIds': tenant_ids, 'includeServiceProvider': include_service_provider } _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_consumer_stats.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_consumer_stats.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request, self.config) _context = self.execute_request(_request, name='get_consumer_stats') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_consumer_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, GetConsumerStatsResult.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def update_upgrade_node(self, body): """Does a PUT request to /public/nodes/software. Sends a request to upgrade the software version of a Node. By default, the Node that the request is sent to is the only one upgraded, but the user can specify if they want to attempt to upgrade all free nodes on the network. Before using this, you need to upload a new package to the Node you want to upgrade by using the /public/packages endpoint. Args: body (UpgradeNodeParameters): TODO: type description here. Example: Returns: UpgradeNodeResult: Response from the API. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ try: self.logger.info('update_upgrade_node called.') # Validate required parameters self.logger.info('Validating required parameters for update_upgrade_node.') self.validate_parameters(body=body) # Prepare query URL self.logger.info('Preparing query URL for update_upgrade_node.') _url_path = '/public/nodes/software' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers self.logger.info('Preparing headers for update_upgrade_node.') _headers = { 'accept': 'application/json', 'content-type': 'application/json; charset=utf-8' } # Prepare and execute request self.logger.info('Preparing and executing request for update_upgrade_node.') _request = self.http_client.put(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) AuthManager.apply(_request) _context = self.execute_request(_request, name = 'update_upgrade_node') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for update_upgrade_node.') 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, UpgradeNodeResult.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 = self.config.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, self.config) _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 update_tenant_protection_policy(self, body=None): """Does a PUT request to /public/tenants/policy. Returns success if the update for protection policy permission data is successful for the specified tenant. Args: body (TenantProtectionPolicyUpdateParameters, optional): Request to update existing protection policies. Returns: TenantProtectionPolicyUpdate: Response from the API. Tenant Protection Policy Mapping Response. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ try: self.logger.info('update_tenant_protection_policy called.') # Prepare query URL self.logger.info( 'Preparing query URL for update_tenant_protection_policy.') _url_path = '/public/tenants/policy' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers self.logger.info( 'Preparing headers for update_tenant_protection_policy.') _headers = { 'accept': 'application/json', 'content-type': 'application/json; charset=utf-8' } # Prepare and execute request self.logger.info( 'Preparing and executing request for update_tenant_protection_policy.' ) _request = self.http_client.put( _query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) AuthManager.apply(_request, self.config) _context = self.execute_request( _request, name='update_tenant_protection_policy') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for update_tenant_protection_policy.') if _context.response.status_code == 0: raise RequestErrorErrorException('Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize( _context.response.raw_body, TenantProtectionPolicyUpdate.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 = self.config.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, self.config) _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_tenants(self, ids=None, properties=None, hierarchy=None, include_self=None, skip_invalid_ids=None, status=None): """Does a GET request to /public/tenants. Returns the list of tenants. Args: ids (list of string, optional): TODO: type description here. Example: properties (list of PropertyEnum, optional): 'ViewBox' indicates view box data for tenant. 'Vlan' indicates vlan data for tenant. 'ProtectionPolicy' indicates protection policy for tenant. 'ProtectionJob' indicates protection job for tenant. 'Entity' indicates entity data for tenant. 'Views' indicates view data for tenant. 'ActiveDirectory' indicates active directory for tenant. 'LdapProvider' indicates ldap provider for tenant. 'SwiftConfig' indicates Swift configuration for tenant. hierarchy (bool, optional): TODO: type description here. Example: include_self (bool, optional): TODO: type description here. Example: skip_invalid_ids (bool, optional): TODO: type description here. Example: status (list of StatusGetTenantsEnum, optional): Filter by tenant status. Returns: list of Tenant: Response from the API. Get Tenants Response. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ try: self.logger.info('get_tenants called.') # Prepare query URL self.logger.info('Preparing query URL for get_tenants.') _url_path = '/public/tenants' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_parameters = { 'ids': ids, 'properties': properties, 'hierarchy': hierarchy, 'includeSelf': include_self, 'skipInvalidIds': skip_invalid_ids, 'status': status } _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare headers self.logger.info('Preparing headers for get_tenants.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info( 'Preparing and executing request for get_tenants.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request, self.config) _context = self.execute_request(_request, name='get_tenants') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_tenants.') if _context.response.status_code == 0: raise RequestErrorErrorException('Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, Tenant.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
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 = self.config.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, self.config) _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(self, fetch_stats=None, fetch_time_series_schema=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. fetch_time_series_schema (bool, optional): Specifies whether to get time series schema info of the cluster. Returns: Cluster: 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 = self.config.get_base_uri() _query_builder += _url_path _query_parameters = { 'fetchStats': fetch_stats, 'fetchTimeSeriesSchema': fetch_time_series_schema } _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, self.config) _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 RequestErrorErrorException('Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, Cluster.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def get_tenant_stats(self, consumer_type=None, skip_group_by_tenant=None, max_count=None, cookie=None, output_format=None, view_boxes_id_list=None, organizations_id_list=None, tenant_ids=None, include_service_provider=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). skip_group_by_tenant (bool, optional): Specifies if we should skip grouping by tenant. If false, and tenant has multiple storage domains, then the stats for the storage domains will be aggregated. If true, then the response will return each storage domain cross tenant independently. 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. output_format (string, optional): Specifies what format to return the data in. Defaults to proto, but can select other options like csv. 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. tenant_ids (list of string, optional): Specifies a list of organizations (tenant) id. This field is added to allow tenantIds json tag. This list will be concatenated with TenantsIdList to form full list of tenantsIdList. include_service_provider(bool, optional): Specifies whether to fetch the consumption of external service providers. These information will be listed as a unique organization (tenant) in response. By default it is false. 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 = self.config.get_base_uri() _query_builder += _url_path _query_parameters = { 'consumerType': consumer_type, 'skipGroupByTenant': skip_group_by_tenant, 'maxCount': max_count, 'cookie': cookie, 'outputFormat': output_format, 'viewBoxesIdList': view_boxes_id_list, 'organizationsIdList': organizations_id_list, 'tenantIds': tenant_ids, 'includeServiceProvider': include_service_provider } _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, self.config) _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_roles(self, tenant_ids=None, all_under_hierarchy=None, name=None): """Does a GET request to /public/roles. If the 'name' parameter is not specified, all roles defined on the Cohesity Cluster are returned. In addition, information about each role is returned such as the name, description, assigned privileges, etc. If an exact role name (such as COHESITY_VIEWER) is specified in the 'name' parameter, only information about that single role is returned. Args: 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. name (string, optional): Specifies the name of the role. Returns: list of RoleInformation: Response from the API. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ try: self.logger.info('get_roles called.') # Prepare query URL self.logger.info('Preparing query URL for get_roles.') _url_path = '/public/roles' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'tenantIds': tenant_ids, 'allUnderHierarchy': all_under_hierarchy, 'name': name } _query_builder = APIHelper.append_url_with_query_parameters(_query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare headers self.logger.info('Preparing headers for get_roles.') _headers = { 'accept': 'application/json' } # Prepare and execute request self.logger.info('Preparing and executing request for get_roles.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name = 'get_roles') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_roles.') if _context.response.status_code == 0: raise ErrorErrorException('Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, RoleInformation.from_dictionary) except Exception as e: self.logger.error(e, exc_info = True) raise
def 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 = self.config.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, self.config) _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
def get_vlans(self, tenant_ids=None, all_under_hierarchy=None, skip_primary_and_bond_iface=None): """Does a GET request to /public/vlans. Returns the VLANs for the Cohesity Cluster. 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. skip_primary_and_bond_iface (bool, optional): SkipPrimaryAndBondIface is to filter interfaces entries which are primary interface or bond interfaces. Returns: list of Vlan: 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_vlans called.') # Prepare query URL self.logger.info('Preparing query URL for get_vlans.') _url_path = '/public/vlans' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'tenantIds': tenant_ids, 'allUnderHierarchy': all_under_hierarchy, 'skipPrimaryAndBondIface': skip_primary_and_bond_iface } _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_vlans.') _headers = {'accept': 'application/json'} # Prepare and execute request self.logger.info('Preparing and executing request for get_vlans.') _request = self.http_client.get(_query_url, headers=_headers) AuthManager.apply(_request) _context = self.execute_request(_request, name='get_vlans') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for get_vlans.') 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, Vlan.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 = self.config.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, self.config) _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 update_vlan(self, id, body=None): """Does a PUT request to /public/vlans/{id}. Returns the created or updated VLAN on the Cohesity Cluster. Args: id (int): Specifies the id of the VLAN. body (Vlan, optional): TODO: type description here. Example: Returns: Vlan: Response from the API. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ try: self.logger.info('update_vlan called.') # Validate required parameters self.logger.info('Validating required parameters for update_vlan.') self.validate_parameters(id=id) # Prepare query URL self.logger.info('Preparing query URL for update_vlan.') _url_path = '/public/vlans/{id}' _url_path = APIHelper.append_url_with_template_parameters( _url_path, {'id': id}) _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers self.logger.info('Preparing headers for update_vlan.') _headers = { 'accept': 'application/json', 'content-type': 'application/json; charset=utf-8' } # Prepare and execute request self.logger.info( 'Preparing and executing request for update_vlan.') _request = self.http_client.put( _query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) AuthManager.apply(_request) _context = self.execute_request(_request, name='update_vlan') # Endpoint and global error handling using HTTP status codes. self.logger.info('Validating response for update_vlan.') 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, Vlan.from_dictionary) except Exception as e: self.logger.error(e, exc_info=True) raise
def delete_active_directory_entry(self, body): """Does a DELETE request to /public/activeDirectory. Deletes the join of the Cohesity Cluster to the specified Active Directory domain. After the deletion, the Cohesity Cluster no longer has access to the principals on the Active Directory. For example, you can no longer log in to the Cohesity Cluster with a user defined in a principal group of the Active Directory domain. Args: body (ActiveDirectoryEntry): Request to delete a join with an Active Directory. Returns: void: Response from the API. No Content Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ try: self.logger.info('delete_active_directory_entry called.') # Validate required parameters self.logger.info( 'Validating required parameters for delete_active_directory_entry.' ) self.validate_parameters(body=body) # Prepare query URL self.logger.info( 'Preparing query URL for delete_active_directory_entry.') _url_path = '/public/activeDirectory' _query_builder = self.config.get_base_uri() _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers self.logger.info( 'Preparing headers for delete_active_directory_entry.') _headers = {'content-type': 'application/json; charset=utf-8'} # Prepare and execute request self.logger.info( 'Preparing and executing request for delete_active_directory_entry.' ) _request = self.http_client.delete( _query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) AuthManager.apply(_request, self.config) _context = self.execute_request( _request, name='delete_active_directory_entry') # Endpoint and global error handling using HTTP status codes. self.logger.info( 'Validating response for delete_active_directory_entry.') if _context.response.status_code == 0: raise RequestErrorErrorException('Error', _context) self.validate_response(_context) except Exception as e: self.logger.error(e, exc_info=True) raise