Skip to content

get_usage_statistics async

get_usage_statistics(
    *,
    config_overrides: Optional[AsyncMacie2ClientConfig] = None,
    filter_by: Optional[__listOfUsageStatisticsFilter] = None,
    max_results: Optional[__integer] = None,
    next_token: Optional[__string] = None,
    sort_by: Optional[UsageStatisticsSortBy] = None,
    time_range: Optional[TimeRange] = None,
) -> GetUsageStatisticsResponse

Retrieves (queries) quotas and aggregated usage data for one or more accounts.

Parameters:

  • filter_by (Optional[__listOfUsageStatisticsFilter], default: None ) –

    An array of objects, one for each condition to use to filter the query results. If you specify more than one condition, Amazon Macie uses an AND operator to join the conditions.

  • max_results (Optional[__integer], default: None ) –

    The maximum number of items to include in each page of the response.

  • next_token (Optional[__string], default: None ) –

    The nextToken string that specifies which page of results to return in a paginated response.

  • sort_by (Optional[UsageStatisticsSortBy], default: None ) –

    The criteria to use to sort the query results.

  • time_range (Optional[TimeRange], default: None ) –

    The inclusive time period to query usage data for. Valid values are: MONTH_TO_DATE, for the current calendar month to date; and, PAST_30_DAYS, for the preceding 30 days. If you don't specify a value, Amazon Macie provides usage data for the preceding 30 days.

Raises:

  • AccessDeniedException –

    Provides information about an error that occurred due to insufficient access to a specified resource.

  • ConflictException –

    Provides information about an error that occurred due to a versioning conflict for a specified resource.

  • InternalServerException –

    Provides information about an error that occurred due to an unknown internal server error, exception, or failure.

  • ResourceNotFoundException –

    Provides information about an error that occurred because a specified resource wasn't found.

  • ServiceQuotaExceededException –

    Provides information about an error that occurred due to one or more service quotas for an account.

  • ThrottlingException –

    Provides information about an error that occurred because too many requests were sent during a certain amount of time.

  • ValidationException –

    Provides information about an error that occurred due to a syntax error in a request.

  • UnknownServiceError –

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

Source code in docs_src/capo_macie2/_services/async_macie2.py
async def get_usage_statistics(
    self,
    *,
    config_overrides: Optional[AsyncMacie2ClientConfig] = None,
    filter_by: Optional[
        "capo_macie2.types.__list_of_usage_statistics_filter.__listOfUsageStatisticsFilter"
    ] = None,
    max_results: Optional["capo_macie2.types.__integer.__integer"] = None,
    next_token: Optional["capo_macie2.types.__string.__string"] = None,
    sort_by: Optional[
        "capo_macie2.types.usage_statistics_sort_by.UsageStatisticsSortBy"
    ] = None,
    time_range: Optional["capo_macie2.types.time_range.TimeRange"] = None,
) -> "capo_macie2.types.get_usage_statistics_response.GetUsageStatisticsResponse":
    """<p>Retrieves (queries) quotas and aggregated usage data for one or more accounts.</p>

    Args:
        filter_by: <p>An array of objects, one for each condition to use to filter the query results. If you specify more than one condition, Amazon Macie uses an AND operator to join the conditions.</p>
        max_results: <p>The maximum number of items to include in each page of the response.</p>
        next_token: <p>The nextToken string that specifies which page of results to return in a paginated response.</p>
        sort_by: <p>The criteria to use to sort the query results.</p>
        time_range: <p>The inclusive time period to query usage data for. Valid values are: MONTH_TO_DATE, for the current calendar month to date; and, PAST_30_DAYS, for the preceding 30 days. If you don't specify a value, Amazon Macie provides usage data for the preceding 30 days.</p>

    Raises:
        capo_macie2.errors.access_denied_exception.AccessDeniedException: <p>Provides information about an error that occurred due to insufficient access to a specified resource.</p>
        capo_macie2.errors.conflict_exception.ConflictException: <p>Provides information about an error that occurred due to a versioning conflict for a specified resource.</p>
        capo_macie2.errors.internal_server_exception.InternalServerException: <p>Provides information about an error that occurred due to an unknown internal server error, exception, or failure.</p>
        capo_macie2.errors.resource_not_found_exception.ResourceNotFoundException: <p>Provides information about an error that occurred because a specified resource wasn't found.</p>
        capo_macie2.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>Provides information about an error that occurred due to one or more service quotas for an account.</p>
        capo_macie2.errors.throttling_exception.ThrottlingException: <p>Provides information about an error that occurred because too many requests were sent during a certain amount of time.</p>
        capo_macie2.errors.validation_exception.ValidationException: <p>Provides information about an error that occurred due to a syntax error in a request.</p>
        capo_macie2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_macie2.types.get_usage_statistics_request.GetUsageStatisticsRequest]",
    ) -> AsyncOperationResponse[
        "capo_macie2.types.get_usage_statistics_response.GetUsageStatisticsResponse"
    ]:
        import capo_macie2._operations.macie2.get_usage_statistics

        (
            output,
            http_response,
        ) = await capo_macie2._operations.macie2.get_usage_statistics.async_get_usage_statistics(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetUsageStatistics")
    )
    input_: capo_macie2.types.get_usage_statistics_request.GetUsageStatisticsRequest = {}
    if filter_by is not None:
        input_["filter_by"] = filter_by
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token
    if sort_by is not None:
        input_["sort_by"] = sort_by
    if time_range is not None:
        input_["time_range"] = time_range

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