associateAssets method

Future<void> associateAssets({
  1. required String assetId,
  2. required String childAssetId,
  3. required String hierarchyId,
  4. String? clientToken,
})

Associates a child asset with the given parent asset through a hierarchy defined in the parent asset's model. For more information, see Associating 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 assetId : The ID of the parent 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 childAssetId : The ID of the child asset to be associated. 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 hierarchyId : The ID of a hierarchy in the parent asset's model. (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.) Hierarchies allow different groupings of assets to be formed that all come from the same asset model. For more information, see Asset hierarchies 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.

Implementation

Future<void> associateAssets({
  required String assetId,
  required String childAssetId,
  required String hierarchyId,
  String? clientToken,
}) async {
  final $payload = <String, dynamic>{
    'childAssetId': childAssetId,
    'hierarchyId': hierarchyId,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
  };
  await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/assets/${Uri.encodeComponent(assetId)}/associate',
    exceptionFnMap: _exceptionFns,
  );
}