All Products
Search
Document Center

Resource Management:ListSharedResources

Last Updated:Mar 14, 2024

Queries the resources you share with other accounts or the resources other accounts share with you.

Operation description

This topic provides an example on how to call the API operation to query the resources that you share with other accounts in the cn-hangzhou region. The response shows that in the resource share rs-6GRmdD3X****, you share the vsw-bp1upw03qyz8n7us9**** resource of the VSwitch type with other accounts.

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:ListSharedResourcesRead
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
ResourceOwnerstringYes

The owner of the resource shares. Valid values:

  • Self: your account. If you set the value to Self, the resources you share with other accounts are queried.
  • OtherAccounts: another account. If you set the value to OtherAccounts, the resources other accounts share with you are queried.
Self
ResourceTypestringNo

The type of the shared resources.

For more information about the types of resources that can be shared, see Services that work with Resource Sharing.

VSwitch
TargetstringNo

The ID of the principal or resource owner.

  • If the value of ResourceOwner is Self, set this parameter to the ID of a principal.
  • If the value of ResourceOwner is OtherAccounts, set this parameter to the ID of a resource owner.
172050525300****
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-6GRmdD3X****
ResourceIdsarrayNo

The ID of a shared resource.

stringNo

The ID of a shared resource.

vsw-bp1upw03qyz8n7us9****

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.

04677DCA-7C33-464B-8811-1B1DA3C3D197
SharedResourcesobject []

The information of the shared resources.

UpdateTimestring

The time when the association of the shared resource was updated.

2020-12-07T07:39:02.921Z
ResourceTypestring

The type of the shared resource.

For more information about the types of resources that can be shared, see Services that work with Resource Sharing.

VSwitch
CreateTimestring

The time when the shared resource was associated with the resource share.

2020-12-07T07:39:02.921Z
ResourceShareIdstring

The ID of the resource share.

rs-6GRmdD3X****
ResourceIdstring

The ID of the shared resource.

vsw-bp1upw03qyz8n7us9****
ResourceStatusstring

The status of the shared resource. This parameter is returned only when you query the resources that other accounts share with you.

Valid values:

  • Available: The resource is available.
  • ZonalResourceInaccessible: The resource is unavailable in the current zone.
  • LimitExceeded: The resource is unavailable because the maximum number of resources that other accounts can share with you exceeds the upper limit.
  • Unavailable: The resource is unavailable.
Available
ResourceStatusMessagestring

The cause of the association failure.

The reason for the association failure.

Examples

Sample success responses

JSONformat

{
  "NextToken": "TGlzdFJlc291cm****",
  "RequestId": "04677DCA-7C33-464B-8811-1B1DA3C3D197",
  "SharedResources": [
    {
      "UpdateTime": "2020-12-07T07:39:02.921Z",
      "ResourceType": "VSwitch",
      "CreateTime": "2020-12-07T07:39:02.921Z",
      "ResourceShareId": "rs-6GRmdD3X****",
      "ResourceId": "vsw-bp1upw03qyz8n7us9****",
      "ResourceStatus": "Available",
      "ResourceStatusMessage": "The reason for the association failure. "
    }
  ]
}

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.ResourceTypeThe ResourceType is invalid.The specified ResourceType 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.
400InvalidParameter.ResourceIdsThe ResourceIds is invalid.The specified ResourceIds parameter is invalid.
400InvalidParameter.ResourceIds.DuplicateThe specified ResourceId contains duplicate values.The specified ResourceIds parameter contains duplicate values.
400InvalidParameter.ResourceIds.LengthThe maximum number of ResourceIds (5) is exceeded.The number of specified ResourceIds values cannot exceed 5.
400InvalidParameter.TargetThe Target is invalid.The Target parameter is invalid.
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
2024-01-24The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 400
2023-10-23The Error code has changed. The response structure of the API has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 400
Output ParametersThe response structure of the API has changed.
2023-10-23The Error code has changed. The response structure of the API has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 400
Output ParametersThe response structure of the API has changed.