全部產品
Search
文件中心

Resource Management:AssociateResourceShare - 關聯共用資源或資源使用者

更新時間:Oct 13, 2025

為共用單元關聯共用資源或資源使用者。

介面說明

本文將提供一個樣本,在cn-hangzhou地區的共用單元rs-6GRmdD3X****中,添加共用資源 VPC 交換器vsw-bp183p93qs667muql****,將其共用給資來源目錄內的成員172050525300****

調試

您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。

調試

授權資訊

下表是API對應的授權資訊,可以在RAM權限原則語句的Action元素中使用,用來給RAM使用者或RAM角色授予調用此API的許可權。具體說明如下:

  • 操作:是指具體的許可權點。

  • 存取層級:是指每個操作的存取層級,取值為寫入(Write)、讀取(Read)或列出(List)。

  • 資源類型:是指操作中支援授權的資源類型。具體說明如下:

    • 對於必選的資源類型,用前面加 * 表示。

    • 對於不支援資源級授權的操作,用全部資源表示。

  • 條件關鍵字:是指雲產品自身定義的條件關鍵字。

  • 關聯操作:是指成功執行操作所需要的其他許可權。操作者必須同時具備關聯操作的許可權,操作才能成功。

操作

存取層級

資源類型

條件關鍵字

關聯操作

resourcesharing:AssociateResourceShare

update

*全部資源

*

  • resourcesharing:Target
  • resourcesharing:RequestedResourceType
  • resourcesharing:ResourceArn

請求參數

名稱

類型

必填

描述

樣本值

ResourceShareId

string

共用單元 ID。

rs-6GRmdD3X****

Resources

array<object>

資源清單。

object

資源清單。

ResourceType

string

共用資源類型。

N 的取值範圍:1~5,即每次最多添加 5 個共用資源。

支援共用的資源類型,請參見支援資源共用的雲端服務

說明

Resources.N.ResourceIdResources.N.ResourceType成對出現,需要同時設定。

VSwitch

ResourceId

string

共用資源 ID。

N 的取值範圍:1~5,即每次最多添加 5 個共用資源。

說明

Resources.N.ResourceId 與 Resources.N.ResourceType 成對出現,需要同時設定。

vsw-bp183p93qs667muql****

Targets

array

資源使用者。

172050525300****

string

資源使用者。取值:

  • AllowExternalTargetsfalse時,即僅允許資來源目錄內共用時,資源使用者可以為資來源目錄 ID、資源夾 ID 或成員 ID。

  • AllowExternalTargetstrue時,即允許共用給任意帳號時,資源使用者可以為阿里雲帳號 ID、資來源目錄 ID、資源夾 ID、成員 ID 或阿里雲服務。

更多資訊,請參見資源共用方式查看資來源目錄 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

TargetProperties

array<object>

資源使用者屬性。

說明

僅當資源使用者為阿里雲服務時可以設定該參數。

object

資源使用者屬性。

說明

僅當資源使用者為阿里雲服務時可以設定該參數。

TargetId

string

資源使用者 ID。

說明

TargetProperties.N.TargetIdTargetProperties.N.Property成對出現,需要同時設定。

172050525300****

Property

string

資源使用者屬性參數。例如:您可以設定資源共用的時間段。timeRangeType取值:

  • timeRange:指定時間段。

  • day:全天。

說明

TargetProperties.N.TargetIdTargetProperties.N.Property成對出現,需要同時設定。

{ "timeRange":{ "timeRangeType":"timeRange", "beginAtTime":"00:00", "timezone":"UTC+8", "endAtTime":"19:59" } }

返回參數

名稱

類型

描述

樣本值

object

返回結果。

RequestId

string

請求 ID。

111FB84A-60A9-403E-9067-E55D7EE95BD1

ResourceShareAssociations

array<object>

共用單元關聯的共用資源或資源使用者資訊。

object

共用單元關聯的共用資源或資源使用者資訊。

UpdateTime

string

更新關聯的時間。存在以下兩種情況:

  • 當關聯類別型AssociationType為資源Resource時,該參數為更新資源的時間。

  • 當關聯類別型AssociationType為資源使用者Target時,該參數為更新資源使用者的時間。

