Skip to content

Integrated Data Lake Client for Python

Introduction

The Integrated Data Lake Python client allows you to perform operations provided by Integrated Data Lake Service.

Further implementation of the Integrated Data Lake SDK library has been shown in a sample project that you can download and test in local or on mindsphere application. Please refer to this repository: mindsphere-python-sdk-examples

For more information about the service, refer to Integrated Data Lake Service.

Hint

Placeholders in the following samples are indicated by angular brackets < >.

Integrated Data Lake Operations

Client Name: ObjectOperationsClient

Query objects

  • Retrieve information of existing objects. In case a folder is specified as input path, all child objects within the folder are returned. Objects in sub-folders of the given folder are not returned. In case a file is specified as input path, only the file is returned. Only the objects of one tenant or subtenant are returned. In case a tenant wants to retrieve information of a subtenant objects, the subtenantId query parameter must be used.
# Import the RestClientConfig and UserToken from mindsphere_core module
from mindsphere_core import RestClientConfig
from mindsphere_core import UserToken

# Import the MindsphereError from mindsphere_core.exceptions module
from mindsphere_core.exceptions import MindsphereError

# Import the ObjectOperationsClient from integrateddatalake module
from integrateddatalake import ObjectOperationsClient
from integrateddatalake import QueryObjectsRequest, Path

# Instantiate the RestClientConfig and UserToken objects
config = RestClientConfig(proxy_host = "<proxy_host>", proxy_port = <proxy_port>)
credentials = UserToken(authorization = "<bearer_token>")

# Create the AggregatesClient object using the RestClientConfig and UserToken objects
objectOperationsClient = ObjectOperationsClient(rest_client_config=config, mindsphere_credentials=credentials)

