createProduct method

Future<CreateProductOutput> createProduct({
  1. required String name,
  2. required String owner,
  3. required ProductType productType,
  4. required ProvisioningArtifactProperties provisioningArtifactParameters,
  5. String? acceptLanguage,
  6. String? description,
  7. String? distributor,
  8. String? idempotencyToken,
  9. String? supportDescription,
  10. String? supportEmail,
  11. String? supportUrl,
  12. List<Tag>? tags,
})

Creates a product.

A delegated admin is authorized to invoke this command.

The user or role that performs this operation must have the cloudformation:GetTemplate IAM policy permission. This policy permission is required when using the ImportFromPhysicalId template source in the information data section.

May throw InvalidParametersException. May throw LimitExceededException. May throw TagOptionNotMigratedException.

Parameter name : The name of the product.

Parameter owner : The owner of the product.

Parameter productType : The type of product.

Parameter provisioningArtifactParameters : The configuration of the provisioning artifact.

Parameter acceptLanguage : The language code.

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

Parameter description : The description of the product.

Parameter distributor : The distributor of the 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 supportDescription : The support information about the product.

Parameter supportEmail : The contact email for product support.

Parameter supportUrl : The contact URL for product support.

^https?:/// / is the pattern used to validate SupportUrl.

Parameter tags : One or more tags.

Implementation

Future<CreateProductOutput> createProduct({
  required String name,
  required String owner,
  required ProductType productType,
  required ProvisioningArtifactProperties provisioningArtifactParameters,
  String? acceptLanguage,
  String? description,
  String? distributor,
  String? idempotencyToken,
  String? supportDescription,
  String? supportEmail,
  String? supportUrl,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    0,
    8191,
    isRequired: true,
  );
  ArgumentError.checkNotNull(owner, 'owner');
  _s.validateStringLength(
    'owner',
    owner,
    0,
    8191,
    isRequired: true,
  );
  ArgumentError.checkNotNull(productType, 'productType');
  ArgumentError.checkNotNull(
      provisioningArtifactParameters, 'provisioningArtifactParameters');
  _s.validateStringLength(
    'acceptLanguage',
    acceptLanguage,
    0,
    100,
  );
  _s.validateStringLength(
    'description',
    description,
    0,
    8191,
  );
  _s.validateStringLength(
    'distributor',
    distributor,
    0,
    8191,
  );
  _s.validateStringLength(
    'idempotencyToken',
    idempotencyToken,
    1,
    128,
  );
  _s.validateStringLength(
    'supportDescription',
    supportDescription,
    0,
    8191,
  );
  _s.validateStringLength(
    'supportEmail',
    supportEmail,
    0,
    254,
  );
  _s.validateStringLength(
    'supportUrl',
    supportUrl,
    0,
    2083,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWS242ServiceCatalogService.CreateProduct'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Name': name,
      'Owner': owner,
      'ProductType': productType.toValue(),
      'ProvisioningArtifactParameters': provisioningArtifactParameters,
      if (acceptLanguage != null) 'AcceptLanguage': acceptLanguage,
      if (description != null) 'Description': description,
      if (distributor != null) 'Distributor': distributor,
      'IdempotencyToken': idempotencyToken ?? _s.generateIdempotencyToken(),
      if (supportDescription != null)
        'SupportDescription': supportDescription,
      if (supportEmail != null) 'SupportEmail': supportEmail,
      if (supportUrl != null) 'SupportUrl': supportUrl,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateProductOutput.fromJson(jsonResponse.body);
}