createAsset method

Future<CreateAssetResponse> createAsset({
  1. required String assetModelId,
  2. required String assetName,
  3. String? assetDescription,
  4. String? assetExternalId,
  5. String? assetId,
  6. String? clientToken,
  7. Map<String, String>? tags,
})

Creates an asset from an existing asset model. For more information, see Creating assets in the IoT SiteWise User Guide.

May throw ConflictingOperationException. May throw InternalFailureException. May throw InvalidRequestException. May throw LimitExceededException. May throw ResourceAlreadyExistsException. May throw ResourceNotFoundException. May throw ThrottlingException.

Parameter assetModelId : The ID of the asset model from which to create the asset. 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 assetName : A friendly name for the asset.

Parameter assetDescription : A description for the asset.

Parameter assetExternalId : An external ID to assign to the asset. 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 assetId : The ID to assign to the asset, if desired. 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 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 tags : A list of key-value pairs that contain metadata for the asset. For more information, see Tagging your IoT SiteWise resources in the IoT SiteWise User Guide.

Implementation

Future<CreateAssetResponse> createAsset({
  required String assetModelId,
  required String assetName,
  String? assetDescription,
  String? assetExternalId,
  String? assetId,
  String? clientToken,
  Map<String, String>? tags,
}) async {
  final $payload = <String, dynamic>{
    'assetModelId': assetModelId,
    'assetName': assetName,
    if (assetDescription != null) 'assetDescription': assetDescription,
    if (assetExternalId != null) 'assetExternalId': assetExternalId,
    if (assetId != null) 'assetId': assetId,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/assets',
    exceptionFnMap: _exceptionFns,
  );
  return CreateAssetResponse.fromJson(response);
}