Subscribe to Event
Headers
Authorization: OAuth the-session-uuidBody
{
"params": {
"namespace": "ZStack/VM",
"eventName": "VMUuid",
"actions": [
{
"actionUuid": "2fbeae18082445d09c890fa076ff9fd9",
"actionType": "sns"
}
],
"labels": [
{
"key": "VMUuid",
"value": "0c60949d81964f23a0d860b30472c51b",
"op": "Equal"
}
]
},
"systemTags": [],
"userTags": []
}In the above example, the systemTags and userTags fields can be omitted. They are listed here to indicate that the body can contain these two fields.
Curl Example
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/subscriptionsParameter List
Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
namespace | String | body (contained in the params structure) | Namespace. |
| 2.3 |
eventName | String | body (contained in the params structure) | Event name. |
| 2.3 |
actions (Optional) | List | body (contained in the params structure) | Event actions. |
| 2.3 |
labels (Optional) | List | body (contained in the params structure) | Event labels. |
| 2.3 |
resourceUuid (Optional) | String | body (contained in the params structure) |
|
| 2.3 |
systemTags (Optional) | List | body | System tags. |
| 2.3 |
userTags (Optional) | List | body | User tags. |
| 2.3 |
name (Optional) | String | body (contained in the params structure) | Resource name. |
| 3.0.0 |
emergencyLevel (Optional) | String | body (contained in the params structure) | Alarm level. |
| 3.8.0 |
tagUuids (Optional) | List | body (contained in the params structure) | List of tag UUIDs. |
| 3.8.0 |
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
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()