2020-12-04T09:40:41.246Z

ResourceArn

string

關聯資源 ARN。

說明

當關聯類別型AssociationType為資源使用者Target時,該參數不可用。

acs:vpc:cn-shanghai:103755469187****:vswitch/vsw-uf62b11ue4m8oz2di****

ResourceShareName

string

共用單元名稱。

test

CreateTime

string

關聯的時間。存在以下兩種情況:

  • 當關聯類別型AssociationType為資源Resource時,該參數為添加資源的時間。

  • 當關聯類別型AssociationType為資源使用者Target時,該參數為添加資源使用者的時間。

2020-12-04T09:40:41.246Z

EntityType

string

關聯實體類型。取值:

  • 當關聯實體為資源時,該參數為資源類型。更多資訊,請參見支援資源共用的雲端服務

  • 當關聯實體為資源使用者時,該參數為Account

VSwitch

ResourceShareId

string

共用單元 ID。

rs-6GRmdD3X****

AssociationStatusMessage

string

關聯失敗的原因。

The reason for the association failure.

AssociationType

string

關聯類別型。取值:

  • Resource:資源。

  • Target:資源使用者。

Resource

AssociationStatus

string

關聯狀態。取值:

  • Associating:關聯中。

  • Associated:已關聯。

  • Failed:關聯失敗。

  • Disassociating:分離中。

  • Disassociated:已分離。

說明

FailedDisassociated狀態的記錄,會在 48~96 小時內被系統自動刪除。

Associating

TargetProperty

string

資源使用者屬性。例如:資源共用的時間段。

說明

僅當資源使用者為阿里雲服務時返回設定該參數。

{ "plan":{ "timeRangeType":"timeRange", "beginAtTime":"00:00", "timezone":"UTC+8", "endAtTime":"19:59" } }

EntityId

string

關聯實體 ID。取值:

  • 當關聯類別型AssociationType為資源Resource時,該參數為資源 ID。

  • 當關聯類別型AssociationType為資源使用者Target 時,該參數為資源使用者 ID。

vsw-bp183p93qs667muql****

樣本

正常返回樣本

JSON格式

{
  "RequestId": "111FB84A-60A9-403E-9067-E55D7EE95BD1",
  "ResourceShareAssociations": [
    {
      "UpdateTime": "2020-12-04T09:40:41.246Z",
      "ResourceArn": "acs:vpc:cn-shanghai:103755469187****:vswitch/vsw-uf62b11ue4m8oz2di****",
      "ResourceShareName": "test",
      "CreateTime": "2020-12-04T09:40:41.246Z",
      "EntityType": "VSwitch",
      "ResourceShareId": "rs-6GRmdD3X****",
      "AssociationStatusMessage": "The reason for the association failure.",
      "AssociationType": "Resource",
      "AssociationStatus": "Associating",
      "TargetProperty": "{\n    \"plan\":{\n        \"timeRangeType\":\"timeRange\",\n        \"beginAtTime\":\"00:00\",\n        \"timezone\":\"UTC+8\",\n        \"endAtTime\":\"19:59\"\n    }\n}",
      "EntityId": "vsw-bp183p93qs667muql****"
    }
  ]
}

錯誤碼

HTTP status code

錯誤碼

錯誤資訊

描述

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.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 ResourceAndTargetBothEmpty Either a resource or a shared target must be specified. 必須指定一個資源或一個資源使用者。
400 InvalidParameter The specified parameter is invalid. 參數無效。
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.ResourceShare The resource share does not exist in the current account. 共用單元不在當前帳號內。
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 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 the limit. 共用的資源超出單個帳號最大限制。
409 ShareWithYourself You cannot share resources with yourself. 資源使用者不能是自己。
409 AssociateConflict You cannot perform the operation while disassociation operation is being performed. 取消關聯中,不能操作關聯。
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. 同一個資源不允許重複共用給目標雲端服務。

訪問錯誤中心查看更多錯誤碼。

變更歷史

更多資訊,參考變更詳情