updateAutomationRule method

Future<UpdateAutomationRuleResponse> updateAutomationRule({
  1. required String ruleArn,
  2. required int ruleRevision,
  3. String? clientToken,
  4. Criteria? criteria,
  5. String? description,
  6. String? name,
  7. OrganizationConfiguration? organizationConfiguration,
  8. String? priority,
  9. List<RecommendedActionType>? recommendedActionTypes,
  10. RuleType? ruleType,
  11. Schedule? schedule,
  12. RuleStatus? status,
})

Updates an existing automation rule.

May throw AccessDeniedException. May throw ForbiddenException. May throw IdempotencyTokenInUseException. May throw IdempotentParameterMismatchException. May throw InternalServerException. May throw InvalidParameterValueException. May throw OptInRequiredException. May throw ResourceNotFoundException. May throw ServiceUnavailableException. May throw ThrottlingException.

Parameter ruleArn : The ARN of the rule to update.

Parameter ruleRevision : The revision number of the rule to update.

Parameter clientToken : A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Must be 1-64 characters long and contain only alphanumeric characters, underscores, and hyphens.

Parameter description : The updated description of the automation rule. Can be up to 1024 characters long and contain alphanumeric characters, underscores, hyphens, spaces, and certain special characters.

Parameter name : The updated name of the automation rule. Must be 1-128 characters long and contain only alphanumeric characters, underscores, and hyphens.

Parameter organizationConfiguration : Updated configuration settings for organization-wide rules, including rule application order and target account IDs.

Parameter priority : The updated priority level of the automation rule, used to determine execution order when multiple rules apply to the same resource.

Parameter recommendedActionTypes : Updated list of recommended action types that this rule can execute, such as SnapshotAndDeleteUnattachedEbsVolume or UpgradeEbsVolumeType.

Parameter ruleType : The updated type of automation rule. Can be either OrganizationRule for organization-wide rules or AccountRule for account-specific rules.

Parameter schedule : The updated schedule configuration for when the automation rule should execute, including cron expression, timezone, and execution window.

Parameter status : The updated status of the automation rule. Can be Active or Inactive.

Implementation

Future<UpdateAutomationRuleResponse> updateAutomationRule({
  required String ruleArn,
  required int ruleRevision,
  String? clientToken,
  Criteria? criteria,
  String? description,
  String? name,
  OrganizationConfiguration? organizationConfiguration,
  String? priority,
  List<RecommendedActionType>? recommendedActionTypes,
  RuleType? ruleType,
  Schedule? schedule,
  RuleStatus? status,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'ComputeOptimizerAutomationService.UpdateAutomationRule'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ruleArn': ruleArn,
      'ruleRevision': ruleRevision,
      'clientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (criteria != null) 'criteria': criteria,
      if (description != null) 'description': description,
      if (name != null) 'name': name,
      if (organizationConfiguration != null)
        'organizationConfiguration': organizationConfiguration,
      if (priority != null) 'priority': priority,
      if (recommendedActionTypes != null)
        'recommendedActionTypes':
            recommendedActionTypes.map((e) => e.value).toList(),
      if (ruleType != null) 'ruleType': ruleType.value,
      if (schedule != null) 'schedule': schedule,
      if (status != null) 'status': status.value,
    },
  );

  return UpdateAutomationRuleResponse.fromJson(jsonResponse.body);
}