Skip to content

IOT Bulk Client for Java

Introduction

The IoT TS Bulk Java client allows you to use IoT TS Bulk APIs while developing applications for MindSphere. Refer to IoT TS Bulk Service for more information about the service.

Hint

In the IoT context, assets are referred to as entity and aspects as propertyset.
Placeholders in the following samples are indicated by angular brackets < >.

IOT Bulk Operations

Client Name: BulkImportOperationsClient

Create bulk import job for importing time series data

  • Creates an import job resource to asynchronously import IoT time series data from files uploaded through IoT File Service. After successful creation of an import job, the provided file contents are validated and imported in the background. The status of a job can be retrieved using the returned job ID. Note that in case of validation errors occuring during or after job creation, no time series data is imported from any of the provided files.
  • Restrictions: Currently only one asset-aspect (entity-property set) combination can be specified as target of the import. Data for performance assets (entities) must be older than 30 minutes in order to be imported, while for simulation assets (entities) no restriction on minimum age exists. In case of simulation assets (entities), all data must be within the same hour. In case of performance assets (entities), all data must be within the same day. The overall size of the files used to import data for one asset-aspect (entity-property set) combination is limited: - For simulation assets (entities), a maximum of 350 MB per hour is allowed - For performance assets (entities), a maximum of 1 GB per day is allowed Note that hour and day intervals are fixed with respect to UTC time hours and days. A maximum of 100 files can be specified per request.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Construct the PackageProvisioningClient object
  BulkImportOperationsClient bulkImportOperationsClient = BulkImportOperationsClient.builder().restClientConfig(config).build();

  CreateImportJobRequest requestObject = new CreateImportJobRequest();
  BulkImportInput bulkImportInput = new BulkImportInput();
  List<Data> listData = new ArrayList<Data>();
  Data data = new Data();
  data.setEntity("5908ae5c5e4f4e18b0be58cd21ee675f");
  List<FileInfo> timeseriesFiles = new ArrayList<FileInfo>();
  data.setPropertySetName("test_2020_11_11");
  FileInfo fileInfo = new FileInfo();
  fileInfo.setFilePath("test1112.json");
  fileInfo.setFrom("2020-06-16T02:00:00.01Z");
  fileInfo.setTo("2020-06-16T02:00:00.30Z");
  timeseriesFiles.add(fileInfo);
  data.setTimeseriesFiles(timeseriesFiles);
  listData.add(data);
  bulkImportInput.setData(listData);
  requestObject.setBulkImportInput(bulkImportInput);

     try {
       JobStatus response = bulkImportOperationsClient.createImportJob(requestObject);
      } catch (MindsphereException e) {
      // Exception handling
      }

Retrieve status of bulk import job

  • Retrieve status of bulk import job.
1
2
3
4
5
6
7
8
  RetrieveImportJobRequest requestObject = new RetrieveImportJobRequest();
  requestObject.setId(("4e37b10ad4774b8bb391209a9d18f1b6"));

     try {
       JobStatus response = bulkImportOperationsClient.retrieveImportJob(requestObject);
      } catch (MindsphereException e) {
      // Exception handling
      }

Client Name: ReadOperationsClientAPITest

Retrieve time series data

  • Retrieve time series data for a single asset (entity) and aspect (property set). Returns data for the specified time range. Returns only the selected properties if 'select' parameter is used. The maximum number of time series data items returned per request is defined by parameter. In case more time series data items are present in the requested time range, only a subset of data items will be returned. In that case response property nextRecord contains the request URL to fetch the next set of time series data items, by increasing the parameter accordingly.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
// Construct the PackageProvisioningClient object
  ReadOperationsClientAPITest readOperationsClient = ReadOperationsClientAPITest.builder().restClientConfig(config).build();

  RetrieveTimeseriesRequest requestObject = new RetrieveTimeseriesRequest();
  requestObject.setEntity("4ab1c8c37a3c47c48447057766ba4107");
  requestObject.setPropertySetName("testaspect1011");
  requestObject.setFrom("2020-06-16T02:00:00.01Z");
  requestObject.setTo("2020-06-16T02:00:00.30Z");

     try {
       TimeSeries response = readOperationsClient.retrieveTimeseries(requestObject);
      } catch (MindsphereException e) {
      // Exception handling
      }

Any questions left?

Ask the community


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