Skip to content

purchase_host_reservation async

purchase_host_reservation(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    client_token: Optional[String] = None,
    currency_code: Optional[CurrencyCodeValues] = None,
    host_id_set: Optional[RequestHostIdSet] = None,
    limit_price: Optional[String] = None,
    offering_id: Optional[OfferingId] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
) -> PurchaseHostReservationResult

Purchase a reservation with configurations that match those of your Dedicated Host. You must have active Dedicated Hosts in your account before you purchase a reservation. This action results in the specified reservation being purchased and charged to your account.

Parameters:

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

    Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see Ensuring Idempotency.

  • currency_code (Optional[CurrencyCodeValues], default: None ) –

    The currency in which the totalUpfrontPrice, LimitPrice, and totalHourlyPrice amounts are specified. At this time, the only supported currency is USD.

  • host_id_set (Optional[RequestHostIdSet], default: None ) –

    The IDs of the Dedicated Hosts with which the reservation will be associated.

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

    The specified limit is checked against the total upfront cost of the reservation (calculated as the offering's upfront cost multiplied by the host count). If the total upfront cost is greater than the specified price limit, the request fails. This is used to ensure that the purchase does not exceed the expected upfront cost of the purchase. At this time, the only supported currency is USD. For example, to indicate a limit price of USD 100, specify 100.00.

  • offering_id (Optional[OfferingId], default: None ) –

    The ID of the offering.

  • tag_specifications (Optional[TagSpecificationList], default: None ) –

    The tags to apply to the Dedicated Host Reservation during purchase.

Raises:

Source code in docs_src/capo_ec2/_services/async_ec2.py
async def purchase_host_reservation(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    client_token: Optional["capo_ec2.types.string.String"] = None,
    currency_code: Optional[
        "capo_ec2.types.currency_code_values.CurrencyCodeValues"
    ] = None,
    host_id_set: Optional[
        "capo_ec2.types.request_host_id_set.RequestHostIdSet"
    ] = None,
    limit_price: Optional["capo_ec2.types.string.String"] = None,
    offering_id: Optional["capo_ec2.types.offering_id.OfferingId"] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
) -> (
    "capo_ec2.types.purchase_host_reservation_result.PurchaseHostReservationResult"
):
    """<p>Purchase a reservation with configurations that match those of your Dedicated Host. You must have active Dedicated Hosts in your account before you purchase a reservation. This action results in the specified reservation being purchased and charged to your account.</p>

    Args:
        client_token: <p>Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Ensuring Idempotency</a>.</p>
        currency_code: <p>The currency in which the <code>totalUpfrontPrice</code>, <code>LimitPrice</code>, and <code>totalHourlyPrice</code> amounts are specified. At this time, the only supported currency is <code>USD</code>.</p>
        host_id_set: <p>The IDs of the Dedicated Hosts with which the reservation will be associated.</p>
        limit_price: <p>The specified limit is checked against the total upfront cost of the reservation (calculated as the offering's upfront cost multiplied by the host count). If the total upfront cost is greater than the specified price limit, the request fails. This is used to ensure that the purchase does not exceed the expected upfront cost of the purchase. At this time, the only supported currency is <code>USD</code>. For example, to indicate a limit price of USD 100, specify 100.00.</p>
        offering_id: <p>The ID of the offering.</p>
        tag_specifications: <p>The tags to apply to the Dedicated Host Reservation during purchase.</p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ec2.types.purchase_host_reservation_request.PurchaseHostReservationRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.purchase_host_reservation_result.PurchaseHostReservationResult"
    ]:
        import capo_ec2._operations.amazon_ec2.purchase_host_reservation

        (
            output,
            http_response,
        ) = await capo_ec2._operations.amazon_ec2.purchase_host_reservation.async_purchase_host_reservation(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PurchaseHostReservation")
    )
    input_: capo_ec2.types.purchase_host_reservation_request.PurchaseHostReservationRequest = {}
    if client_token is not None:
        input_["client_token"] = client_token
    if currency_code is not None:
        input_["currency_code"] = currency_code
    if host_id_set is not None:
        input_["host_id_set"] = host_id_set
    if limit_price is not None:
        input_["limit_price"] = limit_price
    if offering_id is not None:
        input_["offering_id"] = offering_id
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications

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