createMitigationAction method

Future<CreateMitigationActionResponse> createMitigationAction({
  1. required String actionName,
  2. required MitigationActionParams actionParams,
  3. required String roleArn,
  4. List<Tag>? tags,
})

Defines an action that can be applied to audit findings by using StartAuditMitigationActionsTask. Only certain types of mitigation actions can be applied to specific check names. For more information, see Mitigation actions. Each mitigation action can apply only one type of change.

May throw InvalidRequestException. May throw ResourceAlreadyExistsException. May throw LimitExceededException. May throw ThrottlingException. May throw InternalFailureException.

Parameter actionName : A friendly name for the action. Choose a friendly name that accurately describes the action (for example, EnableLoggingAction).

Parameter actionParams : Defines the type of action and the parameters for that action.

Parameter roleArn : The ARN of the IAM role that is used to apply the mitigation action.

Parameter tags : Metadata that can be used to manage the mitigation action.

Implementation

Future<CreateMitigationActionResponse> createMitigationAction({
  required String actionName,
  required MitigationActionParams actionParams,
  required String roleArn,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(actionName, 'actionName');
  _s.validateStringLength(
    'actionName',
    actionName,
    0,
    128,
    isRequired: true,
  );
  ArgumentError.checkNotNull(actionParams, 'actionParams');
  ArgumentError.checkNotNull(roleArn, 'roleArn');
  _s.validateStringLength(
    'roleArn',
    roleArn,
    20,
    2048,
    isRequired: true,
  );
  final $payload = <String, dynamic>{
    'actionParams': actionParams,
    'roleArn': roleArn,
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/mitigationactions/actions/${Uri.encodeComponent(actionName)}',
    exceptionFnMap: _exceptionFns,
  );
  return CreateMitigationActionResponse.fromJson(response);
}