Share Resource

PUT/zstack/v1/accounts/resources/actions

Headers

Authorization: OAuth the-session-uuid

Body

{
  "shareResource": {
    "resourceUuids": [
      "62113cf71892442daf57fe1a21606e7b",
      "e8d14f0a61d7497c83cf9451bdd392a3"
    ],
    "accountUuids": [
      "17c6a138e5f04df4ad8938fa8bd06340",
      "7063dc465e7c42739fdb5fd7d3e373f4"
    ],
    "toPublic": false
  },
  "systemTags": [],
  "userTags": []
}

In the example above, the systemTags and userTags fields are optional. They are listed to indicate that these two fields can be included in the body.

Curl Example

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"shareResource":{"resourceUuids":["05c5cdd1a5693e53ad3212a69b808883","49c6493b8eaf3765806aeb17071e779f"],"accountUuids":["62c084e3a2053b089b8b95fe452856e7","194f8c7d98963e628b9967b0df7eecae"],"toPublic":false}}' \
http://localhost:8080/zstack/v1/accounts/resources/actions

Parameter List

Name

Type

Location

Description

Allowed Values

Starting Version

resourceUuids

List

body (contained in the shareResource structure)

Resource UUID list

 

0.6

accountUuids (Optional)

List

body (contained in the shareResource structure)

Account UUID list

 

0.6

toPublic (Optional)

boolean

body (contained in the shareResource structure)

Share globallyNote: When the toPublic parameter is set to false, the account UUID list cannot be empty

 

0.6

permission (Optional)

String

body (contained in the shareResource structure)

Sharing permission. WRITE indicates write permission; READ indicates read permission

 

4.2.0

systemTags (Optional)

List

body

System tags

 

0.6

userTags (Optional)

List

body

User tags

 

0.6

API Response

On success, this API returns an empty JSON structure {}. On failure, the returned JSON structure contains an error field, for example:

{
  "error": {
    "code": "SYS.1001",
    "description": "A message or a operation timeout",
    "details": "Create VM on KVM timeout after 300s"
  }
}

SDK Examples

Java SDK

ShareResourceAction action = new ShareResourceAction();
action.resourceUuids = asList("05c5cdd1a5693e53ad3212a69b808883","49c6493b8eaf3765806aeb17071e779f");
action.accountUuids = asList("62c084e3a2053b089b8b95fe452856e7","194f8c7d98963e628b9967b0df7eecae");
action.toPublic = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ShareResourceAction.Result res = action.call();

Python SDK

ShareResourceAction action = ShareResourceAction()
action.resourceUuids = [05c5cdd1a5693e53ad3212a69b808883, 49c6493b8eaf3765806aeb17071e779f]
action.accountUuids = [62c084e3a2053b089b8b95fe452856e7, 194f8c7d98963e628b9967b0df7eecae]
action.toPublic = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ShareResourceAction.Result res = action.call()