Create Tag
Headers
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "new-tag",
"value": "new-tag",
"description": "tag-for-volume",
"color": "#FFFFFF",
"type": "simple"
},
"systemTags": [],
"userTags": []
}In the above example, the systemTags and userTags fields can be omitted. They are listed to show 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 POST -d '{"params":{"name":"new-tag","value":"new-tag","description":"tag-for-volume","color":"#FFFFFF","type":"simple"}}' http://localhost:8080/zstack/v1/tagsParameter List
Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
name | String | body (contained in the params structure) | Resource name |
| 3.2.0 |
value | String | body (contained in the params structure) | Tag value |
| 3.2.0 |
description (optional) | String | body (contained in the params structure) | Detailed description of the resource |
| 3.2.0 |
color (optional) | String | body (contained in the params structure) | Tag color |
| 3.2.0 |
type (optional) | String | body (contained in the params structure) | Tag type |
| 3.2.0 |
resourceUuid (optional) | String | body (contained in the params structure) |
|
| 3.2.0 |
systemTags (optional) | List | body |
|
| 3.2.0 |
userTags (optional) | List | body |
|
| 3.2.0 |
API Response
On success, this API returns an empty JSON structure {}. On error, 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
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();