getFindingStatisticsV2 method

Future<GetFindingStatisticsV2Response> getFindingStatisticsV2({
  1. required List<GroupByRule> groupByRules,
  2. int? maxStatisticResults,
  3. FindingScopes? scopes,
  4. SortOrder? sortOrder,
})

Returns aggregated statistical data about findings.

You can use the Scopes parameter to define the data boundary for the query. Currently, Scopes supports AwsOrganizations, which lets you aggregate findings from your entire organization or from specific organizational units. Only the delegated administrator account can use Scopes.

GetFindingStatisticsV2 uses securityhub:GetAdhocInsightResults in the Action element of an IAM policy statement. You must have permission to perform the securityhub:GetAdhocInsightResults action.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw OrganizationalUnitNotFoundException. May throw OrganizationNotFoundException. May throw ThrottlingException. May throw ValidationException.

Parameter groupByRules : Specifies how security findings should be aggregated and organized in the statistical analysis. It can accept up to 5 groupBy fields in a single call.

Parameter maxStatisticResults : The maximum number of results to be returned.

Parameter scopes : Limits the results to findings from specific organizational units or from the delegated administrator's organization. Only the delegated administrator account can use this parameter. Other accounts receive an AccessDeniedException.

This parameter is optional. If you omit it, the delegated administrator sees statistics from all accounts across the entire organization. Other accounts see only statistics for their own findings.

You can specify up to 10 entries in Scopes.AwsOrganizations. If multiple entries are specified, the entries are combined using OR logic.

Parameter sortOrder : Orders the aggregation count in descending or ascending order. Descending order is the default.

Implementation

Future<GetFindingStatisticsV2Response> getFindingStatisticsV2({
  required List<GroupByRule> groupByRules,
  int? maxStatisticResults,
  FindingScopes? scopes,
  SortOrder? sortOrder,
}) async {
  _s.validateNumRange(
    'maxStatisticResults',
    maxStatisticResults,
    1,
    400,
  );
  final $payload = <String, dynamic>{
    'GroupByRules': groupByRules,
    if (maxStatisticResults != null)
      'MaxStatisticResults': maxStatisticResults,
    if (scopes != null) 'Scopes': scopes,
    if (sortOrder != null) 'SortOrder': sortOrder.value,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/findingsv2/statistics',
    exceptionFnMap: _exceptionFns,
  );
  return GetFindingStatisticsV2Response.fromJson(response);
}