Document navigation

Zone Operations

CreateZone

API Request

URLs

POST zstack/v1/zones

Headers

Authorization: OAuth the-session-uuid

Body

{
"params": {
"name": "TestZone",
"description": "test zone"
  },
"systemTags": [],
"userTags": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"TestZone","description":"test zone"}}' \
http://localhost:8080/zstack/v1/zones

Request Parameters

Name Type Location Description Optional Value Starting Version
name String body (contained in the params structure) The resource name. 0.6
description String body (contained in the params structure) Optional. The detailed description of the resource. 0.6
resourceUuid String body (contained in the params structure) Optional. The specified resource UUID. 0.6
systemTags List body Optional. The system tags. 0.6
userTags List body Optional. The user tags. 0.6

API Response

Sample Response

{
"inventory": {
"uuid": "0d26522305c34d07b5661ccda62053c0",
"name": "TestZone",
"description": "Test",
"state": "Enabled",
"type": "zstack",
"createDate": "Jun 7, 2017 9:20:28 PM",
"lastOpDate": "Jun 7, 2017 9:20:28 PM"
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 0.6
inventory ZoneInventory See inventory. 0.6

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 0.6
description String The short description of the error. 0.6
details String The details about the error. 0.6
elaboration String The reserved field. Default value: null. 0.6
opaque LinkedHashMap The reserved field. Default value: null. 0.6
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 0.6

#inventory

Name Type Description Starting Version
uuid String The resource UUID. 0.6
name String The resource name. 0.6
description String The detailed description of the resource. 0.6
state String The resource state. 0.6
type String The resource type. 0.6
createDate Timestamp The creation date. 0.6
lastOpDate Timestamp The last operation date. 0.6

SDK Sample

Java SDK

CreateZoneAction action = new CreateZoneAction();
action.name = "TestZone";
action.description = "test zone";
action.sessionId = "982a09118de64ef7a9051fde346270c5";
CreateZoneAction.Result res = action.call();

Python SDK

action = CreateZoneAction()
action.name = "TestZone"
action.description = "test zone"
action.sessionId = "79e260dca17b4bdf9b7d7b4e150883df"
res = action.call()

DeleteZone

API Request

URLs

DELETE zstack/v1/zones/{uuid}?deleteMode={deleteMode}

Headers

Authorization: OAuth the-session-uuid

Curl Sample

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 05fc0a34be264877a9dc8dfb5f90d619" \
-X DELETE http://localhost:8080/zstack/v1/zones/d3483ca440334af3acc09d8631e814c6?deleteMode=Permissive

Request Parameters

Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 0.6
deleteMode String body

Optional. The delete mode. Options: Permissive | Enforcing. Default mode: Permissive.

  • Permissive: If an error occurs, or if the delete operation is refused, ZStack Cloud will stop the delete operation. In this mode, an error code that contains the failure reason will be returned.
  • Enforcing: ZStack Cloud will ignore all errors and permissions to delete directly the resource. In this mode, the delete operation will always succeed.
0.6
systemTags List body Optional. The system tags. 0.6
userTags List body Optional. The user tags. 0.6

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes 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 Sample

Java SDK

DeleteZoneAction action = new DeleteZoneAction();
action.uuid = "8987020fccd14191a5a89dda6f3db81e";
action.deleteMode = "Permissive";
action.sessionId = "835b1b72c4554a7e92c425ad9eaebc6d";
DeleteZoneAction.Result res = action.call();

Python SDK

action = DeleteZoneAction()
action.uuid = "a4bcb439c99a42e197cac90be83e706e"
action.deleteMode = "Permissive"
action.sessionId = "6eaf02e52c884e378a3730ce4267d83a"
res = action.call()

QueryZone

API Request

URLs

GET zstack/v1/zones
GET zstack/v1/zones/{uuid}

Headers

Authorization: OAuth the-session-uuid

Curl Sample

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth e556a104ae874303897ac67d83564086" \
-X GET http://localhost:8080/zstack/v1/zones?q=name=TestZone&q=state=Enabled
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 7e9fd15bba0d43a2b1a7212c85fb8787" \
-X GET http://localhost:8080/zstack/v1/zones/9276d05c7d7545d6b61bfc50f017b86c

Queryable Fields

You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryZone, and pressing the Tab key.

API Response

Sample Response

{
"inventories": [
    {
"uuid": "a58fb4240ed04129a0896b565f24a9df",
"name": "TestZone",
"description": "Test",
"state": "Enabled",
"type": "zstack",
"createDate": "Jun 7, 2017 9:20:29 PM",
"lastOpDate": "Jun 7, 2017 9:20:29 PM"
    }
  ]
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 0.6
inventories List See inventories. 0.6

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 0.6
description String The detailed description of the error. 0.6
details String The details about the error. 0.6
elaboration String The reserved field. Default value: null. 0.6
opaque LinkedHashMap The reserved field. Default value: null. 0.6
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 0.6

#inventories

Name Type Description Starting Version
uuid String The resource UUID. 0.6
name String The resource name. 0.6
description String The detailed description of the resource. 0.6
state String The resource state. 0.6
type String The resource type. 0.6
createDate Timestamp The creation date. 0.6
lastOpDate Timestamp The last operation date. 0.6

SDK Sample

Java SDK

QueryZoneAction action = new QueryZoneAction();
action.conditions = asList("name=TestZone","state=Enabled");
action.sessionId = "608079b963b54e8a9aa3a2291adae89f";
QueryZoneAction.Result res = action.call();

Python SDK

action = QueryZoneAction()
action.conditions = ["name=TestZone","state=Enabled"]
action.sessionId = "be89929b7fd34d25a5c1a7f47f4490cd"
res = action.call()

UpdateZone

API Request

URLs

PUT zstack/v1/zones/{uuid}/actions

Headers

Authorization: OAuth the-session-uuid

Body

{
"updateZone": {
"name": "TestZone2",
"description": "test second zone"
  },
"systemTags": [],
"userTags": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateZone":{"name":"TestZone2","description":"test second zone"}}' \
http://localhost:8080/zstack/v1/zones/3fc9a2d76b043ead90c537561edcb50e/actions

Request Parameters

Name Type Location Description Optional Value Starting Version
name String body (contained in the updateZone structure) Optional. The resource name. 0.6
description String body (contained in the updateZone structure) Optional. The detailed description of the resource. 0.6
uuid String url The resource UUID. 0.6
systemTags List body Optional. The system tags. 0.6
userTags List body Optional. The user tags. 0.6

API Response

Sample Response

{
"inventory": {
"uuid": "eb5d94d030e84fb286c4f281520b163b",
"name": "TestZone",
"description": "Test",
"state": "Enabled",
"type": "zstack",
"createDate": "Jun 7, 2017 9:20:45 PM",
"lastOpDate": "Jun 7, 2017 9:20:45 PM"
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 0.6
inventory ZoneInventory See inventory. 0.6

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 0.6
description String The brief description of the error. 0.6
details String The details about the error. 0.6
elaboration String The reserved field. Default value: null. 0.6
opaque LinkedHashMap The reserved field. Default value: null. 0.6
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 0.6

#inventory

Name Type Description Starting Version
uuid String The resource UUID. 0.6
name String The resource name. 0.6
description String The detailed description of the resource. 0.6
state String The resource state. 0.6
type String The resource type. 0.6
createDate Timestamp The creation date. 0.6
lastOpDate Timestamp The last operation date. 0.6

SDK Sample

Java SDK

UpdateZoneAction action = new UpdateZoneAction();
action.name = "TestZone2";
action.description = "test second zone";
action.uuid = "e676dc07cbad45ccb96fd6033ed3c72f";
action.sessionId = "14b97d8a960b4c758389f6b6f5930210";
UpdateZoneAction.Result res = action.call();

Python SDK

action = UpdateZoneAction()
action.name = "TestZone2"
action.description = "test second zone"
action.uuid = "20ab7e6d18134e84ac5322741be661ca"
action.sessionId = "8b46ebd366c54b808c63812ecef9fff0"
res = action.call()

ChangeZoneState

API Request

URLs

PUT zstack/v1/zones/{uuid}/actions

Headers

Authorization: OAuth the-session-uuid

Body

{
"changeZoneState": {
"stateEvent": "enable"
  },
"systemTags": [],
"userTags": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"changeZoneState":{"stateEvent":"enable"}}' \
http://localhost:8080/zstack/v1/zones/af28b8e014ba35619ab68739fe72c2a3/actions

Request Parameters

Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 0.6
stateEvent String body (contained in the changeZoneState structure) The state event.
  • enable
  • disable
0.6
systemTags List body Optional. The system tags. 0.6
userTags List body Optional. The user tags. 0.6

API Response

Sample Response

{
"inventory": {
"uuid": "5ea6fdd8a3a24fa2b17b1b89ad29da6b",
"name": "TestZone",
"description": "Test",
"state": "Enabled",
"type": "zstack",
"createDate": "Jun 7, 2017 9:21:08 PM",
"lastOpDate": "Jun 7, 2017 9:21:08 PM"
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 0.6
inventory ZoneInventory See inventory. 0.6

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 0.6
description String The brief description of the error. 0.6
details String The details about the error. 0.6
elaboration String The reserved field. Default value: null. 0.6
opaque LinkedHashMap The reserved field. Default value: null. 0.6
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 0.6

#inventory

Name Type Description Starting Version
uuid String The resource UUID. 0.6
name String The resource name. 0.6
description String The detailed description of the resource. 0.6
state String The resource state. 0.6
type String The resource type. 0.6
createDate Timestamp The creation date. 0.6
lastOpDate Timestamp The last operation date. 0.6

SDK Sample

Java SDK

ChangeZoneStateAction action = new ChangeZoneStateAction();
action.uuid = "61defcb978894aec8839a099bd0eb1a2";
action.stateEvent = "enable";
action.sessionId = "166c291cd367487c9032f4f23531863c";
ChangeZoneStateAction.Result res = action.call();

Python SDK

action = ChangeZoneStateAction()
action.uuid = "8feaadcae6f847a7b7fe707d150b7fef"
action.stateEvent = "enable"
action.sessionId = "b6988f47cb2e4a13abe7b2116d3a2a78"
res = action.call()