Skip to content

Asset Management Client for Java

Introduction

The Asset Management Java client allows you to interact with the digital representation of a machine or automation system through a Java object model, abstracting the interaction with the MindSphere API.

See Asset Management for more information about the service.

Aspect type operations

The Aspect Type client manages static and dynamic aspect types. It lists, creates, updates and reads the aspect types.

Client name: AspectTypeClient

List all aspect types

Get all aspect types of the tenant.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
  // Construct the AspectTypeClient object
  AspectTypeClient aspecttypeClient = AspectTypeClient.builder()
                                          .mindsphereCredentials(credentials)
                                          .restClientConfig(config)
                                          .build();

  AspectTypes aspectTypes = null;
  try {
    aspectTypes = aspecttypeClient.getAspectTypes(page, size, sort, filter, ifNoneMatch);
  }catch (MindsphereException e) {
    // Exception handling
  }

Create an aspect type

Create an aspect type. Only adding variables is supported.

1
2
3
4
5
6
7
  //Create client object "aspecttypeClient" as shown above
  AspectTypeResource aspectType = null;
  try {
    aspectType = aspecttypeClient.createAspectType(id, aspectTypeDto);
  } catch (MindsphereException e) {
    // Exception handling
  }

Update an aspect type

Update an existing aspect type. Only adding variables is supported.

1
2
3
4
5
6
7
  //Create client object "aspecttypeClient" as shown above
  AspectTypeResource aspectType = null;
  try {
    aspectType = aspecttypeClient.updateAspectType(id, aspectTypeDto, IfMatch);
  } catch (MindsphereException e) {
    // Exception handling
  }

Read an aspect type

Read an aspect type.

1
2
3
4
5
6
7
  //Create client object "aspecttypeClient" as shown above
  AspectTypeResource aspectTypeResource = null;
  try {
    aspectTypeResource = aspecttypeClient.getAspectTypeById(id, ifNoneMatch);
  } catch (MindsphereException e) {
    // Exception handling
  }

Delete an aspect type

Delete an aspect type. An aspect type can only be deleted if there is no asset type using it.

1
2
3
4
5
6
7
  //Create client object "aspecttypeClient" as shown above
  boolean deleted = false;
  try {
    deleted = aspecttypeClient.deleteAspectType(id, ifMatch);
  } catch (MindsphereException e) {
    // Exception handling
  }

Asset type operations

The Asset type client manages asset types.

Client name: AssetTypeClient

List all asset types

List all asset types of the tenant.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
    // Construct the AssetTypeClient object
    AssetTypeClient assetTypeClient = AssetTypeClient.builder()
                                          .mindsphereCredentials(credentials)
                                          .restClientConfig(config)
                                          .build();

    AssetTypes assetTypes = null;
    try {
        assetTypes = assetTypeClient.getAssetTypes(page, size, sort, filter, ifNoneMatch);
    } catch (MindsphereException e) {
        // Exception handling
    }

Create an asset type

Create an asset type.

1
2
3
4
5
6
7
    //Create client object "assetTypeClient" as shown above
    AssetTypeResource assetTypeResource = null
    try {
        assetTypeResource = assetTypeClient.createAssetType(id, assetTypeDto);
    } catch (MindsphereException e) {
        // Exception handling
    }

Update an asset type

Update an existing asset type.

1
2
3
4
5
6
7
    //Create client object "assetTypeClient" as shown above
    AssetTypeResource assetTypeResource = null;
    try {
        assetTypeResource = assetTypeClient.updateAssetType(id, assetTypeDto, ifMatch);
    } catch (MindsphereException e) {
        // Exception handling
    }

Read an asset type

Read an asset type.

1
2
3
4
5
6
7
    //Create client object "assetTypeClient" as shown above
    AssetTypeResource assetTypeResource = null;
    try {
        assetTypeResource = assetTypeClient.getAssetTypeById(id, ifNoneMatch, exploded);
    } catch (MindsphereException e) {
        // Exception handling
    }

Delete an asset type

Delete an asset type. Deletion is only possible when the type has no child-type and there is no asset that instantiates it.

1
2
3
4
5
6
7
    //Create client object "assetTypeClient" as shown above
    boolean deleted = false;
    try {
        deleted = assetTypeClient.deleteAssetType(id, ifMatch);
    } catch (MindsphereException e) {
        // Exception handling
    }

Asset operations

The Asset client manages the users' assets and their locations. Only three different types of assets can be created: device types, agent types and hierarchy types.

Client name: AssetClient

List all asset types

List all assets available for the authenticated user.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
    // Construct the AssetClient object
    AssetClient assetClient = AssetClient.builder()
                                 .mindsphereCredentials(credentials)
                                 .restClientConfig(config)
                                 .build();

    Assets assets = null;
    try{
        assets = assetClient.getAssets(page, size, sort, filter, ifNoneMatch);
    } catch (MindsphereException e) {
        // Exception handling
    }

