copyProduct method
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. If you copy a product to another account, you must first share the product in a portfolio using CreatePortfolioShare.
This operation is performed asynchronously. To track the progress of the operation, use DescribeCopyProductStatus.
May throw InvalidParametersException.
May throw ResourceNotFoundException.
Parameter sourceProductArn :
The Amazon Resource Name (ARN) of the source product.
Parameter acceptLanguage :
The language code.
-
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 {
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.value).toList(),
'IdempotencyToken': idempotencyToken ?? _s.generateIdempotencyToken(),
if (sourceProvisioningArtifactIdentifiers != null)
'SourceProvisioningArtifactIdentifiers':
sourceProvisioningArtifactIdentifiers
.map((e) => e.map((k, e) => MapEntry(k.value, e)))
.toList(),
if (targetProductId != null) 'TargetProductId': targetProductId,
if (targetProductName != null) 'TargetProductName': targetProductName,
},
);
return CopyProductOutput.fromJson(jsonResponse.body);
}