copyProduct method

Future<CopyProductOutput> copyProduct({
  1. required String sourceProductArn,
  2. String? acceptLanguage,
  3. List<CopyOption>? copyOptions,
  4. String? idempotencyToken,
  5. List<Map<ProvisioningArtifactPropertyName, String>>? sourceProvisioningArtifactIdentifiers,
  6. String? targetProductId,
  7. String? targetProductName,
})

Copies the specified source product to the specified target product or a new product.

You can copy a product to the same account or another account. You can copy a product to the same region or another region.

This operation is performed asynchronously. To track the progress of the operation, use DescribeCopyProductStatus.

May throw ResourceNotFoundException. May throw InvalidParametersException.

Parameter sourceProductArn : The Amazon Resource Name (ARN) of the source product.

Parameter acceptLanguage : The language code.

  • en - English (default)
  • jp - Japanese
  • zh - Chinese

Parameter copyOptions : The copy options. If the value is CopyTags, the tags from the source product are copied to the target product.

Parameter idempotencyToken : A unique identifier that you provide to ensure idempotency. If multiple requests differ only by the idempotency token, the same response is returned for each repeated request.

Parameter sourceProvisioningArtifactIdentifiers : The identifiers of the provisioning artifacts (also known as versions) of the product to copy. By default, all provisioning artifacts are copied.

Parameter targetProductId : The identifier of the target product. By default, a new product is created.

Parameter targetProductName : A name for the target product. The default is the name of the source product.

Implementation

Future<CopyProductOutput> copyProduct({
  required String sourceProductArn,
  String? acceptLanguage,
  List<CopyOption>? copyOptions,
  String? idempotencyToken,
  List<Map<ProvisioningArtifactPropertyName, String>>?
      sourceProvisioningArtifactIdentifiers,
  String? targetProductId,
  String? targetProductName,
}) async {
  ArgumentError.checkNotNull(sourceProductArn, 'sourceProductArn');
  _s.validateStringLength(
    'sourceProductArn',
    sourceProductArn,
    1,
    1224,
    isRequired: true,
  );
  _s.validateStringLength(
    'acceptLanguage',
    acceptLanguage,
    0,
    100,
  );
  _s.validateStringLength(
    'idempotencyToken',
    idempotencyToken,
    1,
    128,
  );
  _s.validateStringLength(
    'targetProductId',
    targetProductId,
    1,
    100,
  );
  _s.validateStringLength(
    'targetProductName',
    targetProductName,
    0,
    8191,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWS242ServiceCatalogService.CopyProduct'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'SourceProductArn': sourceProductArn,
      if (acceptLanguage != null) 'AcceptLanguage': acceptLanguage,
      if (copyOptions != null)
        'CopyOptions': copyOptions.map((e) => e.toValue()).toList(),
      'IdempotencyToken': idempotencyToken ?? _s.generateIdempotencyToken(),
      if (sourceProvisioningArtifactIdentifiers != null)
        'SourceProvisioningArtifactIdentifiers':
            sourceProvisioningArtifactIdentifiers
                .map((e) => e.map((k, e) => MapEntry(k.toValue(), e)))
                .toList(),
      if (targetProductId != null) 'TargetProductId': targetProductId,
      if (targetProductName != null) 'TargetProductName': targetProductName,
    },
  );

  return CopyProductOutput.fromJson(jsonResponse.body);
}