All Products
Search
Document Center

Resource Management:AssociateResourceShare

Last Updated:Mar 14, 2024

Associates resources or principals with a resource share.

Operation description

This topic provides an example on how to call the API operation to associate the vSwitch vsw-bp183p93qs667muql**** and the member 172050525300**** with the resource share rs-6GRmdD3X**** in the cn-hangzhou region. After the association, the vSwitch is shared with the member.

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:AssociateResourceShareWrite
  • All Resources
    *
  • resourcesharing:Target
none

Request parameters

ParameterTypeRequiredDescriptionExample
ResourceShareIdstringYes

The ID of the resource share.

rs-6GRmdD3X****
Resourcesobject []No

The information about the resources.

ResourceTypestringNo

The type of a shared resource.

Valid values of N: 1 to 5. This indicates that a maximum of five shared resources can be specified at a time.

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

Note Resources.N.ResourceId and Resources.N.ResourceType must be used in pairs.
VSwitch
ResourceIdstringNo

The ID of a shared resource.

Valid values of N: 1 to 5. This indicates that a maximum of five shared resources can be specified at a time.

Note Resources.N.ResourceId and Resources.N.ResourceType must be used in pairs.
vsw-bp183p93qs667muql****
TargetsarrayNo

The information about the principals.

stringNo

The information about a principal.

  • If the value of AllowExternalTargets for the resource share is false, the resource share supports only resource sharing within a resource directory. In this case, you can set this parameter to the ID of the resource directory, ID of a folder in the resource directory, or ID of a member in the resource directory.
  • If the value of AllowExternalTargets for the resource share is true, the resource share supports both resource sharing within a resource directory and resource sharing outside a resource directory. In this case, you can set this parameter to the ID of an independent Alibaba Cloud account, ID of the resource directory, ID of a folder in the resource directory, ID of a member in the resource directory, or the name of an Alibaba Cloud service.

For more information, see Resource sharing modes, View the ID of a resource directory, View the ID of a folder, or View the ID of a member.

Valid values of N: 1 to 5. This indicates that a maximum of five principals can be specified at a time.

172050525300****
PermissionNamesarrayNo

The information about the permissions. If you do not configure this parameter, the system automatically associates the default permission for the specified resource type with the resource share. For more information, see Permission library.

stringNo

The name of a permission. If you do not configure this parameter, the system automatically associates the default permission for the specified resource type with the resource share. For more information, see Permission library.

AliyunRSDefaultPermissionVSwitch
TargetPropertiesobject []No

The properties of the principal.

Note This parameter is available only when you specify an Alibaba Cloud service as a principal.
TargetIdstringNo

The ID of the principal.

Note TargetProperties.N.TargetId and TargetProperties.N.Property must be used in pairs.
172050525300****
PropertystringNo

The property parameter of the principal. For example, you can specify a parameter that indicates the time range for resource sharing. Valid values of timeRangeType:

  • timeRange: a specific time range
  • day: all day
Note TargetProperties.N.TargetId and TargetProperties.N.Property must be used in pairs.
{ "timeRange":{ "timeRangeType":"timeRange", "beginAtTime":"00:00", "timezone":"UTC+8", "endAtTime":"19:59" } }

Response parameters

ParameterTypeDescriptionExample
object

The returned result.

RequestIdstring

The request ID.

111FB84A-60A9-403E-9067-E55D7EE95BD1
ResourceShareAssociationsobject []

The information about the entities that are associated with the resource share.

UpdateTimestring

The time when the association of the entity was updated. The value of this parameter depends on the value of the AssociationType parameter:

  • If the value of AssociationType is Resource, the value of this parameter is the time when the association of the shared resource was updated.
  • If the value of AssociationType is Target, the value of this parameter is the time when the association of the principal was updated.
2020-12-04T09:40:41.246Z
EntityIdstring

The ID of the entity. The value of this parameter depends on the value of the AssociationType parameter:

  • If the value of AssociationType is Resource, the value of this parameter is the ID of the shared resource.
  • If the value of AssociationType is Target, the value of this parameter is the ID of the principal.
vsw-bp183p93qs667muql****
ResourceShareNamestring

The name of the resource share.

test
CreateTimestring

The time when the association of the entity was created. The value of this parameter depends on the value of the AssociationType parameter:

  • If the value of AssociationType is Resource, the value of this parameter is the time when the shared resource was associated with the resource share.
  • If the value of AssociationType is Target, the value of this parameter is the time when the principal was associated with the resource share.
2020-12-04T09:40:41.246Z
EntityTypestring

The type of the entity. The value of this parameter depends on the value of the AssociationType parameter:

  • If the value of AssociationType is Resource, the value of this parameter is the type of the shared resource. For information about the types of resources that can be shared, see Services that work with Resource Sharing.
  • If the value of AssociationType is Target, the value of this parameter is Account.
VSwitch
ResourceShareIdstring

The ID of the resource share.

rs-6GRmdD3X****
AssociationStatusMessagestring

The cause of the association failure.

The reason for the association failure.
AssociationTypestring

The association type. Valid values:

  • Resource
  • Target
Resource
AssociationStatusstring

The association status. Valid values:

  • Associating: The entity is being associated.
  • Associated: The entity is associated.
  • Failed: The entity fails to be associated.
  • Disassociating: The entity is being disassociated.
  • Disassociated: The entity is disassociated.
