Skip to content

get_usage

get_usage(
    usage_plan_id: String,
    start_date: String,
    end_date: String,
    *,
    config_overrides: Optional[APIGatewayClientConfig] = None,
    key_id: Optional[String] = None,
    position: Optional[String] = None,
    limit: Optional[NullableInteger] = None,
) -> Usage

Gets the usage data of a usage plan in a specified time interval.

Parameters:

  • usage_plan_id (String) –

    The Id of the usage plan associated with the usage data.

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

    The Id of the API key associated with the resultant usage data.

  • start_date (String) –

    The starting date (e.g., 2016-01-01) of the usage data.

  • end_date (String) –

    The ending date (e.g., 2016-12-31) of the usage data.

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

    The current pagination position in the paged result set.

  • limit (Optional[NullableInteger], default: None ) –

    The maximum number of returned results per page. The default value is 25 and the maximum value is 500.

Raises:

  • BadRequestException –

    The submitted request is not valid, for example, the input is incomplete or incorrect. See the accompanying error message for details.

  • NotFoundException –

    The requested resource is not found. Make sure that the request URI is correct.

  • TooManyRequestsException –

    The request has reached its throttling limit. Retry after the specified time period.

  • UnauthorizedException –

    The request is denied because the caller has insufficient permissions.

  • UnknownServiceError –

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

Source code in docs_src/capo_api_gateway/_services/api_gateway.py
def get_usage(
    self,
    usage_plan_id: "capo_api_gateway.types.string.String",
    start_date: "capo_api_gateway.types.string.String",
    end_date: "capo_api_gateway.types.string.String",
    *,
    config_overrides: Optional[APIGatewayClientConfig] = None,
    key_id: Optional["capo_api_gateway.types.string.String"] = None,
    position: Optional["capo_api_gateway.types.string.String"] = None,
    limit: Optional[
        "capo_api_gateway.types.nullable_integer.NullableInteger"
    ] = None,
) -> "capo_api_gateway.types.usage.Usage":
    """<p>Gets the usage data of a usage plan in a specified time interval.</p>

    Args:
        usage_plan_id: <p>The Id of the usage plan associated with the usage data.</p>
        key_id: <p>The Id of the API key associated with the resultant usage data.</p>
        start_date: <p>The starting date (e.g., 2016-01-01) of the usage data.</p>
        end_date: <p>The ending date (e.g., 2016-12-31) of the usage data.</p>
        position: <p>The current pagination position in the paged result set.</p>
        limit: <p>The maximum number of returned results per page. The default value is 25 and the maximum value is 500.</p>

    Raises:
        capo_api_gateway.errors.bad_request_exception.BadRequestException: <p>The submitted request is not valid, for example, the input is incomplete or incorrect. See the accompanying error message for details.</p>
        capo_api_gateway.errors.not_found_exception.NotFoundException: <p>The requested resource is not found. Make sure that the request URI is correct.</p>
        capo_api_gateway.errors.too_many_requests_exception.TooManyRequestsException: <p>The request has reached its throttling limit. Retry after the specified time period.</p>
        capo_api_gateway.errors.unauthorized_exception.UnauthorizedException: <p>The request is denied because the caller has insufficient permissions.</p>
        capo_api_gateway.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_api_gateway.types.get_usage_request.GetUsageRequest]",
    ) -> OperationResponse["capo_api_gateway.types.usage.Usage"]:
        import capo_api_gateway._operations.backplane_control_service.get_usage

        output, http_response = (
            capo_api_gateway._operations.backplane_control_service.get_usage.get_usage(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetUsage")
    )
    input_: capo_api_gateway.types.get_usage_request.GetUsageRequest = {
        "usage_plan_id": usage_plan_id,
        "start_date": start_date,
        "end_date": end_date,
    }
    if key_id is not None:
        input_["key_id"] = key_id
    if position is not None:
        input_["position"] = position
    if limit is not None:
        input_["limit"] = limit

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