Source code for integrateddatalake.clients.objects_metadata_catalog_operations_client

# coding: utf-8

"""
    Data Lake API

    Service for storing Objects, download objects, add extended metadata tags,  subscribe for notifications, import tenant specific MindSphere Time Series data, and enable data access using cross account access and STS in Integrated MindSphere Data Lake. - Objects reside in user specified path like below example. Extension in object name is optional. Root path can be denoted as \"/\"       /basefolder/subfolder/objectname.objectext   - The following generic error codes might occur at any of the specified operations. Generic errors are prefixed with 'mdsp.core.generic.'.    - missingParameter   - invalidParameter   - missingRequestBodyProperty   - invalidRequestBodyProperty   - unauthorized   - forbidden   - noMatch   - unsupportedMediaType   - tooManyRequests   - internalServerError  # noqa: E501
"""


from __future__ import absolute_import

from mindsphere_core.mindsphere_core import logger
from mindsphere_core import mindsphere_core, exceptions, token_service
from mindsphere_core.token_service import init_credentials


[docs]class ObjectsMetadataCatalogOperationsClient: __base_path__ = "/api/datalake/v3" __model_package__ = __name__.split(".")[0] def __init__(self, rest_client_config=None, mindsphere_credentials=None): self.rest_client_config = rest_client_config self.mindsphere_credentials = init_credentials(mindsphere_credentials)
[docs] def create_or_update_object_metadata(self, request_object): """Create/Update Metadata for the object. Create/Update metadata. If tenant is operating for a subtenant object, he should specify subtenant in request query parameter. If path contains special characters which require URL encoding, it should be done as appropriate. Maximum 8 tags are allowed, where each tag can be maximum 128 characters. :param CreateOrUpdateObjectMetadataRequest request_object: It contains the below parameters --> |br| ( path* - path of an object denoting folders and object name. e.g. basefolder/subfolder/objectname.objectext ), |br| ( metadata* - Metadata ), |br| ( subtenantId - Only to be used by tenants, to address a subtenant's object metadata. If not provided by a tenant, its own object metadata is addressed. Subtenants are not allowed to use this parameter and can only address their own object metadata. e.g. subtenantId \"204a896c-a23a-11e9-a2a3-2a2ae2dbcce4\" ) :return: None """ logger.info( "ObjectsMetadataCatalogOperationsClient.create_or_update_object_metadata() invoked." ) if request_object is None: raise exceptions.MindsphereClientError( "`request_object` is not passed when calling `create_or_update_object_metadata`" ) if request_object.path is None: raise exceptions.MindsphereClientError( "The required parameter `path` is missing from `request_object`, when calling `create_or_update_object_metadata`" ) if request_object.metadata is None: raise exceptions.MindsphereClientError( "The required parameter `metadata` is missing from `request_object`, when calling `create_or_update_object_metadata`" ) end_point_url = "/objectMetadata/{path}" end_point_url = end_point_url.format(path=request_object.path) token = token_service.fetch_token( self.rest_client_config, self.mindsphere_credentials ) api_url = mindsphere_core.build_url( self.__base_path__, end_point_url, self.rest_client_config ) headers = { "Content-Type": "application/json", "Authorization": "Bearer " + str(token), } query_params = {"subtenantId": request_object.subtenant_id} form_params, local_var_files, body_params = {}, {}, request_object.metadata logger.info( "ObjectsMetadataCatalogOperationsClient.create_or_update_object_metadata() --> Proceeding for API Invoker." ) return mindsphere_core.invoke_service( self.rest_client_config, api_url, headers, "PUT", query_params, form_params, body_params, local_var_files, None, self.__model_package__, )
[docs] def query_object_metadata(self, request_object): """Get a list of metadata Get Metadata for the object. :param QueryObjectMetadataRequest request_object: It contains the below parameters --> |br| ( filter* - Specifies the additional filtering criteria. This is encoded and is in the JSON format. 'filter' should have only one operator from the list [or,and,none]. 'none' operator must have only one property from this list [name,size,tags,lastModified,location]. 'and/or' operator must have minimum two properties from this list [name,size,tags,lastModified,location]. ), |br| ( subtenantId - Specifies the search based on subtenantId. if, subtenantId is denoted as \"**\", it will search for data in tenants & all subtenants. ), |br| ( size - Specifies the number of elements in a page ), |br| ( page - Specifies the requested page index ) :return: SearchResponse """ logger.info( "ObjectsMetadataCatalogOperationsClient.query_object_metadata() invoked." ) if request_object is None: raise exceptions.MindsphereClientError( "`request_object` is not passed when calling `query_object_metadata`" ) if request_object.filter is None: raise exceptions.MindsphereClientError( "The required parameter `filter` is missing from `request_object`, when calling `query_object_metadata`" ) end_point_url = "/objectMetadata" end_point_url = end_point_url.format() token = token_service.fetch_token( self.rest_client_config, self.mindsphere_credentials ) api_url = mindsphere_core.build_url( self.__base_path__, end_point_url, self.rest_client_config ) headers = { "Accept": "application/json", "Authorization": "Bearer " + str(token), } query_params = { "subtenantId": request_object.subtenant_id, "filter": request_object.filter, "size": request_object.size, "page": request_object.page, } form_params, local_var_files, body_params = {}, {}, None logger.info( "ObjectsMetadataCatalogOperationsClient.query_object_metadata() --> Proceeding for API Invoker." ) return mindsphere_core.invoke_service( self.rest_client_config, api_url, headers, "GET", query_params, form_params, body_params, local_var_files, "SearchResponse", self.__model_package__, )
[docs] def retrieve_object_metadata(self, request_object): """Get Metadata for the object. Get Metadata for the object. If tenant is operating for a subtenant object, he should specify subtenant in request query parameter. If path contains special characters which require URL encoding, it should be done as appropriate. :param RetrieveObjectMetadataRequest request_object: It contains the below parameters --> |br| ( path* - path of an object denoting folders and object name. e.g. basefolder/subfolder/objectname.objectext ), |br| ( subtenantId - * Only to be used by tenants, to address object metadata tags on subtenant's path. * If not provided by a tenant, then object metadata tags will be taken on tenant's own path. * Subtenants are not allowed to use this parameter and they can only address object metadata tags on their own path. * e.g. subtenantId \"204a896c-a23a-11e9-a2a3-2a2ae2dbcce4\". ) :return: ObjectMetaDataResponse """ logger.info( "ObjectsMetadataCatalogOperationsClient.retrieve_object_metadata() invoked." ) if request_object is None: raise exceptions.MindsphereClientError( "`request_object` is not passed when calling `retrieve_object_metadata`" ) if request_object.path is None: raise exceptions.MindsphereClientError( "The required parameter `path` is missing from `request_object`, when calling `retrieve_object_metadata`" ) end_point_url = "/objectMetadata/{path}" end_point_url = end_point_url.format(path=request_object.path) token = token_service.fetch_token( self.rest_client_config, self.mindsphere_credentials ) api_url = mindsphere_core.build_url( self.__base_path__, end_point_url, self.rest_client_config ) headers = { "Accept": "application/json", "Authorization": "Bearer " + str(token), } query_params = {"subtenantId": request_object.subtenant_id} form_params, local_var_files, body_params = {}, {}, None logger.info( "ObjectsMetadataCatalogOperationsClient.retrieve_object_metadata() --> Proceeding for API Invoker." ) return mindsphere_core.invoke_service( self.rest_client_config, api_url, headers, "GET", query_params, form_params, body_params, local_var_files, "ObjectMetaDataResponse", self.__model_package__, )