updateAssetModel method
- required String assetModelId,
- required String assetModelName,
- List<
AssetModelCompositeModel> ? assetModelCompositeModels, - String? assetModelDescription,
- String? assetModelExternalId,
- List<
AssetModelHierarchy> ? assetModelHierarchies, - List<
AssetModelProperty> ? assetModelProperties, - String? clientToken,
- String? ifMatch,
- String? ifNoneMatch,
- AssetModelVersionType? matchForVersionType,
Updates an asset model and all of the assets that were created from the model. Each asset created from the model inherits the updated asset model's property and hierarchy definitions. For more information, see Updating assets and models in the IoT SiteWise User Guide.
To replace an existing asset model property with a new one with the same
name, do the following:
-
Submit an
UpdateAssetModelrequest with the entire existing property removed. -
Submit a second
UpdateAssetModelrequest that includes the new property. The new asset property will have the samenameas the previous one and IoT SiteWise will generate a new uniqueid.
May throw ConflictingOperationException.
May throw InternalFailureException.
May throw InvalidRequestException.
May throw LimitExceededException.
May throw PreconditionFailedException.
May throw ResourceAlreadyExistsException.
May throw ResourceNotFoundException.
May throw ThrottlingException.
Parameter assetModelId :
The ID of the asset model to update. This can be either the actual ID in
UUID format, or else externalId: followed by the external ID,
if it has one. For more information, see Referencing
objects with external IDs in the IoT SiteWise User Guide.
Parameter assetModelName :
A unique name for the asset model.
Parameter assetModelCompositeModels :
The composite models that are part of this asset model. It groups
properties (such as attributes, measurements, transforms, and metrics) and
child composite models that model parts of your industrial equipment. Each
composite model has a type that defines the properties that the composite
model supports. Use composite models to define alarms on this asset model.
Parameter assetModelDescription :
A description for the asset model.
Parameter assetModelExternalId :
An external ID to assign to the asset model. The asset model must not
already have an external ID. The external ID must be unique within your
Amazon Web Services account. For more information, see Using
external IDs in the IoT SiteWise User Guide.
Parameter assetModelHierarchies :
The updated hierarchy definitions of the asset model. Each hierarchy
specifies an asset model whose assets can be children of any other assets
created from this asset model. For more information, see Asset
hierarchies in the IoT SiteWise User Guide.
You can specify up to 10 hierarchies per asset model. For more information, see Quotas in the IoT SiteWise User Guide.
Parameter assetModelProperties :
The updated property definitions of the asset model. For more information,
see Asset
properties in the IoT SiteWise User Guide.
You can specify up to 200 properties per asset model. For more information, see Quotas in the IoT SiteWise User Guide.
Parameter clientToken :
A unique case-sensitive identifier that you can provide to ensure the
idempotency of the request. Don't reuse this client token if a new
idempotent request is required.
Parameter ifMatch :
The expected current entity tag (ETag) for the asset model’s latest or
active version (specified using matchForVersionType). The
update request is rejected if the tag does not match the latest or active
version's current entity tag. See Optimistic
locking for asset model writes in the IoT SiteWise User Guide.
Parameter ifNoneMatch :
Accepts * to reject the update request if an active version
(specified using matchForVersionType as ACTIVE)
already exists for the asset model.
Parameter matchForVersionType :
Specifies the asset model version type (LATEST or
ACTIVE) used in conjunction with If-Match or
If-None-Match headers to determine the target ETag for the
update operation.
Implementation
Future<UpdateAssetModelResponse> updateAssetModel({
required String assetModelId,
required String assetModelName,
List<AssetModelCompositeModel>? assetModelCompositeModels,
String? assetModelDescription,
String? assetModelExternalId,
List<AssetModelHierarchy>? assetModelHierarchies,
List<AssetModelProperty>? assetModelProperties,
String? clientToken,
String? ifMatch,
String? ifNoneMatch,
AssetModelVersionType? matchForVersionType,
}) async {
final headers = <String, String>{
if (ifMatch != null) 'If-Match': ifMatch.toString(),
if (ifNoneMatch != null) 'If-None-Match': ifNoneMatch.toString(),
if (matchForVersionType != null)
'Match-For-Version-Type': matchForVersionType.value,
};
final $payload = <String, dynamic>{
'assetModelName': assetModelName,
if (assetModelCompositeModels != null)
'assetModelCompositeModels': assetModelCompositeModels,
if (assetModelDescription != null)
'assetModelDescription': assetModelDescription,
if (assetModelExternalId != null)
'assetModelExternalId': assetModelExternalId,
if (assetModelHierarchies != null)
'assetModelHierarchies': assetModelHierarchies,
if (assetModelProperties != null)
'assetModelProperties': assetModelProperties,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
};
final response = await _protocol.send(
payload: $payload,
method: 'PUT',
requestUri: '/asset-models/${Uri.encodeComponent(assetModelId)}',
headers: headers,
exceptionFnMap: _exceptionFns,
);
return UpdateAssetModelResponse.fromJson(response);
}