Updating an asset or component model (Amazon CLI) - Amazon IoT SiteWise
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Updating an asset or component model (Amazon CLI)

You can use the Amazon Command Line Interface (Amazon CLI) to update an asset model or component model.

Use the UpdateAssetModel API to update the name, description, and properties of an asset model or component model. For asset models only, you can update hierarchies. Specify the following parameters:

  • assetModelId – The ID of the asset. This is the actual ID in UUID format, or the externalId:myExternalId if it has one. For more information, see Referencing objects with external IDs in the Amazon IoT SiteWise User Guide.

Specify the updated model in the payload. To learn about the expected format of an asset model or component model, see Creating asset models.

Warning

The UpdateAssetModel API overwrites the existing model with the model that you provide in the payload. To avoid deleting your model's properties or hierarchies, you must include their IDs and definitions in the updated model payload. To learn how to query your model's existing structure, see the DescribeAssetModel operation.

Note

The following procedure can only update composite models of type AWS/ALARM. If you want to update CUSTOM composite models, use UpdateAssetModelCompositeModel instead. For more information, see Updating custom composite models (Components).

To update an asset model or component model (Amazon CLI)
  1. Run the following command to retrieve the existing model definition. Replace asset-model-id with the ID or the external ID of the asset model or component model to update.

    aws iotsitewise describe-asset-model --asset-model-id asset-model-id

    The operation returns a response that contains the model's details. The response has the following structure.

    { "assetModelId": "String", "assetModelArn": "String", "assetModelName": "String", "assetModelDescription": "String", "assetModelProperties": Array of AssetModelProperty, "assetModelHierarchies": Array of AssetModelHierarchyDefinition, "assetModelCompositeModels": Array of AssetModelCompositeModel, "assetModelCompositeModelSummaries": Array of AssetModelCompositeModelSummary, "assetModelCreationDate": "String", "assetModelLastUpdateDate": "String", "assetModelStatus": { "state": "String", "error": { "code": "String", "message": "String" }, "assetModelType": "String" } }

    For more information, see the DescribeAssetModel operation.

  2. Create a file called update-asset-model.json and copy the previous command's response into the file.

  3. Remove the following key-value pairs from the JSON object in update-asset-model.json:

    • assetModelId

    • assetModelArn

    • assetModelCompositeModelSummaries

    • assetModelCreationDate

    • assetModelLastUpdateDate

    • assetModelStatus

    • assetModelType

    The UpdateAssetModel operation expects a payload with the following structure:

    { "assetModelName": "String", "assetModelDescription": "String", "assetModelProperties": Array of AssetModelProperty, "assetModelHierarchies": Array of AssetModelHierarchyDefinition, "assetModelCompositeModels": Array of AssetModelCompositeModel }
  4. In update-asset-model.json, do any of the following:

    • Change the asset model's name (assetModelName).

    • Change, add, or remove the asset model's description (assetModelDescription).

    • Change, add, or remove any of the asset model's properties (assetModelProperties). You can't change the dataType of existing properties or the window of existing metrics. For more information, see Defining data properties.

    • Change, add, or remove any of the asset model's hierarchies (assetModelHierarchies). You can't change the childAssetModelId of existing hierarchies. For more information, see Defining asset model hierarchies.

  5. Run the following command to update the asset model with the definition stored in update-asset-model.json. Replace asset-model-id with the ID of the asset model:

    aws iotsitewise update-asset-model \ --asset-model-id asset-model-id \ --cli-input-json file://model-payload.json