All Products
Search
Document Center

Resource Management:ListResourceShares

Last Updated:Mar 22, 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 by using the account whose ID is 151266687691****:

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

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

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:ListResourceSharesRead
  • 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 share. Valid values:

  • Active: The resource share is enabled.
  • Pending: The resource share is associated with one or more resource sharing invitations that are waiting for confirmation.
  • Deleting: The resource share is being deleted.
  • Deleted: The resource share is deleted.
Note The system 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 ID of a resource share.

stringNo

The ID of a resource share.

rs-PqysnzIj****
PermissionNamestringNo

The name of the permission. For more information, see Permission library.

AliyunRSDefaultPermissionVSwitch

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

Response parameters

ParameterTypeDescriptionExample
object
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 ID of the request.

2F23CFB6-A721-4E90-AC1E-0E30FA8B45DA
ResourceSharesobject []

The information of the resource shares.

UpdateTimestring

The time when the resource share was updated.

2020-12-03T08:01:43.638Z
ResourceShareNamestring

The name of the resource share.

test
ResourceShareOwnerstring

The owner of the resource share.

151266687691****
CreateTimestring

The time when the resource share was created.

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

The ID of the resource share.

rs-PqysnzIj****
ResourceShareStatusstring

The status of the resource share. Valid values:

  • Active: The resource share is enabled.
  • Pending: The resource share is associated with one or more resource sharing invitations that are waiting for confirmation.
  • Deleting: The resource share is being deleted.
  • Deleted: The resource share is deleted.
Note The system deletes the records of resource shares in the Deleted state within 48 hours to 96 hours after you delete the resource shares.
Active
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

Examples

Sample success responses

JSONformat

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

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.

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 changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 400
Input ParametersThe request parameters of the API has changed.
    delete Input Parameters: ResourceGroupId
Output ParametersThe response structure of the API has changed.
2023-03-02The Error code has changed. The request parameters of the API has changed. The response structure of the API has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 400
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: ResourceGroupId
Output ParametersThe response structure of the API has changed.