Note The system deletes the records of entities in the Failed or Disassociated state within 48 hours to 96 hours.
Associating
TargetPropertystring

The properties of the principal, such as the time range within which the resource is shared.

Note This parameter is returned only if the principal is an Alibaba Cloud service.
{ "plan":{ "timeRangeType":"timeRange", "beginAtTime":"00:00", "timezone":"UTC+8", "endAtTime":"19:59" } }

Examples

Sample success responses

JSONformat

{
  "RequestId": "111FB84A-60A9-403E-9067-E55D7EE95BD1",
  "ResourceShareAssociations": [
    {
      "UpdateTime": "2020-12-04T09:40:41.246Z",
      "EntityId": "vsw-bp183p93qs667muql****",
      "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}"
    }
  ]
}

Error codes

HTTP status codeError codeError messageDescription
400MissingParameter.ResourceShareIdYou must specify ResourceShareId.You must specify ResourceShareId.
400InvalidParameter.ResourceShareIdThe ResourceShareId is invalid.The ResourceShareId parameter is invalid.
400InvalidParameter.ResourcesThe Resources is invalid.The specified shared resource is invalid.
400InvalidParameter.Resources.DuplicateThe Resources contains duplicate values.The specified Resources parameter contains duplicate values.
400InvalidParameter.Resources.LengthThe maximum number of Resources exceeds 5.The number of specified shared resources cannot exceed 5.
400InvalidParameter.TargetsThe Targets is invalid.The specified Targets parameter is invalid.
400InvalidParameter.Targets.DuplicateThe Targets contains duplicate values.The specified Targets parameter contains duplicate values.
400InvalidParameter.Targets.LengthThe maximum number of Targets exceeds 5.The number of Targets values cannot exceed 5.
400InvalidTargetThe shared target does not exist in the resource directory.The specified Targets value is not a member in the resource directory.
400ResourceAndTargetBothEmptyEither a resource or a shared target must be specified.You must specify a resource or a resource account.
400InvalidParameterThe specified parameter is invalid.The specified parameter is invalid.
400InvalidParameter.ResourceTypeThe ResourceType is invalid.The specified ResourceType parameter is invalid.
400InvalidParameter.PermissionNames.DuplicateThe PermissionNames duplicate values.Duplicate values are specified for the PermissionNames parameter.
400InvalidParameter.PermissionNames.LengthThe maximum length of PermissionNames exceeds quota limit.The length of the value specified for the PermissionNames parameter exceeds the limit.
400InvalidParameter.TargetPropertiesThe TargetProperties is invalid.The TargetProperties is invalid.
400InvalidParameter.TargetProperties.DuplicateThe TargetProperties contains duplicate values.TargetProperties contains duplicate parameters.
400InvalidParameter.TargetProperties.LengthThe TargetProperties beyond the length limit.The TargetProperties beyond the length limit.
404EntityNotExists.ResourceShareThe resource share does not exist in the current account.The resource share does not exist in the current account.
404EntityNotExists.PermissionThe resource share permission does not exist.You do not have the required permissions.
409NotEnableSharingWithResourceDirectoryYou have not enabled sharing with your Resource Directory.You have not enabled sharing with Resource Directory.
409AccountNotInResourceDirectoryThe account is not a master or a member of a resource directory.The specified Targets value is not a member in the resource directory.
409ResourceShareStatusMismatchActionThe status of the resource share does not allow the specified operation.The status of the resource share does not allow the specified operation.
409QuotaExceeded.SharedResource.CountThe maximum number of shared resources per account exceeds the limit.The maximum number of Resources values per account is exceeded.
409ShareWithYourselfYou cannot share resources with yourself.You cannot share resources with yourself.
409AssociateConflictYou cannot perform the operation while disassociation operation is being performed.The association operation is not supported while an disassociation is being performed.
409NotManagementAccountOnly the management account of the service is allowed to share such resources.Only the management account of the resource directory can be used to share the current type of resource. If you still want to use the current account, contact the owner of the management account to configure the current account as a delegated administrator account of the trusted service to which the resource belongs.
409QuotaExceeded.PendingInvitationsThe maximum number of pending invitations exceeds the limit.The number of invitations exceeds the upper limit.
409InvalidTarget.LegalEntityMismatchThe target account does not have the same legal entity as the resource owner account.The enterprise name of the principal is inconsistent with that of the resource owner.
409ExternalTargetsNotAllowed.ResourceTypeThe resource share includes resource types that cannot be shared with accounts outside the resource directory.The resource share contains resources that do not support this operation.
409InvalidTarget.SiteMismatchCross-site resource sharing is not supported.The principal and resource owner are registered at different sites.
409NotSupport.Service.ExistInOtherResourceShareThe resource type has been shared to the target service through other resourceShare. Please share it in the same resourceShare.-
409NotSupport.Service.AssociateConflictThe same resource cannot be shared repeatedly to the target service.-

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-01-23The Error code has changed. The request parameters of the API has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 400
    delete Error Codes: 404
    delete Error Codes: 409
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: TargetProperties
2024-01-03The Error code has changed. The response structure of the API has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    Error Codes 400 change
    Error Codes 409 change
    delete Error Codes: 404
Output ParametersThe response structure of the API has changed.
2023-04-07The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    Error Codes 409 change
    delete Error Codes: 400
    delete Error Codes: 404
2023-04-07The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    Error Codes 409 change
    delete Error Codes: 400
    delete Error Codes: 404