Document navigation

Tag Operations

CreateSystemTag

API Request

URLs
POST zstack/v1/system-tags
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "resourceType": "HostVO",
    "resourceUuid": "c31d63c6d40d489e87fa7e1ee5707d47",
    "tag": "reservedMemory::1G"
  },
  "systemTags": [],
  "userTags": []
}
Note: 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":{"resourceType":"HostVO","resourceUuid":"47609e353c6f331f93ac114d06379f8d","tag":"reservedMemory::1G"}}' \
http://localhost:8080/zstack/v1/system-tags
Request Parameters
Name Type Location Description Optional Value Starting Version
resourceType String body (contained in the params structure) The resource type, which must be specified when you create a tag. 0.6
resourceUuid String body (contained in the params structure) The resource UUID. If specified, the system will not allocate randomly a UUID to the resource. 0.6
tag String body (contained in the params structure) The tag string. 0.6
systemTags List body Optional. The system tags. 0.6
userTags List body Optional. The user tags. 0.6
Note:
  • When you create a system tag in ZStack Cloud, you can specify whether to automatically uninstall the physical PCI device allocated from the device specifications when the VM instance is shut down. You can also delete or change the configurations of existing VM instances. Note that you can add the autoReleaseSpecReleatedPhysicalPciDevice option to SystemTags.
    • Format of the autoReleaseSpecReleatedPhysicalPciDevice option: autoReleaseSpecReleatedPhysicalPciDevice
    • Example: autoReleaseSpecReleatedPhysicalPciDevice
  • When you create a system tag in ZStack Cloud, you can specify whether to automatically uninstall the virtual PCI device allocated from the device specifications when the VM instance is shut down. You can also delete or change the configurations of existing VM instances. Note that you can add the autoReleaseSpecReleatedVirtualPciDevice option to SystemTags.
    • Format of the autoReleaseSpecReleatedVirtualPciDevice option: autoReleaseSpecReleatedVirtualPciDevice
    • Example: autoReleaseSpecReleatedVirtualPciDevice
  • You create system tags in ZStack Cloud to identify VM instances or VPC vRouters for which high availability policy is enabled or disabled. You can specify the resourceBindings option when you create SystemTags.
    • Format: resourceBindings::Cluster:clusterUuid
    • Example: resourceBindings::Cluster:2sdasf231jvznsdak
  • You create system tags in ZStack Cloud to identify and filter the images of HA load balancers or VPC vRouters. You can specify the applianceType option when you create SystemTags.
    • Format: applianceType::type
    • Example: applianceType::slb
  • You create system tags in ZStack Cloud to identify HA load balancers. You can specify the SlbGroupUuid option when you create SystemTags.
    • Format: SlbGroupUuid::uuid
    • Example: SlbGroupUuid::12345678
  • When you add a system tag on ZStack Cloud, you can specify a custom parameter to the boot.ipxe file by adding extraBootParams to the SystemTags option.
    • Format: extraBootParams::{custom parameter}
    • Example: extraBootParams::{acpi=noirq noapic}

API Response

