Skip to content

get_usage_statistics

get_usage_statistics(
    detector_id: DetectorId,
    *,
    config_overrides: Optional[GuardDutyClientConfig] = None,
    usage_statistic_type: Optional[UsageStatisticType] = None,
    usage_criteria: Optional[UsageCriteria] = None,
    unit: Optional[String] = None,
    max_results: Optional[MaxResults] = None,
    next_token: Optional[String] = None,
) -> GetUsageStatisticsResponse

Lists Amazon GuardDuty usage statistics over the last 30 days for the specified detector ID. For newly enabled detectors or data sources, the cost returned will include only the usage so far under 30 days. This may differ from the cost metrics in the console, which project usage over 30 days to provide a monthly cost estimate. For more information, see Understanding How Usage Costs are Calculated.

Parameters:

  • detector_id (DetectorId) –

    The ID of the detector that specifies the GuardDuty service whose usage 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.

  • usage_statistic_type (Optional[UsageStatisticType], default: None ) –

    The type of usage statistics to retrieve.

  • usage_criteria (Optional[UsageCriteria], default: None ) –

    Represents the criteria used for querying usage.

  • unit (Optional[String], default: None ) –

    The currency unit you would like to view your usage statistics in. Current valid values are USD.

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

    The maximum number of results to return in the response.

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

    A token to use for paginating results that are returned in the response. Set the value of this parameter to null for the first request to a list action. For subsequent calls, use the NextToken value returned from the previous request to continue listing results after the first page.

Raises:

Source code in docs_src/capo_guardduty/_services/guard_duty.py
def get_usage_statistics(
    self,
    detector_id: "capo_guardduty.types.detector_id.DetectorId",
    *,
    config_overrides: Optional[GuardDutyClientConfig] = None,
    usage_statistic_type: Optional[
        "capo_guardduty.types.usage_statistic_type.UsageStatisticType"
    ] = None,
    usage_criteria: Optional[
        "capo_guardduty.types.usage_criteria.UsageCriteria"
    ] = None,
    unit: Optional["capo_guardduty.types.string.String"] = None,
    max_results: Optional["capo_guardduty.types.max_results.MaxResults"] = None,
    next_token: Optional["capo_guardduty.types.string.String"] = None,
) -> (
    "capo_guardduty.types.get_usage_statistics_response.GetUsageStatisticsResponse"
):
    """<p>Lists Amazon GuardDuty usage statistics over the last 30 days for the specified detector ID. For newly enabled detectors or data sources, the cost returned will include only the usage so far under 30 days. This may differ from the cost metrics in the console, which project usage over 30 days to provide a monthly cost estimate. For more information, see <a href="https://docs.aws.amazon.com/guardduty/latest/ug/monitoring_costs.html#usage-calculations">Understanding How Usage Costs are Calculated</a>.</p>

    Args:
        detector_id: <p>The ID of the detector that specifies the GuardDuty service whose usage statistics you want to retrieve.</p> <p>To find the <code>detectorId</code> in the current Region, see the Settings page in the GuardDuty console, or run the <a href="https://docs.aws.amazon.com/guardduty/latest/APIReference/API_ListDetectors.html">ListDetectors</a> API.</p>
        usage_statistic_type: <p>The type of usage statistics to retrieve.</p>
        usage_criteria: <p>Represents the criteria used for querying usage.</p>
        unit: <p>The currency unit you would like to view your usage statistics in. Current valid values are USD.</p>
        max_results: <p>The maximum number of results to return in the response.</p>
        next_token: <p>A token to use for paginating results that are returned in the response. Set the value of this parameter to null for the first request to a list action. For subsequent calls, use the NextToken value returned from the previous request to continue listing results after the first page.</p>

    Raises:
        capo_guardduty.errors.bad_request_exception.BadRequestException: <p>A bad request exception object.</p>
        capo_guardduty.errors.internal_server_error_exception.InternalServerErrorException: <p>An internal server error exception object.</p>
        capo_guardduty.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_guardduty.types.get_usage_statistics_request.GetUsageStatisticsRequest]",
    ) -> OperationResponse[
        "capo_guardduty.types.get_usage_statistics_response.GetUsageStatisticsResponse"
    ]:
        import capo_guardduty._operations.guard_duty_api_service.get_usage_statistics

        output, http_response = (
            capo_guardduty._operations.guard_duty_api_service.get_usage_statistics.get_usage_statistics(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetUsageStatistics")
    )
    input_: capo_guardduty.types.get_usage_statistics_request.GetUsageStatisticsRequest = {
        "detector_id": detector_id
    }
    if usage_statistic_type is not None:
        input_["usage_statistic_type"] = usage_statistic_type
    if usage_criteria is not None:
        input_["usage_criteria"] = usage_criteria
    if unit is not None:
        input_["unit"] = unit
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output