Queries a list of principals.
Operation description
If you are a resource owner, you can query the principals that you share your resources with. If you are a principal, you can query the resource shares that you are a part of.
This topic provides an example of how to query the list of principals for a resource share that you created in the cn-hangzhou region. The response shows that you shared resources with the principals 114240524784**** and 172050525300****.
Try it now
Test
RAM authorization
Action | Access level | Resource type | Condition key | Dependent action |
resourcesharing:ListSharedTargets | list | *All Resource
| None | None |
Request parameters
Parameter | Type | Required | Description | Example |
ResourceOwner | string | Yes | The owner of the resource share.
| Self |
ResourceType | string | No | The type of the shared resource. For more information about the resource types that can be shared, see Services that work with Resource Sharing. | VSwitch |
ResourceId | string | No | The ID of the shared resource. | vsw-bp1upw03qyz8n7us9**** |
ResourceArn | string | No | The Alibaba Cloud Resource Name (ARN) of the shared resource. | acs:vpc:cn-shanghai:103755469187****:vswitch/vsw-uf62b11ue4m8oz2di**** |
MaxResults | integer | No | The maximum number of entries to return for a single request. Valid values: 1 to 100. Default value: 20. | 20 |
NextToken | string | No | The pagination token that is used in the next request to retrieve a new page of results. If the response is truncated, you can use this token to initiate another request and retrieve the remaining entries. | TGlzdFJlc291cm**** |
| ResourceShareIds | array | No | The IDs of resource shares. The value of N can be from 1 to 5. You can specify up to 5 resource share IDs. | rs-6GRmdD3X**** |
string | No | The ID of the resource share. The value of N can be from 1 to 5. You can specify up to 5 resource share IDs. | rs-6GRmdD3X**** | |
| Targets | array | No | The principals. | 114240524784**** |
string | No | The principal. Valid values:
For more information, see Methods of resource sharing, View the ID of a resource directory, View the ID of a folder, or View the ID of a member. The value of N can be from 1 to 5. You can add up to 5 principals at a time. | 114240524784**** |
Response elements
Element | Type | Description | Example |
object | The response parameters. | ||
NextToken | string | The pagination token that is used in the next request to retrieve a new page of results. If the response is truncated, you can use this token to initiate another request and retrieve the remaining entries. | TGlzdFJlc291cm**** |
RequestId | string | The request ID. | 04677DCA-7C33-464B-8811-1B1DA3C3D197 |
| SharedTargets | array<object> | The information about the principals. | |
object | The information about the principal. | ||
TargetId | string | The ID of the principal or the resource owner. Valid values:
| 114240524784**** |
UpdateTime | string | The time when the association with the principal was updated. | 2020-12-07T09:16:59.905Z |
CreateTime | string | The time when the principal was associated with the resource share. | 2020-12-07T09:16:59.905Z |
ResourceShareId | string | The ID of the resource share. | rs-6GRmdD3X**** |
External | boolean | Indicates whether the principal is an account outside the resource directory. Valid values:
| false |
TargetProperty | string | The properties of the principal. For example, the time period for resource sharing. Note This parameter is returned only when the principal is an Alibaba Cloud service. | { "timeRange":{ "timeRangeType":"timeRange", "beginAtTime":"00:00", "timezone":"UTC+8", "endAtTime":"19:59" } } |
Examples
Success response
JSON format
{
"NextToken": "TGlzdFJlc291cm****",
"RequestId": "04677DCA-7C33-464B-8811-1B1DA3C3D197",
"SharedTargets": [
{
"TargetId": "114240524784****",
"UpdateTime": "2020-12-07T09:16:59.905Z",
"CreateTime": "2020-12-07T09:16:59.905Z",
"ResourceShareId": "rs-6GRmdD3X****",
"External": false,
"TargetProperty": "{\n \"timeRange\":{\n \"timeRangeType\":\"timeRange\",\n \"beginAtTime\":\"00:00\",\n \"timezone\":\"UTC+8\",\n \"endAtTime\":\"19:59\"\n }\n}"
}
]
}Error codes
HTTP status code | Error code | Error message | Description |
400 | MissingParameter.ResourceOwner | You must specify ResourceOwner. | You must specify ResourceOwner. |
400 | InvalidParameter.ResourceOwner | The ResourceOwner is invalid. | The ResourceOwner parameter is invalid. |
400 | InvalidParameter.ResourceType | The ResourceType is invalid. | The specified ResourceType parameter is invalid. |
400 | InvalidParameter.MaxResults | The MaxResults is invalid. | The MaxResults parameter is invalid. |
400 | InvalidParameter.NextToken | The NextToken is invalid. | The NextToken parameter is invalid. |
400 | InvalidParameter.NextToken.Length | The maximum length of NextToken exceeds 256 characters. | The length of NextToken cannot exceed 256 characters. |
400 | InvalidParameter.ResourceShareIds | The ResourceShareIds is invalid. | The ResourceShareIds parameter is invalid. |
400 | InvalidParameter.ResourceShareIds.Duplicate | The ResourceShareIds contains duplicate values. | The ResourceShareIds parameter contains duplicate values. |
400 | InvalidParameter.ResourceShareIds.Length | The maximum length of ResourceShareIds exceeds 5 characters. | The number of ResourceShareIds values cannot exceed 5. |
400 | InvalidParameter.Targets | The Targets is invalid. | The specified Targets parameter is invalid. |
400 | InvalidParameter.Targets.Duplicate | The Targets contains duplicate values. | The specified Targets parameter contains duplicate values. |
400 | InvalidParameter.Targets.Length | The maximum number of Targets exceeds 5. | The number of Targets values cannot exceed 5. |
400 | InvalidParameter.ResourceId | The ResourceId is invalid. | The ResourceId parameter is invalid. |
400 | InvalidParameter | The specified parameter is invalid. | The specified parameter is invalid. |
400 | InvalidParameter.ResourceArn | The ResourceArn is invalid. | The ResourceArn is invalid. |
400 | InvalidParameter.ResourceConflict | Both ResourceId and ResourceArn cannot be specified simultaneously. Please provide only one of these parameters. | Both ResourceId and ResourceArn cannot be specified simultaneously. Please provide only one of these parameters. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.