createPlan method

Future<CreatePlanResponse> createPlan({
  1. required String executionRole,
  2. required String name,
  3. required RecoveryApproach recoveryApproach,
  4. required List<String> regions,
  5. required List<Workflow> workflows,
  6. Map<String, AssociatedAlarm>? associatedAlarms,
  7. String? description,
  8. String? primaryRegion,
  9. int? recoveryTimeObjectiveMinutes,
  10. ReportConfiguration? reportConfiguration,
  11. Map<String, String>? tags,
  12. List<Trigger>? triggers,
})

Creates a new Region switch plan. A plan defines the steps required to shift traffic from one Amazon Web Services Region to another.

You must specify a name for the plan, the primary Region, and at least one additional Region. You can also provide a description, execution role, recovery time objective, associated alarms, triggers, and workflows that define the steps to execute during a Region switch.

Parameter executionRole : An execution role is a way to categorize a Region switch plan.

Parameter name : The name of a Region switch plan.

Parameter recoveryApproach : The recovery approach for a Region switch plan, which can be active/active (activeActive) or active/passive (activePassive).

Parameter regions : An array that specifies the Amazon Web Services Regions for a Region switch plan. Specify two Regions.

Parameter workflows : An array of workflows included in a Region switch plan.

Parameter associatedAlarms : The alarms associated with a Region switch plan.

Parameter description : The description of a Region switch plan.

Parameter primaryRegion : The primary Amazon Web Services Region for the application. This is the Region where the application normally runs before any Region switch occurs.

Parameter recoveryTimeObjectiveMinutes : Optionally, you can specify an recovery time objective for a Region switch plan, in minutes.

Parameter tags : The tags to apply to the Region switch plan.

Parameter triggers : The triggers associated with a Region switch plan.

Implementation

Future<CreatePlanResponse> createPlan({
  required String executionRole,
  required String name,
  required RecoveryApproach recoveryApproach,
  required List<String> regions,
  required List<Workflow> workflows,
  Map<String, AssociatedAlarm>? associatedAlarms,
  String? description,
  String? primaryRegion,
  int? recoveryTimeObjectiveMinutes,
  ReportConfiguration? reportConfiguration,
  Map<String, String>? tags,
  List<Trigger>? triggers,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'ArcRegionSwitch.CreatePlan'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'executionRole': executionRole,
      'name': name,
      'recoveryApproach': recoveryApproach.value,
      'regions': regions,
      'workflows': workflows,
      if (associatedAlarms != null) 'associatedAlarms': associatedAlarms,
      if (description != null) 'description': description,
      if (primaryRegion != null) 'primaryRegion': primaryRegion,
      if (recoveryTimeObjectiveMinutes != null)
        'recoveryTimeObjectiveMinutes': recoveryTimeObjectiveMinutes,
      if (reportConfiguration != null)
        'reportConfiguration': reportConfiguration,
      if (tags != null) 'tags': tags,
      if (triggers != null) 'triggers': triggers,
    },
  );

  return CreatePlanResponse.fromJson(jsonResponse.body);
}