调用AssociateResourceShare为共享单元关联共享资源或资源使用者。
仅支持共享给资源目录内的成员账号。
本文将提供一个示例,在地域cn-hangzhou
下的共享单元rs-6GRmdD3X****
中,添加共享资源VPC交换机vsw-bp183p93qs667muql****
,将其共享给资源目录内的成员账号172050525300****
。
请求参数
名称 | 类型 | 是否必选 | 示例值 | 描述 |
---|---|---|---|---|
Action | String | 是 | AssociateResourceShare |
要执行的操作。取值:AssociateResourceShare。 |
RegionId | String | 是 | cn-hangzhou |
地域ID。 支持资源共享的地域,请参见DescribeRegions。 |
ResourceShareId | String | 是 | rs-6GRmdD3X**** |
共享单元ID。 |
Resources.N.ResourceId | String | 否 | vsw-bp183p93qs667muql**** |
共享资源ID。 N的取值范围:1~5,即每次最多添加5个共享资源。 说明 Resources.N.ResourceId与Resources.N.ResourceType成对出现,需要同时设置。
|
Resources.N.ResourceType | String | 否 | VSwitch |
共享资源类型。 N的取值范围:1~5,即每次最多添加5个共享资源。 取值:VSwitch。 说明
|
Targets.N | RepeatList | 否 | 172050525300**** |
资源使用者。 资源共享的受益方,可以使用共享的资源,通常为资源目录内的成员账号UID。关于如何获取成员账号UID,请参见查看成员基本信息。 N的取值范围:1~5,即每次最多添加5个资源使用者。 |
关于公共请求参数的详情,请参见公共参数。
返回数据
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
RequestId | String | 111FB84A-60A9-403E-9067-E55D7EE95BD1 |
请求ID。 |
ResourceShareAssociations | Array of ResourceShareAssociation |
共享单元关联的共享资源或资源使用者信息。 |
|
AssociationStatus | String | Associating |
关联状态。取值:
说明
Failed 和Disassociated 状态的记录,会在48~96小时内被系统自动删除。
|
AssociationStatusMessage | String | The reason for the association failure. |
关联失败的原因。 |
AssociationType | String | Resource |
关联类型:取值:
|
CreateTime | String | 2020-12-04T09:40:41.246Z |
关联的时间。存在以下两种情况:
|
EntityId | String | vsw-bp183p93qs667muql**** |
关联实体ID。取值:
|
EntityType | String | VSwitch |
关联实体类型。取值:
|
ResourceShareId | String | rs-6GRmdD3X**** |
共享单元ID。 |
ResourceShareName | String | test |
共享单元名称。 |
UpdateTime | String | 2020-12-04T09:40:41.246Z |
更新关联的时间。存在以下两种情况:
|
示例
请求示例
https://resourcesharing.aliyuncs.com/?Action=AssociateResourceShare
&RegionId=cn-hangzhou
&ResourceShareId=rs-6GRmdD3X****
&Resources.1.ResourceId=vsw-bp183p93qs667muql****
&Resources.1.ResourceType=VSwitch
&Targets.1=172050525300****
&RegionId=cn-hangzhou
&<公共请求参数>
正常返回示例
XML
格式
<AssociateResourceShareResponse>
<ResourceShareAssociations>
<ResourceShareId>rs-6GRmdD3X****</ResourceShareId>
<EntityId>vsw-bp183p93qs667muql****</EntityId>
<EntityType>VSwitch</EntityType>
<AssociationStatusMessage></AssociationStatusMessage>
<AssociationType>Resource</AssociationType>
<CreateTime>2020-12-04T09:40:41.246Z</CreateTime>
<UpdateTime>2020-12-04T09:40:41.246Z</UpdateTime>
<ResourceShareName>test</ResourceShareName>
<AssociationStatus>Associating</AssociationStatus>
</ResourceShareAssociations>
<ResourceShareAssociations>
<ResourceShareId>rs-6GRmdD3X****</ResourceShareId>
<EntityId>172050525300****</EntityId>
<EntityType>Account</EntityType>
<AssociationStatusMessage></AssociationStatusMessage>
<AssociationType>Target</AssociationType>
<CreateTime>2020-12-04T09:40:41.250Z</CreateTime>
<UpdateTime>2020-12-04T09:40:41.250Z</UpdateTime>
<ResourceShareName>test1</ResourceShareName>
<AssociationStatus>Associating</AssociationStatus>
</ResourceShareAssociations>
<RequestId>111FB84A-60A9-403E-9067-E55D7EE95BD1</RequestId>
</AssociateResourceShareResponse>
JSON
格式
{
"ResourceShareAssociations": [
{
"ResourceShareId": "rs-6GRmdD3X****",
"EntityId": "vsw-bp183p93qs667muql****",
"EntityType": "VSwitch",
"AssociationStatusMessage": "",
"AssociationType": "Resource",
"CreateTime": "2020-12-04T09:40:41.246Z",
"UpdateTime": "2020-12-04T09:40:41.246Z",
"ResourceShareName": "test",
"AssociationStatus": "Associating"
},
{
"ResourceShareId": "rs-6GRmdD3X****",
"EntityId": "172050525300****",
"EntityType": "Account",
"AssociationStatusMessage": "",
"AssociationType": "Target",
"CreateTime": "2020-12-04T09:40:41.250Z",
"UpdateTime": "2020-12-04T09:40:41.250Z",
"ResourceShareName": "test1",
"AssociationStatus": "Associating"
}
],
"RequestId": "111FB84A-60A9-403E-9067-E55D7EE95BD1"
}
错误码
HttpCode | 错误码 | 错误信息 | 描述 |
---|---|---|---|
400 | MissingParameter.ResourceShareId | You must specify ResourceShareId. | ResourceShareId参数缺失。 |
400 | InvalidParameter.ResourceShareId | The ResourceShareId is invalid. | ResourceShareId参数错误。 |
400 | InvalidParameter.Resources | The Resources is invalid. | 选定的共享资源无效。 |
400 | InvalidParameter.Resources.Length | The maximum number of Resources exceeds 5. | 选定的共享资源数量超限(最大5个)。 |
400 | InvalidParameter.Resources.Duplicate | The Resources contains duplicate values. | 选定的共享资源有重复项。 |
400 | InvalidParameter.Targets | The Targets is invalid. | 资源使用者的参数不符合规则。 |
400 | InvalidParameter.Targets.Length | The maximum number of Targets exceeds 5. | 资源使用者数量超限(最大5个)。 |
400 | InvalidParameter.Targets.Duplicate | The Targets contains duplicate values. | 资源使用者有重复项。 |
409 | AccountNotInResourceDirectory | The account is not a master or a member of a resource directory. | 资源使用者不在资源目录内。 |
404 | EntityNotExists.ResourceShare | The resource share does not exist in the current account. | 共享单元不在当前账号内。 |
409 | ResourceShareStatusMismatchAction | The status of the resource share does not allow the specified operation. | 共享单元的状态不支持当前操作。 |
409 | QuotaExceeded.SharedResource.Count | The maximum number of shared resources per account exceeds 10. | 共享的资源超出单个账号最大限制(最大10个)。 |
409 | ShareWithYourself | You cannot share resources with yourself. | 资源使用者不能是自己。 |
400 | InvalidTarget | The shared target does not exist in the resource directory. | 资源使用者不在资源目录内。 |
400 | ResourceAndTargetBothEmpty | Either a resource or a shared target must be specified. | 必须指定一个资源或一个资源使用者。 |
409 | AssociateConflict | You cannot perform the operation while disassociation operation is being performed. | 取消关联中,不能操作关联。 |
400 | InvalidParameter | The specified parameter is invalid. | 参数无效。 |
访问错误中心查看更多错误码。