createAutomationRuleV2 method

Future<CreateAutomationRuleV2Response> createAutomationRuleV2({
  1. required List<AutomationRulesActionV2> actions,
  2. required Criteria criteria,
  3. required String description,
  4. required String ruleName,
  5. required double ruleOrder,
  6. String? clientToken,
  7. RuleStatusV2? ruleStatus,
  8. Map<String, String>? tags,
})

Creates a V2 automation rule.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter actions : A list of actions to be performed when the rule criteria is met.

Parameter criteria : The filtering type and configuration of the automation rule.

Parameter description : A description of the V2 automation rule.

Parameter ruleName : The name of the V2 automation rule.

Parameter ruleOrder : The value for the rule priority.

Parameter clientToken : A unique identifier used to ensure idempotency.

Parameter ruleStatus : The status of the V2 automation rule.

Parameter tags : A list of key-value pairs associated with the V2 automation rule.

Implementation

Future<CreateAutomationRuleV2Response> createAutomationRuleV2({
  required List<AutomationRulesActionV2> actions,
  required Criteria criteria,
  required String description,
  required String ruleName,
  required double ruleOrder,
  String? clientToken,
  RuleStatusV2? ruleStatus,
  Map<String, String>? tags,
}) async {
  _s.validateNumRange(
    'ruleOrder',
    ruleOrder,
    1.0,
    1000.0,
    isRequired: true,
  );
  final $payload = <String, dynamic>{
    'Actions': actions,
    'Criteria': criteria,
    'Description': description,
    'RuleName': ruleName,
    'RuleOrder': ruleOrder,
    'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (ruleStatus != null) 'RuleStatus': ruleStatus.value,
    if (tags != null) 'Tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/automationrulesv2/create',
    exceptionFnMap: _exceptionFns,
  );
  return CreateAutomationRuleV2Response.fromJson(response);
}