Skip to content

purchase_capacity_block

purchase_capacity_block(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    dry_run: Optional[Boolean] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
    capacity_block_offering_id: Optional[OfferingId] = None,
    instance_platform: Optional[CapacityReservationInstancePlatform] = None,
) -> PurchaseCapacityBlockResult

Purchase the Capacity Block for use with your account. With Capacity Blocks you ensure GPU capacity is available for machine learning (ML) workloads. You must specify the ID of the Capacity Block offering you are purchasing.

Parameters:

  • 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.

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

    The tags to apply to the Capacity Block during launch.

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

    The ID of the Capacity Block offering.

  • instance_platform (Optional[CapacityReservationInstancePlatform], default: None ) –

    The type of operating system for which to reserve capacity.

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def purchase_capacity_block(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
    capacity_block_offering_id: Optional[
        "capo_ec2.types.offering_id.OfferingId"
    ] = None,
    instance_platform: Optional[
        "capo_ec2.types.capacity_reservation_instance_platform.CapacityReservationInstancePlatform"
    ] = None,
) -> "capo_ec2.types.purchase_capacity_block_result.PurchaseCapacityBlockResult":
    """<p>Purchase the Capacity Block for use with your account. With Capacity Blocks you ensure GPU capacity is available for machine learning (ML) workloads. You must specify the ID of the Capacity Block offering you are purchasing.</p>

    Args:
        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>
        tag_specifications: <p>The tags to apply to the Capacity Block during launch.</p>
        capacity_block_offering_id: <p>The ID of the Capacity Block offering.</p>
        instance_platform: <p>The type of operating system for which to reserve capacity.</p>

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

    def _handler(
        req: "OperationRequest[capo_ec2.types.purchase_capacity_block_request.PurchaseCapacityBlockRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.purchase_capacity_block_result.PurchaseCapacityBlockResult"
    ]:
        import capo_ec2._operations.amazon_ec2.purchase_capacity_block

        output, http_response = (
            capo_ec2._operations.amazon_ec2.purchase_capacity_block.purchase_capacity_block(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PurchaseCapacityBlock")
    )
    input_: capo_ec2.types.purchase_capacity_block_request.PurchaseCapacityBlockRequest = {}
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications
    if capacity_block_offering_id is not None:
        input_["capacity_block_offering_id"] = capacity_block_offering_id
    if instance_platform is not None:
        input_["instance_platform"] = instance_platform

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output