Queries resource groups.

Usage notes

You can call this API operation to query all resource groups within the current account. You can also call this API operation to query a specific resource group based on the status, ID, identifier, or display name of the resource group.

This topic provides an example on how to call the API operation to query the basic information about the resource groups rg-1hSBH2**** and rg-9gLOoK**** within the current account.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes ListResourceGroups

The operation that you want to perform. Set the value to ListResourceGroups.

Status String No OK

The status of the resource group. This parameter specifies a filter condition for the query. Valid values:

  • Creating: The resource group is being created.
  • OK: The resource group is created.
  • PendingDelete: The resource group is waiting to be deleted.
PageNumber Integer No 1

The number of the page to return.

Pages start from page 1. Default value: 1.

PageSize Integer No 10

The number of entries to return on each page.

Valid values: 1 to 100. Default value: 10.

ResourceGroupId String No rg-9gLOoK****

The ID of the resource group. This parameter specifies a filter condition for the query.

The ID can be a maximum of 18 characters in length and must start with rg-.

Note This parameter is incorporated into the ResourceGroupIds parameter. If you configure both the ResourceGroupId and ResourceGroupIds parameters, the value of the ResourceGroupIds parameter prevails.
DisplayName String No my-project

The display name of the resource group. This parameter specifies a filter condition for the query. Fuzzy match is supported.

The display name can be a maximum of 50 characters in length.

Name String No my-project

The identifier of the resource group. This parameter specifies a filter condition for the query. Fuzzy match is supported.

The identifier can be a maximum of 50 characters in length and can contain letters, digits, and hyphens (-).

Tag Array No

The tag. This parameter specifies a filter condition for the query.

Key String No k1

The tag key.

Value String No v1

The tag value.

IncludeTags Boolean No false

Specifies whether to return the information of tags. Valid values:

  • false (default value)
  • true
Note If you configure the Tag parameter, the system returns the information of tags regardless of the setting of the IncludeTags parameter.
ResourceGroupIds Array of String No {"rg-1hSBH2****","rg-9gLOoK****"}

The IDs of the resource groups. This parameter specifies a filter condition for the query.

You can specify a maximum of 100 resource group IDs.

Note If you configure both the ResourceGroupId and ResourceGroupIds parameters, the value of the ResourceGroupIds parameter prevails.

For more information about common request parameters, see Common parameters.

Response parameters

Parameter Type Example Description
TotalCount Integer 2

The total number of entries returned.

RequestId String 4B450CA1-36E8-4AA2-8461-86B42BF4CC4E

The ID of the request.

PageSize Integer 10

The number of entries returned per page.

PageNumber Integer 1

The page number of the returned page.

ResourceGroups Array of ResourceGroup

The information of the resource groups.

ResourceGroup
DisplayName String my-project

The display name of the resource group.

Status String OK

The status of the resource group. Valid values:

  • Creating: The resource group is being created.
  • OK: The resource group is created.
  • PendingDelete: The resource group is waiting to be deleted.
AccountId String 123456789****

The ID of the Alibaba Cloud account to which the resource group belongs.

Name String my-project

The identifier of the resource group.

CreateDate String 2015-01-23T12:33:18Z

The time when the resource group was created. The time is displayed in UTC.

Id String rg-9gLOoK****

The ID of the resource group.

Tags Array of Tag

The tags that are added to the resource group.

Tag
TagKey String k1

The tag key.

TagValue String v1

The tag value.

Examples

Sample requests

https://resourcemanager.aliyuncs.com/?Action=ListResourceGroups
&IncludeTags=true
&ResourceGroupIds.1=rg-1hSBH2****
&ResourceGroupIds.2=rg-9gLOoK****
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<ListResourceGroupsResponse>
    <RequestId>4B450CA1-36E8-4AA2-8461-86B42BF4CC4E</RequestId>
    <PageNumber>1</PageNumber>
    <PageSize>10</PageSize>
    <TotalCount>2</TotalCount>
    <ResourceGroups>
        <ResourceGroup>
            <Id>rg-1hSBH2****</Id>
            <AccountId>123456789****</AccountId>
            <Name>default</Name>
            <DisplayName>Default resource group</DisplayName>
            <Status>OK</Status>
            <CreateDate>2015-01-23T12:33:18Z</CreateDate>
            <Tags>
                <Tag>
                    <TagKey>k1</TagKey>
                    <TagValue>v1</TagValue>
                </Tag>
            </Tags>
        </ResourceGroup>
        <ResourceGroup>
            <Id>rg-9gLOoK****</Id>
            <AccountId>123456789****</AccountId>
            <Name>my-project</Name>
            <DisplayName>my-project</DisplayName>
            <Status>OK</Status>
            <CreateDate>2015-01-23T12:33:18Z</CreateDate>
            <Tags>
                <Tag>
                    <TagKey>k2</TagKey>
                    <TagValue>v2</TagValue>
                </Tag>
            </Tags>
        </ResourceGroup>
    </ResourceGroups>
</ListResourceGroupsResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "4B450CA1-36E8-4AA2-8461-86B42BF4CC4E",
  "PageNumber" : 1,
  "PageSize" : 10,
  "TotalCount" : 2,
  "ResourceGroups" : {
    "ResourceGroup" : [ {
      "Id" : "rg-1hSBH2****",
      "AccountId" : "123456789****",
      "Name" : "default",
      "DisplayName" : "Default resource group",
      "Status" : "OK",
      "CreateDate" : "2015-01-23T12:33:18Z",
      "Tags" : {
        "Tag" : [ {
          "TagKey" : "k1",
          "TagValue" : "v1"
        } ]
      }
    }, {
      "Id" : "rg-9gLOoK****",
      "AccountId" : "123456789****",
      "Name" : "my-project",
      "DisplayName" : "my-project",
      "Status" : "OK",
      "CreateDate" : "2015-01-23T12:33:18Z",
      "Tags" : {
        "Tag" : [ {
          "TagKey" : "k2",
          "TagValue" : "v2"
        } ]
      }
    } ]
  }
}

Error codes

For a list of error codes, visit the API Error Center.