createAssetModelCompositeModel method
- required String assetModelCompositeModelName,
- required String assetModelCompositeModelType,
- required String assetModelId,
- String? assetModelCompositeModelDescription,
- String? assetModelCompositeModelExternalId,
- String? assetModelCompositeModelId,
- List<
AssetModelPropertyDefinition> ? assetModelCompositeModelProperties, - String? clientToken,
- String? composedAssetModelId,
- String? ifMatch,
- String? ifNoneMatch,
- AssetModelVersionType? matchForVersionType,
- String? parentAssetModelCompositeModelId,
Creates a custom composite model from specified property and hierarchy
definitions. There are two types of custom composite models,
inline and component-model-based.
Use component-model-based custom composite models to define standard, reusable components. A component-model-based custom composite model consists of a name, a description, and the ID of the component model it references. A component-model-based custom composite model has no properties of its own; its referenced component model provides its associated properties to any created assets. For more information, see Custom composite models (Components) in the IoT SiteWise User Guide.
Use inline custom composite models to organize the properties of an asset model. The properties of inline custom composite models are local to the asset model where they are included and can't be used to create multiple assets.
To create a component-model-based model, specify the
composedAssetModelId of an existing asset model with
assetModelType of COMPONENT_MODEL.
To create an inline model, specify the
assetModelCompositeModelProperties and don't include an
composedAssetModelId.
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 assetModelCompositeModelName :
A unique name for the composite model.
Parameter assetModelCompositeModelType :
The composite model type. Valid values are AWS/ALARM,
CUSTOM, or AWS/L4E_ANOMALY.
Parameter assetModelId :
The ID of the asset model this composite model is a part of.
Parameter assetModelCompositeModelDescription :
A description for the composite model.
Parameter assetModelCompositeModelExternalId :
An external ID to assign to the composite model.
If the composite model is a derived composite model, or one nested inside
a component model, you can only set the external ID using
UpdateAssetModelCompositeModel and specifying the derived ID
of the model or property from the created model it's a part of.
Parameter assetModelCompositeModelId :
The ID of the composite model. IoT SiteWise automatically generates a
unique ID for you, so this parameter is never required. However, if you
prefer to supply your own ID instead, you can specify it here in UUID
format. If you specify your own ID, it must be globally unique.
Parameter assetModelCompositeModelProperties :
The property definitions of the composite model. For more information, see
Inline custom composite models in the IoT SiteWise User Guide.
You can specify up to 200 properties per composite 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 composedAssetModelId :
The ID of a component model which is reused to create this composite
model.
Parameter ifMatch :
The expected current entity tag (ETag) for the asset model’s latest or
active version (specified using matchForVersionType). The
create 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 create 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
create operation.
Parameter parentAssetModelCompositeModelId :
The ID of the parent composite model in this asset model relationship.
Implementation
Future<CreateAssetModelCompositeModelResponse>
createAssetModelCompositeModel({
required String assetModelCompositeModelName,
required String assetModelCompositeModelType,
required String assetModelId,
String? assetModelCompositeModelDescription,
String? assetModelCompositeModelExternalId,
String? assetModelCompositeModelId,
List<AssetModelPropertyDefinition>? assetModelCompositeModelProperties,
String? clientToken,
String? composedAssetModelId,
String? ifMatch,
String? ifNoneMatch,
AssetModelVersionType? matchForVersionType,
String? parentAssetModelCompositeModelId,
}) 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>{
'assetModelCompositeModelName': assetModelCompositeModelName,
'assetModelCompositeModelType': assetModelCompositeModelType,
if (assetModelCompositeModelDescription != null)
'assetModelCompositeModelDescription':
assetModelCompositeModelDescription,
if (assetModelCompositeModelExternalId != null)
'assetModelCompositeModelExternalId':
assetModelCompositeModelExternalId,
if (assetModelCompositeModelId != null)
'assetModelCompositeModelId': assetModelCompositeModelId,
if (assetModelCompositeModelProperties != null)
'assetModelCompositeModelProperties':
assetModelCompositeModelProperties,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
if (composedAssetModelId != null)
'composedAssetModelId': composedAssetModelId,
if (parentAssetModelCompositeModelId != null)
'parentAssetModelCompositeModelId': parentAssetModelCompositeModelId,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri:
'/asset-models/${Uri.encodeComponent(assetModelId)}/composite-models',
headers: headers,
exceptionFnMap: _exceptionFns,
);
return CreateAssetModelCompositeModelResponse.fromJson(response);
}