Skip to content

get_credits async

get_credits(
    account_id: str,
    start_date: datetime,
    *,
    config_overrides: Optional[AsyncBillingClientConfig] = None,
    end_date: Optional[datetime] = None,
    payer_account_flag: Optional[bool] = None,
) -> GetCreditsResponse

Returns the list of Amazon Web Services account credits for the specified account. Each credit includes its identifier, type, monetary amounts, applicable products, expiration, sharing configuration, and current enabled status.

When the caller is the management account of a consolidated billing family and payerAccountFlag is true, the response aggregates credits across the entire family. Otherwise, the response includes only credits owned by the account specified in accountId.

Parameters:

  • account_id (str) –

    The Amazon Web Services account ID. Must be a 12-digit numeric string.

  • start_date (datetime) –

    The start date for the credit period as Unix epoch seconds. Must be a past date that is not more than one year before the current date.

  • end_date (Optional[datetime], default: None ) –

    The end date for the credit period as Unix epoch seconds. Must not be a future date and must be on or after startDate. Defaults to the current date when omitted.

  • payer_account_flag (Optional[bool], default: None ) –

    When true and the caller is the management account, the response aggregates credits across the entire consolidated billing family. When false or omitted, returns only credits for the specified accountId.

Raises:

Source code in docs_src/capo_billing/_services/async_billing.py
async def get_credits(
    self,
    account_id: str,
    start_date: datetime.datetime,
    *,
    config_overrides: Optional[AsyncBillingClientConfig] = None,
    end_date: Optional[datetime.datetime] = None,
    payer_account_flag: Optional[bool] = None,
) -> "capo_billing.types.get_credits_response.GetCreditsResponse":
    """<p>Returns the list of Amazon Web Services account credits for the specified account. Each credit includes its identifier, type, monetary amounts, applicable products, expiration, sharing configuration, and current enabled status.</p> <p>When the caller is the management account of a consolidated billing family and <code>payerAccountFlag</code> is <code>true</code>, the response aggregates credits across the entire family. Otherwise, the response includes only credits owned by the account specified in <code>accountId</code>.</p>

    Args:
        account_id: <p>The Amazon Web Services account ID. Must be a 12-digit numeric string.</p>
        start_date: <p>The start date for the credit period as Unix epoch seconds. Must be a past date that is not more than one year before the current date.</p>
        end_date: <p>The end date for the credit period as Unix epoch seconds. Must not be a future date and must be on or after <code>startDate</code>. Defaults to the current date when omitted.</p>
        payer_account_flag: <p>When <code>true</code> and the caller is the management account, the response aggregates credits across the entire consolidated billing family. When <code>false</code> or omitted, returns only credits for the specified <code>accountId</code>.</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_credits_request.GetCreditsRequest]",
    ) -> AsyncOperationResponse[
        "capo_billing.types.get_credits_response.GetCreditsResponse"
    ]:
        import capo_billing._operations.aws_billing.get_credits

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetCredits")
    )
    input_: capo_billing.types.get_credits_request.GetCreditsRequest = {
        "account_id": account_id,
        "start_date": start_date,
    }
    if end_date is not None:
        input_["end_date"] = end_date
    if payer_account_flag is not None:
        input_["payer_account_flag"] = payer_account_flag

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