SubscribeEvent
API Request
URLs
POST zstack/v1/zwatch/events/subscriptions
Headers
Authorization: OAuth the-session-uuid
Body
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"params": {
"namespace": "ZStack/VM",
"eventName": "VMUuid",
"actions": [
{
"actionUuid": "2fbeae18082445d09c890fa076ff9fd9",
"actionType": "sns"
}
],
"labels": [
{
"key": "VMUuid",
"value": "0c60949d81964f23a0d860b30472c51b",
"op": "Equal"
}
]
},
"systemTags": [],
"userTags": []
}

Curl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"namespace":"ZStack/VM","eventName":"VMUuid","actions":[{"actionUuid":"c7b1b7e054494aeab843a9c7371cdfc4","actionType":"sns"}],"labels":[{"key":"VMUuid","value":"47056270f2ea45409a419f1165f83945","op":"Equal"}]}}' \
http://localhost:8080/zstack/v1/zwatch/events/subscriptions
Request Parameters
Name | Type | Location | Description | Optional Value | Starting Version |
---|---|---|---|---|---|
namespace | String | body (contained in the params structure) | The namespace. | 2.3 | |
eventName | String | body (contained in the params structure) | The event name. | 2.3 | |
actions | List | body (contained in the params structure) | Optional. The event actions. | 2.3 | |
labels | List | body (contained in the params structure) | Optional. The event labels. | 2.3 | |
resourceUuid | String | body (contained in the params structure) | Optional. | 2.3 | |
systemTags | List | body | Optional. The system tags. | 2.3 | |
userTags | List | body | Optional. The user tags. | 2.3 | |
name | String | body (contained in the params structure) | Optional. The resource name. | 3.0.0 | |
emergencyLevel | String | body (contained in the params structure) | Optional. The alarm emergency level. |
|
3.8.0 |
tagUuids | List | body (contained in the params structure) | Optional. The tag UUID list. | 3.8.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
SubscribeEventAction action = new SubscribeEventAction();
action.namespace = "ZStack/VM";
action.eventName = "VMUuid";
action.actions = asList([actionUuid:08a502ad6e944ceb8c70f523b69385e3, actionType:sns]);
action.labels = asList([key:VMUuid, value:896391b873dc41288c0841b5fe8cb71b, op:Equal]);
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SubscribeEventAction.Result res = action.call();
Python
SDK
SubscribeEventAction action = SubscribeEventAction()
action.namespace = "ZStack/VM"
action.eventName = "VMUuid"
action.actions = [[actionUuid:393df28f2bab49aba01fc229dae849c8, actionType:sns]]
action.labels = [[key:VMUuid, value:abd2e73d08d248b6be73e31eb6a97e82, op:Equal]]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
SubscribeEventAction.Result res = action.call()