startPlanExecution method

Future<StartPlanExecutionResponse> startPlanExecution({
  1. required ExecutionAction action,
  2. required String planArn,
  3. required String targetRegion,
  4. String? comment,
  5. String? latestVersion,
  6. ExecutionMode? mode,
  7. String? recoveryExecutionId,
})

Starts the execution of a Region switch plan. You can execute a plan in either graceful or ungraceful mode.

Specifing ungraceful mode either changes the behavior of the execution blocks in a workflow or skips specific execution blocks.

May throw AccessDeniedException. May throw IllegalArgumentException. May throw IllegalStateException. May throw ResourceNotFoundException.

Parameter action : The action to perform. Valid values are activate (to shift traffic to the target Region) or deactivate (to shift traffic away from the target Region).

Parameter planArn : The Amazon Resource Name (ARN) of the plan to execute.

Parameter targetRegion : The Amazon Web Services Region to target with this execution. This is the Region that traffic will be shifted to or from, depending on the action.

Parameter comment : An optional comment explaining why the plan execution is being started.

Parameter latestVersion : A boolean value indicating whether to use the latest version of the plan. If set to false, you must specify a specific version.

Parameter mode : The plan execution mode. Valid values are graceful, for starting the execution in graceful mode, or ungraceful, for starting the execution in ungraceful mode.

Parameter recoveryExecutionId : The execution identifier of the recovery execution that ran in the opposite region post-recovery is ran in. Required when starting a post-recovery execution.

Implementation

Future<StartPlanExecutionResponse> startPlanExecution({
  required ExecutionAction action,
  required String planArn,
  required String targetRegion,
  String? comment,
  String? latestVersion,
  ExecutionMode? mode,
  String? recoveryExecutionId,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'ArcRegionSwitch.StartPlanExecution'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'action': action.value,
      'planArn': planArn,
      'targetRegion': targetRegion,
      if (comment != null) 'comment': comment,
      if (latestVersion != null) 'latestVersion': latestVersion,
      if (mode != null) 'mode': mode.value,
      if (recoveryExecutionId != null)
        'recoveryExecutionId': recoveryExecutionId,
    },
  );

  return StartPlanExecutionResponse.fromJson(jsonResponse.body);
}