创建共享单元。
接口说明
阿里云资源共享(Resource Sharing)支持将一个账号下的指定资源共享给一个或多个目标账号使用。更多信息,请参见资源共享概述。
本文将提供一个示例,在cn-hangzhou地域,使用资源目录管理账号创建一个名为test的共享单元,将 VPC 交换机vsw-bp183p93qs667muql****共享给资源目录内的成员172050525300****。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
 调试
        
            调试
        
    
授权信息
| 操作 | 访问级别 | 资源类型 | 条件关键字 | 关联操作 | 
| resourcesharing:CreateResourceShare | create | *全部资源 
 | 
 | 无 | 
请求参数
| 名称 | 类型 | 必填 | 描述 | 示例值 | 
| ResourceShareName | string | 是 | 共享单元名称。 长度范围:1~50 个字符。 格式:允许输入英文字母、数字、中文、半角句号(.)、下划线(_)或短划线(-)。 | test | 
| Resources | array<object> | 否 | 共享资源列表。 | |
| object | 否 | 共享资源列表。 | ||
| ResourceId | string | 否 | 共享资源 ID。 N 的取值范围:1~5,即每次最多添加 5 个共享资源。 说明 
 
 | vsw-bp183p93qs667muql**** | 
| ResourceType | string | 否 | 共享资源类型。 N 的取值范围:1~5,即每次最多添加 5 个共享资源。 支持共享的资源类型,请参见支持资源共享的云服务。 说明 
 
 | VSwitch | 
| Targets | array | 否 | 资源使用者。 | 172050525300**** | 
| string | 否 | 资源使用者。取值: 
 更多信息,请参见资源共享方式、查看资源目录 ID、查看资源夹 ID或查看成员 ID。 N 的取值范围:1~5,即每次最多添加 5 个资源使用者。 | 172050525300**** | |
| ResourceArns | array | 否 | 共享资源 ARN 列表。 N 的取值范围:1~5,即每次最多添加 5 个共享资源。 | |
| string | 否 | 共享资源 ARN。 说明 
 资源 ARN 格式请参见支持资源共享的云服务。 | acs:vpc:cn-shanghai:103755469187****:vswitch/vsw-uf62b11ue4m8oz2di**** | |
| PermissionNames | array | 否 | 共享权限名称。为空时,系统自动绑定资源类型关联的默认权限。具体信息,请参见权限库。 | |
| string | 否 | 共享权限名称。为空时,系统自动绑定资源类型关联的默认权限。具体信息,请参见权限库。 | AliyunRSDefaultPermissionVSwitch | |
| AllowExternalTargets | boolean | 否 | 是否允许共享给资源目录外的账号。取值: 
 | false | 
| ResourceGroupId | string | 否 | 资源组 ID。 | rg-aekz5nlvlak**** | 
| TargetProperties | array<object> | 否 | 资源使用者属性。 说明 
 仅当资源使用者为阿里云服务时可以设置该参数。 | |
| object | 否 | 资源使用者属性。 说明 
 仅当资源使用者为阿里云服务时可以设置该参数。 | ||
| Property | string | 否 | 资源使用者属性参数。例如:您可以设置资源共享的时间段。 
 说明 
 
 | { "timeRange":{ "timeRangeType":"timeRange", "beginAtTime":"00:00", "timezone":"UTC+8", "endAtTime":"19:59" } } | 
| TargetId | string | 否 | 资源使用者 ID。 说明 
 
 | 172050525300**** | 
| Tag | array<object> | 否 | 标签列表。最多可以绑定 20 个标签。 | |
| object | 否 | 标签列表。 | ||
| Key | string | 否 | 标签键。 说明 
 最多支持 128 个字符,不能以 | k1 | 
| Value | string | 否 | 标签值。 说明 
 最多支持 128 个字符,不能以 | v1 | 
返回参数
| 名称 | 类型 | 描述 | 示例值 | 
| object | 返回参数。 | ||
| RequestId | string | 请求 ID。 | 2C3FA051-61DC-4F3E-81E9-E4830524DF4B | 
| ResourceShare | object | 共享单元信息。 | |
| AllowExternalTargets | boolean | 是否允许共享给资源目录外的账号。取值: 
 | false | 
| CreateTime | string | 共享单元创建时间。 | 2020-12-03T08:02:22.413Z | 
| ResourceShareId | string | 共享单元 ID。 | rs-qSkW1HBY**** | 
| ResourceShareName | string | 共享单元名称。 | test | 
| ResourceShareOwner | string | 共享单元归属者。 | 151266687691**** | 
| ResourceShareStatus | string | 共享单元状态。取值: 
 说明 
 Deleted 状态的共享单元记录,会在 48~96 小时内被系统自动删除。 | Active | 