try:

    # Path Object
    # Create Query Object Request
    queryObjectsRequest = QueryObjectsRequest(
        path="<path>", 
        subtenant_id="<subtenantId>", 
        page_token="<pageToken>"
    )

    # Initiate the API call
    response = objectOperationsClient.query_objects(queryObjectsRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Delete an object

  • Delete the object located at specified path.
deleteObjectRequest = DeleteObjectRequest(path="<path>")
try:
    response = objectOperationsClient.delete_object(deleteObjectRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Delete multiple objects in bulk

  • Create asynchronous job to delete multiple objects for the specified paths. If any of the given paths doesnt exist then job will return status as COMPLETED_WITH_ERRORS. Jobs which are completed with or without errors would be deleted periodically.Data once deleted cannot be recovered.
deleteObjectsJobRequestObjects = DeleteObjectsJobRequestObjects(path='<path>')
objects = list([deleteObjectsJobRequestObjects])
deleteObjectsJobRequest = DeleteObjectsJobRequest(objects=objects)
createDeleteObjectsJobRequest = CreateDeleteObjectsJobRequest(delete_objects_job=deleteObjectsJobRequest)

try:
    response = objectOperationsClient.create_delete_objects_job(createDeleteObjectsJobRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Fetch details of all the Delete Objects Jobs

  • Create asynchronous job to delete multiple objects for the specified paths. If any of the given paths doesnt exist then job will return the status as COMPLETED_WITH_ERRORS. Jobs which are completed with or without errors would be deleted periodically.Data once deleted cannot be recovered.
getAllDeleteObjectsJobRequest = GetAllDeleteObjectsJobRequest()

try:
    response = objectOperationsClient.get_all_delete_objects_job(getAllDeleteObjectsJobRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Fetch status and details of Delete Objects Job

  • Retrieve information of given Delete Objects Job. Only the objects of one tenant or subtenant are returned. In case a tenant wants to retrieve information on a subtenant's objects, the subtenantId query parameter must be used.
getDeleteObjectsJobRequest = GetDeleteObjectsJobRequest(id='<id>')

try:
    response = objectOperationsClient.get_delete_objects_job(getDeleteObjectsJobRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Fetch errors of Delete Objects Job

  • Retrieve errors of given Delete Objects Job. This endpoint should be called only when /deleteObjectsJobs/{id} returns the status as COMPLETED_WITH_ERRORS. Only the objects of one tenant or subtenant are returned. In case a tenant wants to retrieve information on a subtenant objects, the subtenantId query parameter must be used.
deleteObjectsJobRequestObjects = DeleteObjectsJobRequestObjects(path='<path>')
objects = [deleteObjectsJobRequestObjects]
deleteObjectsJobRequest = DeleteObjectsJobRequest(objects=objects)
createDeleteObjectsJobRequest = CreateDeleteObjectsJobRequest(delete_objects_job=deleteObjectsJobRequest)
response1 = objectOperationsClient.create_delete_objects_job(createDeleteObjectsJobRequest)
getDeleteObjectsJobErrorsRequest = GetDeleteObjectsJobErrorsRequest(id=response1.id)

try:
    response2 = objectOperationsClient.get_delete_objects_job_errors(getDeleteObjectsJobErrorsRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Client Name: ObjectEventSubscriptionOperationsClient

List event subscriptions for the tenant or subtenant

  • List object event subscriptions for the tenant or subtenant. If requester is tenant, all the subscriptions for the tenant as well as its all subtenants are returned. If requester is a subtenant, all the subscriptions for the subtenant are returned. If tenant wants to filter results for a particular subtenant, filter query parameter subtenantId can be used. This filter query parameter is applicable only if the requester is tenant.
# Import the RestClientConfig and UserToken from mindsphere_core module
from mindsphere_core import RestClientConfig
from mindsphere_core import UserToken

# Import the MindsphereError from mindsphere_core.exceptions module
from mindsphere_core.exceptions import MindsphereError

# Import the ObjectOperationsClient from integrateddatalake module
from integrateddatalake import ObjectEventSubscriptionOperationsClient
from integrateddatalake import QueryObjectEventSubscriptionsRequest

# Instantiate the RestClientConfig and UserToken objects
config = RestClientConfig(proxy_host = "<proxy_host>", proxy_port = <proxy_port>)
credentials = UserToken(authorization = "<bearer_token>")

# Create the AggregatesClient object using the RestClientConfig and UserToken objects
objectEventSubscriptionOperationsClient = ObjectEventSubscriptionOperationsClient(rest_client_config=config, mindsphere_credentials=credentials)

queryObjectEventSubscriptionsRequest = QueryObjectEventSubscriptionsRequest()
try:
    response = objectEventSubscriptionOperationsClient.query_object_event_subscriptions(queryObjectEventSubscriptionsRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Create object event subscription

  • Allows users to subscribe for event notifications generated when the objects of a tenant or subtenant are created, updated, or deleted. Multiple subscriptions for the same path can be created when each has a different destination. Similarly, multiple subscriptions for the same destination can be created when each has a different path. Maximum 15 subscriptions can be created for a tenant or for a subtenant. Path in request payload should be upto folders and not upto object e.g. \"myfolder/mysubfolder\". Notification Content Based on the configured subscriptions,event notification messages are published to the destination. The event notification content is formatted in JSON according to this example. If object operation happened in subtenant folder, both tenantId and subtenantId will be part of the message. If object operation happened in tenant folder, only tenantId will be part of the message.
subscription = Subscription(
    path='<path>',
    destination='<destination_uri>'
)
createObjectEventSubscriptionRequest = CreateObjectEventSubscriptionRequest(subscription=subscription)

try:
    response = objectEventSubscriptionOperationsClient.create_object_event_subscription(createObjectEventSubscriptionRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Update object event subscription by id

  • Update object event subscription.
subscription1 = Subscription(
    path='<path1>',
    destination='<destination_uri>'
)
createObjectEventSubscriptionRequest = CreateObjectEventSubscriptionRequest(subscription=subscription1)
response1 = objectEventSubscriptionOperationsClient.create_object_event_subscription(createObjectEventSubscriptionRequest)

subscription2 = Subscription(
    path='<path2>',
    destination='<destination_uri>'
)
patchObjectEventSubscriptionRequest = PatchObjectEventSubscriptionRequest(
    if_match=response1.e_tag,
    id=response1.id,
    subscription=subscription2
)

try:
    response2 = objectEventSubscriptionOperationsClient.patch_object_event_subscription(patchObjectEventSubscriptionRequest)
    print(response2)

except MindsphereError as err:
    # Exception Handling

Read object event subscription by id

  • Read object event subscription for the tenant.
retrieveObjectEventSubscriptionRequest = RetrieveObjectEventSubscriptionRequest(id='<id')
try:
    response = objectEventSubscriptionOperationsClient.retrieve_object_event_subscription(retrieveObjectEventSubscriptionRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Delete object event subscription by id

  • Delete object event subscription (Unsubscribe).
subscription = Subscription(
    path='<path>',
    destination='<destination_uri>'
)
createObjectEventSubscriptionRequest = CreateObjectEventSubscriptionRequest(subscription=subscription)
response1 = objectEventSubscriptionOperationsClient.create_object_event_subscription(createObjectEventSubscriptionRequest)

deleteObjectEventSubscriptionRequest = DeleteObjectEventSubscriptionRequest(
    if_match=response1.e_tag,
    id=response1.id
)
try:
    response2 = objectEventSubscriptionOperationsClient.delete_object_event_subscription(deleteObjectEventSubscriptionRequest)
    print(response2)

except MindsphereError as err:
    # Exception Handling

Client Name: ObjectAccessOperationsClient

Generate signed URLs to upload an object

  • Generate signed URLs to upload one or more objects.
  • Signed URL response for upload
# Import the RestClientConfig and UserToken from mindsphere_core module
from mindsphere_core import RestClientConfig
from mindsphere_core import UserToken

# Import the MindsphereError from mindsphere_core.exceptions module
from mindsphere_core.exceptions import MindsphereError

# Import the ObjectOperationsClient from integrateddatalake module
from integrateddatalake import objectAccessOperationsClient
from integrateddatalake import GenerateUrlPayload, GenerateUploadObjectUrlsRequest

# Instantiate the RestClientConfig and UserToken objects
config = RestClientConfig(proxy_host = "<proxy_host>", proxy_port = <proxy_port>)
credentials = UserToken(authorization = "<bearer_token>")

# Create the AggregatesClient object using the RestClientConfig and UserToken objects
objectAccessOperationsClient = ObjectAccessOperationsClient(rest_client_config=config, mindsphere_credentials=credentials)

path = Path('<path>')
generateUrlPayload = GenerateUrlPayload(paths=[path])
generateUploadObjectUrlsRequest = GenerateUploadObjectUrlsRequest(generateUrlPayload)

try:
    response = objectAccessOperationsClient.generate_upload_object_urls(generateUploadObjectUrlsRequest)
    signedUrl = response.object_urls[0]['signedUrl']
    objectPath = '<path_to_file>/<file_name>.csv'
    objectFile = open(objectPath, 'rb')
    response = objectAccessOperationsClient.upload_file_object(signed_url=signedUrl, upload_file=objectFile)
    print(response)

except MindsphereError as err:
    # Exception Handling

Generate signed URLs to download an object

  • Generate signed URLs to download single object.
  • Generate signed URLs to download one or more objects.
  • Signed URL response for download
path = Path('<path>')
generateUrlPayload = GenerateUrlPayload(paths=[path])
generateDownloadObjectUrlsRequest = GenerateDownloadObjectUrlsRequest(generateUrlPayload)

try:
    response = objectAccessOperationsClient.generate_download_object_urls(generateDownloadObjectUrlsRequest)
    signedUrl = response.object_urls[0]['signedUrl']
    file = objectAccessOperationsClient.download_file_object(signed_url=signedUrl)
    open('<path_to_file>/<file_name>.csv', 'wb').write(file)

except MindsphereError as err:
    # Exception Handling

Get a list of cross accounts

  • Get list of cross accounts on which access was given.
    • If requester is tenant, all the cross account for the tenant as well as its all subtenants are returned.
    • If requester is a subtenant, all the cross accounts for the subtenant are returned.
    • If tenant wants to filter results for a particular subtenant, filter query parameter subtenantId can be used. This filter query parameter is applicable only if the requester is tenant.

NOTE: Works with [eu1] domains only

listCrossAccountRequest = ListCrossAccountRequest(subtenat_id=None, 500, 0)
try:
    listCrossAccountResponse = objectAccessOperationsClient.list_cross_account(request_object=listCrossAccountRequest)
    print(listCrossAccountResponse)

except MindsphereError as err:
    # Exception Handling

Create a cross account

  • Create a cross account on which access needs to be given for paths.
    • If, in request body subtenant is denoted as , it is a special cross account. In this case, on this cross account, tenant implicitly gets Read Only access to the storage account's root level data path for itself and for all its subtenants. For this case, the authorization token should be that of the tenant.

NOTE: Works with [eu1] domains only

crossAccountRequest = CrossAccountRequest(
    name='test1254',
    accessor_account_id=687043204292,
    description='sdsfsfgf'
)
createCrossAccountRequest = CreateCrossAccountRequest(crossAccountRequest)

try:
    response = objectAccessOperationsClient.create_cross_account(createCrossAccountRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Get details of selected cross account

  • Get details of selected cross account.

NOTE: Works with [eu1] domains only

getCrossAccountRequest = GetCrossAccountRequest(id='<id>')
try:
    response = objectAccessOperationsClient.get_cross_account(getCrossAccountRequest)

except MindsphereError as err:
    # Exception Handling

Update a cross account

  • Update a cross account on which access needs to be managed.

NOTE: Works with [eu1] domains only

crossAccountUpdateRequest = CrossAccountUpdateRequest(name='abcdd', description='rgregerr')
updateCrossAccountRequest = UpdateCrossAccountRequest(
    if_match='<e_tag>',
    id='<id>',
    cross_account_request=crossAccountUpdateRequest
)
try:
    response = objectAccessOperationsClient.update_cross_account(updateCrossAccountRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Delete cross account

  • Delete cross account and corresponding accesses.

NOTE: Works with [eu1] domains only

deleteCrossAccountRequest = DeleteCrossAccountRequest(
    if_match='<e_tag>',
    id='<id>'
)
try:
    response = objectAccessOperationsClient.delete_cross_account(deleteCrossAccountRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Create a cross account access

  • Create a cross account access. Create a cross account access. If the cross account is created for tenant and all subtenants (**), then this operation is implicitly handled and not allowed through API. Maximum 5 cross account accesses can be created with ENABLED status. Maximum 10 cross accounts can be created with DISABLED status.

NOTE: Works with [eu1] domains only

crossAccountAccessRequest = CrossAccountAccessRequest(
    description='<description>',
    path='<path>',
    permission=Permission.DELETE,
    status='<ENABLED/DISABLED>'
)
createCrossAccountAccessRequest = CreateCrossAccountAccessRequest(
    cross_account_access_request=crossAccountAccessRequest,
    id='<cross_account_id>'
)
try:
    response = objectAccessOperationsClient.create_cross_account_access(createCrossAccountAccessRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Get a list of cross account accesses

This section shows two options for achieving the following behavior:

  • Get list of cross account accesses.

NOTE: Works with [eu1] domains only

getCrossAccountAccessRequest = GetCrossAccountAccessRequest(
    access_id='<access_id>', 
    id='<cross_account_id>'
)
try:
    response = objectAccessOperationsClient.get_cross_account_access(getCrossAccountAccessRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Get a cross account access

  • Get a selected access for a selected cross account.

NOTE: Works with [eu1] domains only

getCrossAccountRequest = GetCrossAccountRequest(
    id='<cross_account_id>'
)
try:
    response = objectAccessOperationsClient.get_cross_account(getCrossAccountRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Update a cross account access

  • Update a cross account access. This operation is not allowed when the cross account is created for special case of tenant and all subtenants (**). Maximum 5 cross account accesses can be present with ENABLED status. Maximum 10 cross accounts can be present with DISABLED status.

NOTE: Works with [eu1] domains only

crossAccountUpdateRequest = CrossAccountUpdateRequest(
    name='<name>', 
    description='<description>'
)
updateCrossAccountRequest = UpdateCrossAccountRequest(
    if_match='<e_tag>',
    id='<id>',
    cross_account_request=crossAccountUpdateRequest
)
try:
    response = objectAccessOperationsClient.update_cross_account(updateCrossAccountRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Delete a cross account access

If the cross account is created for tenant and all subtenants (**), then this operation is implicitly handled by deletion of cross account and not allowed through API.

NOTE: Works with [eu1] domains only

deleteCrossAccountAccessRequest = DeleteCrossAccountAccessRequest(
    access_id='<access_id>',
    if_match='<e_tag>',
    id='<cross_account_id>'
)
try:
    response = objectAccessOperationsClient.delete_cross_account_access(deleteCrossAccountAccessRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Client Name: ObjectOperationsWithAccessTokenClient

List all folders having write premission

This API can be accessed by tenantadmin to list all write permission folders including that of subtenants. Subtenant can access this API to get list write permission folders owned by subtenant. Size parameter value should not be more than 1000.

NOTE: Works with [eu1] domains only

# Import the RestClientConfig and UserToken from mindsphere_core module
from mindsphere_core import RestClientConfig
from mindsphere_core import UserToken

# Import the MindsphereError from mindsphere_core.exceptions module
from mindsphere_core.exceptions import MindsphereError

# Import the ObjectOperationsClient from integrateddatalake module
from integrateddatalake import ObjectOperationsWithAccessTokenClient
from integrateddatalake import ListAccessTokenPermissionsRequest

# Instantiate the RestClientConfig and UserToken objects
config = RestClientConfig(proxy_host = "<proxy_host>", proxy_port = <proxy_port>)
credentials = UserToken(authorization = "<bearer_token>")

# Create the AggregatesClient object using the RestClientConfig and UserToken objects
objectOperationsWithAccessTokenClient = ObjectOperationsWithAccessTokenClient(rest_client_config=config, mindsphere_credentials=credentials)

listAccessTokenPermissionsRequest = ListAccessTokenPermissionsRequest()

try:
    response = objectOperationsWithAccessTokenClient.list_access_token_permissions(listAccessTokenPermissionsRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Allows to give write premission on folder/path

  • Allows users (tenant) to give write permission on folder/path. This API can only be accessed by tenantadmin. Tenantadmin can also provide write permission on subtenant folder. Write permission on root folder can also be given, except TSI folder

NOTE: Works with [eu1] domains only

accessTokenPermissionRequest = AccessTokenPermissionRequest(
    path='<path>',
    permission=AccessPermission.WRITE
)
try:
    accessTokenPermissionsRequest = AccessTokenPermissionsRequest(write_path_payload=accessTokenPermissionRequest)
    response = objectOperationsWithAccessTokenClient.access_token_permissions(accessTokenPermissionsRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Details of the write folder request for the given id

This API can be accessed by tenantadmin to get details of the request including that for subtenants. Subtenant can access this API, to get details of the request belongs to their write folder.

NOTE: Works with [eu1] domains only

getAccessTokenPermissionsRequest = GetAccessTokenPermissionsRequest(id='<id>')
try:
    response = objectOperationsWithAccessTokenClient.get_access_token_permissions(getAccessTokenPermissionsRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Generate AWS STS token

  • Allows the users to request temporary, limited-privilege AWS credentials to get read-only or write-only access on the URI returned in the response.
    • Read permission will always be on the root level.
    • Path field is optional for READ permission. If value for path is not provided then it will be considered on root level
    • Ensure to enable write access on the path before requesting token with write permission.
    • Write access can be enabled using POST /accessTokenPermissions endpoint.
    • An access token requested for a given path also automatically gives access to all subpaths of the path. For example, if an access token is requested for path /a and there are subpaths /a/b and /a/b/c, the token allows to access those too.
    • An access token with write permissions can only be requested for the paths defined by resource accessTokenPermissions. An acecss token with read permissions can only be requested for the root path /.

NOTE: Works with [eu1] domains only

generateSTSPayload = GenerateSTSPayload()
generateAccessTokenRequest = GenerateAccessTokenRequest(sts_payload=generateSTSPayload)
try:
    response = objectOperationsWithAccessTokenClient.generate_access_token(request_object=generateAccessTokenRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Delete write permission on folder for the given id

This API can be accessed by the tenantadmin only.

NOTE: Works with [eu1] domains only

deleteAccessTokenPermissionsRequest = DeleteAccessTokenPermissionsRequest(id='<id>')
try:
    response = objectOperationsWithAccessTokenClient.delete_access_token_permissions(deleteAccessTokenPermissionsRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Client Name: TimeSeriesBulkImportClient

Query all time series bulk import jobs

  • Query all time series bulk import jobs currently existing, which are owned by the client tenant or subtenant. If requester is tenant, all the import jobs for the tenant as well as its all subtenants are returned. If requester is a subtenant, all the iport jobs for the subtenant are returned. If tenant wants to filter results for a particular subtenant, filter query parameter subtenantId can be used. This filter query parameter is applicable only if the requester is tenant.
# Import the RestClientConfig and UserToken from mindsphere_core module
from mindsphere_core import RestClientConfig
from mindsphere_core import UserToken

# Import the MindsphereError from mindsphere_core.exceptions module
from mindsphere_core.exceptions import MindsphereError

# Import the ObjectOperationsClient from integrateddatalake module
from integrateddatalake import TimeSeriesBulkImportClient
from integrateddatalake import QueryTimeSeriesImportJobsRequest

# Instantiate the RestClientConfig and UserToken objects
config = RestClientConfig(proxy_host = "<proxy_host>", proxy_port = <proxy_port>)
credentials = UserToken(authorization = "<bearer_token>")

# Create the AggregatesClient object using the RestClientConfig and UserToken objects
timeSeriesBulkImportClient = TimeSeriesBulkImportClient(rest_client_config=config, mindsphere_credentials=credentials)

queryTimeSeriesImportJobsRequest = QueryTimeSeriesImportJobsRequest()
try:
    response = timeSeriesBulkImportClient.query_time_series_import_jobs(queryTimeSeriesImportJobsRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Create a bulk import job of time series data into data lake

The import takes into account time series data from the provided aspects associated to the provided assets, in the given time range.

importJobRequest = ImportJobRequest(
    name='<name>',
    destination='<destination>',
    _from='<20XX-XX-XXTXX:XX:XX.XXXZ>',
    to='<20XX-XX-XXTXX:XX:XX.XXXZ>',
    aspect_names=['<aspect_name>'],
    asset_ids=['<asset_id>']
)
createTimeSeriesImportJobRequest = CreateTimeSeriesImportJobRequest(import_job=importJobRequest)
try:
    importJobResponse = timeSeriesBulkImportClient.create_time_series_import_job(createTimeSeriesImportJobRequest)
    print(importJobResponse)

except MindsphereError as err:
    # Exception Handling

Delete time series bulk import job by id

Deletes the completed time series bulk import job.

deleteTimeSeriesImportJobRequest = DeleteTimeSeriesImportJobRequest(id='<id>')
try:
    response = timeSeriesBulkImportClient.delete_time_series_import_job(deleteTimeSeriesImportJobRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Retrieve status of time series bulk import job

Retrieves the status of time series bulk import job.

retrieveTimeSeriesImportJobRequest = RetrieveTimeSeriesImportJobRequest(id='<id>')
try:
    response = timeSeriesBulkImportClient.retrieve_time_series_import_job(retrieveTimeSeriesImportJobRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Client Name: ObjectsMetadataCatalogOperationsClient

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.
# Import the RestClientConfig and UserToken from mindsphere_core module
from mindsphere_core import RestClientConfig
from mindsphere_core import UserToken

# Import the MindsphereError from mindsphere_core.exceptions module
from mindsphere_core.exceptions import MindsphereError

# Import the ObjectOperationsClient from integrateddatalake module
from integrateddatalake import ObjectsMetadataCatalogOperationsClient
from integrateddatalake import Metadata, CreateOrUpdateObjectMetadataRequest

# Instantiate the RestClientConfig and UserToken objects
config = RestClientConfig(proxy_host = "<proxy_host>", proxy_port = <proxy_port>)
credentials = UserToken(authorization = "<bearer_token>")

# Create the AggregatesClient object using the RestClientConfig and UserToken objects
objectsMetadataCatalogOperationsClient = ObjectsMetadataCatalogOperationsClient(rest_client_config=config, mindsphere_credentials=credentials)

tags = ['<tag1>', '<tag2>']
metadata = Metadata(tags=tags)
createOrUpdateObjectMetadataRequest = CreateOrUpdateObjectMetadataRequest(
    path='<path>',
    metadata=metadata
)

try:
    response = objectsMetadataCatalogOperationsClient.create_or_update_object_metadata(createOrUpdateObjectMetadataRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

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.

retrieveObjectMetadataRequest = RetrieveObjectMetadataRequest(
    path='<path>'
)

try:
    response = objectsMetadataCatalogOperationsClient.retrieve_object_metadata(retrieveObjectMetadataRequest)
    print(response)

except MindsphereError as err:
    # Exception Handling

Any questions left?

Ask the community


Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.


Last update: April 7, 2022