Source code for integrateddatalake.clients.time_series_bulk_import_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 TimeSeriesBulkImportClient: __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_time_series_import_job(self, request_object): """Creates a bulk import job of time series data into data lake. Creates an asynchronous job to bulk import 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. :param CreateTimeSeriesImportJobRequest request_object: It contains the below parameters --> |br| ( ImportJob* - Bulk import job ) :return: ImportJobResponse """ logger.info( "TimeSeriesBulkImportClient.create_time_series_import_job() invoked." ) if request_object is None: raise exceptions.MindsphereClientError( "`request_object` is not passed when calling `create_time_series_import_job`" ) if request_object.import_job is None: raise exceptions.MindsphereClientError( "The required parameter `ImportJob` is missing from `request_object`, when calling `create_time_series_import_job`" ) end_point_url = "/timeSeriesImportJobs" 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 = {} form_params, local_var_files, body_params = {}, {}, request_object.import_job logger.info( "TimeSeriesBulkImportClient.create_time_series_import_job() --> Proceeding for API Invoker." ) return mindsphere_core.invoke_service( self.rest_client_config, api_url, headers, "POST", query_params, form_params, body_params, local_var_files, "ImportJobResponse", self.__model_package__, )
[docs] def delete_time_series_import_job(self, request_object): """Delete time series bulk import job by id. Delete completed time series bulk import job. :param DeleteTimeSeriesImportJobRequest request_object: It contains the below parameters --> |br| ( id* - Unique id of the time series bulk import job. ) :return: None """ logger.info( "TimeSeriesBulkImportClient.delete_time_series_import_job() invoked." ) if request_object is None: raise exceptions.MindsphereClientError( "`request_object` is not passed when calling `delete_time_series_import_job`" ) if request_object.id is None: raise exceptions.MindsphereClientError( "The required parameter `id` is missing from `request_object`, when calling `delete_time_series_import_job`" ) end_point_url = "/timeSeriesImportJobs/{id}" end_point_url = end_point_url.format(id=request_object.id) 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 = {} form_params, local_var_files, body_params = {}, {}, None logger.info( "TimeSeriesBulkImportClient.delete_time_series_import_job() --> Proceeding for API Invoker." ) return mindsphere_core.invoke_service( self.rest_client_config, api_url, headers, "DELETE", query_params, form_params, body_params, local_var_files, None, self.__model_package__, )
[docs] def query_time_series_import_jobs(self, request_object): """Query all time series bulk import jobs. Query all time series bulk import jobs currently existing, which are owned by the client's 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. :param QueryTimeSeriesImportJobsRequest request_object: It contains the below parameters --> |br| ( page - Specifies the requested page index ), |br| ( size - Specifies the number of elements in a page ), |br| ( filter - JSON-based filter expression. Supported values: 'subtenantId'. Supported operations: 'eq'. Decoded example value: { \"subtenantId\": \"204a896c-a23a-11e9-a2a3-2a2ae2dbcce4\" } ) :return: ImportJobListResource """ logger.info( "TimeSeriesBulkImportClient.query_time_series_import_jobs() invoked." ) end_point_url = "/timeSeriesImportJobs" 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 = { "page": request_object.page, "size": request_object.size, "filter": request_object.filter, } form_params, local_var_files, body_params = {}, {}, None logger.info( "TimeSeriesBulkImportClient.query_time_series_import_jobs() --> 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, "ImportJobListResource", self.__model_package__, )
[docs] def retrieve_time_series_import_job(self, request_object): """Retrieve status of time series bulk import job. Retrieve status of time series bulk import job. :param RetrieveTimeSeriesImportJobRequest request_object: It contains the below parameters --> |br| ( id* - Unique id for getting status of the time series bulk import job. ) :return: ImportJobResponse """ logger.info( "TimeSeriesBulkImportClient.retrieve_time_series_import_job() invoked." ) if request_object is None: raise exceptions.MindsphereClientError( "`request_object` is not passed when calling `retrieve_time_series_import_job`" ) if request_object.id is None: raise exceptions.MindsphereClientError( "The required parameter `id` is missing from `request_object`, when calling `retrieve_time_series_import_job`" ) end_point_url = "/timeSeriesImportJobs/{id}" end_point_url = end_point_url.format(id=request_object.id) 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 = {} form_params, local_var_files, body_params = {}, {}, None logger.info( "TimeSeriesBulkImportClient.retrieve_time_series_import_job() --> 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, "ImportJobResponse", self.__model_package__, )
[docs] def retrieve_time_series_import_job_details(self, request_object): """Retreive details of a time series bulk import job. Retreive details of a time series bulk import job. Details are only available once a job is not any longer in status PENDING. :param RetrieveTimeSeriesImportJobDetailsRequest request_object: It contains the below parameters --> |br| ( id* - Unique id for getting status of the time series bulk import job. ) :return: ImportJobDetails """ logger.info( "TimeSeriesBulkImportClient.retrieve_time_series_import_job_details() invoked." ) if request_object is None: raise exceptions.MindsphereClientError( "`request_object` is not passed when calling `retrieve_time_series_import_job_details`" ) if request_object.id is None: raise exceptions.MindsphereClientError( "The required parameter `id` is missing from `request_object`, when calling `retrieve_time_series_import_job_details`" ) end_point_url = "/timeSeriesImportJobs/{id}/details" end_point_url = end_point_url.format(id=request_object.id) 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 = {} form_params, local_var_files, body_params = {}, {}, None logger.info( "TimeSeriesBulkImportClient.retrieve_time_series_import_job_details() --> 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, "ImportJobDetails", self.__model_package__, )