- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
GetCapacityReservationUsageCommand
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.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { EC2Client, GetCapacityReservationUsageCommand } from "@aws-sdk/client-ec2"; // ES Modules import
// const { EC2Client, GetCapacityReservationUsageCommand } = require("@aws-sdk/client-ec2"); // CommonJS import
const client = new EC2Client(config);
const input = { // GetCapacityReservationUsageRequest
CapacityReservationId: "STRING_VALUE", // required
NextToken: "STRING_VALUE",
MaxResults: Number("int"),
DryRun: true || false,
};
const command = new GetCapacityReservationUsageCommand(input);
const response = await client.send(command);
// { // GetCapacityReservationUsageResult
// NextToken: "STRING_VALUE",
// CapacityReservationId: "STRING_VALUE",
// InstanceType: "STRING_VALUE",
// TotalInstanceCount: Number("int"),
// AvailableInstanceCount: Number("int"),
// State: "active" || "expired" || "cancelled" || "pending" || "failed" || "scheduled" || "payment-pending" || "payment-failed" || "assessing" || "delayed" || "unsupported",
// InstanceUsages: [ // InstanceUsageSet
// { // InstanceUsage
// AccountId: "STRING_VALUE",
// UsedInstanceCount: Number("int"),
// },
// ],
// };
GetCapacityReservationUsageCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
CapacityReservationId Required | string | undefined | The ID of the Capacity Reservation. |
DryRun | boolean | undefined | 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 |
MaxResults | number | undefined | 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 . |
NextToken | string | undefined | The token to use to retrieve the next page of results. |
GetCapacityReservationUsageCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
AvailableInstanceCount | number | undefined | The remaining capacity. Indicates the number of instances that can be launched in the Capacity Reservation. |
CapacityReservationId | string | undefined | The ID of the Capacity Reservation. |
InstanceType | string | undefined | The type of instance for which the Capacity Reservation reserves capacity. |
InstanceUsages | InstanceUsage[] | undefined | Information about the Capacity Reservation usage. |
NextToken | string | undefined | The token to use to retrieve the next page of results. This value is |
State | CapacityReservationState | undefined | The current state of the Capacity Reservation. A Capacity Reservation can be in one of the following states:
|
TotalInstanceCount | number | undefined | The number of instances for which the Capacity Reservation reserves capacity. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
EC2ServiceException | Base exception class for all service exceptions from EC2 service. |