Skip to content

get_credit_allocation_history async

get_credit_allocation_history(
    account_id: AccountId,
    start_date: datetime,
    end_date: datetime,
    *,
    config_overrides: Optional[AsyncBillingClientConfig] = None,
    credit_id: Optional[int] = None,
    next_token: Optional[PageToken] = None,
    max_results: Optional[int] = None,
) -> GetCreditAllocationHistoryResponse

Returns the per-billing-month allocation history for credits applied to an Amazon Web Services account's bills. Traverses the consolidated billing family to capture cross-account credit applications. Supports pagination and optional filtering to a single credit.

Parameters:

  • account_id (AccountId) –

    The Amazon Web Services account ID whose allocation history to retrieve. Must be a 12-digit numeric string.

  • credit_id (Optional[int], default: None ) –

    Filters the result to a single credit. When omitted, returns allocation entries for all credits.

  • start_date (datetime) –

    The inclusive start date of the range, in Unix epoch seconds. This value must be earlier than endDate. You get credit allocations for bills whose billing period starts on or after startDate and before endDate. If startDate is in the middle of a billing period, that period isn't included. The range can't exceed 24 calendar months.

  • end_date (datetime) –

    The exclusive end date of the range, in Unix epoch seconds. To get one billing month, set startDate to the first day of that month. Then set endDate to the first day of the next month. Use 00:00 UTC for both.

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

    Pagination token from a previous response. Pass the value returned in nextToken to retrieve the next page of results.

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

    The maximum number of records to return per page. Range: 1 to 1000. Default: 100.

Raises:

Source code in docs_src/capo_billing/_services/async_billing.py
async def get_credit_allocation_history(
    self,
    account_id: "capo_billing.types.account_id.AccountId",
    start_date: datetime.datetime,
    end_date: datetime.datetime,
    *,
    config_overrides: Optional[AsyncBillingClientConfig] = None,
    credit_id: Optional[int] = None,
    next_token: Optional["capo_billing.types.page_token.PageToken"] = None,
    max_results: Optional[int] = None,
) -> "capo_billing.types.get_credit_allocation_history_response.GetCreditAllocationHistoryResponse":
    """<p>Returns the per-billing-month allocation history for credits applied to an Amazon Web Services account's bills. Traverses the consolidated billing family to capture cross-account credit applications. Supports pagination and optional filtering to a single credit.</p>

    Args:
        account_id: <p>The Amazon Web Services account ID whose allocation history to retrieve. Must be a 12-digit numeric string.</p>
        credit_id: <p>Filters the result to a single credit. When omitted, returns allocation entries for all credits.</p>
        start_date: <p>The inclusive start date of the range, in Unix epoch seconds. This value must be earlier than <code>endDate</code>. You get credit allocations for bills whose billing period starts on or after <code>startDate</code> and before <code>endDate</code>. If <code>startDate</code> is in the middle of a billing period, that period isn't included. The range can't exceed 24 calendar months.</p>
        end_date: <p>The exclusive end date of the range, in Unix epoch seconds. To get one billing month, set <code>startDate</code> to the first day of that month. Then set <code>endDate</code> to the first day of the next month. Use 00:00 UTC for both.</p>
        next_token: <p>Pagination token from a previous response. Pass the value returned in <code>nextToken</code> to retrieve the next page of results.</p>
        max_results: <p>The maximum number of records to return per page. Range: 1 to 1000. Default: 100.</p>

    Raises:
        capo_billing.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access to perform this action.</p>
        capo_billing.errors.internal_server_exception.InternalServerException: <p>The request processing failed because of an unknown error, exception, or failure. </p>
        capo_billing.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling. </p>
        capo_billing.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by an Amazon Web Services service. </p>
        capo_billing.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_billing.types.get_credit_allocation_history_request.GetCreditAllocationHistoryRequest]",
    ) -> AsyncOperationResponse[
        "capo_billing.types.get_credit_allocation_history_response.GetCreditAllocationHistoryResponse"
    ]:
        import capo_billing._operations.aws_billing.get_credit_allocation_history

        (
            output,
            http_response,
        ) = await capo_billing._operations.aws_billing.get_credit_allocation_history.async_get_credit_allocation_history(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetCreditAllocationHistory")
    )
    input_: capo_billing.types.get_credit_allocation_history_request.GetCreditAllocationHistoryRequest = {
        "account_id": account_id,
        "start_date": start_date,
        "end_date": end_date,
    }
    if credit_id is not None:
        input_["credit_id"] = credit_id
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results

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