All Products
Search
Document Center

Elastic Compute Service:DescribeCapacityReservations

Last Updated:Nov 14, 2024

Queries the details of one or more capacity reservations. The details of a capacity reservation that you can query include the status, effective time, expiration time, and private pool type of the capacity reservation and the number of instances that have used the capacity reservation.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
ecs:DescribeCapacityReservationsget
*CapacityReservation
acs:ecs:{#regionId}:{#accountId}:capacityreservation/*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The region ID of the capacity reservation. You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou
ResourceGroupIdstringNo

The ID of the resource group to which the capacity reservation belongs. If you specify this parameter to query resources, up to 1,000 resources that belong to the specified resource group can be displayed in the response.

Note Resources in the default resource group are displayed in the response regardless of whether you specify this parameter.
rg-bp67acfmxazb4p****
Tagarray<object>No

The tags.

objectNo
KeystringNo

The key of tag N. Valid values of N: 1 to 20.

If you specify a single tag to query resources, up to 1,000 resources with this tag are returned in the response. If you specify multiple tags to query resources, up to 1,000 resources with all these tags are returned in the response. To query more than 1,000 resources with the specified tags, call the ListTagResources operation.

TestKey
ValuestringNo

The value of tag N. Valid values of N: 1 to 20.

TestValue
MaxResultsintegerNo

The number of entries per page.

Valid values: 1 to 100.

Default value: 10.

10
NextTokenstringNo

The pagination token that is used in the next request to retrieve a new page of results. You must specify the token that is obtained from the previous query as the value of the NextToken parameter.

caeba0bbb2be03f84eb48b699f0a4883
PrivatePoolOptions.IdsstringNo

The IDs of capacity reservations. The value can be a JSON array that consists of up to 100 capacity reservation IDs. Separate the IDs with commas (,).

["crp-bp1gubrkqutenqdd****", "crp-bp67acfmxazb5****"]
PlatformstringNo

The operating system of the instance. Valid values:

  • windows: Windows operating systems.
  • linux: Linux operating systems.
  • all: all operating system types.

Default value: all.

linux
InstanceTypestringNo

The instance type.

ecs.c6.large
ZoneIdstringNo

The zone ID of the capacity reservation.

cn-hangzhou-h
InstanceChargeTypestringNo

The billing method of the instance. Valid values:

  • PostPaid: pay-as-you-go.
  • PrePaid: subscription.

Default value: PostPaid.

PostPaid
StatusstringNo

The state of the capacity reservation. Valid values:

  • All: All states.
  • Pending: The capacity reservation is being initialized. Scheduled capacity reservations enter the Pending state after they are created.
  • Preparing: The capacity reservation is being prepared. Scheduled capacity reservations are in the Preparing state while resources are being provisioned.
  • Prepared: The capacity reservation is to take effect. After resources are provisioned, scheduled capacity reservations remain in the Prepared state until they take effect.
  • Active: The capacity reservation is in effect.
  • Released: The capacity reservation has been released manually or automatically when it expired.

Default value: Active.

Active

Response parameters

ParameterTypeDescriptionExample
object
NextTokenstring

A pagination token. It can be used in the next request to retrieve a new page of results.If NextToken is empty, no next page exists.

caeba0bbb2be03f84eb48b699f0a****
RequestIdstring

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3****
TotalCountinteger

The total number of entries returned.

1
MaxResultsinteger

The maximum number of entries returned per page.

10
CapacityReservationSetarray<object>

Details of the capacity reservations.

CapacityReservationItemobject
Statusstring

The status of the capacity reservation. Valid values:

  • Pending: The capacity reservation is being initialized.
  • Preparing: The capacity reservation is being prepared.
  • Prepared: The capacity reservation is to take effect.
  • Active: The capacity reservation is in effect.
  • Released: The capacity reservation has been released manually or automatically when it expired.
Active
TimeSlotstring
Note This parameter is in invitational preview and is not publicly available.
null
PrivatePoolOptionsMatchCriteriastring

The type of the private pool generated after the capacity reservation takes effect. Valid values:

  • Open: open private pool.
  • Target: targeted private pool.
Open
PrivatePoolOptionsIdstring

The ID of the capacity reservation.

crp-bp1gubrkqutenqdd****
PrivatePoolOptionsNamestring

The name of the capacity reservation.

crpTestName
RegionIdstring

The region ID of the capacity reservation.

cn-hangzhou
InstanceChargeTypestring

The billing method of the instances created by using the capacity reservation. Valid values:

  • PostPaid: pay-as-you-go.
  • PrePaid: subscription.
PostPaid
EndTimestring

The time when the capacity reservation expires.

2021-02-19T03:02Z
StartTimestring

The time when the capacity reservation takes effect.

2021-02-19T02:01Z
Descriptionstring

The description of the capacity reservation.

This is description.
EndTimeTypestring

The release mode of the capacity reservation. Valid values:

  • Limited: The capacity reservation is automatically released at a specified time.
  • Unlimited: The capacity reservation is manually released. You can release the capacity reservation anytime.
Unlimited
ResourceGroupIdstring

The ID of the resource group to which the capacity reservation belongs.

rg-bp67acfmxazb4p****
Platformstring

The operating system type of the instances created by using the capacity reservation. Valid values:

  • windows
  • linux
linux
AllocatedResourcesarray<object>

Details of the allocated resources.

AllocatedResourceobject
UsedAmountinteger

The number of instances that have used the capacity reservation.

2
TotalAmountinteger

The total number of instances for which the capacity of an instance type is reserved.

2
AvailableAmountinteger

The number of available instances.

2
zoneIdstring

The zone ID.

cn-hangzhou-h
InstanceTypestring

The instance type of the instances.

ecs.c6.large
CapacityReservationUsagesarray<object>

Details of instance usage.

CapacityReservationUsageobject
AccountIdstring

The ID of the Alibaba Cloud account.

105909559088****
ServiceNamestring

The name of the Alibaba Cloud service.

maxcompute.aliyuncs.com
UsedAmountinteger

The number of instances that are used by the Alibaba Cloud account or service.

20
Tagsarray<object>

The tags that are added to the capacity reservation.

Tagobject
TagValuestring

The tag value.

TestValue
TagKeystring

The tag key.

TestKey
StartTimeTypestring

The mode in which the capacity reservation takes effect. Valid values:

  • Now: The capacity reservation takes effect immediately after it is created.
  • Later: The capacity reservation takes effect at a specified time.
Now
SavingPlanIdstring

The ID of the savings plan used with the capacity reservation.

spn-c29b5e18pJMT****
ReservedInstanceIdstring

The ID of the reserved instance used with the capacity reservation.

ri-bpzhex2ulpzf53****
CapacityReservationOwnerIdstring

The ID of the capacity reservation owner.

100************7

Examples

Sample success responses

JSONformat

{
  "NextToken": "caeba0bbb2be03f84eb48b699f0a****",
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
  "TotalCount": 1,
  "MaxResults": 10,
  "CapacityReservationSet": {
    "CapacityReservationItem": [
      {
        "Status": "Active",
        "TimeSlot": "null",
        "PrivatePoolOptionsMatchCriteria": "Open",
        "PrivatePoolOptionsId": "crp-bp1gubrkqutenqdd****",
        "PrivatePoolOptionsName": "crpTestName",
        "RegionId": "cn-hangzhou",
        "InstanceChargeType": "PostPaid",
        "EndTime": "2021-02-19T03:02Z",
        "StartTime": "2021-02-19T02:01Z",
        "Description": "This is description.",
        "EndTimeType": "Unlimited",
        "ResourceGroupId": "rg-bp67acfmxazb4p****",
        "Platform": "linux",
        "AllocatedResources": {
          "AllocatedResource": [
            {
              "UsedAmount": 2,
              "TotalAmount": 2,
              "AvailableAmount": 2,
              "zoneId": "cn-hangzhou-h",
              "InstanceType": "ecs.c6.large",
              "CapacityReservationUsages": {
                "CapacityReservationUsage": [
                  {
                    "AccountId": "105909559088****",
                    "ServiceName": "maxcompute.aliyuncs.com",
                    "UsedAmount": 20
                  }
                ]
              }
            }
          ]
        },
        "Tags": {
          "Tag": [
            {
              "TagValue": "TestValue",
              "TagKey": "TestKey"
            }
          ]
        },
        "StartTimeType": "Now",
        "SavingPlanId": "spn-c29b5e18pJMT****",
        "ReservedInstanceId": "ri-bpzhex2ulpzf53****",
        "CapacityReservationOwnerId": "100************7\n"
      }
    ]
  }
}

Error codes

HTTP status codeError codeError messageDescription
400MissingParameter.RegionIdThe specified RegionId should not be null.The RegionId parameter is required.
400InvalidParameter.NameThe specified PrivatePoolOptions.Name is invalid.-
400InvalidParameter.PrivatePoolOptions.IdsThe specified PrivatePoolOptions.Ids is invalid.-
400DedicatedHostNotSupportedDedicatedHost is not supported for PrivatePool.The private pool does not support dedicated hosts.
400SpotNotSupportedSpot is not supported for PrivatePool.The private pool does not support preemptible instances.
400ClassicNetworkNotSupportedClassic network is not supported for PrivatePool.The private pool does not support instances in the classic network.
400Invalid.InstanceIdInstance does not exist.The specified instance does not exist.
400Invalid.PrivatePoolOptions.MatchCriteriaTarget mode does not support this operation.The operation is not supported while the PrivatePoolOptions.MatchCriteria parameter is set to Target.
400MissingParameter.PrivatePoolOptions.IdThe specified PrivatePoolOptions.Id should not be null.The PrivatePoolOptions.Id parameter is required.
400Invalid.PrivatePoolOptions.IdThe PrivatePool does not exist.The private pool does not exist.
400Invalid.InstanceTypeThe InstanceType does not match the PrivatePool.The instance type and the private pool do not match.
400Invalid.InstanceChargeTypeThe InstanceChargeType does not match the PrivatePool.The instance billing method and the private pool do not match.
400Invalid.ZoneIdThe ZoneId does not match the PrivatePool.The zone and the private pool do not match.
400Invalid.PrivatePoolOptions.statusThe PrivatePool has been used up.-
400Invalid.PrivatePoolOptions.MatchCriteriaThe PrivatePoolOptions.MatchCriteria does not match the PrivatePool.The specified PrivatePoolOptions.MatchCriteria parameter does not match the private pool.
400InvalidPlatform.ValueNotSupportedThe Platform does not match the PrivatePool.The specified Platform parameter does not match the private pool.
400Invalid.PrivatePoolOptions.statusThe PrivatePool is expired or inactive.-
400Invalid.PrivatePoolOptions.statusThe PrivatePool status is not valid.-
400Invalid.PrivatePoolOptions.statusThe Instance should be created within 48 hours once the PrivatePool is started.-
400InvalidAliUidThe PrivatePool does not belong to the user of the Instance.The specified private pool does not belong to the user who attempted to create the instance.
400Invalid.InstanceIdThe Instance dose not attached to a PrivatePool.The instance and the private pool do not match.
400MissingParameter.PackageTypeThe specified parameter "PackageType" can not be empty.-
400MissingParameter.PrivatePoolOptions.IdsThe specified parameter "PrivatePoolOptions.Ids" can not be empty.-
400MissingParameter.PrivatePoolOptions.IdThe specified parameter "PrivatePoolOptions.Id" can not be empty.-
400MissingParameter.InstanceCpuCoreCountThe specified parameter "InstanceCpuCoreCount" can not be empty.-
400MissingParameter.InstanceAmountThe specified parameter "InstanceAmount" can not be empty.-
400MissingParameter.InstanceCpuCoreCountOrInstanceAmountThe specified parameter "InstanceCpuCoreCount" and "InstanceAmount" must not be empty at the same time.-
400Invalid.TooManyPrivatePoolOptions.IdsToo many PrivatePoolOptions.Ids in this request.The number of specified private pool IDs exceeds the upper limit.
400Invalid.TooManyZoneIdsToo many ZoneIds in the request.The number of specified zone IDs exceeds the upper limit.
400Invalid.TooManyInstanceTypesToo many InstanceTypes in the request.The number of specified instance types exceeds the upper limit.
400Invalid.TooManyUnpaidPrivatePoolToo many PrivatePools create but still unpaid.Multiple private pools are created but not paid.
400Invalid.InstanceCpuCoreCountOrInstanceAmountBoth InstanceCpuCoreCount and InstanceAmount are provided.The InstanceCpuCoreCount and InstanceAmount parameters cannot be both specified.
400Invalid.PrivatePoolOptions.IdsThe specified parameter "PrivatePoolOptions.Ids" exist invalid element Id.-
400Invalid.PackageTypeThe specified parameter "PackageType" is invalid.-
400Invalid.PrivatePool.PurchaseThe PrivatePool has already paid.The private pool is already paid.
400Invalid.AssuranceTimes.NotSupportedThe value of AssuranceTimes is not supported.The specified AssuranceTimes parameter is invalid.
400Invalid.TooManyInstanceTypesThe specified parameter "InstanceType" should only has one item.-
400Invalid.PrivatePoolOptions.MatchCriteriaThe specified parameter "PrivatePoolOptions.MatchCriteria" is invalid.-
400RepeatStartPrivatePoolPrivatePool has already been started.The private pool is already started.
400Invalid.PrivatePoolOptions.IdThe specified parameter "PrivatePoolOptions.Id" should be empty.-
400Invalid.InstanceIdModify DedicatedHost Instance's attachment attributes is not supported.-
400Invalid.InstanceIdModify Spot Instance's attachment attributes is not supported.-
400Invalid.InstanceIdModify Classic Network Instance's attachment attributes is not supported.-
400InvalidParameter.RegionIdThe specified RegionId is not exist.The specified RegionId parameter does not exist.
400InvalidPermission.ResourceShareAssocoatedThe current resource is associated to a shared relationship and cannot be released.The current resource is bound to a sharing relationship and cannot be released.
500InternalErrorThe request processing has failed due to some unknown error, exception or failure.An internal error has occurred. Try again later.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-12-07The Error code has changed. The response structure of the API has changedView Change Details
2021-06-18The Error code has changed. The response structure of the API has changedView Change Details