Skip to content

purchase_scheduled_instances async

purchase_scheduled_instances(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    client_token: Optional[String] = None,
    dry_run: Optional[Boolean] = None,
    purchase_requests: Optional[PurchaseRequestSet] = None,
) -> PurchaseScheduledInstancesResult

You can no longer purchase Scheduled Instances.

Purchases the Scheduled Instances with the specified schedule.

Scheduled Instances enable you to purchase Amazon EC2 compute capacity by the hour for a one-year term. Before you can purchase a Scheduled Instance, you must call DescribeScheduledInstanceAvailability to check for available schedules and obtain a purchase token. After you purchase a Scheduled Instance, you must call RunScheduledInstances during each scheduled time period.

After you purchase a Scheduled Instance, you can't cancel, modify, or resell your purchase.

Parameters:

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

    Unique, case-sensitive identifier that ensures the idempotency of the request. For more information, see Ensuring Idempotency.

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

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • purchase_requests (Optional[PurchaseRequestSet], default: None ) –

    The purchase requests.

Raises:

Source code in docs_src/capo_ec2/_services/async_ec2.py
async def purchase_scheduled_instances(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    client_token: Optional["capo_ec2.types.string.String"] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    purchase_requests: Optional[
        "capo_ec2.types.purchase_request_set.PurchaseRequestSet"
    ] = None,
) -> "capo_ec2.types.purchase_scheduled_instances_result.PurchaseScheduledInstancesResult":
    """<note> <p>You can no longer purchase Scheduled Instances.</p> </note> <p>Purchases the Scheduled Instances with the specified schedule.</p> <p>Scheduled Instances enable you to purchase Amazon EC2 compute capacity by the hour for a one-year term. Before you can purchase a Scheduled Instance, you must call <a>DescribeScheduledInstanceAvailability</a> to check for available schedules and obtain a purchase token. After you purchase a Scheduled Instance, you must call <a>RunScheduledInstances</a> during each scheduled time period.</p> <p>After you purchase a Scheduled Instance, you can't cancel, modify, or resell your purchase.</p>

    Args:
        client_token: <p>Unique, case-sensitive identifier that ensures 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>
        dry_run: <p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
        purchase_requests: <p>The purchase requests.</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_scheduled_instances_request.PurchaseScheduledInstancesRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.purchase_scheduled_instances_result.PurchaseScheduledInstancesResult"
    ]:
        import capo_ec2._operations.amazon_ec2.purchase_scheduled_instances

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PurchaseScheduledInstances")
    )
    input_: capo_ec2.types.purchase_scheduled_instances_request.PurchaseScheduledInstancesRequest = {}
    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
    if purchase_requests is not None:
        input_["purchase_requests"] = purchase_requests

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