Skip to content

get_capacity_reservation_usage

get_capacity_reservation_usage(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    capacity_reservation_id: Optional[CapacityReservationId] = None,
    next_token: Optional[String] = None,
    max_results: Optional[GetCapacityReservationUsageRequestMaxResults] = None,
    dry_run: Optional[Boolean] = None,
) -> GetCapacityReservationUsageResult

Gets usage information about a Capacity Reservation. If the Capacity Reservation is shared, it shows usage information for the Capacity Reservation owner and each Amazon Web Services account that is currently using the shared capacity. If the Capacity Reservation is not shared, it shows only the Capacity Reservation owner's usage.

Parameters:

  • capacity_reservation_id (Optional[CapacityReservationId], default: None ) –

    The ID of the Capacity Reservation.

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

    The token to use to retrieve the next page of results.

  • max_results (Optional[GetCapacityReservationUsageRequestMaxResults], default: None ) –

    The maximum number of items to return for this request. To get the next page of items, make another request with the token returned in the output. For more information, see Pagination.

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

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def get_capacity_reservation_usage(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    capacity_reservation_id: Optional[
        "capo_ec2.types.capacity_reservation_id.CapacityReservationId"
    ] = None,
    next_token: Optional["capo_ec2.types.string.String"] = None,
    max_results: Optional[
        "capo_ec2.types.get_capacity_reservation_usage_request_max_results.GetCapacityReservationUsageRequestMaxResults"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> "capo_ec2.types.get_capacity_reservation_usage_result.GetCapacityReservationUsageResult":
    """<p>Gets usage information about a Capacity Reservation. If the Capacity Reservation is shared, it shows usage information for the Capacity Reservation owner and each Amazon Web Services account that is currently using the shared capacity. If the Capacity Reservation is not shared, it shows only the Capacity Reservation owner's usage.</p>

    Args:
        capacity_reservation_id: <p>The ID of the Capacity Reservation.</p>
        next_token: <p>The token to use to retrieve the next page of results.</p>
        max_results: <p>The maximum number of items to return for this request. To get the next page of items, make another request with the token returned in the output. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Query-Requests.html#api-pagination">Pagination</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>

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

    def _handler(
        req: "OperationRequest[capo_ec2.types.get_capacity_reservation_usage_request.GetCapacityReservationUsageRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.get_capacity_reservation_usage_result.GetCapacityReservationUsageResult"
    ]:
        import capo_ec2._operations.amazon_ec2.get_capacity_reservation_usage

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetCapacityReservationUsage")
    )
    input_: capo_ec2.types.get_capacity_reservation_usage_request.GetCapacityReservationUsageRequest = {}
    if capacity_reservation_id is not None:
        input_["capacity_reservation_id"] = capacity_reservation_id
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results
    if dry_run is not None:
        input_["dry_run"] = dry_run

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