createPortfolio method

Future<CreatePortfolioOutput> createPortfolio({
  1. required String displayName,
  2. required String providerName,
  3. String? acceptLanguage,
  4. String? description,
  5. String? idempotencyToken,
  6. List<Tag>? tags,
})

Creates a portfolio.

A delegated admin is authorized to invoke this command.

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

Parameter displayName : The name to use for display purposes.

Parameter providerName : The name of the portfolio provider.

Parameter acceptLanguage : The language code.

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

Parameter description : The description of the portfolio.

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 tags : One or more tags.

Implementation

Future<CreatePortfolioOutput> createPortfolio({
  required String displayName,
  required String providerName,
  String? acceptLanguage,
  String? description,
  String? idempotencyToken,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(displayName, 'displayName');
  _s.validateStringLength(
    'displayName',
    displayName,
    1,
    100,
    isRequired: true,
  );
  ArgumentError.checkNotNull(providerName, 'providerName');
  _s.validateStringLength(
    'providerName',
    providerName,
    1,
    50,
    isRequired: true,
  );
  _s.validateStringLength(
    'acceptLanguage',
    acceptLanguage,
    0,
    100,
  );
  _s.validateStringLength(
    'description',
    description,
    0,
    2000,
  );
  _s.validateStringLength(
    'idempotencyToken',
    idempotencyToken,
    1,
    128,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWS242ServiceCatalogService.CreatePortfolio'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'DisplayName': displayName,
      'ProviderName': providerName,
      if (acceptLanguage != null) 'AcceptLanguage': acceptLanguage,
      if (description != null) 'Description': description,
      'IdempotencyToken': idempotencyToken ?? _s.generateIdempotencyToken(),
      if (tags != null) 'Tags': tags,
    },
  );

  return CreatePortfolioOutput.fromJson(jsonResponse.body);
}