Sample Response
{
  "inventory": {
    "inherent": false,
    "uuid": "55d86810cb564ecc934fa79d498b9dc3",
    "resourceType": "HostVO",
    "tag": "reservedMemory::1G",
    "type": "System",
    "createDate": "Apr 24, 2017 7:10:55 PM",
    "lastOpDate": "Apr 24, 2017 7:10:55 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 SystemTagInventory 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
inherent Boolean The inherent system tag. 0.6
uuid String The resource UUID. 0.6
resourceUuid String The resource UUID. If specified, the system will not allocate randomly a UUID to the resource. 0.6
resourceType String The resource type, which must be specified when you create a tag. 0.6
tag String The tag string. 0.6
type String The reserved field for internal use. 0.6
createDate Timestamp The creation date. 0.6
lastOpDate Timestamp The last operation date. 0.6

SDK Sample

Java SDK
CreateSystemTagAction action = new CreateSystemTagAction();
action.resourceType = "HostVO";
action.resourceUuid = "c63dfecc5c3f4f24bdab3eda92036eef";
action.tag = "reservedMemory::1G";
action.sessionId = "494209d421304d1cb9b8aaab7cac3a45";
CreateSystemTagAction.Result res = action.call();
Python SDK
CreateSystemTagAction action = CreateSystemTagAction()
action.resourceType = "HostVO"
action.resourceUuid = "d8f0bf84c4bc41c99ff7129a369515c1"
action.tag = "reservedMemory::1G"
action.sessionId = "f84ee562742b4aaab791842d71f5d472"
CreateSystemTagAction.Result res = action.call()

QuerySystemTag

API Request

URLs
GET zstack/v1/system-tags
GET zstack/v1/system-tags/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 67bf58bea6854e568556b0e9f4bc84f6" \
-X GET http://localhost:8080/zstack/v1/system-tags?q=inherent=true&q=resourceType=HostVO
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth c798e7031aaa430386636f9ff8d6bb17" \
-X GET http://localhost:8080/zstack/v1/system-tags/7c8162efed2840c08a43e0afdcebf01b

Queryable Fields

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

API Response

Sample Response
{
  "inventories": [
    {
      "inherent": false,
      "uuid": "0bba7cb618314646aea4e70b9be3bfea",
      "resourceType": "HostVO",
      "tag": "reservedMemory::1G",
      "type": "System",
      "createDate": "May 11, 2017 1:22:40 PM",
      "lastOpDate": "May 11, 2017 1:22:40 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 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
#inventories
Name Type Description Starting Version
inherent Boolean The inherent system tag. 0.6
uuid String The resource UUID. 0.6
resourceUuid String The resource UUID. If specified, the system will not allocate randomly a UUID to the resource. 0.6
resourceType String The resource type, which must be specified when you create a tag. 0.6
tag String The tag string. 0.6
type String The reserved field for internal use. 0.6
createDate Timestamp The creation date. 0.6
lastOpDate Timestamp The last operation date. 0.6

SDK Sample

Java SDK
QuerySystemTagAction action = new QuerySystemTagAction();
action.conditions = asList("inherent=true","resourceType=HostVO");
action.sessionId = "05c74fc02e574e678a407f0ccef8ae5f";
QuerySystemTagAction.Result res = action.call();
Python SDK
QuerySystemTagAction action = QuerySystemTagAction()
action.conditions = ["inherent=true","resourceType=HostVO"]
action.sessionId = "a1d2f95577514d0a918ce1502dc27e33"
QuerySystemTagAction.Result res = action.call()

UpdateSystemTag

API Request

URLs
PUT zstack/v1/system-tags/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updateSystemTag": {
    "tag": "for-large-DB"
  },
  "systemTags": [],
  "userTags": []
}
Note: 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 '{"updateSystemTag":{"tag":"for-large-DB"}}' \
http://localhost:8080/zstack/v1/system-tags/2cb4ac52794535c3ae61f9612c1579e7/actions
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 0.6
tag String body (contained in the updateSystemTag structure) The tag string. 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": {
    "inherent": false,
    "uuid": "c17377dfd0794521a4fe02b6eb16cc5a",
    "resourceType": "HostVO",
    "tag": "reservedMemory::1G",
    "type": "System",
    "createDate": "May 11, 2017 1:22:30 PM",
    "lastOpDate": "May 11, 2017 1:22:30 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 SystemTagInventory 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
inherent Boolean The inherent system tag. 0.6
uuid String The resource UUID. 0.6
resourceUuid String The resource UUID. If specified, the system will not allocate randomly a UUID to the resource. 0.6
resourceType String The resource type, which must be specified when you create a tag. 0.6
tag String The tag string. 0.6
type String The reserved field for internal use. 0.6
createDate Timestamp The creation date. 0.6
lastOpDate Timestamp The last operation date. 0.6

SDK Sample

Java SDK
UpdateSystemTagAction action = new UpdateSystemTagAction();
action.uuid = "1ba32bc1af0446b29bd969029a6052a5";
action.tag = "for-large-DB";
action.sessionId = "367f6162107a47d58c471c9164139fab";
UpdateSystemTagAction.Result res = action.call();
Python SDK
UpdateSystemTagAction action = UpdateSystemTagAction()
action.uuid = "be98b2f4e342485486cfa612eeabcaa5"
action.tag = "for-large-DB"
action.sessionId = "6b7af956a9a9477eba02753417380070"
UpdateSystemTagAction.Result res = action.call()

CreateUserTag

API Request

URLs
POST zstack/v1/user-tags
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "resourceType": "DiskOfferingVO",
    "resourceUuid": "beff527f6ccb45c8b215c59434b2fa5c",
    "tag": "for-large-DB"
  },
  "systemTags": [],
  "userTags": []
}
Note: 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":{"resourceType":"DiskOfferingVO","resourceUuid":"0a93a8d099a9339bb21b6e14a4ca3eea","tag":"for-large-DB"}}' \
http://localhost:8080/zstack/v1/user-tags
Request Parameters
Name Type Location Description Optional Value Starting Version
resourceType String body (contained in the params structure) The resource type, which must be specified when you create a tag. 0.6
resourceUuid String body (contained in the params structure) The resource UUID. If specified, the system will not allocate randomly a UUID to the resource. 0.6
tag String body (contained in the params structure) The tag string. 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": "b97c64cbf0524f809c05bf9eaf262b79",
    "resourceType": "DiskOfferingVO",
    "tag": "for-large-DB",
    "type": "User",
    "createDate": "May 11, 2017 1:22:33 PM",
    "lastOpDate": "May 11, 2017 1:22:33 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 UserTagInventory 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
resourceUuid String The resource UUID. If specified, the system will not allocate randomly a UUID to the resource. 0.6
resourceType String The resource type, which must be specified when you create a tag. 0.6
tag String The tag string. 0.6
type String The reserved field for internal use. 0.6
createDate Timestamp The creation date. 0.6
lastOpDate Timestamp The last operation date. 0.6

SDK Sample

Java SDK
CreateUserTagAction action = new CreateUserTagAction();
action.resourceType = "DiskOfferingVO";
action.resourceUuid = "824246fa21d8405fbd48ea1cc7dbf049";
action.tag = "for-large-DB";
action.sessionId = "5d9cde1f7e6a43f586ec78dedf743201";
CreateUserTagAction.Result res = action.call();
Python SDK
CreateUserTagAction action = CreateUserTagAction()
action.resourceType = "DiskOfferingVO"
action.resourceUuid = "11f5e230f43d49e69815c35fbd39bad5"
action.tag = "for-large-DB"
action.sessionId = "6301b756253c4103adbf8c891d858e5f"
CreateUserTagAction.Result res = action.call()

QueryUserTag

API Request

URLs

GET zstack/v1/user-tags
GET zstack/v1/user-tags/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/user-tags?q=resourceType=DiskOfferingVO&q=tag=for-large-DB
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/user-tags/e2a3aa3463dd382fb9e434304167f331

Queryable Fields

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

API Response

Sample Response
{
  "inventories": [
    {
      "uuid": "ae4f2dd05a513e1e8d350d448c2071a9",
      "resourceType": "DiskOfferingVO",
      "tag": "for-large-DB",
      "type": "User",
      "createDate": "Nov 14, 2017 10:20:57 PM",
      "lastOpDate": "Nov 14, 2017 10:20:57 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 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
#inventories
Name Type Description Starting Version
uuid String The resource UUID. 0.6
resourceUuid String The UUID of the associated resource. If specified, the system will not allocate randomly a UUID to the resource. 0.6
resourceType String The resource type, which must be specified when you create a tag. 0.6
tag String The tag string. 0.6
type String The reserved field for internal use. 0.6
createDate Timestamp The creation date. 0.6
lastOpDate Timestamp The last operation date. 0.6

SDK Sample

Java SDK
QueryUserTagAction action = new QueryUserTagAction();
action.conditions = asList("resourceType=DiskOfferingVO","tag=for-large-DB");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryUserTagAction.Result res = action.call();
Python SDK
QueryUserTagAction action = QueryUserTagAction()
action.conditions = ["resourceType=DiskOfferingVO","tag=for-large-DB"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryUserTagAction.Result res = action.call()

DeleteTag

API Request

URLs
DELETE zstack/v1/tags/{uuid}?deleteMode={deleteMode}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 7a2a51da1758430382624e00144e70c5" \
-X DELETE http://localhost:8080/zstack/v1/tags/1d33d909355247508cdbf9a0c0037dbe?deleteMode=Permissive
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource name. 0.6
deleteMode String body Optional. The delete mode. Options: Permissive | Enforcing. Default mode: Permissive. 0.6
systemTags List body Optional. The system tags. 0.6
userTags List body Optional. The user tags. 0.6
Note:
  • When you delete a tag in ZStack Cloud, you can specify whether to automatically uninstall the physical PCI device allocated from the device specifications when the VM instance is shut down. You can also delete or change the configurations of existing VM instances. Note that you can add the autoReleaseSpecReleatedPhysicalPciDevice option to SystemTags.
    • Format of the autoReleaseSpecReleatedPhysicalPciDevice option: autoReleaseSpecReleatedPhysicalPciDevice
    • Example: autoReleaseSpecReleatedPhysicalPciDevice
  • When you delete a tag in ZStack Cloud, you can specify whether to automatically uninstall the virtual PCI device allocated from the device specifications when the VM instance is shut down. You can also delete or change the configurations of existing VM instances. Note that you can add the autoReleaseSpecReleatedVirtualPciDevice option to SystemTags.
    • Format of the autoReleaseSpecReleatedVirtualPciDevice option: autoReleaseSpecReleatedVirtualPciDevice
    • Example: autoReleaseSpecReleatedVirtualPciDevice

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
DeleteTagAction action = new DeleteTagAction();
action.uuid = "8262e178c23140f6a4de6f0d9e6a0913";
action.deleteMode = "Permissive";
action.sessionId = "94c2bff91f834a96b691a36e47888967";
DeleteTagAction.Result res = action.call();
Python SDK
DeleteTagAction action = DeleteTagAction()
action.uuid = "86a3f5e633dd40358cab072951058ec9"
action.deleteMode = "Permissive"
action.sessionId = "87c504af0b5a484d87a5ad4ddac57baa"
DeleteTagAction.Result res = action.call()

CreateTag

API Request

URLs
POST zstack/v1/tags
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "name": "new-tag",
    "value": "new-tag",
    "description": "tag-for-volume",
    "color": "#FFFFFF",
    "type": "simple"
  },
  "systemTags": [],
  "userTags": []
}
Note: 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":"new-tag","value":"new-tag","description":"tag-for-volume","color":"#FFFFFF","type":"simple"}}' http://localhost:8080/zstack/v1/tags
Request Parameters
Name Type Location Description Optional Value Starting Version
name String body (contained in the params structure) The resource name. 3.2.0
value String body (contained in the params structure) The tag value. 3.2.0
description String body (contained in the params structure) Optional. The detailed description of the resource. 3.2.0
color String body (contained in the params structure) Optional. The tag color. 3.2.0
type String body (contained in the params structure) Optional. The tag type.
  • simple
  • withToken
3.2.0
resourceUuid String body (contained in the params structure) Optional. 3.2.0
systemTags List body Optional. 3.2.0
userTags List body Optional. 3.2.0

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
CreateTagAction action = new CreateTagAction();
action.name = "new-tag";
action.value = "new-tag";
action.description = "tag-for-volume";
action.color = "#FFFFFF";
action.type = "simple";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateTagAction.Result res = action.call();
Python SDK
CreateTagAction action = new CreateTagAction();
action.name = "new-tag";
action.value = "new-tag";
action.description = "tag-for-volume";
action.color = "#FFFFFF";
action.type = "simple";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateTagAction.Result res = action.call();

QueryTag

API Request

URLs
GET zstack/v1/tags
GET zstack/v1/tags/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/tags
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/tags/6f81ada534e3363f9e8a00caa2f48564

Queryable Fields

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

API Response

Sample Response
{
  "inventories": [
    {
      "uuid": "f7ac675964d0386b89d8df713f68aee0",
      "name": "SSD",
      "value": "SSD",
      "description": "SSD volume",
      "color": "#FFFFFF",
      "type": "simple",
      "createDate": "Nov 14, 2017 10:20:57 PM",
      "lastOpDate": "Nov 14, 2017 10:20:57 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. 3.2.0
inventories List See inventories. 3.2.0
#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. 3.2.0
description String The brief description of the error. 3.2.0
details String The details about the error. 3.2.0
elaboration String The reserved field. Default value: null. 3.2.0
opaque LinkedHashMap The reserved field. Default value: null. 3.2.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.2.0
#inventories
Name Type Description Starting Version
uuid String The resource UUID. 3.2.0
name String The resource name. 3.2.0
value String 3.2.0
description String The detailed description of the resource. 3.2.0
color String 3.2.0
createDate Timestamp The creation date. 3.2.0
lastOpDate Timestamp The last operation date. 3.2.0
type TagPatternType See type. 3.2.0
#type
Name Type Description Starting Version
name String The resource name. 3.2.0
ordinal int 3.2.0

SDK Sample

Java SDK
QueryTagAction action = new QueryTagAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryTagAction.Result res = action.call();
Python SDK
QueryTagAction action = QueryTagAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryTagAction.Result res = action.call()

UpdateTag

API Request

URLs
PUT zstack/v1/tags/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updateTag": {
    "value": "new-tag",
    "description": "tag-for-volume",
    "color": "#FFFFFF"
  },
  "systemTags": [],
  "userTags": []
}
Note: 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 '{"updateTag":{"value":"new-tag","description":"tag-for-volume","color":"#FFFFFF"}}' http://localhost:8080/zstack/v1/tags/bc54e798f6ad4b9aa6a71365271d9464/actions
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 3.2.0
name String body (contained in the updateTag structure) Optional. The resource name. 3.2.0
value String body (contained in the updateTag structure) Optional. The tag value. 3.2.0
description String body (contained in the updateTag structure) Optional. The detailed description of the resource. 3.2.0
color String body (contained in the updateTag structure) Optional. The tag color. 3.2.0
systemTags List body Optional. The system tags. 3.2.0
userTags List body Optional. The user tags. 3.2.0

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
UpdateTagAction action = new UpdateTagAction();
action.uuid = "a2bdf841dfdd48ecae5cabf44d0088e1";
action.value = "new-tag";
action.description = "tag-for-volume";
action.color = "#FFFFFF";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateTagAction.Result res = action.call();
Python SDK
UpdateTagAction action = UpdateTagAction()
action.uuid = "982dddcd308b423baf8f82a74afc4e1c"
action.value = "new-tag"
action.description = "tag-for-volume"
action.color = "#FFFFFF"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateTagAction.Result res = action.call()

AttachTagToResources

API Request

URLs
POST zstack/v1/tags/{tagUuid}/resources
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "resourceUuids": [
      "bcd0e0f674aa47298dcbdc0efeffb55d"
    ]
  },
  "systemTags": [],
  "userTags": []
}
Note: 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":{"resourceUuids":["80ed93103b624518ab0e642c6611bc0f"]}}' http://localhost:8080/zstack/v1/tags/05811acb63e34f4c9c62b19a8eb4090b/resources
Request Parameters
Name Type Location Description Optional Value Starting Version
tagUuid String url The tag UUID. 3.2.0
resourceUuids List body (contained in the params structure) The resource UUID list. 3.2.0
tokens Map body (contained in the params structure) Optional. The key and the value stored by the tag. 3.2.0
systemTags List body Optional. The system tags. 3.2.0
userTags List body Optional. The user tags. 3.2.0

API Response

Note:

After the API call succeeded, the success is returned as true. The number of successfully cloned VM instances can be returned by numberOfClonedVm. Actually, due to resource limitations, a portion of VM instances are cloned successfully, while another portion of VM instances fail to be cloned. The reason for each cloning failure is stored in the error field of inventories.

Sample Response
{
  "results": [
    {
      "inventory": {
        "tagPatternUuid": "f9060711c8453a2580f840d7aa1c5485",
        "uuid": "b2f817b3400232018956a4d2d198edc4",
        "resourceType": "DiskOfferingVO",
        "tag": "for-large-DB",
        "type": "User",
        "createDate": "Nov 14, 2017 10:20:57 PM",
        "lastOpDate": "Nov 14, 2017 10:20:57 PM"
      },
      "success": true
    }
  ]
}
Name Type Description Starting Version
success boolean 3.2.0
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 3.2.0
results List See results. 3.2.0
#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. 3.2.0
description String The brief description of the error. 3.2.0
details String The details about the error. 3.2.0
elaboration String The reserved field. Default value: null. 3.2.0
opaque LinkedHashMap The reserved field. Default value: null. 3.2.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.2.0
#results
Name Type Description Starting Version
success boolean 3.2.0
error ErrorCode See error. 3.2.0
inventory UserTagInventory See inventory. 3.2.0
#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. 3.2.0
description String The brief description of the error. 3.2.0
details String The details about the error. 3.2.0
elaboration String The reserved field. Default value: null. 3.2.0
opaque LinkedHashMap The reserved field. Default value: null. 3.2.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.2.0
#inventory
Name Type Description Starting Version
tagPatternUuid String 3.2.0
uuid String The resource UUID. 3.2.0
resourceUuid String 3.2.0
resourceType String 3.2.0
tag String 3.2.0
type String 3.2.0
createDate Timestamp The creation date. 3.2.0
lastOpDate Timestamp The last operation date. 3.2.0
tagPattern TagPatternInventory See tagPattern. 3.2.0
#tagPattern
Name Type Description Starting Version
uuid String The resource UUID. 3.2.0
name String The resource name. 3.2.0
value String 3.2.0
description String The detailed description of the resource. 3.2.0
color String 3.2.0
createDate Timestamp The creation date. 3.2.0
lastOpDate Timestamp The last operation date. 3.2.0
type TagPatternType See type. 3.2.0
#type
Name Type Description Starting Version
name String The resource name. 3.2.0
ordinal int 3.2.0

SDK Sample

Java SDK
AttachTagToResourcesAction action = new AttachTagToResourcesAction();
action.tagUuid = "6369948f4523457b87c311c550aa3e16";
action.resourceUuids = asList("ae2fdc6bbd254fcba9c36ac174c87a31");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AttachTagToResourcesAction.Result res = action.call();
Python SDK
AttachTagToResourcesAction action = AttachTagToResourcesAction()
action.tagUuid = "1e9bee8a666340fe86599fa03962af90"
action.resourceUuids = [a4bb584d6c50401c98b7535dca839ba0]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AttachTagToResourcesAction.Result res = action.call()

DetachTagFromResources

API Request

URLs
DELETE zstack/v1/tags/{tagUuid}/resources?resourceUuids={resourceUuids}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/tags/a8d23deaee2f4e7f96d11f066a180b92/resources?resourceUuids=44f7b0ec930f458c9f4e7705ad7a0cb9
Request Parameters
Name Type Location Description Optional Value Starting Version
tagUuid String url The tag UUID. 3.2.0
resourceUuids List url The resource UUID list. 3.2.0
systemTags List body Optional. The system tags. 3.2.0
userTags List body Optional. The user tags. 3.2.0

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
DetachTagFromResourcesAction action = new DetachTagFromResourcesAction();
action.tagUuid = "09f0323668dc47fdac599724f1e6eb26";
action.resourceUuids = asList("170664525bde452db0923d200ac8e57b");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DetachTagFromResourcesAction.Result res = action.call();
Python SDK
DetachTagFromResourcesAction action = DetachTagFromResourcesAction()
action.tagUuid = "ff438628636242909e58eed72696aae8"
action.resourceUuids = [7719cc49d1574d479316d43f77183899]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DetachTagFromResourcesAction.Result res = action.call()
API Reference | 5.4.12 | ZStack Cloud · ZCF | ZStack Resource Center