| UpdateTime | string | 共享单元更新时间。 | 2020-12-03T08:02:22.413Z | 
示例
正常返回示例
JSON格式
{
  "RequestId": "2C3FA051-61DC-4F3E-81E9-E4830524DF4B",
  "ResourceShare": {
    "AllowExternalTargets": false,
    "CreateTime": "2020-12-03T08:02:22.413Z",
    "ResourceShareId": "rs-qSkW1HBY****",
    "ResourceShareName": "test",
    "ResourceShareOwner": "151266687691****",
    "ResourceShareStatus": "Active",
    "UpdateTime": "2020-12-03T08:02:22.413Z"
  }
}错误码
| HTTP status code | 错误码 | 错误信息 | 描述 | 
|---|---|---|---|
| 400 | InvalidParameter.ResourceShareName | The ResourceShareName is invalid. | 共享单元名称无效。 | 
| 400 | InvalidParameter.ResourceShareName.Length | The maximum length of ResourceShareName exceeds 50 characters. | 共享单元名称字数超长(最大50字符)。 | 
| 400 | InvalidParameter.Resources | The Resources is invalid. | 选定的共享资源无效。 | 
| 400 | InvalidParameter.Resources.Duplicate | The Resources contains duplicate values. | 选定的共享资源有重复项。 | 
| 400 | InvalidParameter.Resources.Length | The maximum number of Resources exceeds 5. | 选定的共享资源数量超限(最大5个)。 | 
| 400 | InvalidParameter.Targets | The Targets is invalid. | 资源使用者的参数不符合规则。 | 
| 400 | InvalidParameter.Targets.Duplicate | The Targets contains duplicate values. | 资源使用者有重复项。 | 
| 400 | InvalidParameter.Targets.Length | The maximum number of Targets exceeds 5. | 资源使用者数量超限(最大5个)。 | 
| 400 | InvalidTarget | The shared target does not exist in the resource directory. | 资源使用者不在资源目录内。 | 
| 400 | InvalidParameter | The specified parameter is invalid. | 参数无效。 | 
| 400 | MissingParameter.ResourceShareName | You must specify ResourceShareName. | 共享单元名称缺失。 | 
| 400 | InvalidParameter.ResourceType | The ResourceType is invalid. | 传入的资源类型错误。 | 
| 400 | InvalidParameter.PermissionNames.Duplicate | The PermissionNames duplicate values. | 参数PermissionNames重复。 | 
| 400 | InvalidParameter.PermissionNames.Length | The maximum length of PermissionNames exceeds quota limit. | PermissionNames长度超限。 | 
| 400 | InvalidParameter.TargetProperties | The TargetProperties is invalid. | TargetProperties参数无效。 | 
| 400 | InvalidParameter.TargetProperties.Duplicate | The TargetProperties contains duplicate values. | TargetProperties包含重复的参数。 | 
| 400 | InvalidParameter.TargetProperties.Length | The TargetProperties beyond the length limit. | TargetProperties数量超过限制。 | 
| 400 | InvalidParameter.ResourceArns | The ResourceArns is invalid. | ResourceArns参数无效。 | 
| 400 | InvalidParameter.ResourceArns.Duplicate | The ResourceArns contains duplicate values. | 资源ARN参数有重复项。 | 
| 400 | InvalidParameter.ResourceArns.Length | The ResourceArns beyond the length limit. | 资源ARN数量超限(最大5个)。 | 
| 400 | InvalidParameter.ResourceConflict | Both Resources and ResourceArns cannot be specified simultaneously. Please provide only one of these parameters. | Resources 和 ResourceArns 不能同时指定。请仅提供其中一个参数。 | 
| 400 | NotSupport.ResourceType.ResourcesParameter | The Resources parameter does not support this resource type. Please use ResourceArns instead. | 当前资源类型不支持Resources参数,请使用ResourceArns参数。 | 
| 404 | EntityNotExists.Permission | The resource share permission does not exist. | 共享权限不存在。 | 
| 409 | NotEnableSharingWithResourceDirectory | You have not enabled sharing with your Resource Directory. | 未开启与资源目录组织的共享。 | 
| 409 | AccountNotInResourceDirectory | The account is not a master or a member of a resource directory. | 资源使用者不在资源目录内。 | 
| 409 | QuotaExceeded.ResourceShare.Count | The maximum number of ResourceShare exceeds the limit. | 共享单元数量超出限制。 | 
| 409 | EntityAlreadyExists.ResourceShare | The specified resource share ID already exists. | 共享单元ID已存在。 | 
| 409 | QuotaExceeded.SharedResource.Count | The maximum number of shared resources per account exceeds the limit. | 共享的资源超出单个账号最大限制。 | 
| 409 | ShareWithYourself | You cannot share resources with yourself. | 资源使用者不能是自己。 | 
| 409 | NotManagementAccount | Only the management account of the service is allowed to share such resources. | 当前资源类型仅支持资源目录的管理账号共享资源。如仍需使用当前账号,请联系管理账号将当前账号设置为当前资源类型所属可信服务的委派管理员账号。 | 
| 409 | QuotaExceeded.PendingInvitations | The maximum number of pending invitations exceeds the limit. | 邀请数量超出限制。 | 
| 409 | InvalidTarget.LegalEntityMismatch | The target account does not have the same legal entity as the resource owner account. | 共享目标账号的企业名称与共享者不一致。 | 
| 409 | ExternalTargetsNotAllowed.ResourceType | The resource share includes resource types that cannot be shared with accounts outside the resource directory. | 共享单元中包含不支持组织外共享的资源类型。 | 
| 409 | InvalidTarget.SiteMismatch | Cross-site resource sharing is not supported. | 共享目标账号与共享者站点不一致。 | 
| 409 | NotSupport.Service.ExistInOtherResourceShare | The resource type has been shared to the target service through other resourceShare. Please share it in the same resourceShare. | 此资源类型已经通过其他共享单元共享给目标云服务,请在同一个共享单元中共享。 | 
| 409 | NotSupport.Service.AssociateConflict | The same resource cannot be shared repeatedly to the target service. | 同一个资源不允许重复共享给目标云服务。 | 
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。