createRule method
Creates a rule for use with the specified detector.
May throw AccessDeniedException.
May throw InternalServerException.
May throw ThrottlingException.
May throw ValidationException.
Parameter detectorId :
The detector ID for the rule's parent detector.
Parameter expression :
The rule expression.
Parameter language :
The language of the rule.
Parameter outcomes :
The outcome or outcomes returned when the rule expression matches.
Parameter ruleId :
The rule ID.
Parameter description :
The rule description.
Parameter tags :
A collection of key and value pairs.
Implementation
Future<CreateRuleResult> createRule({
required String detectorId,
required String expression,
required Language language,
required List<String> outcomes,
required String ruleId,
String? description,
List<Tag>? tags,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AWSHawksNestServiceFacade.CreateRule'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'detectorId': detectorId,
'expression': expression,
'language': language.value,
'outcomes': outcomes,
'ruleId': ruleId,
if (description != null) 'description': description,
if (tags != null) 'tags': tags,
},
);
return CreateRuleResult.fromJson(jsonResponse.body);
}