There are more AWS SDK examples available in the AWS Doc SDK Examples
Use DescribeAssetModel
with an AWS SDK or CLI
The following code examples show how to use DescribeAssetModel
.
- CLI
-
- AWS CLI
-
To describe an asset model
The following
describe-asset-model
example describes a wind farm asset model.aws iotsitewise describe-asset-model \ --asset-model-id
a1b2c3d4-5678-90ab-cdef-22222EXAMPLE
Output:
{ "assetModelId": "a1b2c3d4-5678-90ab-cdef-22222EXAMPLE", "assetModelArn": "arn:aws:iotsitewise:us-west-2:123456789012:asset-model/a1b2c3d4-5678-90ab-cdef-22222EXAMPLE", "assetModelName": "Wind Farm Model", "assetModelDescription": "Represents a wind farm that comprises many wind turbines", "assetModelProperties": [ { "id": "a1b2c3d4-5678-90ab-cdef-99999EXAMPLE", "name": "Total Generated Power", "dataType": "DOUBLE", "unit": "kW", "type": { "metric": { "expression": "sum(power)", "variables": [ { "name": "power", "value": { "propertyId": "a1b2c3d4-5678-90ab-cdef-66666EXAMPLE", "hierarchyId": "a1b2c3d4-5678-90ab-cdef-77777EXAMPLE" } } ], "window": { "tumbling": { "interval": "1h" } } } } }, { "id": "a1b2c3d4-5678-90ab-cdef-88888EXAMPLE", "name": "Region", "dataType": "STRING", "type": { "attribute": { "defaultValue": " " } } } ], "assetModelHierarchies": [ { "id": "a1b2c3d4-5678-90ab-cdef-77777EXAMPLE", "name": "Wind Turbines", "childAssetModelId": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE" } ], "assetModelCreationDate": 1575671284.0, "assetModelLastUpdateDate": 1575671988.0, "assetModelStatus": { "state": "ACTIVE" } }
For more information, see Describing a specific asset model in the AWS IoT SiteWise User Guide.
-
For API details, see DescribeAssetModel
in AWS CLI Command Reference.
-
- Java
-
- SDK for Java 2.x
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. /** * Retrieves the property IDs associated with a specific asset model. * * @param assetModelId the ID of the asset model that defines the properties. * @return a {@link CompletableFuture} that represents a {@link Map} result that associates the property name to the * propert ID. The calling code can attach callbacks, then handle the result or exception by calling * {@link CompletableFuture#join()} or {@link CompletableFuture#get()}. * <p> * If any completion stage in this method throws an exception, the method logs the exception cause and keeps * it available to the calling code as a {@link CompletionException}. By calling * {@link CompletionException#getCause()}, the calling code can access the original exception. */ public CompletableFuture<Map<String, String>> getPropertyIds(String assetModelId) { ListAssetModelPropertiesRequest modelPropertiesRequest = ListAssetModelPropertiesRequest.builder().assetModelId(assetModelId).build(); return getAsyncClient().listAssetModelProperties(modelPropertiesRequest) .handle((response, throwable) -> { if (response != null) { return response.assetModelPropertySummaries().stream() .collect(Collectors .toMap(AssetModelPropertySummary::name, AssetModelPropertySummary::id)); } else { logger.error("Error occurred while fetching property IDs: {}.", throwable.getCause().getMessage()); throw (CompletionException) throwable; } }); }
-
For API details, see DescribeAssetModel in AWS SDK for Java 2.x API Reference.
-