deleteAssetModel method

Future<DeleteAssetModelResponse> deleteAssetModel({
  1. required String assetModelId,
  2. String? clientToken,
  3. String? ifMatch,
  4. String? ifNoneMatch,
  5. AssetModelVersionType? matchForVersionType,
})

Deletes an asset model. This action can't be undone. You must delete all assets created from an asset model before you can delete the model. Also, you can't delete an asset model if a parent asset model exists that contains a property formula expression that depends on the asset model that you want to delete. For more information, see Deleting assets and models in the IoT SiteWise User Guide.

May throw ConflictingOperationException. May throw InternalFailureException. May throw InvalidRequestException. May throw PreconditionFailedException. May throw ResourceNotFoundException. May throw ThrottlingException.

Parameter assetModelId : The ID of the asset model to delete. 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 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 delete 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 delete 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 delete operation.

Implementation

Future<DeleteAssetModelResponse> deleteAssetModel({
  required String assetModelId,
  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 $query = <String, List<String>>{
    if (clientToken != null) 'clientToken': [clientToken],
  };
  final response = await _protocol.send(
    payload: null,
    method: 'DELETE',
    requestUri: '/asset-models/${Uri.encodeComponent(assetModelId)}',
    queryParams: $query,
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return DeleteAssetModelResponse.fromJson(response);
}