Ada lebih banyak AWS SDK contoh yang tersedia di GitHub repo SDKContoh AWS Dokumen
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Gunakan DescribeAssetModel
dengan AWS SDK atau CLI
Contoh kode berikut menunjukkan cara menggunakanDescribeAssetModel
.
- CLI
-
- AWS CLI
-
Untuk menggambarkan model aset
describe-asset-model
Contoh berikut menjelaskan model aset ladang angin.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" } }
Untuk informasi selengkapnya, lihat Menjelaskan model aset tertentu di Panduan Pengguna AWS SiteWise IoT.
-
Untuk API detailnya, lihat DescribeAssetModel
di Referensi AWS CLI Perintah.
-
- Java
-
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. /** * 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; } }); }
-
Untuk API detailnya, lihat DescribeAssetModeldi AWS SDK for Java 2.x APIReferensi.
-