Create an asset type

Create a new asset with the provided content.

1
2
3
4
5
6
7
    //Create client object "assetClient" as shown above
    AssetResource assetResource = null;
    try{
        assetResource = assetClient.createAsset(assetDto);
    } catch (MindsphereException e) {
        // Exception handling
    }

Return an asset

Read a single asset. All static properties of an asset are returned.

1
2
3
4
5
6
7
    //Create client object "assetClient" as shown above
    AssetResource assetResource = null;
    try{
        assetResource = assetClient.getAssetById(id, ifNoneMatch);
    } catch (MindsphereException e) {
        // Exception handling
    }

Update an asset

Update an existing asset with the provided content. Only values can be modified. The asset structure has to be modified in the asset type.

1
2
3
4
5
6
7
    //Create client object "assetClient" as shown above
    AssetResource assetResource = null;
    try{
        AssetResource assetResource = assetClient.updateAsset(id, assetDto, ifMatch);
    } catch (MindsphereException e) {
        // Exception handling
    }

Delete an asset

Delete an existing asset. After deletion, only the users with an admin role can read it, but modification is not possible anymore. It's not possible to delete an asset if it has children.

1
2
3
4
5
6
7
    //Create client object "assetClient" as shown above
    Boolean deleted = false;
    try{
        deleted = assetClient.deleteAsset(id, ifMatch);
    } catch (MindsphereException e) {
        // Exception handling
    }

Move an asset

Move an existing asset and all its children in the instance hierarchy.

1
2
3
4
5
6
7
    //Create client object "assetClient" as shown above
    AssetResource assetResource = null;
    try{
        assetResource = assetClient.moveAsset(id, assetMoveDto, ifMatch);
    } catch (MindsphereException e) {
        // Exception handling
    }

Get root asset of the user

Read the root asset of the user, from which the whole asset hierarchy can be rebuilt.

1
2
3
4
5
6
7
    //Create client object "assetClient" as shown above
    AssetResource assetResource = null;
    try{
        assetResource = assetClient.getRootAsset(ifNoneMatch);
    } catch (MindsphereException e) {
        // Exception handling
    }

Asset structure operations

Client name: AssetStructureClient

Get variables of an asset

Get all variables of an asset.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
    // Construct the AssetStructureClient object
    AssetStructureClient assetStructureClient = AssetStructureClient.builder()
                                                    .mindsphereCredentials(credentials)
                                                    .restClientConfig(config)
                                                    .build();

    StructureVariables structureVariables = null;
    try{
        structureVariables = assetStructureClient.getVariables(id, page, size, sort, filter, ifNoneMatch);
    } catch (MindsphereException e) {
        // Exception handling
    }

Get all aspects of an asset

Get all static and dynamic aspects of a specified asset.

1
2
3
4
5
6
7
    //Create client object "assetStructureClient" as shown above
    StructureAspects structureAspects = null;
    try{
        structureAspects = assetStructureClient.getAspects(id, page, size, sort, filter, ifNoneMatch);
    } catch (MindsphereException e) {
        // Exception handling
    }

Asset location operations

Client name: AssetLocationClient

Create or Update location

Creates or updates a location that is assigned to the given asset.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
    // Construct the AssetLocationClient object
    AssetLocationClient assetLocationClient = AssetLocationClient.builder()
                                                  .mindsphereCredentials(credentials)
                                                  .restClientConfig(config)
                                                  .build();

    try{
        assetLocationClient.createOrUpdateAssetLocation(id, location, ifMatch);
    } catch (MindsphereException e) {
        // Exception handling
    }

Delete location assigned to the asset

Delete a location that is assigned to the asset.

1
2
3
4
5
6
7
    //Create client object "assetLocationClient" as shown above
    AssetResource assetResource = null;
    try{
        assetResource = assetLocationClient.deleteAssetLocation(id, ifMatch);
    } catch (MindsphereException e) {
        // Exception handling
    }

Page Iterators

The page iterators for the Asset Management API client can be used to get a specific page, the next page or the previous page of data.

The page iterators currently support the following operations:

  • getPage(Integer pageNumber);
  • next();
  • previous();

Following iterators are provided for different controllers in Asset management:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
  try {
      // Create Asset Client
      AssetClient assetClient =  AssetClient.builder()
                                     .mindsphereCredentials(credentials)
                                     .restClientConfig(config)
                                     .build();

          // Create Asset Page Iterator
    AssetPageIterator assetPageIterator = new AssetPageIterator(assetClient, pageSize);

    Assets assets = assetPageIterator.getPage(10);
  } 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.