createAutomationRule method
Creates an automation rule based on input parameters.
May throw AccessDeniedException.
May throw InternalException.
May throw InvalidAccessException.
May throw InvalidInputException.
May throw LimitExceededException.
Parameter actions :
One or more actions to update finding fields if a finding matches the
conditions specified in Criteria.
Parameter criteria :
A set of ASFF finding field attributes and corresponding expected values
that Security Hub CSPM uses to filter findings. If a rule is enabled and a
finding matches the conditions specified in this parameter, Security Hub
CSPM applies the rule action to the finding.
Parameter description :
A description of the rule.
Parameter ruleName :
The name of the rule.
Parameter ruleOrder :
An integer ranging from 1 to 1000 that represents the order in which the
rule action is applied to findings. Security Hub CSPM applies rules with
lower values for this parameter first.
Parameter isTerminal :
Specifies whether a rule is the last to be applied with respect to a
finding that matches the rule criteria. This is useful when a finding
matches the criteria for multiple rules, and each rule has different
actions. If a rule is terminal, Security Hub CSPM applies the rule action
to a finding that matches the rule criteria and doesn't evaluate other
rules for the finding. By default, a rule isn't terminal.
Parameter ruleStatus :
Whether the rule is active after it is created. If this parameter is equal
to ENABLED, Security Hub CSPM starts applying the rule to
findings and finding updates after the rule is created. To change the
value of this parameter after creating a rule, use
BatchUpdateAutomationRules .
Parameter tags :
User-defined tags associated with an automation rule.
Implementation
Future<CreateAutomationRuleResponse> createAutomationRule({
required List<AutomationRulesAction> actions,
required AutomationRulesFindingFilters criteria,
required String description,
required String ruleName,
required int ruleOrder,
bool? isTerminal,
RuleStatus? ruleStatus,
Map<String, String>? tags,
}) async {
_s.validateNumRange(
'ruleOrder',
ruleOrder,
1,
1000,
isRequired: true,
);
final $payload = <String, dynamic>{
'Actions': actions,
'Criteria': criteria,
'Description': description,
'RuleName': ruleName,
'RuleOrder': ruleOrder,
if (isTerminal != null) 'IsTerminal': isTerminal,
if (ruleStatus != null) 'RuleStatus': ruleStatus.value,
if (tags != null) 'Tags': tags,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/automationrules/create',
exceptionFnMap: _exceptionFns,
);
return CreateAutomationRuleResponse.fromJson(response);
}