Skip to content

get_finding_statistics_v2 async

get_finding_statistics_v2(
    *,
    config_overrides: Optional[AsyncSecurityHubClientConfig] = None,
    group_by_rules: Optional[GroupByRules] = None,
    scopes: Optional[FindingScopes] = None,
    sort_order: Optional[SortOrder] = None,
    max_statistic_results: Optional[MaxStatisticResults] = None,
) -> GetFindingStatisticsV2Response

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.

Parameters:

  • group_by_rules (Optional[GroupByRules], default: None ) –

    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.

  • scopes (Optional[FindingScopes], default: None ) –

    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.

  • sort_order (Optional[SortOrder], default: None ) –

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

  • max_statistic_results (Optional[MaxStatisticResults], default: None ) –

    The maximum number of results to be returned.

Raises:

  • AccessDeniedException –

    You don't have permission to perform the action specified in the request.

  • ConflictException –

    The request causes conflict with the current state of the service resource.

  • InternalServerException –

    The request has failed due to an internal failure of the service.

  • OrganizationalUnitNotFoundException –

    The request failed because one or more organizational units specified in the request don't exist within the caller's organization.

  • OrganizationNotFoundException –

    The request failed because one or more organizations specified in the request don't exist or don't belong to the caller's organization.

  • ThrottlingException –

    The limit on the number of requests per second was exceeded.

  • ValidationException –

    The request has failed validation because it's missing required fields or has invalid inputs.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_securityhub/_services/async_security_hub.py
async def get_finding_statistics_v2(
    self,
    *,
    config_overrides: Optional[AsyncSecurityHubClientConfig] = None,
    group_by_rules: Optional[
        "capo_securityhub.types.group_by_rules.GroupByRules"
    ] = None,
    scopes: Optional["capo_securityhub.types.finding_scopes.FindingScopes"] = None,
    sort_order: Optional["capo_securityhub.types.sort_order.SortOrder"] = None,
    max_statistic_results: Optional[
        "capo_securityhub.types.max_statistic_results.MaxStatisticResults"
    ] = None,
) -> "capo_securityhub.types.get_finding_statistics_v2_response.GetFindingStatisticsV2Response":
    """<p>Returns aggregated statistical data about findings.</p> <p>You can use the <code>Scopes</code> parameter to define the data boundary for the query. Currently, <code>Scopes</code> supports <code>AwsOrganizations</code>, which lets you aggregate findings from your entire organization or from specific organizational units. Only the delegated administrator account can use <code>Scopes</code>.</p> <p> <code>GetFindingStatisticsV2</code> uses <code>securityhub:GetAdhocInsightResults</code> in the <code>Action</code> element of an IAM policy statement. You must have permission to perform the <code>securityhub:GetAdhocInsightResults</code> action.</p>

    Args:
        group_by_rules: <p>Specifies how security findings should be aggregated and organized in the statistical analysis. It can accept up to 5 <code>groupBy</code> fields in a single call.</p>
        scopes: <p>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 <code>AccessDeniedException</code>.</p> <p>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.</p> <p>You can specify up to 10 entries in <code>Scopes.AwsOrganizations</code>. If multiple entries are specified, the entries are combined using OR logic.</p>
        sort_order: <p>Orders the aggregation count in descending or ascending order. Descending order is the default.</p>
        max_statistic_results: <p>The maximum number of results to be returned.</p>

    Raises:
        capo_securityhub.errors.access_denied_exception.AccessDeniedException: <p>You don't have permission to perform the action specified in the request.</p>
        capo_securityhub.errors.conflict_exception.ConflictException: <p>The request causes conflict with the current state of the service resource.</p>
        capo_securityhub.errors.internal_server_exception.InternalServerException: <p> The request has failed due to an internal failure of the service. </p>
        capo_securityhub.errors.organizational_unit_not_found_exception.OrganizationalUnitNotFoundException: <p>The request failed because one or more organizational units specified in the request don't exist within the caller's organization.</p>
        capo_securityhub.errors.organization_not_found_exception.OrganizationNotFoundException: <p>The request failed because one or more organizations specified in the request don't exist or don't belong to the caller's organization.</p>
        capo_securityhub.errors.throttling_exception.ThrottlingException: <p> The limit on the number of requests per second was exceeded. </p>
        capo_securityhub.errors.validation_exception.ValidationException: <p>The request has failed validation because it's missing required fields or has invalid inputs.</p>
        capo_securityhub.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_securityhub.types.get_finding_statistics_v2_request.GetFindingStatisticsV2Request]",
    ) -> AsyncOperationResponse[
        "capo_securityhub.types.get_finding_statistics_v2_response.GetFindingStatisticsV2Response"
    ]:
        import capo_securityhub._operations.security_hub_api_service.get_finding_statistics_v2

        (
            output,
            http_response,
        ) = await capo_securityhub._operations.security_hub_api_service.get_finding_statistics_v2.async_get_finding_statistics_v2(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetFindingStatisticsV2")
    )
    input_: capo_securityhub.types.get_finding_statistics_v2_request.GetFindingStatisticsV2Request = {}
    if group_by_rules is not None:
        input_["group_by_rules"] = group_by_rules
    if scopes is not None:
        input_["scopes"] = scopes
    if sort_order is not None:
        input_["sort_order"] = sort_order
    if max_statistic_results is not None:
        input_["max_statistic_results"] = max_statistic_results

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output