getFindingsStatistics method

Future<GetFindingsStatisticsResponse> getFindingsStatistics({
  1. required String detectorId,
  2. FindingCriteria? findingCriteria,
  3. List<FindingStatisticType>? findingStatisticTypes,
  4. GroupByType? groupBy,
  5. int? maxResults,
  6. OrderBy? orderBy,
})

Lists GuardDuty findings statistics for the specified detector ID.

You must provide either findingStatisticTypes or groupBy parameter, and not both. You can use the maxResults and orderBy parameters only when using groupBy.

There might be regional differences because some flags might not be available in all the Regions where GuardDuty is currently supported. For more information, see Regions and endpoints.

May throw BadRequestException. May throw InternalServerErrorException.

Parameter detectorId : The ID of the detector whose findings statistics you want to retrieve.

To find the detectorId in the current Region, see the Settings page in the GuardDuty console, or run the ListDetectors API.

Parameter findingCriteria : Represents the criteria that is used for querying findings.

Parameter findingStatisticTypes : The types of finding statistics to retrieve.

Parameter groupBy : Displays the findings statistics grouped by one of the listed valid values.

Parameter maxResults : The maximum number of results to be returned in the response. The default value is 25.

You can use this parameter only with the groupBy parameter.

Parameter orderBy : Displays the sorted findings in the requested order. The default value of orderBy is DESC.

You can use this parameter only with the groupBy parameter.

Implementation

Future<GetFindingsStatisticsResponse> getFindingsStatistics({
  required String detectorId,
  FindingCriteria? findingCriteria,
  List<FindingStatisticType>? findingStatisticTypes,
  GroupByType? groupBy,
  int? maxResults,
  OrderBy? orderBy,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    100,
  );
  final $payload = <String, dynamic>{
    if (findingCriteria != null) 'findingCriteria': findingCriteria,
    if (findingStatisticTypes != null)
      'findingStatisticTypes':
          findingStatisticTypes.map((e) => e.value).toList(),
    if (groupBy != null) 'groupBy': groupBy.value,
    if (maxResults != null) 'maxResults': maxResults,
    if (orderBy != null) 'orderBy': orderBy.value,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/detector/${Uri.encodeComponent(detectorId)}/findings/statistics',
    exceptionFnMap: _exceptionFns,
  );
  return GetFindingsStatisticsResponse.fromJson(response);
}