Skip to content

get_resources_statistics_v2 async

get_resources_statistics_v2(
    *,
    config_overrides: Optional[AsyncSecurityHubClientConfig] = None,
    group_by_rules: Optional[ResourceGroupByRules] = None,
    scopes: Optional[ResourceScopes] = None,
    sort_order: Optional[SortOrder] = None,
    max_statistic_results: Optional[MaxStatisticResults] = None,
) -> GetResourcesStatisticsV2Response

Retrieves statistical information about Amazon Web Services resources and their associated security findings.

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

If you set GroupByField to ResourceSubCategory, ResourceInfo.AIDetails.HostResourceType, or ResourceInfo.AIDetails.CanonicalId, you must include a ResourceCategory string filter with comparison set to EQUALS and value AI/ML in the corresponding ResourceGroupByRule.

Parameters:

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

    How resource statistics should be aggregated and organized in the response.

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

    Limits the results to resources 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 resources.

    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 ) –

    Sorts aggregated statistics.

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

    The maximum number of results to be returned.

Raises:

Source code in docs_src/capo_securityhub/_services/async_security_hub.py
async def get_resources_statistics_v2(
    self,
    *,
    config_overrides: Optional[AsyncSecurityHubClientConfig] = None,
    group_by_rules: Optional[
        "capo_securityhub.types.resource_group_by_rules.ResourceGroupByRules"
    ] = None,
    scopes: Optional[
        "capo_securityhub.types.resource_scopes.ResourceScopes"
    ] = 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_resources_statistics_v2_response.GetResourcesStatisticsV2Response":
    """<p>Retrieves statistical information about Amazon Web Services resources and their associated security 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 resources from your entire organization or from specific organizational units. Only the delegated administrator account can use <code>Scopes</code>.</p> <p>If you set <code>GroupByField</code> to <code>ResourceSubCategory</code>, <code>ResourceInfo.AIDetails.HostResourceType</code>, or <code>ResourceInfo.AIDetails.CanonicalId</code>, you must include a <code>ResourceCategory</code> string filter with comparison set to <code>EQUALS</code> and value <code>AI/ML</code> in the corresponding <code>ResourceGroupByRule</code>.</p>

    Args:
        group_by_rules: <p>How resource statistics should be aggregated and organized in the response.</p>
        scopes: <p>Limits the results to resources 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 resources.</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>Sorts aggregated statistics.</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.resource_not_found_exception.ResourceNotFoundException: <p>The request was rejected because we can't find the specified resource.</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_resources_statistics_v2_request.GetResourcesStatisticsV2Request]",
    ) -> AsyncOperationResponse[
        "capo_securityhub.types.get_resources_statistics_v2_response.GetResourcesStatisticsV2Response"
    ]:
        import capo_securityhub._operations.security_hub_api_service.get_resources_statistics_v2

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetResourcesStatisticsV2")
    )
    input_: capo_securityhub.types.get_resources_statistics_v2_request.GetResourcesStatisticsV2Request = {}
    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