Skip to content

transfer_credit async

transfer_credit(
    credit_id: CreditId,
    destination_account_id: AccountId,
    *,
    config_overrides: Optional[AsyncBillingClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    dry_run: Optional[bool] = None,
) -> TransferCreditResponse

Moves a credit to another account in the same consolidated billing family. The credit keeps its ID, balance, end date, and applicable products. Only the account that owns the credit changes.

The transfer removes the credit's sharing settings. The new owner or the payer can set them again. Any amount reserved for a bill that isn't finalized moves with the credit and still applies to that bill.

You must be the payer of both accounts. You can't transfer a credit that has ended, has no available balance, or is the original credit of a split. A transfer creates no credit, so it doesn't count toward the split limit, and the payer can transfer the credit back. This operation is idempotent and supports a dry run.

Parameters:

  • credit_id (CreditId) –

    The ID of the credit to transfer.

  • destination_account_id (AccountId) –

    The Amazon Web Services account ID that becomes the owner of the credit. The account must be in your consolidated billing family and must not be the current owner.

  • client_token (Optional[ClientToken], default: None ) –

    A unique, case-sensitive identifier that you provide to ensure that the operation completes no more than one time. If you retry a successful request with the same client token and parameters, the retry completes without performing any further actions. If you reuse a client token with different parameters, the request fails with a ValidationException.

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

    Specifies whether to validate the request and return the result without changing the credit.

Raises:

  • AccessDeniedException –

    You don't have sufficient access to perform this action.

  • ConflictException –

    The requested operation would cause a conflict with the current state of a service resource associated with the request. Resolve the conflict before retrying this request.

  • InternalServerException –

    The request processing failed because of an unknown error, exception, or failure.

  • ResourceNotFoundException –

    The specified ARN in the request doesn't exist.

  • ServiceQuotaExceededException –

    You've reached the limit of resources you can create, or exceeded the size of an individual resource.

  • ThrottlingException –

    The request was denied due to request throttling.

  • ValidationException –

    The input fails to satisfy the constraints specified by an Amazon Web Services service.

  • UnknownServiceError –

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

Source code in docs_src/capo_billing/_services/async_billing.py
async def transfer_credit(
    self,
    credit_id: "capo_billing.types.credit_id.CreditId",
    destination_account_id: "capo_billing.types.account_id.AccountId",
    *,
    config_overrides: Optional[AsyncBillingClientConfig] = None,
    client_token: Optional["capo_billing.types.client_token.ClientToken"] = None,
    dry_run: Optional[bool] = None,
) -> "capo_billing.types.transfer_credit_response.TransferCreditResponse":
    """<p>Moves a credit to another account in the same consolidated billing family. The credit keeps its ID, balance, end date, and applicable products. Only the account that owns the credit changes.</p> <p>The transfer removes the credit's sharing settings. The new owner or the payer can set them again. Any amount reserved for a bill that isn't finalized moves with the credit and still applies to that bill.</p> <p>You must be the payer of both accounts. You can't transfer a credit that has ended, has no available balance, or is the original credit of a split. A transfer creates no credit, so it doesn't count toward the split limit, and the payer can transfer the credit back. This operation is idempotent and supports a dry run.</p>

    Args:
        credit_id: <p>The ID of the credit to transfer.</p>
        destination_account_id: <p>The Amazon Web Services account ID that becomes the owner of the credit. The account must be in your consolidated billing family and must not be the current owner.</p>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure that the operation completes no more than one time. If you retry a successful request with the same client token and parameters, the retry completes without performing any further actions. If you reuse a client token with different parameters, the request fails with a <code>ValidationException</code>.</p>
        dry_run: <p>Specifies whether to validate the request and return the result without changing the credit.</p>

    Raises:
        capo_billing.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access to perform this action.</p>
        capo_billing.errors.conflict_exception.ConflictException: <p> The requested operation would cause a conflict with the current state of a service resource associated with the request. Resolve the conflict before retrying this request. </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.resource_not_found_exception.ResourceNotFoundException: <p> The specified ARN in the request doesn't exist. </p>
        capo_billing.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p> You've reached the limit of resources you can create, or exceeded the size of an individual resource. </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.transfer_credit_request.TransferCreditRequest]",
    ) -> AsyncOperationResponse[
        "capo_billing.types.transfer_credit_response.TransferCreditResponse"
    ]:
        import capo_billing._operations.aws_billing.transfer_credit

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("TransferCredit")
    )
    input_: capo_billing.types.transfer_credit_request.TransferCreditRequest = {
        "credit_id": credit_id,
        "destination_account_id": destination_account_id,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if dry_run is not None:
        input_["dry_run"] = dry_run

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