createServiceAction method

Future<CreateServiceActionOutput> createServiceAction({
  1. required Map<ServiceActionDefinitionKey, String> definition,
  2. required ServiceActionDefinitionType definitionType,
  3. required String name,
  4. String? acceptLanguage,
  5. String? description,
  6. String? idempotencyToken,
})

Creates a self-service action.

May throw InvalidParametersException. May throw LimitExceededException.

Parameter definition : The self-service action definition. Can be one of the following:

Name
The name of the AWS Systems Manager document (SSM document). For example, AWS-RestartEC2Instance.

If you are using a shared SSM document, you must provide the ARN instead of the name.

Version
The AWS Systems Manager automation document version. For example, "Version": "1"
AssumeRole
The Amazon Resource Name (ARN) of the role that performs the self-service actions on your behalf. For example, "AssumeRole": "arn:aws:iam::12345678910:role/ActionRole".

To reuse the provisioned product launch role, set to "AssumeRole": "LAUNCH_ROLE".

Parameters
The list of parameters in JSON format.

For example: {\"Name\":\"InstanceId\",\"Type\":\"TARGET\"} or {\"Name\":\"InstanceId\",\"Type\":\"TEXT_VALUE\"}.

Parameter definitionType : The service action definition type. For example, SSM_AUTOMATION.

Parameter name : The self-service action name.

Parameter acceptLanguage : The language code.

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

Parameter description : The self-service action description.

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.

Implementation

Future<CreateServiceActionOutput> createServiceAction({
  required Map<ServiceActionDefinitionKey, String> definition,
  required ServiceActionDefinitionType definitionType,
  required String name,
  String? acceptLanguage,
  String? description,
  String? idempotencyToken,
}) async {
  ArgumentError.checkNotNull(definition, 'definition');
  ArgumentError.checkNotNull(definitionType, 'definitionType');
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    1,
    256,
    isRequired: true,
  );
  _s.validateStringLength(
    'acceptLanguage',
    acceptLanguage,
    0,
    100,
  );
  _s.validateStringLength(
    'description',
    description,
    0,
    1024,
  );
  _s.validateStringLength(
    'idempotencyToken',
    idempotencyToken,
    1,
    128,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWS242ServiceCatalogService.CreateServiceAction'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Definition': definition.map((k, e) => MapEntry(k.toValue(), e)),
      'DefinitionType': definitionType.toValue(),
      'Name': name,
      if (acceptLanguage != null) 'AcceptLanguage': acceptLanguage,
      if (description != null) 'Description': description,
      'IdempotencyToken': idempotencyToken ?? _s.generateIdempotencyToken(),
    },
  );

  return CreateServiceActionOutput.fromJson(jsonResponse.body);
}