All Products
Search
Document Center

Resource Management:ListResourceShares

Last Updated:Dec 03, 2024

Queries resource shares.

Operation description

This topic provides an example on how to call the API operation to query the resource shares that are created by using the current Alibaba Cloud account in the cn-hangzhou region. The response shows that the following resource shares are created within the account 151266687691****:

  • rs-hX9wC5jO****, which is in the Deleted state
  • rs-PqysnzIj****, which is in the Active state

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
resourcesharing:ListResourceShareslist
*All Resources
*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
ResourceOwnerstringYes

The owner of the resource shares. Valid values:

  • Self: the current account
  • OtherAccounts: an account other than the current account
Self
ResourceShareNamestringNo

The name of the resource share.

test
ResourceShareStatusstringNo

The status of the resource shares. Valid values:

  • Active
  • Pending
  • Deleting
  • Deleted
Note The system automatically deletes the records of resource shares in the Deleted state within 48 hours to 96 hours after you delete the resource shares.
Active
MaxResultsintegerNo

The maximum number of entries to return for a single request.

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

20
NextTokenstringNo

The token that is used to initiate the next request if the response of the current request is truncated. You can use the token to initiate another request and obtain the remaining records.

TGlzdFJlc291cm****
ResourceShareIdsarrayNo

The IDs of the resource shares.

Valid values of N: 1 to 5. This indicates that a maximum of five resource shares can be specified at a time.

stringNo

The ID of a resource share.

rs-PqysnzIj****
PermissionNamestringNo

The information about the permissions. For more information, see Permission library.

AliyunRSDefaultPermissionVSwitch
ResourceGroupIdstringNo

The ID of the resource group.

rg-aekz5nlvlak****
Tagarray<object>No

The tags.

objectNo

A tag.

KeystringNo

The tag key.

Note The tag key can be 128 characters in length and cannot start with acs: or aliyun. The tag key cannot contain http:// or https://.
k1
ValuestringNo

The tag value.

Note The tag value can be 128 characters in length and cannot start with acs:. The tag value cannot contain http:// or https://.
v1

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

Response parameters

ParameterTypeDescriptionExample
object

The returned result.

NextTokenstring

The token that is used to initiate the next request if the response of the current request is truncated. You can use the token to initiate another request and obtain the remaining records.

TGlzdFJlc291cm****
RequestIdstring

The request ID.

2F23CFB6-A721-4E90-AC1E-0E30FA8B45DA
ResourceSharesarray<object>

The information about the resource shares.

ResourceShareobject

The information about a resource share.

AllowExternalTargetsboolean

Indicates whether resources in the resource share can be shared with accounts outside the resource directory. Valid values:

  • false: Resources in the resource share can be shared only with accounts in the resource directory.
  • true: Resources in the resource share can be shared with both accounts in the resource directory and accounts outside the resource directory.
false
CreateTimestring

The time when the resource share was created.

2020-12-03T02:20:31.292Z
ResourceGroupIdstring

The ID of the resource group.

rg-aekz5nlvlak****
ResourceShareIdstring

The ID of the resource share.

rs-PqysnzIj****
ResourceShareNamestring

The name of the resource share.

test
ResourceShareOwnerstring

The owner of the resource share.

151266687691****
ResourceShareStatusstring

The status of the resource share. Valid values:

  • Active
  • Pending
  • Deleting
  • Deleted
Note The system automatically deletes the records of resource shares in the Deleted state within 48 hours to 96 hours after you delete the resource shares.
Active
Tagsarray<object>

The tags.

Tagobject

A tag.

Keystring

The tag key.

k1
Valuestring

The tag value.

v1
UpdateTimestring

The time when the resource share was updated.

2020-12-03T08:01:43.638Z

Examples

Sample success responses

JSONformat

{
  "NextToken": "TGlzdFJlc291cm****",
  "RequestId": "2F23CFB6-A721-4E90-AC1E-0E30FA8B45DA",
  "ResourceShares": [
    {
      "AllowExternalTargets": false,
      "CreateTime": "2020-12-03T02:20:31.292Z",
      "ResourceGroupId": "rg-aekz5nlvlak****",
      "ResourceShareId": "rs-PqysnzIj****",
      "ResourceShareName": "test",
      "ResourceShareOwner": "151266687691****",
      "ResourceShareStatus": "Active",
      "Tags": [
        {
          "Key": "k1",
          "Value": "v1"
        }
      ],
      "UpdateTime": "2020-12-03T08:01:43.638Z"
    }
  ]
}

Error codes

HTTP status codeError codeError messageDescription
400MissingParameter.ResourceOwnerYou must specify ResourceOwner.You must specify ResourceOwner.
400InvalidParameter.ResourceOwnerThe ResourceOwner is invalid.The ResourceOwner parameter is invalid.
400InvalidParameter.ResourceShareNameThe ResourceShareName is invalid.The ResourceShareName parameter is invalid.
400InvalidParameter.ResourceShareName.LengthThe maximum length of ResourceShareName exceeds 50 characters.The length of ResourceShareName cannot exceed 50 characters.
400InvalidParameter.ResourceShareStatusThe ResourceShareStatus is invalid.The ResourceShareStatus parameter is invalid.
400InvalidParameter.MaxResultsThe MaxResults is invalid.The MaxResults parameter is invalid.
400InvalidParameter.NextTokenThe NextToken is invalid.The NextToken parameter is invalid.
400InvalidParameter.NextToken.LengthThe maximum length of NextToken exceeds 256 characters.The length of NextToken cannot exceed 256 characters.
400InvalidParameter.ResourceShareIdsThe ResourceShareIds is invalid.The ResourceShareIds parameter is invalid.
400InvalidParameter.ResourceShareIds.DuplicateThe ResourceShareIds contains duplicate values.The ResourceShareIds parameter contains duplicate values.
400InvalidParameter.ResourceShareIds.LengthThe maximum length of ResourceShareIds exceeds 5 characters.The number of ResourceShareIds values cannot exceed 5.
400InvalidParameterThe specified parameter is invalid.The specified parameter is invalid.
400InvalidParameter.ResourceOwnerAndTagYou cannot use ResourceOwner set to OtherAccounts and tags in one request.You cannot use ResourceOwner set to OtherAccounts and tags in one request.

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

Change history

Change timeSummary of changesOperation
2023-04-03The Error code has changed. The request parameters of the API has changed. The response structure of the API has changedView Change Details
2023-03-02The Error code has changed. The request parameters of the API has changed. The response structure of the API has changedView Change Details