def get(self, request, **kwargs): """ route <str:id>/aspects return List of all aspects for provided asset id. param id : Unique identifier of an asset. (passed in keyword arguments.) description This method internally calls method list_asset_aspects of StructureClient class. This class is available as dependency in assetmanagement-<version-here>-py3-none-any.whl apiEndpoint : GET /api/assetmanagement/v3/assets/{id}/aspects of asset management service. apiNote Get all static and dynamic aspects of a given asset. throws Error if an error occurs while attempting to invoke the sdk call. """ logger.info("assets/<str:id>/aspects invoked.") client = sdk_util.build_sdk_client(self.__class__.__name__, request) if request.method == "GET": try: request_object = GetRootAssetRequest(if_none_match=None) asset = client.get_root_asset(request_object) asset = serialization_filter.sanitize_for_serialization(asset) resonse = json.dumps(asset) logger.info(resonse) except exceptions.MindsphereError as err: logger.error(err) return HttpResponse( err, content_type="application/json", status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) return HttpResponse( resonse, content_type="application/json", status=status.HTTP_200_OK )
def get(self, request, **kwargs): """ get time series route : timeseriesaggregate/get/<str:entityid>/<str:propertyname> requestparam : entityId - An Asset Id for which aggregates are to be retrieved. requestparam : propertySetName - property setname for which aggregates will be be retrieved. note : Non existent/Incorrect entityId and propertySetName will result in MindsphereError. param ---> request - HttpRequest object returns : Time series aggregates in String format. returnType : String description : This method - get internally calls method retrieve_aggregates of AggregatesClient class. This class is available as dependency in tsaggregates-<version-here>-py3-none-any.whl. For retrieve_aggregates, two parameters are passed - entityId - An Asset Id for which aggregates are to be retrieved and property setname for which aggregates will be be retrieved. With an absence of any other parameters aggregates will be returned by following rule : The parameters from, to, intervalUnit, intervalValue, and count are used to determine the time range and interval length to return aggregates for. Intelligent auto-completion is applied to allow clients to only provide a subset of the parameters, according to the following rules: In case none of the parameters is provided, intervalUnit is set to DAY, intervalValue is set to 1, to is set to the current time, and from is set to the current time minus 7 days. apiEndpoint : GET /api/iottsaggregates/v4/aggregates of aggregate service. service. apiNote : Returns a list of aggregates for a given asset and aspect. The time range of the aggregates can be defined by a combination of parameters; such as from, to, intervalUnit, intervalValue and count. Time range can be specified anywhere in past or future for which timeseries data is present. In the case no time series data was available for an aggregation interval, no aggregate will be returned. Pre-computed aggregates are aligned with the tenant's time zone. throws MindsphereError : if an error occurs while attempting to invoke the sdk call. """ logger.info( "timeseriesaggregate/get/<str:entityid>/<str:propertyname> invoked" ) client = sdk_util.build_sdk_client(self.__class__.__name__, request) if request.method == "GET": try: entity_id = kwargs.get("entityid", "") property_name = kwargs.get("propertyname", "") logger.info("Request params are- enitityID:" + entity_id + " propertyName: " + property_name) request_object = RetrieveAggregatesRequest() request_object.asset_id = entity_id request_object.aspect_name = property_name aggregateList = client.retrieve_aggregates(request_object) aggregate_json = serialization_filter.sanitize_for_serialization( aggregateList) aggregate_json = json.dumps(aggregate_json) logger.info( "Getting response successfully for timeseriesaggregate" + aggregate_json) except exceptions.MindsphereError as err: logger.error("Getting error for timeseriesaggregate" + err) return HttpResponse( err, content_type="application/json", status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) return HttpResponse(aggregate_json, content_type="application/json", status=status.HTTP_200_OK)
def get(self, request, **kwargs): """ get time series route timeSeries/get/<str:entityid>/<str:propertyname>/<str:from>/<str:to> param entityId - unique identifier of the asset (entity) param propertyname - Name of the aspect (property set). param from - Beginning of the time range to be retrieved (exclusive). param to - End of the time range to be retrieved (inclusive). return Timeseries data on successful execution. description This method internally calls method retrieve_timeseries of TimeSeriesOperationsClient class. This class is available as dependency in timeseries-<version-here>-py3-none-any.whl. entityId, propertySetName, from and to are passed in request object as given by user(path variables) and hence incorrect/non-existent values for entiyId and/or propertyname will result in MindsphereError. apiEndpoint : GET /api/iottimeseries/v3/timeseries/{entityId}/{propertySetName} of timeseries service. service. service. apiNote Retrieve time series data for one combination of an asset (entity) and an(a) aspect (property set). throws MindsphereError if an error occurs while attempting to invoke the sdk call. """ logger.info( "timeSeries/get/<str:entityid>/<str:propertyname>/<str:from>/<str:to> invoked" ) client = sdk_util.build_sdk_client(self.__class__.__name__, request) if request.method == "GET": try: entity_id = kwargs.get("entityid", "") property_name = kwargs.get("propertyname", "") _from = kwargs.get("from", "") to = kwargs.get("to", "") qryparam = request.query_params logger.info("Request params are- enitityID:" + entity_id + " propertyName: " + property_name + " from:" + _from + " to:" + to) request_object = RetrieveTimeseriesRequest() request_object.entity_id = entity_id request_object.property_set_name = property_name request_object._from = qryparam['from'] request_object.to = qryparam['to'] timseriesList = client.retrieve_timeseries(request_object) timeseries_json = serialization_filter.sanitize_for_serialization( timseriesList) timeseries_json = json.dumps(timeseries_json) logger.info("Getting response successfully for gettimeSeries" + timeseries_json) except exceptions.MindsphereError as err: logger.error(err.message) return HttpResponse( json.dumps(err.message.message), content_type="application/json", status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) return HttpResponse(timeseries_json, content_type="application/json", status=status.HTTP_200_OK)
def get(self, request, **kwargs): """ create Diagnostic Activation. route mindconnect/diagnosticActivationsCreate/<str:agentid>/<str:status> param : agentid ---> Unique identifier of the agent. param : status ---> Status of the activation. return Created diagnostic activation data. description This method internally calls method diagnostic_activations_post of DiagnosticActivationsClient class. This class is available as dependency in mindconnect-<version-here>-py3-none-any.whl. apiEndpoint : POST /api/mindconnect/v3/diagnosticActivations of mindconnect service. apiNote Creates a new diagnostic activation. throws MindsphereError if an error occurs while attempting to invoke the sdk call. """ logger.info( "mindconnect/diagnosticActivationsCreate/<str:agentid>/<str:status> invoked" ) client = sdk_util.build_sdk_client(self.__class__.__name__, request) if request.method == "GET": try: agent_id = kwargs.get("agentid", "") status = kwargs.get("status", "") logger.info("Request params are- agentid:" + agent_id + " status: " + status) diagnosticActivation = DiagnosticActivation(agent_id=agent_id, status=status) request_object = DiagnosticActivationsPostRequest( diagnostic_activation=diagnosticActivation) response = client.diagnostic_activations_post(request_object) respose_json = serialization_filter.sanitize_for_serialization( response) respose_json = json.dumps(respose_json) logger.info( "Getting response successfully for diagnosticActivationsCreate" + respose_json) except exceptions.MindsphereError as err: logger.error("Getting error for diagnosticActivationsCreate" + err) return HttpResponse( err, content_type="application/json", status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) return HttpResponse(respose_json, content_type="application/json", status=status.HTTP_200_OK)
def put(self, request, **kwargs): """ put time series """ logger.info('timeSeries/put invoked') client = sdk_util.build_sdk_client(self.__class__.__name__, request) if request.method == "PUT": try: # timeseries = UpdatedTimeSeries() # timeSeriesItem = TimeSeriesItem() # timeSeriesItem.entity_id = "535140e4980e413497d112015ddd47ff" # timeSeriesItem.property_set_name = "testaspect2812" # # timeSeriesDataItem = TimeSeriesDataItem() # timeSeriesDataItem.fields = { # "test": 15 # } # timeSeriesDataItem.time = "2020-11-11T02:52:00Z" # timeSeriesDataItems = [timeSeriesDataItem] # timeSeriesItem.data = timeSeriesDataItems # timeSeriesItems = [timeSeriesItem] # timeseries.timeseries = tim = timeSeriesItems # createOrUpdateTimeseriesRequest = CreateOrUpdateTimeseriesRequest() # createOrUpdateTimeseriesRequest.timeseries = timeseries requestObj = json.dumps(request.data) timeseries = json.loads(requestObj) createOrUpdateTimeseriesRequest = CreateOrUpdateTimeseriesRequest( ) createOrUpdateTimeseriesRequest.timeseries = timeseries response = client.create_or_update_timeseries( createOrUpdateTimeseriesRequest) timeseries_json = serialization_filter.sanitize_for_serialization( response) timeseries_json = json.dumps(timeseries_json) logger.info("timeseries updated Successfully " + timeseries_json) except exceptions.MindsphereError as err: logger.error(err.message) return HttpResponse( json.dumps(err.message.message), content_type="application/json", status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) return HttpResponse(timeseries_json, content_type="application/json", status=status.HTTP_200_OK)
def get(self, request, **kwargs): """ route mindconnect/recoverableRecordIdDownloadLinkGet/<str:id> param id - Unique identifier of the recoverable record. return Response of download link in String format. description This method internally calls method recoverable_records_id_download_link_get of RecordRecoveryClient class. This class is available as dependency in mindconnect-<version-here>-py3-none-any.whl. apiEndpoint : GET /api/mindconnect/v3/recoverableRecords/{id}/downloadLink of mindconnect service. service. apiNote Get download link of record payload. throws MindsphereError if an error occurs while attempting to invoke the sdk call. """ logger.info( "mindconnect/recoverableRecordIdDownloadLinkGet/<str:id> invoked") client = sdk_util.build_sdk_client(self.__class__.__name__, request) if request.method == "GET": try: id = kwargs.get("id", "") logger.info("Request param is- Id:" + id) request_object = RecoverableRecordsIdDownloadLinkGetRequest( id=id) response = client.recoverable_records_id_download_link_get( request_object) respose_json = serialization_filter.sanitize_for_serialization( response) respose_json = json.dumps(respose_json) logger.info( "Getting response successfully for recoverableRecordIdDownloadLinkGet " + respose_json) except exceptions.MindsphereError as err: logger.error( "Getting error for recoverableRecordIdDownloadLinkGet " + err) return HttpResponse( err, content_type="application/json", status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) return HttpResponse(respose_json, content_type="application/json", status=status.HTTP_200_OK)
def get(self, request, **kwargs): """ route mindconnect/diagnosticActivationsGetbyidmessage/<str:id> param id - Unique identifier of diagnostic activation resource. (required) return Paged diagnostic information messages. description This method - diagnosticActivationsIdGetTest internally calls method diagnosticActivationsIdMessagesGet of DiagnosticActivationsClient class. This class is available as dependency in mindconnect-<version-here>-py3-none-any.whl. apiEndpoint : GET /api/mindconnect/v3/diagnosticActivations/{id}/messages of mindconnect service. apiNote Get a diagnostic messages of specific activation resource. throws MindsphereError if an error occurs while attempting to invoke the sdk call. """ logger.info( "mindconnect/diagnosticActivationsGetbyidmessage/<str:id> invoked") client = sdk_util.build_sdk_client(self.__class__.__name__, request) if request.method == "GET": try: did = kwargs.get("id", "") logger.info("Request param is - Id:" + did) request_object = DiagnosticActivationsIdMessagesGetRequest( id=did) response = client.diagnostic_activations_id_messages_get( request_object) respose_json = serialization_filter.sanitize_for_serialization( response) respose_json = json.dumps(respose_json) logger.info( "Getting response successfully for diagnosticActivationsGetbyidmessage " + respose_json) except exceptions.MindsphereError as err: logger.error( "Getting error for diagnosticActivationsGetbyidmessage " + err) return HttpResponse( err, content_type="application/json", status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) return HttpResponse(respose_json, content_type="application/json", status=status.HTTP_200_OK)
def get(self, request, **kwargs): """ route mindconnect/datapointMappingCreate return Created data point mapping. description This method internally calls method data_point_mappings_post of MappingsClient class. This class is available as dependency in mindconnect-<version-here>-py3-none-any.whl. apiEndpoint : POST /api/mindconnect/v3/dataPointMappings of mindconnect service. apiNote Create single mapping. throws MindsphereError if an error occurs while attempting to invoke the sdk call. """ logger.info("mindconnect/datapointMappingCreate invoked.") client = sdk_util.build_sdk_client(self.__class__.__name__, request) if request.method == "GET": try: mapping = Mapping(agent_id="ad22f8a7ebb24b8fb41767afd2c63f08", data_point_id="SDKDP13", entity_id="078b1908bc9347678168760934465587", property_set_name="TyreTemperature", property_name="FLWheel", keep_mapping=False) request_object = DataPointMappingsPostRequest(mapping=mapping) response = client.data_point_mappings_post(request_object) respose_json = serialization_filter.sanitize_for_serialization( response) respose_json = json.dumps(respose_json) logger.info( "Getting response successfully for datapointMappingCreate " + respose_json) except exceptions.MindsphereError as err: logger.error("Getting error for datapointMappingCreate " + err) return HttpResponse( err, content_type="application/json", status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) return HttpResponse(respose_json, content_type="application/json", status=status.HTTP_200_OK)
def put(self, request, **kwargs): """ Create aspect type. route assets/aspects param tenantName - Name of the tenant for which you want to create aspect type. Passed in request. return Created aspect type information object. description This method internally calls method save_aspect_type of AspecttypeClient class. This class is available as dependency in assetmanagement-<version-here>-py3-none-any.whl apiEndpoint : PUT /api/assetmanagement/v3/aspecttypes/{id} of asset management service. apiNote Create or Update an aspect type throws MindsphereError if an error occurs while attempting to invoke the sdk call. """ logger.info("put aspectt invoked.") client = sdk_util.build_sdk_client(self.__class__.__name__, request) if request.method == "PUT": try: ifmatch = kwargs.get("ifmatch", "") aspect_id = kwargs.get("id", "") requestObj = json.dumps(request.data) aspect = json.loads(requestObj) request_object = SaveAspectTypeRequest(id=aspect_id, aspecttype=aspect, if_match=ifmatch) response = client.save_aspect_type(request_object) response = serialization_filter.sanitize_for_serialization(response) response = json.dumps(response) applink = {"ApplinK": getLink()} response = json.loads(response) response.update(applink) print(json.dumps(response)) logger.info("Getting response successfully " + json.dumps(response)) except exceptions.MindsphereError as err: logger.error(err.message) status_code = err.message.status_code return HttpResponse( json.dumps(err.message.message), content_type="application/json", status=status_code, ) return HttpResponse( json.dumps(response), content_type="application/json", status=status.HTTP_200_OK )
def get(self, request, **kwargs): """ route mindconnect/datapointMappingGet/<str:id> param id - Unique identifier of the mapping resource. return Data point mapping data for Id in String format. description This method - dataPointMappingsIdGetTest internally calls method dataPointMappingsIdGet of MappingsClient class. This class is available as dependency in mindconnect-<version-here>-py3-none-any.whl. apiEndpoint : GET /api/mindconnect/v3/dataPointMappings/{id} of mindconnect service. service. apiNote Get a mapping by id. throws MindsphereError if an error occurs while attempting to invoke the sdk call. """ logger.info("mindconnect/datapointMappingGet/<str:id> invoked") client = sdk_util.build_sdk_client(self.__class__.__name__, request) if request.method == "GET": try: id = kwargs.get("id", "") logger.info("Request param is- Id:" + id) request_object = DataPointMappingsIdGetRequest(id=id) response = client.data_point_mappings_id_get(request_object) respose_json = serialization_filter.sanitize_for_serialization( response) respose_json = json.dumps(respose_json) logger.info( "Getting response successfully for datapointMappingGet by id " + respose_json) except exceptions.MindsphereError as err: logger.error("Getting error for datapointMappingGet by id" + err) return HttpResponse( err, content_type="application/json", status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) return HttpResponse(respose_json, content_type="application/json", status=status.HTTP_200_OK)
def get(self, request, **kwargs): """ list multi part file route files/fileservicelistmultipartfile/<str:entity_id>/<str:path> param entityId - An Asset Id for which multipart file needs to be retrieved. note Non existent/Incorrect entityId will result in MindsphereError. param filePath - path of the file along with filename. return List of files description This method internally calls method get_file_list of FileServiceClient class. This class is available as dependency in iotfileservices-<version-here>-py3-none-any.whl. apiEndpoint : GET /api/iotfile/v3/fileslist/{entityId}/{filepath} of iot file service. apiNote list multi part uploads throws MindsphereError if an error occurs while attempting to invoke the sdk call. """ logger.info("files/fileservicelistmultipartfile/<str:entity_id>/<str:path> invoked") client = sdk_util.build_sdk_client(self.__class__.__name__, request) if request.method == "GET": try: path = kwargs.get("path", "") entity_id = kwargs.get("entity_id", "") logger.info("Request params are- path:" + path + " entityId:" + entity_id) response = data_generator.generate_file_list_input(entity_id, path) payload = serialization_filter.sanitize_for_serialization(response) payload = json.dumps(payload) logger.info("Getting response for fileservicelistmultipartfile "+payload) except exceptions.MindsphereError as err: logger.error("Getting error for fileservicelistmultipartfile "+err) return HttpResponse( err, content_type="application/json", status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) return HttpResponse( payload, content_type="application/json", status=status.HTTP_200_OK )
def get(self, request, **kwargs): """ search file route files/fileservicesearch/<str:entity_id> param entityId - An Asset Id for which file needs to be searched. note Non existent/Incorrect entityId will result in MindsphereError. return List of Files. description This method internally calls method search_files of FileServiceClient class. This class is available as dependency in iotfileservices-<version-here>-py3-none-any.whl. apiEndpoint : GET /api/iotfile/v3/files/{entityId} of iot file service. service. apiNote Search files for the specified asset (entity). throws MindsphereError if an error occurs while attempting to invoke the sdk call. """ logger.info("files/fileservicesearch/<str:entity_id> invoked") client = sdk_util.build_sdk_client(self.__class__.__name__, request) if request.method == "GET": try: entity_id = kwargs.get("entity_id", "") logger.info("Request param is- entityID: " + entity_id) request_object = data_generator.generate_search_files_input(entity_id) # search Api call response = client.search_files(request_object) payload = serialization_filter.sanitize_for_serialization(response) payload = json.dumps(payload) logger.info("getting response successfully for fileservicesearch "+payload) except exceptions.MindsphereError as err: logger.error("Getting error for fileservicesearch " + err) return HttpResponse( err, content_type="application/json", status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) return HttpResponse( payload, content_type="application/json", status=status.HTTP_200_OK )
def get(self, request): """ get Diagnostic Activations. route mindconnect/diagnosticActivationsGet return Diagnostic activations data in String format. description This method internally calls method diagnostic_activations_get of DiagnosticActivationsClient class. This class is available as dependency in mindconnect-<version-here>-py3-none-any.whl. apiEndpoint : GET /api/mindconnect/v3/diagnosticActivations of mindconnect service. apiNote Gets diagnostic activations. throws MindsphereError if an error occurs while attempting to invoke the sdk call. """ logger.info("mindconnect/diagnosticActivationsGet invoked") client = sdk_util.build_sdk_client(self.__class__.__name__, request) if request.method == "GET": try: requestObject = DiagnosticActivationsGetRequest() response = client.diagnostic_activations_get(requestObject) respose_json = serialization_filter.sanitize_for_serialization( response) respose_json = json.dumps(respose_json) logger.info( "Getting response successfully for diagnosticActivationsGet" + respose_json) except exceptions.MindsphereError as err: logger.error("Getting error for diagnosticActivationsGet" + err) return HttpResponse( err, content_type="application/json", status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) return HttpResponse(respose_json, content_type="application/json", status=status.HTTP_200_OK)
def get(self, request, **kwargs): """ route mindconnect/recoverableRecordGet return Recoverable record data on successful execution. description This method internally calls method recoverable_records_get of RecordRecoveryClient class. This class is available as dependency in mindconnect-<version-here>-py3-none-any.whl. apiEndpoint : GET /api/mindconnect/v3/recoverableRecords of mindconnect service. apiNote Get all recoverable records. throws MindsphereError if an error occurs while attempting to invoke the sdk call. """ logger.info("mindconnect/recoverableRecordGet invoked.") client = sdk_util.build_sdk_client(self.__class__.__name__, request) if request.method == "GET": try: request_object = RecoverableRecordsGetRequest() response = client.recoverable_records_get(request_object) respose_json = serialization_filter.sanitize_for_serialization( response) respose_json = json.dumps(respose_json) logger.info( "Getting response successfully for recoverableRecordGet " + respose_json) except exceptions.MindsphereError as err: logger.error("Getting error for recoverableRecordGet " + err) return HttpResponse( err, content_type="application/json", status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) return HttpResponse(respose_json, content_type="application/json", status=status.HTTP_200_OK)
def get(self, request, **kwargs): logger.info("mindconnect/diagnosticinfoget invoked") client = sdk_util.build_sdk_client(self.__class__.__name__, request) if request.method == "GET": try: requestObject = DiagnosticInformationGetRequest() response = client.diagnostic_information_get(requestObject) respose_json = serialization_filter.sanitize_for_serialization( response) respose_json = json.dumps(respose_json) logger.info( "Getting response successfully for diagnosticinfoget " + respose_json) except exceptions.MindsphereError as err: logger.error("Getting error for diagnosticinfoget " + err) return HttpResponse( err, content_type="application/json", status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) return HttpResponse(respose_json, content_type="application/json", status=status.HTTP_200_OK)
def get(self, request): """ route assets/assetfiles return Details of uploaded file upon successful execution. description This method internally calls method upload_file of FilesClient class. This class is available as dependency in assetmanagement-<version-here>-py3-none-any.whl. Sample data required for POST call is generated via generate_file_input method in data_generator module. apiEndpoint : POST /api/assetmanagement/v3/files of asset management service. apiNote Upload files to be used in Asset Management. throws MindsphereError if an error occurs while attempting to invoke the sdk call. """ logger.info("assets/assetfiles invoked.") client = sdk_util.build_sdk_client(self.__class__.__name__, request) if request.method == "GET": try: sample_file, file_name = data_generator.generate_file_input() request_object = data_generator.generate_upload_file_input(sample_file, 'private', file_name) resource = client.upload_file(request_object) payload = serialization_filter.sanitize_for_serialization(resource) payload = json.dumps(payload) logger.info("Getting response successfully for assetfiles" + payload) except exceptions.MindsphereError as err: logger.error("Getting error for assetfiles " + err) return HttpResponse( err, content_type="application/json", status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) return HttpResponse( payload, content_type="application/json", status=status.HTTP_200_OK )
def get(self, request, **kwargs): """ get time series route : timeseriesaggregate/get/<str:entityid>/<str:propertyname>/<str:from>/<str:to> param --> entityId - An Asset Id for which aggregates are to be retrieved. param --> propertySetName - property set name for which aggregates will be be retrieved. note : Non existent/Incorrect entityId and propertySetName will result in MindsphereError. param ---> from : Point in time from which aggregates are to be retrieved. param ---> to : Point in time to which aggregates are to be retrieved. param ---> request : HttpRequest object. returns : Time series aggregates in String format. description : This method - get internally calls method retrieve_aggregates of AggregatesClient class. This class is available as dependency in tsaggregates-<version-here>-py3-none-any.whl. The parameters from, to, intervalUnit, intervalValue, and count are used to determine the time range and interval length to return aggregates for. If intervalUnit and intervalValue are not provided, the largest available interval length fitting into the used time range is chosen. If count is not provided, but the other parameters are, count will be derived based on the time range divided by the intervalUnit and intervalValue. In case parameters from or to are provided but do not coincide with the pre-calculated interval boundaries of the used interval, from and to are shifted such that the overall time range contains the provided one and time range boundaries coincide with interval boundaries. If from, to and count are provided, intervalUnit, intervalValue is determined based on the time range divided by count. apiEndpoint : GET /api/iottsaggregates/v4/aggregates of aggregate service. service. apiNote : Returns a list of aggregates for a given asset and aspect. The time range of the aggregates can be defined by a combination of parameters; such as from, to, intervalUnit, intervalValue and count. Time range can be specified anywhere in past or future for which timeseries data is present. In the case no time series data was available for an aggregation interval, no aggregate will be returned. Pre-computed aggregates are aligned with the tenant's time zone. throws MindsphereError : if an error occurs while attempting to invoke the sdk call. """ logger.info( "timeseriesaggregate/get/<str:entityid>/<str:propertyname>/<str:from>/<str:to>" ) client = sdk_util.build_sdk_client(self.__class__.__name__, request) if request.method == "GET": try: entity_id = kwargs.get("entityid", "") property_name = kwargs.get("propertyname", "") _from = kwargs.get("from", "") to = kwargs.get("to", "") logger.info("Request params are- enitityID:" + entity_id + " propertyName: " + property_name + " from:" + _from + " to:" + to) request_object = RetrieveAggregatesRequest() request_object.asset_id = entity_id request_object.aspect_name = property_name request_object._from = _from request_object.to = to aggregateList = client.retrieve_aggregates(request_object) aggregate_json = serialization_filter.sanitize_for_serialization( aggregateList) aggregate_json = json.dumps(aggregate_json) logger.info( "Getting response successfully for timeseriesaggregate" + aggregate_json) except exceptions.MindsphereError as err: logger.error("Getting error for timeseriesaggregate" + err) return HttpResponse( err, content_type="application/json", status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) return HttpResponse(aggregate_json, content_type="application/json", status=status.HTTP_200_OK)