getRules method

Future<GetRulesResult> getRules({
  1. required String detectorId,
  2. int? maxResults,
  3. String? nextToken,
  4. String? ruleId,
  5. String? ruleVersion,
})

Get all rules for a detector (paginated) if ruleId and ruleVersion are not specified. Gets all rules for the detector and the ruleId if present (paginated). Gets a specific rule if both the ruleId and the ruleVersion are specified.

This is a paginated API. Providing null maxResults results in retrieving maximum of 100 records per page. If you provide maxResults the value must be between 50 and 100. To get the next page result, a provide a pagination token from GetRulesResult as part of your request. Null pagination token fetches the records from the beginning.

May throw ValidationException. May throw ResourceNotFoundException. May throw InternalServerException. May throw ThrottlingException. May throw AccessDeniedException.

Parameter detectorId : The detector ID.

Parameter maxResults : The maximum number of rules to return for the request.

Parameter nextToken : The next page token.

Parameter ruleId : The rule ID.

Parameter ruleVersion : The rule version.

Implementation

Future<GetRulesResult> getRules({
  required String detectorId,
  int? maxResults,
  String? nextToken,
  String? ruleId,
  String? ruleVersion,
}) async {
  ArgumentError.checkNotNull(detectorId, 'detectorId');
  _s.validateStringLength(
    'detectorId',
    detectorId,
    1,
    64,
    isRequired: true,
  );
  _s.validateNumRange(
    'maxResults',
    maxResults,
    50,
    100,
  );
  _s.validateStringLength(
    'ruleId',
    ruleId,
    1,
    64,
  );
  _s.validateStringLength(
    'ruleVersion',
    ruleVersion,
    1,
    5,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSHawksNestServiceFacade.GetRules'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'detectorId': detectorId,
      if (maxResults != null) 'maxResults': maxResults,
      if (nextToken != null) 'nextToken': nextToken,
      if (ruleId != null) 'ruleId': ruleId,
      if (ruleVersion != null) 'ruleVersion': ruleVersion,
    },
  );

  return GetRulesResult.fromJson(jsonResponse.body);
}