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. The interaction with the Industrial IoT API is abstracted through a Java object model. Refer to Asset Management for more information about the service.
Further implementation of the Asset Management SDK library has been shown in a sample project that you can download and test in local or on Insights Hub application. Please refer to this repository: industrial-iot-java-sdk-examples
Hint
Placeholders in the following samples are indicated by angular brackets < >
.
Aspect Type Operations¶
The aspect type client manages static and dynamic aspect types. It lists, creates, updates, reads and deletes the aspect types.
Client name: AspecttypeClient
List all Aspect Types¶
This section shows two ways of getting a list of all aspect types of the tenant.
// Construct the AspecttypeClient object
AspecttypeClient aspect_type_client = AspecttypeClient.builder()
.mindsphereCredentials(<credentials>)
.restClientConfig(<config>)
.build();
AspectTypeListResource aspect_types = null;
try {
aspect_types = aspect_type_client.listAspectTypes(<page>, <size>, <sort>, <filter>, <ifNoneMatch>);
}catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the ListAspectTypesRequest
model.
// Construct the AspecttypeClient object as shown above
ListAspectTypesRequest request_object = new ListAspectTypesRequest();
request_object.setPage(<page>);
request_object.setSize(<size>);
request_object.setFilter(<filter>);
AspectTypeListResource aspectTypes = null;
try {
aspect_types = aspect_type_client.listAspectTypes(request_object);
}catch (MindsphereException e) {
// Exception handling
}
Create an Aspect Type¶
This section shows two ways of creating an aspect type.
// Construct the AspecttypeClient object as shown above
AspectTypeResource aspect_type_resource = null;
try {
aspect_type_resource = aspect_type_client.saveAspectType(<aspect_type_id>, <aspect_type>, <ifMatch>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the SaveAspectTypeRequest
model.
// Construct the AspecttypeClient object as shown above
SaveAspectTypeRequest request_object = new SaveAspectTypeRequest();
request_object.setId(<aspect_type_id>);
request_object.setAspecttype(<aspect_type>);
AspectTypeResource aspect_type_resource = null;
try {
aspect_type_resource = aspect_type_client.saveAspectType(request_object);
}catch (MindsphereException e) {
// Exception handling
}
Update an Aspect Type¶
This section shows two options for updating an existing aspect type. Variables can only be added, but not removed or renamed.
// Construct the AspecttypeClient object as shown above
AspectTypeResource aspect_type_resource = null;
try {
aspect_type_resource = aspect_type_client.updateAspectType(<ifMatch>, <aspect_type_id>, <aspect_type>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the UpdateAspectTypeRequest
model.
// Construct the AspecttypeClient object as shown above
UpdateAspectTypeRequest request_object = new UpdateAspectTypeRequest();
request_object.setId(<aspect_type_id>);
request_object.setAspecttype(<aspect_type>);
request_object.setIfMatch(<ifMatch>);
AspectTypeResource aspect_type_resource = null;
try {
aspect_type_resource = aspect_type_client.updateAspectType(request_object);
}catch (MindsphereException e) {
// Exception handling
}
Read an Aspect Type¶
This section shows two options for reading an aspect type.
// Construct the AspecttypeClient object as shown above
AspectTypeResource aspect_type_resource = null;
try {
aspect_type_resource = aspect_type_client.getAspectType(<aspect_type_id>, <ifNoneMatch>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the GetAspectTypeRequest
model.
// Construct the AspecttypeClient object as shown above
GetAspectTypeRequest request_object = new GetAspectTypeRequest();
request_object.setId(<aspect_type_id>);
AspectTypeResource aspect_type_resource = null;
try {
aspect_type_resource = aspect_type_client.getAspectType(request_object);
}catch (MindsphereException e) {
// Exception handling
}
Delete an Aspect Type¶
This section shows two options for deleting an aspect type. An aspect type can only be deleted, if no asset type uses it.
// Construct the AspecttypeClient object as shown above
try {
aspect_type_client.deleteAspectType(<ifMatch>, <aspect_type_id>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the DeleteAspectTypeRequest
model.
// Construct the AspecttypeClient object as shown above
DeleteAspectTypeRequest request_object = new DeleteAspectTypeRequest();
request_object.setId(<aspect_type_id>);
request_object.setIfMatch(<ifMatch>);
try {
aspect_type_client.deleteAspectType(request_object);
}catch (MindsphereException e) {
// Exception handling
}
Get Aspect Types using Filters¶
Get Aspect Types with a Specific Parameter¶
This code sample uses the filter - equals
functionality to get all aspect types whose name or tenant ID is equal to the input value.
// Construct the AspecttypeClient object as shown above
AspectTypeListResource aspect_types = null;
try {
aspect_types = aspect_type_client.getAspectTypesEqualTo(FieldTypeEnum.NAME, <filter_value>);
}catch (MindsphereException e) {
// Exception handling
}
Get Aspect Types with a Parameter from a List¶
Use the filter - in
functionality to get all aspect types whose name or tenant ID matches any value in an array of values.
// Construct the AspecttypeClient object as shown above
AspectTypeListResource aspect_types = null;
try {
aspect_types = aspect_type_client.getAspectTypesLike(FieldTypeEnum.NAME, <filter_value_1>, <filter_value_2>);
}catch (MindsphereException e) {
// Exception handling
}
Get Aspect Types where a Parameter Starts with a Specific Value¶
Use the filter - startsWith
functionality to get all aspect types whose name or tenant ID starts with an input value.
// Construct the AspecttypeClient object as shown above
AspectTypeListResource aspect_types = null;
try {
aspect_types = aspect_type_client.getAspectTypesStartsWith(FieldTypeEnum.NAME, <filter_value>);
}catch (MindsphereException e) {
// Exception handling
}
Get Aspect Types where a Parameter Ends with a Specific Value¶
Use the filter - endsWith
functionality to get all aspect types whose name or tenant ID ends with an input value.
// Construct the AspecttypeClient object as shown above
AspectTypeListResource aspect_types = null;
try {
aspect_types = aspect_type_client.getAspectTypesEndsWith(FieldTypeEnum.NAME, <filter_value>);
}catch (MindsphereException e) {
// Exception handling
}
Get Aspect Types where a Parameter Contains a Specific Value¶
Use the filter - contains
functionality of Asset management to get all aspect types whose name or tenantId contains an input value.
// Construct the AspecttypeClient object as shown above
AspectTypeListResource aspect_types = null;
try {
aspect_types = aspect_type_client.getAspectTypesContains(FieldTypeEnum.NAME, <filter_value>);
}catch (MindsphereException e) {
// Exception handling
}
Asset Type Operations¶
The asset type client manages asset types. It lists, creates, updates, reads and deletes the asset types. It can also be used to add and delete file assignments to the asset types.
Client name: AssettypeClient
List all Asset Types¶
This section shows two options for listing all asset types of the tenant.
// Construct the AssettypeClient object
AssettypeClient asset_type_client = AssettypeClient.builder()
.mindsphereCredentials(<credentials>)
.restClientConfig(<config>)
.build();
AssetTypeListResource asset_types = null;
try {
asset_types = asset_type_client.listAssetTypes(<page>, <size>, <sort>, <filter>, <ifNoneMatch>, <exploded>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the ListAssetTypesRequest
model.
// Construct the AssettypeClient object as shown above
ListAssetTypesRequest request_object = new ListAssetTypesRequest();
request_object.setPage(<page>);
request_object.setSize(<size>);
AssetTypeListResource asset_types = null;
try {
asset_types = asset_type_client.listAssetTypes(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Create an Asset Type¶
This section shows two options for creating an asset type.
// Construct the AssettypeClient object as shown above
AssetTypeResource asset_type_resource = null
try {
asset_type_resource = asset_type_client.saveAssetType(<asset_type_id>, <asset_type>, <ifMatch>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the SaveAssetTypeRequest
model.
// Construct the AssettypeClient object as shown above
SaveAssetTypeRequest request_object = new SaveAssetTypeRequest();
request_object.setId(<asset_type_id>);
request_object.setAssettype(<asset_type>);
AssetTypeResource asset_type_resource = null
try {
asset_type_resource = asset_type_client.saveAssetType(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Update an Asset Type¶
This section shows two options for updating an existing asset type.
// Construct the AssettypeClient object as shown above
AssetTypeResource asset_type_resource = null;
try {
asset_type_resource = asset_type_client.updateAssetType(<ifMatch>, <asset_type_id>, <asset_type>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the UpdateAssetTypeRequest
model.
// Construct the AssettypeClient object as shown above
UpdateAssetTypeRequest request_object = new UpdateAssetTypeRequest();
request_object.setId(<asset_type_id>);
request_object.setAssettype(<asset_type>);
request_object.setIfMatch(<ifMatch>);
AssetTypeResource asset_type_resource = null;
try {
asset_type_resource = asset_type_client.updateAssetType(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Read an Asset Type¶
This section shows two options for reading an asset type.
// Construct the AssettypeClient object as shown above
AssetTypeResource asset_type_resource = null;
try {
asset_type_resource = asset_type_client.getAssetType(<asset_type_id>, <ifNoneMatch>, <exploded>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the GetAssetTypeRequest
model.
// Construct the AssettypeClient object as shown above
GetAssetTypeRequest request_object = new GetAssetTypeRequest();
request_object.setId(<asset_type_id>);
AssetTypeResource asset_type_resource = null;
try {
asset_type_resource = asset_type_client.getAssetType(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Delete an Asset Type¶
This section shows two options for deleting an asset type. Deletion is only possible for asset types without children and when there is no asset instantiating them.
// Construct the AssettypeClient object as shown above
try {
asset_type_client.deleteAssetType(<ifMatch>, <asset_type_id>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the DeleteAssetTypeRequest
model.
// Construct the AssettypeClient object as shown above
DeleteAssetTypeRequest request_object = new DeleteAssetTypeRequest();
request_object.setId(<asset_type_id>);
request_object.setIfMatch(<ifMatch>);
try {
asset_type_client.deleteAssetType(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Add a New File Assignment to an Asset Type¶
This section shows two options for adding a new file assignment to an asset type. By default, this file is assigned to asset types extending this type and assets instantiated from it.
// Construct the AssettypeClient object as shown above
AssetTypeResource asset_type_resource = null;
try {
asset_type_resource = asset_type_client.saveAssetTypeFileAssignment(<ifMatch>, <asset_type_id>, <key>, <assignment>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the SaveAssetTypeFileAssignmentRequest
model.
// Construct the AssettypeClient object as shown above
SaveAssetTypeFileAssignmentRequest request_object = new SaveAssetTypeFileAssignmentRequest();
request_object.setId(<asset_type_id>);
request_object.setKey(<key>);
request_object.setAssignment(<assignment>);
request_object.setIfMatch(<ifMatch>);
AssetTypeResource asset_type_resource = null;
try {
asset_type_resource = asset_type_client.saveAssetTypeFileAssignment(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Delete a File Assignment from an Asset Type¶
This section shows two options for deleting a file assignment from an asset type. If the file is assigned to the asset type's parent, its key will be displayed in the inherited value field.
// Construct the AssettypeClient object as shown above
AssetTypeResource asset_type_resource = null;
try {
asset_type_resource = asset_type_client.deleteAssetTypeFileAssignment(<asset_type_id>, <key>, <ifMatch>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the DeleteAssetTypeFileAssignmentRequest
model.
// Construct the AssettypeClient object as shown above
DeleteAssetTypeFileAssignmentRequest request_object = new DeleteAssetTypeFileAssignmentRequest();
request_object.setId(<asset_type_id>);
request_object.setKey(<key>);
request_object.setIfMatch(<ifMatch>);
AssetTypeResource asset_type_resource = null;
try {
asset_type_resource = asset_type_client.deleteAssetTypeFileAssignment(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Get Asset Types using Filters¶
Get Asset Types with a Specific Parameter¶
Use the filter - equals
functionality to get all asset types whose name or tenant ID or parent type ID is equal to the input value.
// Construct the AssettypeClient object as shown above
AssetTypeListResource asset_types = null;
try {
asset_types = asset_type_client.getAssetTypesEqualTo(FieldTypeEnum.NAME, <filter_value>);
}catch (MindsphereException e) {
// Exception handling
}
Get Asset Types with a Parameter from a List¶
Use the filter - in
functionality to get all asset types whose name or tenant ID or parent type ID matches any value in an array of values.
// Construct the AssettypeClient object as shown above
AssetTypeListResource asset_types = null;
try {
asset_types = asset_type_client.getAssetTypesLike(FieldTypeEnum.NAME, <filter_value_1>, <filter_value_2>);
}catch (MindsphereException e) {
// Exception handling
}
Get Asset Types where a Parameter Starts with a Specific Value¶
Use the filter - startsWith
functionality to get all asset types whose name or tenant ID or parent type ID starts with an input value.
// Construct the AssettypeClient object as shown above
AssetTypeListResource asset_types = null;
try {
asset_types = asset_type_client.getAssetTypesStartsWith(FieldTypeEnum.NAME, <filter_value>);
}catch (MindsphereException e) {
// Exception handling
}
Get Asset Types where a Parameter Ends with a Specific Value¶
Use the filter - endsWith
functionality to get all asset types whose name or tenant ID or parent type ID ends with an input value.
// Construct the AssettypeClient object as shown above
AssetTypeListResource asset_types = null;
try {
asset_types = asset_type_client.getAssetTypesEndsWith(FieldTypeEnum.NAME, <filter_value>);
}catch (MindsphereException e) {
// Exception handling
}
Get Asset Types where a Parameter Contains a Specific Value¶
Use the filter - contains
functionality to get all asset types whose name or tenant ID or parent type ID contains an input value.
// Construct the AssettypeClient object as shown above
AssetTypeListResource asset_types = null;
try {
asset_types = asset_type_client.getAssetTypesContains(FieldTypeEnum.NAME, <filter_value>);
}catch (MindsphereException e) {
// Exception handling
}
Asset Operations¶
The asset client manages the user's assets and their locations. Three different types of assets can be created: device types, agent types and hierarchy types. The asset client lists, creates, updates, reads, deletes, moves and replaces the asset. It can also be used to add and delete file assignments to assets.
Client name: AssetsClient
List all Assets¶
This section shows two options for listing all assets available for the authenticated user.
// Construct the AssetClient object
AssetsClient asset_client = AssetsClient.builder()
.mindsphereCredentials(<credentials>)
.restClientConfig(<config>)
.build();
AssetListResource assets = null;
try{
assets = asset_client.listAssets(<page>, <size>, <sort>, <filter>, <ifNoneMatch>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the ListAssetsRequest
model.
// Construct the AssetClient object as shown above
ListAssetsRequest request_object = new ListAssetsRequest();
request_object.setPage(<page>);
request_object.setSize(<size>);
AssetListResource assets = null;
try{
assets = asset_client.listAssets(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Create an Asset¶
This section shows two options for creating a new asset with the provided content.
// Construct the AssetClient object as shown above
AssetResourceWithHierarchyPath asset_resource = null;
try{
asset_resource = asset_client.addAsset(<asset>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the AddAssetRequest
model.
// Construct the AssetClient object as shown above
AddAssetRequest request_object = new AddAssetRequest();
request_object.setAsset(<asset>);
AssetResourceWithHierarchyPath asset_resource = null;
try{
asset_resource = asset_client.addAsset(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Read an Asset¶
This section shows two options for reading a single asset. All static properties of the asset are returned.
// Construct the AssetClient object as shown above
AssetResourceWithHierarchyPath asset_resource = null;
try{
asset_resource = asset_client.getAsset(<asst_id>, <ifNoneMatch>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the GetAssetRequest
model.
// Construct the AssetClient object as shown above
GetAssetRequest request_object = new GetAssetRequest();
request_object.setId(<asst_id>);
AssetResourceWithHierarchyPath asset_resource = null;
try{
asset_resource = asset_client.getAsset(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Update an Asset¶
This section shows two options for updating an existing asset with the provided content. Only values can be modified, but not the asset structure. The asset structure can be modified in the asset type.
// Construct the AssetClient object as shown above
AssetResourceWithHierarchyPath asset_resource = null;
try{
asset_resource = asset_client.updateAsset(<ifMatch>, <asst_id>, <asset_update>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the UpdateAssetRequest
model.
// Construct the AssetClient object as shown above
UpdateAssetRequest request_object = new UpdateAssetRequest();
request_object.setId(<asst_id>);
request_object.setAsset(<asset_update>);
request_object.setIfMatch(<ifMatch>);
AssetResourceWithHierarchyPath asset_resource = null;
try{
asset_resource = asset_client.updateAsset(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Delete an Asset¶
This section shows two options for deleting an existing asset. After deletion, users with an admin role can still read the asset, but modification is not possible anymore. It is not possible to delete an asset if it has children.
// Construct the AssetClient object as shown above
try{
asset_client.deleteAsset(<ifMatch>, <asst_id>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the DeleteAssetRequest
model.
// Construct the AssetClient object as shown above
DeleteAssetRequest request_object = new DeleteAssetRequest();
request_object.setId(<asst_id>);
request_object.setIfMatch(<ifMatch>);
try{
asset_client.deleteAsset(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Move an Asset¶
This section shows two options for moving an existing asset and all of its children in the instance hierarchy.
// Construct the AssetClient object as shown above
AssetResourceWithHierarchyPath asset_resource = null;
try{
asset_resource = asset_client.moveAsset(<ifMatch>, <asset_id>, <asset_move>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the MoveAssetRequest
model.
// Construct the AssetClient object as shown above
MoveAssetRequest request_object = new MoveAssetRequest();
request_object.setId(<asset_id>);
request_object.setMoveParameters(<asset_move>);
request_object.setIfMatch(<ifMatch>);
AssetResourceWithHierarchyPath asset_resource = null;
try{
asset_resource = asset_client.moveAsset(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Replace an Asset¶
This section shows two options for updating an asset with the provided content.
// Construct the AssetClient object as shown above
AssetResourceWithHierarchyPath asset_resource = null;
try{
asset_resource = asset_client.replaceAsset(<ifMatch>, <asset_id>, <asset_update>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the ReplaceAssetRequest
model.
// Construct the AssetClient object as shown above
ReplaceAssetRequest request_object = new ReplaceAssetRequest();
request_object.setId(<asset_id>);
request_object.setAsset(<asset_update>);
request_object.setIfMatch(<ifMatch>);
AssetResourceWithHierarchyPath asset_resource = null;
try{
asset_resource = asset_client.replaceAsset(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Get the User's Root Asset¶
This section shows two options for reading the user's root asset, from which the whole asset hierarchy can be rebuilt.
// Construct the AssetClient object as shown above
RootAssetResource root_asset_resource = null;
try{
root_asset_resource = asset_client.getRootAsset(<ifNoneMatch>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the GetRootAssetRequest
model.
// Construct the AssetClient object as shown above
GetRootAssetRequest request_object = new GetRootAssetRequest();
request_object.setIfNoneMatch(<ifNoneMatch>);
RootAssetResource root_asset_resource = null;
try{
root_asset_resource = asset_client.getRootAsset(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Add a New File Assignment to an Asset¶
This section shows two options for adding a new file assignment to an asset. The file is also assigned to all children of the asset by default.
// Construct the AssetClient object as shown above
AssetResourceWithHierarchyPath asset_resource = null;
try {
asset_resource = asset_client.saveAssetFileAssignment(<asset_id>, <key>, <ifMatch>, <assignment>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the SaveAssetFileAssignmentRequest
model.
// Construct the AssetClient object as shown above
SaveAssetFileAssignmentRequest request_object = new SaveAssetFileAssignmentRequest();
request_object.setId(<asset_id>);
request_object.setKey(<key>);
request_object.setAssignment(<assignment>);
request_object.setIfMatch(<ifMatc>h);
AssetResourceWithHierarchyPath asset_resource = null;
try {
asset_resource = asset_client.saveAssetFileAssignment(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Delete a File Assignment from an Asset¶
This section shows two options for deleting a file assignment from an asset.
// Construct the AssetClient object as shown above
AssetResourceWithHierarchyPath asset_resource = null;
try {
asset_resource = asset_client.deleteAssetFileAssigment(<asset_id>, <key>, <ifMatch>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the DeleteAssetFileAssigmentRequest
model.
// Construct the AssetClient object as shown above
DeleteAssetFileAssigmentRequest request_object = new DeleteAssetFileAssigmentRequest();
request_object.setId(response.getAssetId());
request_object.setKey(<key>);
request_object.setIfMatch(<ifMatch>);
AssetResourceWithHierarchyPath asset_resource = null;
try {
asset_resource = asset_client.deleteAssetFileAssigment(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Get Assets using Filters¶
Get Assets with a Specific Parameter¶
Use the filter - equals
functionality to get all assets whose properties like name, tenantId, assetId, externalId, subtenant is equal to the input value.
// Construct the AssetClient object as shown above
AssetListResource assets = null;
try {
assets = asset_client.getAssetsEqualTo(FieldTypeEnum.NAME, <filter_value>);
}catch (MindsphereException e) {
// Exception handling
}
Get Assets with a Parameter from a List¶
Use the filter - in
functionality to get all assets whose properties like name, tenantId, assetId, externalId, subtenant matches any value in an array of values.
// Construct the AssetClient object as shown above
AssetListResource assets = null;
try {
assets = asset_client.getAssetsLike(FieldTypeEnum.NAME, <filter_value_1>, <filter_value_2>);
}catch (MindsphereException e) {
// Exception handling
}
Get Assets where a Parameter Starts with a Specific Value¶
Use the filter - startsWith
functionality to get all assets whose name or tenantId or parentTypeId starts with an input value.
// Construct the AssetClient object as shown above
AssetListResource assets = null;
try {
assets = asset_client.getAssetsStartsWith(FieldTypeEnum.NAME, <filter_value>);
}catch (MindsphereException e) {
// Exception handling
}
Get Assets where a Parameter Ends with a Specific Value¶
Use the filter - endsWith
functionality to get all assets whose name or tenant ID or parent type ID ends with an input value.
// Construct the AssetClient object as shown above
AssetListResource assets = null;
try {
assets = asset_client.getAssetsEndsWith(FieldTypeEnum.NAME, <filter_value>);
}catch (MindsphereException e) {
// Exception handling
}
Get Assets where a Parameter Contains a Specific Value¶
Use the filter - contains
functionality to get all assets whose name or tenant ID or parent type ID contains an input value.
// Construct the AssetClient object as shown above
AssetListResource assets = null;
try {
assets = asset_client.getAssetsContains(FieldTypeEnum.NAME, <filter_value>);
}catch (MindsphereException e) {
// Exception handling
}
Get Assets of a Specific Type¶
Use the filter - hasType
functionality to get all assets of a particular type.
// Construct the AssetClient object as shown above
AssetListResource assets = null;
try {
assets = asset_client.getAssetsOfType(<filter_value>);
}catch (MindsphereException e) {
// Exception handling
}
Structure Operations¶
The structure client is used to list an asset's aspects and variables.
Client name: StructureClient
Get an Asset's Variables¶
This section shows two options for getting all variables of an asset.
// Construct the StructureClient object
StructureClient structure_client = StructureClient.builder()
.mindsphereCredentials(<credentials>)
.restClientConfig(<config>)
.build();
VariableListResource structure_variables = null;
try{
structure_variables = structure_client.listAssetVariables(<asset_id>, <page>, <size>, <sort>, <filter>, <ifNoneMatch>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the ListAssetVariablesRequest
model.
// Construct the StructureClient object as shown above
ListAssetVariablesRequest request_object = new ListAssetVariablesRequest();
request_object.setId(assetId());
VariableListResource structure_variables = null;
try{
structure_variables = structure_client.listAssetVariables(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Get all Aspects of an Asset¶
This section shows two options for getting all static and dynamic aspects of an asset.
// Construct the StructureClient object as shown above
AspectListResource structure_aspects = null;
try{
structure_aspects = structure_client.listAssetAspects(<asset_id>, <page>, <size>, <sort>, <filter>, <ifNoneMatch>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the ListAssetAspectsRequest
model.
// Construct the StructureClient object as shown above
ListAssetAspectsRequest request_object = new ListAssetAspectsRequest();
request_object.setId(assetId());
AspectListResource structure_aspects = null;
try{
structure_aspects = structure_client.listAssetAspects(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Locations Operations¶
The locations client manages the location of an asset. It can be used to create, update and delete an asset's location.
Client name: LocationsClient
Create or Update an Asset's Location¶
This section shows two options for creating or updating the location that is assigned to an asset. If no location is defined for the asset yet, a new one is created. Otherwise, it is updated.
// Construct the AssetLocationClient object
LocationsClient locations_client = LocationsClient.builder()
.mindsphereCredentials(<credentials>)
.restClientConfig(<config>)
.build();
try{
locations_client.saveAssetLocation(<ifMatch>, <asset_id>, <location>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the SaveAssetLocationRequest
model.
// Construct the AssetLocationClient object as shown above
SaveAssetLocationRequest request_object = new SaveAssetLocationRequest();
request_object.setId(<asset_id>);
request_object.setIfMatch(<ifMatch>);
request_object.setLocation(<location>);
try{
locations_client.saveAssetLocation(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Delete an Asset's Location¶
This section shows two options for deleting the location from an asset.
// Construct the AssetLocationClient object as shown above
AssetResourceWithHierarchyPath asset_resource = null;
try{
asset_resource = locations_client.deleteAssetLocation(<ifMatch>, <asset_id>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the DeleteAssetLocationRequest
model.
// Construct the AssetLocationClient object as shown above
DeleteAssetLocationRequest request_object = new DeleteAssetLocationRequest();
request_object.setId(<asset_id>);
request_object.setIfMatch(<ifMatch>);
AssetResourceWithHierarchyPath asset_resource = null;
try{
asset_resource = locations_client.deleteAssetLocation(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Billboard Operations¶
The billboard client can be used to list all available resources.
Client name: BillboardClient
List all Available Resources¶
List all links for available resources
// Construct the BillboardClient object
BillboardClient billboard_client = BillboardClient.builder()
.mindsphereCredentials(<credentials>)
.restClientConfig(<config>)
.build();
BillboardResource billboard_resource = null;
try{
billboard_resource = billboard_client.getBillboard();
} catch (MindsphereException e) {
// Exception handling
}
File Operations¶
The files client manages files that can be assigned to a resource. It is used to list, read, upload, delete, replace and download a file.
Client name: FilesClient
List all Files¶
This section shows two options for getting metadata of all uploaded files.
// Construct the FilesClient object
FilesClient files_client = FilesClient.builder()
.mindsphereCredentials(<credentials>)
.restClientConfig(<config>)
.build();
FileMetadataListResource file_metadata_list_resource = null;
try{
file_metadata_list_resource = files_client.listFiles(<page>, <size>, <sort>, <filter>, <ifNoneMatch>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the ListFilesRequest
model.
// Construct the FilesClient object as shown above
ListFilesRequest request_object = new ListFilesRequest();
request_object.setPage(<page>);
request_object.setSize(<size>);
FileMetadataListResource file_metadata_list_resource = null;
try{
file_metadata_list_resource = files_client.listFiles(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Get a File¶
This section shows two options for getting the metadata of a file with the user defined ID.
// Construct the FilesClient object as shown above
FileMetadataResource file_metadata_resource = null;
try{
file_metadata_resource = files_client.getFile(<file_id>, <ifNoneMatch>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the GetFileRequest
model.
// Construct the FilesClient object as shown above
GetFileRequest request_object = new GetFileRequest();
request_object.setFileId(<file_id>);
FileMetadataResource file_metadata_resource = null;
try{
file_metadata_resource = files_client.getFile(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Download a File¶
This section shows two options for returning a file by its ID.
// Construct the FilesClient object as shown above
byte[] file_contents = null;
try{
file_contents = files_client.downloadFile(<file_id>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the DownloadFileRequest
model.
// Construct the FilesClient object as shown above
DownloadFileRequest request_object = new DownloadFileRequest();
request_object.setFileId(<file_id>);
byte[] file_contents = null;
try{
file_contents = files_client.downloadFile(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Replace a File¶
This section shows two options for updating a previously uploaded file. The maximum file size is 5 MB.
// Construct the FilesClient object as shown above
FileMetadataResource file_metadata_resource = null;
try{
file_metadata_resource = files_client.replaceFile(<ifMatch>, <file_id>, <file>, <name>, <scope>, <description>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the ReplaceFileRequest
model.
// Construct the FilesClient object as shown above
ReplaceFileRequest request_object = new ReplaceFileRequest();
request_object.setIfMatch(<ifMatch>);
request_object.setFileId(<file_id>);
request_object.setFile(<file>);
request_object.setName(<name>);
request_object.setScope(<scope>);
FileMetadataResource file_metadata_resource = null;
try{
file_metadata_resource = files_client.replaceFile(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Upload a File¶
This section shows two options for uploading a file to be used in Asset Management.
// Construct the FilesClient object as shown above
FileMetadataResource file_metadata_resource = null;
try{
file_metadata_resource = files_client.uploadFile(<file>, <name>, <scope>, <description>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the UploadFileRequest
model.
// Construct the FilesClient object as shown above
UploadFileRequest request_object = new UploadFileRequest();
request_object.setFile(<file>);
request_object.setName(<name>);
FileMetadataResource file_metadata_resource = null;
try{
file_metadata_resource = files_client.uploadFile(request_object);
} catch (MindsphereException e) {
// Exception handling
}
Delete a File¶
This section shows two options for deleting a file.
// Construct the FilesClient object as shown above
try{
deleteFile(<ifMatch>, <file_id>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the DeleteFileRequest
model.
// Construct the FilesClient object as shown above
DeleteFileRequest request_object = new DeleteFileRequest();
request_object.setIfMatch(<ifMatch>);
request_object.setFileId(<file_id>);
try{
deleteFile(request_object);
} 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 support the following operations:
getPage(Integer pageNumber);
next();
previous();
The following iterators are provided for different controllers in Asset Management:
- AspectTypePageIterator
- AssetTypePageIterator
- AssetPageIterator
- StructureAspectsPageIterator
- StructureVariablesPageIterator
try {
// Construct the AssetsClient object
AssetsClient asset_client = AssetsClient.builder()
.mindsphereCredentials(<credentials>)
.restClientConfig(<config>)
.build();
// Create Asset Page Iterator
AssetPageIterator asset_page_iterator = new AssetPageIterator(asset_client, <page_size>);
AssetListResource assets = asset_page_iterator.getPage(10);
} catch (MindsphereException e) {
// Exception handling
}
Except where otherwise noted, content on this site is licensed under the Development License Agreement.