ZWatch Operations
Metric Operations
GetAllMetricMetadata
API Request
URLs
GET zstack/v1/zwatch/metrics/meta-data
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/zwatch/events/meta-data?name=VMHAProcess
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| name | String | query | Optional. The name of the metric. | 3.9.0 | |
| namespace | String | query | Optional. The namespace of the metric. | 3.9.0 | |
| systemTags | List | query | Optional. The system tags. | 2.3 | |
| userTags | List | query | Optional. The system tags. | 2.3 |
API Response
Sample Response
{
"metrics": [
{
"namespace": "ZStack/VM",
"name": "org.zstack.zwatch.datatype.Metric@4efa6b58",
"description": "CPUIdleUtilization",
"labelNames": [
"VMUuid",
"CPUNum"
],
"driver": "PrometheusDatabaseDriver"
}
]
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.3 |
| metrics | List | See metrics. | 2.3 |
#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 |
#metrics
| Name | Type | Description | Starting Version |
|---|---|---|---|
| namespace | String | The namespace. | 2.3 |
| name | String | The resource name. | 2.3 |
| description | String | The description of the metric. | 3.9.0 |
| labelNames | List | The label names. | 2.3 |
SDK Sample
Java SDK
GetAllMetricMetadataAction action = new GetAllMetricMetadataAction();
action.name = "VMHAProcess";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetAllMetricMetadataAction.Result res = action.call();
Python SDK
action = GetAllMetricMetadataAction()
action.name = "VMHAProcess"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
GetMetricLabelValue
API Request
URLs
GET zstack/v1/zwatch/metrics/label-values
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/zwatch/metrics/label-values?namespace=ZStack/VM&metricName=CPUIdleUtilization&startTime=1.58806818E9&endTime=1.58806824E9&labelNames=CPUNum&filterLabels=VMUuid=e47f7145f4cd4fca8e2856038ecdf3e1
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| namespace | String | query | The namespace. | 2.3 | |
| metricName | String | query | The metric name. | 2.3 | |
| labelNames | List | query | The name list of the target labels. | 2.3 | |
| filterLabels | List | query | Optional. The label filter list. For example, you can set the HostUuid label to e47f7145f4cd4fca8e2856038ecdf3e1 to filter values specified in labelNames. | 2.3 | |
| startTime | Long | query | Optional. The start time. | 3.9.0 | |
| endTime | Long | query | Optional. The end time. | 3.9.0 | |
| systemTags | List | query | Optional. The system tags. | 2.3 | |
| userTags | List | query | Optional. The user tags. | 2.3 |
API Response
Sample Response
{
"labels": [
{
"VMUuid": "e47f7145f4cd4fca8e2856038ecdf3e1",
"CPUNum": "1"
}
]
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| labels | List | The label values. | 0.6 |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 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 |
SDK Sample
Java SDK
GetMetricLabelValueAction action = new GetMetricLabelValueAction();
action.namespace = "ZStack/VM";
action.metricName = "CPUIdleUtilization";
action.startTime = 1.58806818E9;
action.endTime = 1.58806824E9;
action.labelNames = asList("CPUNum");
action.filterLabels = asList("VMUuid=e47f7145f4cd4fca8e2856038ecdf3e1");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetMetricLabelValueAction.Result res = action.call();
Python SDK
action = GetMetricLabelValueAction()
action.namespace = "ZStack/VM"
action.metricName = "CPUIdleUtilization"
action.startTime = 1.58806818E9
action.endTime = 1.58806824E9
action.labelNames = [CPUNum]
action.filterLabels = [VMUuid=e47f7145f4cd4fca8e2856038ecdf3e1]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
GetMetricData
API Request
URLs
GET zstack/v1/zwatch/metrics
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/zwatch/metrics?namespace=ZStack/VM&metricName=CPUIdleUtilization&startTime=1.588831825415E12&period=30.0&labels=VMUuid=b89391d8b93b470a99055001a4383cc7&labels=CPUNum=4
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| namespace | String | query | The namespace. | 2.3 | |
| metricName | String | query | The metric name. | 2.3 | |
| startTime | Long | query | Optional. The start time. | 2.3 | |
| endTime | Long | query | Optional. The end time. | 2.3 | |
| period | Integer | query | Optional. The interval for returning data. | 2.3 | |
| labels | List | query | Optional. The filter labels. | 2.3 | |
| systemTags | List | query | Optional. The system tags. | 2.3 | |
| userTags | List | query | Optional. The user tags. | 2.3 | |
| functions | List | query | Optional. The function list. | 2.3 | |
| offsetAheadOfCurrentTime | Long | query | Optional. | 2.3 |
API Response
Sample Response
{
"data": [
{
"value": 101.02,
"time": 1.519829245957E12,
"labels": {
"VMUuid": "9304ab73d9b84852ad1d5061fd4760a5"
}
}
]
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.3 |
| data | List | See data. | 2.3 |
#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 |
#data
| Name | Type | Description | Starting Version |
|---|---|---|---|
| value | double | The metric value. | 0.6 |
| time | long | The time when the record was generated. | 0.6 |
| labels | Map | The label values. | 0.6 |
SDK Sample
Java SDK
GetMetricDataAction action = new GetMetricDataAction();
action.namespace = "ZStack/VM";
action.metricName = "CPUIdleUtilization";
action.startTime = 1.519829246005E12;
action.period = 30.0;
action.labels = asList("VMUuid=3bb5b754320a4331bd907f10d8683568","CPUNum=4");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetMetricDataAction.Result res = action.call();
Python SDK
action = GetMetricDataAction()
action.namespace = "ZStack/VM"
action.metricName = "CPUIdleUtilization"
action.startTime = 1.519829246005E12
action.period = 30.0
action.labels = [VMUuid=b577cfe6aad447c1b2e793fdc6d7975b, CPUNum=4]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
PutMetricData
API Request
URLs
POST zstack/v1/zwatch/metrics
Headers
Authorization: OAuth the-session-uuid
Body
{
"params": {
"namespace": "MyNameSpace",
"data": [
{
"metricName": "UserDefinedName",
"value": 100.01,
"labels": {
"label1": "value1"
}
}
]
},
"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":{"namespace":"MyNameSpace","data":[{"metricName":"UserDefinedName","value":100.01,"labels":{"label1":"value1"}}]}}' \
http://localhost:8080/zstack/v1/zwatch/metrics
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| namespace | String | body (contained in the params structure) | The custom namespace. | 2.3 | |
| data | List | body (contained in the params structure) | The data. | 2.3 | |
| systemTags | List | body | Optional. The system tags. | 2.3 | |
| userTags | List | body | Optional. The user tags. | 2.3 |
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
PutMetricDataAction action = new PutMetricDataAction();
action.namespace = "MyNameSpace";
action.data = asList([metricName:UserDefinedName, value:100.01, labels:[label1:value1]]);
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
PutMetricDataAction.Result res = action.call();
Python SDK
action = PutMetricDataAction()
action.namespace = "MyNameSpace"
action.data = [[metricName:UserDefinedName, value:100.01, labels:[label1:value1]]]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
Event Operations
GetAllEventMetadata
API Request
URLs
GET zstack/v1/zwatch/events/meta-data
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/zwatch/events/meta-data
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| name | String | query | Optional. The name of the event. | 3.9.0 | |
| namespace | String | query | Optional. The namespace of the event. | 3.9.0 | |
| systemTags | List | query | Optional. The system tags. | 0.6 | |
| userTags | List | query | Optional. The user tags. | 0.6 |
API Response
Sample Response
{
"events": [
{
"namespace": "ZStack/VM",
"name": "org.zstack.zwatch.datatype.EventFamily@631b5229",
"description": "VMHAProcess",
"labelNames": [
"HAProcess",
"HADetails"
]
}
]
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.3 |
| events | List | See events. | 2.3 |
#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 |
#events
| Name | Type | Description | Starting Version |
|---|---|---|---|
| namespace | String | The namespace. | 2.3 |
| name | String | The resource name. | 2.3 |
| description | String | The description of the event. | 3.9.0 |
| labelNames | List | The label names. | 2.3 |
SDK Sample
Java SDK
GetAllEventMetadataAction action = new GetAllEventMetadataAction();
action.name = "VMHAProcess";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetAllEventMetadataAction.Result res = action.call();
Python SDK
action = GetAllEventMetadataAction()
action.name = "VMHAProcess"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
GetEventData
API Request
URLs
GET zstack/v1/zwatch/events
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/zwatch/events?startTime=1.596444516295E12&limit=10.0&conditions=HostUuid=99ca12b945a8489c93a3412cbc744193&count=false&start=0.0
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| startTime | Long | query | Optional. The start time. | 2.3 | |
| endTime | Long | query | Optional. The end time. | 2.3 | |
| limit | Integer | query | Optional. The maximum number of returned items. | 2.3 | |
| offsetAheadOfCurrentTime | Long | query | Optional. The offset (in milliseconds) between the query time and the current time. Note that the query time is earlier than the current time. For example, if you query messages collected in the last one hour, 3600000 (the offset) will be transferred to the system. | 3.3.0 | |
| conditions | List | query | Optional. The filter conditions. | 3.3.0 | |
| count | boolean | query | Optional. Whether to query the number of events. | 3.3.0 | |
| endpointUuid | String | query | Optional. Endpoint UUID. | 3.3.0 | |
| systemTags | List | query | Optional. The system tags. | 2.3 | |
| userTags | List | query | Optional. The system tags. | 2.3 |
API Response
Sample Response
{
"events": [
{
"namespace": "ZStack/VM",
"name": "org.zstack.zwatch.datatype.EventFamily@2c24d960",
"labels": {},
"emergencyLevel": "Normal",
"resourceId": "b7bbe5fb9ab049c5a36bf8a646471cff",
"resourceName": "VmInstanceVO",
"time": 1.596444516324E12
}
]
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| total | Long | The number of the events. | 3.3.0 |
| success | boolean | Whether the operation succeeded. | 3.3.0 |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.3 |
| events | List | See events. | 2.3 |
#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. | 2.3 |
| description | String | The brief description of the error. | 2.3 |
| details | String | The details about the error. | 2.3 |
| elaboration | String | The reserved field. Default value: null. | 2.3 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.3 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.3 |
#events
| Name | Type | Description | Starting Version |
|---|---|---|---|
| namespace | String | The namespace. | 2.3 |
| name | String | The event name. | 2.3 |
| labels | Map | The labels. | 2.3 |
| resourceId | String | The UUID of the resource whose event was generated. If not null, the corresponding alarming messages for the associated resources are triggered. | 2.3 |
| resourceName | String | The resource name. | 2.3 |
| error | String | If the event means the error, this field is the details about the error. | 2.3 |
| time | long | The time when the event was triggered. | 2.3 |
| dataUuid | String | The data UUID. | 3.3 |
| accountUuid | String | The account UUID. | 3.3 |
| emergencyLevel | EmergencyLevel | See emergencyLevel. | 2.3 |
#emergencyLevel
| Name | Type | Description | Starting Version |
|---|---|---|---|
| name | String | The resource name. | 2.3 |
| ordinal | int | The ordinal number. | 2.3 |
#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. | 2.3 |
| description | String | The brief description of the error. | 2.3 |
| details | String | The details about the error. | 2.3 |
| elaboration | String | The reserved field. Default value: null. | 2.3 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.3 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.3 |
SDK Sample
Java SDK
GetEventDataAction action = new GetEventDataAction();
action.startTime = 1.596444516404E12;
action.limit = 10.0;
action.conditions = asList("HostUuid=00d80d7c47124d6d8e2c7736e9af1c34");
action.count = false;
action.start = 0.0;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetEventDataAction.Result res = action.call();
Python SDK
action = GetEventDataAction()
action.startTime = 1.596444516405E12
action.limit = 10.0
action.conditions = [HostUuid=7581302347d0439fbdde32b914e2449a]
action.count = false
action.start = 0.0
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
UpdateEventData
API Request
URLs
PUT zstack/v1/zwatch/events/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
"updateEventData": {
"dataUuid": "a24e9918fdf83d0aae19846bd52411e4",
"updateMode": "OnlyOne",
"readStatus": "Read"
},
"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 '{"updateEventData":{"dataUuid":"a24e9918fdf83d0aae19846bd52411e4","updateMode":"OnlyOne","readStatus":"Read"}}' http://localhost:8080/zstack/v1/zwatch/events/actions
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| dataUuid | String | body (contained in the updateEventData structure) | Optional. The start time of the target messages. Make sure that InRange is transferred to updateMode. | 3.3.0 | |
| dataStartTime | Long | body (contained in the updateEventData structure) | Optional. The start time of the target messages. Make sure that InRange is transferred to updateMode. | 3.3.0 | |
| dataEndTime | Long | body (contained in the updateEventData structure) | Optional. The end time of the target messages. Make sure that InRange is transferred to updateMode. | 3.3.0 | |
| updateMode | String | body (contained in the updateEventData structure) | The range of the target messages to be updated. Options:
|
|
3.3.0 |
| readStatus | String | body (contained in the updateEventData structure) | Optional. The read status of the updated messages. |
|
3.3.0 |
| systemTags | List | body | Optional. The system tags. | 3.3.0 | |
| userTags | List | body | Optional. The user tags. | 3.3.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
UpdateEventDataAction action = new UpdateEventDataAction();
action.dataUuid = "a24e9918fdf83d0aae19846bd52411e4";
action.updateMode = "OnlyOne";
action.readStatus = "Read";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateEventDataAction.Result res = action.call();
Python SDK
action = UpdateEventDataAction()
action.dataUuid = "a24e9918fdf83d0aae19846bd52411e4"
action.updateMode = "OnlyOne"
action.readStatus = "Read"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
QueryEventRecord
API Request
URLs
GET zstack/v1/zwatch/event-records
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/zwatch/event-records?q=dataUuid=bcb5816592553e04a101e37c69d1837a
Queryable Fields
You can check all queryable fields and resource names that can be queried across tables by using the CLI tool, entering QueryEventRecord, and pressing the Tab key.
API Response
Sample Response
{
"inventories": [
{
"id": 1.0,
"createTime": 1.510669257141E12,
"namespace": "ZStack/PrimaryStorage",
"name": "PrimaryStorageDisconnected",
"emergencyLevel": "Emergent",
"resourceId": "ff1d1d9429da35cfb3d4dfad772d0f3a",
"dataUuid": "64f3d04e7144348db07585dfc9293582",
"accountUuid": "1f2c621ce02d37268da28bb368f6b265",
"subscriptionUuid": "e30c7668d9c13585915da7e6442f6749",
"readStatus": true,
"labels": "{\"Error\":\"No Host state is Enabled, Please check the availability of the host\"}"
}
]
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 4.1.0 |
| inventories | List | See inventories. | 4.1.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. | 4.1.0 |
| description | String | The brief description of the error. | 4.1.0 |
| details | String | The details about the error. | 4.1.0 |
| elaboration | String | The reserved field. Default value: null. | 4.1.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 4.1.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. | 4.1.0 |
#inventories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| time | long | The time. | 4.1.0 |
| count | long | The count. | 4.1.0 |
| id | long | The message ID. | 4.1.0 |
| createTime | long | The creation date. | 4.1.0 |
| namespace | String | The namespace. | 4.1.0 |
| name | String | The name. | 4.1.0 |
| emergencyLevel | String | The emergency level of an alarm. | 4.1.0 |
| resourceId | String | The resource UUID. | 4.1.0 |
| error | String | The error information. | 4.1.0 |
| dataUuid | String | The message UUID. | 4.1.0 |
| accountUuid | String | The account UUID. | 4.1.0 |
| subscriptionUuid | String | The event alarm UUID. | 4.1.0 |
| readStatus | Boolean | The read status. | 4.1.0 |
| labels | String | The labels. | 4.1.0 |
SDK Sample
Java SDK
QueryEventRecordAction action = new QueryEventRecordAction();
action.conditions = asList("dataUuid=1e5badf2a4a43bae91b16dbd1aee0c0b");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryEventRecordAction.Result res = action.call();
Python SDK
action = QueryEventRecordAction()
action.conditions = ["dataUuid=60290f65736a317cb52b0721d90ce315"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
Alarm Operations
CreateAlarm
API Request
URLs
POST zstack/v1/zwatch/alarms
Headers
Authorization: OAuth the-session-uuid
Body
{
"params": {
"name": "VM CPU Alarm",
"comparisonOperator": "LessThanOrEqualTo",
"period": 60.0,
"namespace": "ZStack/VM",
"metricName": "org.zstack.zwatch.datatype.Metric@c2e79f0",
"threshold": 60.0,
"repeatInterval": 1800.0,
"enableRecovery": true,
"labels": [
{
"key": "VMUuid",
"value": "c38c7d80b66b4db0a607f80c9e8676a0",
"op": "Equal"
}
],
"actions": [
{
"actionUuid": "0d0f8958cdb04b1294fb04169c06a096",
"actionType": "sns"
}
],
"repeatCount": -1.0,
"type": "Any"
},
"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":"VM CPU Alarm","comparisonOperator":"LessThanOrEqualTo","period":60.0,"namespace":"ZStack/VM","metricName":"org.zstack.zwatch.datatype.Metric@565e1ebe","threshold":60.0,"repeatInterval":1800.0,"enableRecovery":true,"labels":[{"key":"VMUuid","value":"85b0dc413b5040d18d6726f6ae515c42","op":"Equal"}],"actions":[{"actionUuid":"eb00cb48ff0148cbb5358cad4f6f94a0","actionType":"sns"}]"repeatCount":-1.0,"type":"Any"}}' http://localhost:8080/zstack/v1/zwatch/alarms
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| name | String | body (contained in the params structure) | The resource name. | 2.3 | |
| description | String | body (contained in the params structure) | Optional. The detailed description of the resource. | 2.3 | |
| comparisonOperator | String | body (contained in the params structure) | The threshold comparison operator. |
|
2.3 |
| period | Integer | body (contained in the params structure) | The threshold duration. | 2.3 | |
| namespace | String | body (contained in the params structure) | The namespace. | 2.3 | |
| metricName | String | body (contained in the params structure) | The metric name. | 2.3 | |
| threshold | Double | body (contained in the params structure) | The threshold. | 2.3 | |
| repeatInterval | Integer | body (contained in the params structure) | Optional. The alarm repeat interval. | 2.3 | |
| labels | List | body (contained in the params structure) | Optional. The label list. | 2.3 | |
| actions | List | body (contained in the params structure) | Optional. The alarm action list. | 2.3 | |
| resourceUuid | String | body (contained in the params structure) | Optional. | 2.3 | |
| repeatCount | Integer | body (contained in the params structure) | Optional. The alarm repeat count. | 3.3.0 | |
| type | String | body (contained in the params structure) | Optional. The alarm type. | 3.3.0 | |
| systemTags | List | body | Optional. The system tags. | 2.3 | |
| userTags | List | body | Optional. The user tags. | 2.3 | |
| enableRecovery | Boolean | body (contained in the params structure) | Whether to enable the recovery notification. | 3.4.0 | |
| emergencyLevel | String | body (contained in the params structure) | Optional. The alarm emergency level. |
|
3.8.0 |
API Response
Sample Response
{
"inventory": {
"uuid": "6ff094db7e8b4640880751c5a17e7b63",
"name": "VM CPU Alarm",
"comparisonOperator": "LessThanOrEqualTo",
"period": 60.0,
"namespace": "ZStack/VM",
"metricName": "org.zstack.zwatch.datatype.Metric@c2e79f0",
"threshold": 30.0,
"repeatInterval": 1800.0,
"repeatCount": -1.0,
"status": "Alarm",
"state": "Enabled",
"enableRecovery": true,
"createDate": "Jul 6, 2018 1:51:02 PM",
"lastOpDate": "Jul 6, 2018 1:51:02 PM",
"labels": [
{
"uuid": "cccd980c3bb84f4486d96a960eb08edb",
"key": "VMUuid",
"operator": "\u003d",
"value": "f486fd81583747459d8a6cd47f9228e5"
}
],
"actions": [
{
"alarmUuid": "8a6a98e3cc484388a746d725265886b3",
"actionType": "sns",
"actionUuid": "86a2b51fbc7f406c906711081852fa49"
}
]
}
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.3 |
| inventory | AlarmInventory | See inventory. | 2.3 |
#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. | 2.3 |
| description | String | The brief description of the error. | 2.3 |
| details | String | The details about the error. | 2.3 |
| elaboration | String | The reserved field. Default value: null. | 2.3 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.3 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.3 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.3 |
| name | String | Th resource name. | 2.3 |
| description | String | The detailed description of the resource. | 2.3 |
| period | Integer | The threshold duration. | 2.3 |
| namespace | String | The namespace. | 2.3 |
| metricName | String | The metric name. | 2.3 |
| threshold | Double | The threshold. | 2.3 |
| repeatInterval | Integer | The alarm repeat interval. | 2.3 |
| enableRecovery | Boolean | Whether to enable the recovery notification. | 3.4.0 |
| createDate | Timestamp | The creation date. | 2.3 |
| lastOpDate | Timestamp | The last operation date. | 2.3 |
| comparisonOperator | ComparisonOperator | See comparisonOperator. | 2.3 |
| status | AlarmStatus | See status. | 2.3 |
| labels | List | See labels. | 2.3 |
| actions | List | See actions. | 2.3 |
#comparisonOperator
| Name | Type | Description | Starting Version |
|---|---|---|---|
| name | String | The resource name. | 2.3 |
| ordinal | int | The ordinal number. | 2.3 |
#status
| Name | Type | Description | Starting Version |
|---|---|---|---|
| OK | AlarmStatus | The alarm is in normal status. | 2.3 |
| Alarm | AlarmStatus | The alarm is triggered. | 2.3 |
| InsufficientData | AlarmStatus | The data is insufficient. | 2.3 |
#labels
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.3 |
| key | String | The label key. | 2.3 |
| operator | String | The comparison operator. | 2.3 |
| value | String | The label value. | 2.3 |
#actions
| Name | Type | Description | Starting Version |
|---|---|---|---|
| alarmUuid | String | The alarm UUID. | 2.3 |
| actionType | String | The action type. | 2.3 |
| actionUuid | String | The action UUID. | 2.3 |
SDK Sample
Java SDK
CreateAlarmAction action = new CreateAlarmAction();
action.name = "VM CPU Alarm";
action.comparisonOperator = "LessThanOrEqualTo";
action.period = 60.0;
action.namespace = "ZStack/VM";
action.metricName = "org.zstack.zwatch.datatype.Metric@c2e79f0";
action.threshold = 60.0;
action.repeatInterval = 1800.0;
action.labels = asList([key:VMUuid, value:45821a26f579447fa77bfb82b1b0268e, op:Equal]);
action.actions = asList([actionUuid:8e06ec09862c46c3aaf9fc6337815ffb, actionType:sns]);
action.repeatCount = -1.0;
action.type = "Any";
action.enableRecovery = true;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateAlarmAction.Result res = action.call();
Python SDK
action = CreateAlarmAction()
action.name = "VM CPU Alarm"
action.comparisonOperator = "LessThanOrEqualTo"
action.period = 60.0
action.namespace = "ZStack/VM"
action.metricName = "org.zstack.zwatch.datatype.Metric@c2e79f0"
action.threshold = 60.0
action.repeatInterval = 1800.0
action.labels = [[key:VMUuid, value:7dd44bfe750f42859528b27ef90f1412, op:Equal]]
action.actions = [[actionUuid:b1acb139666140d09f4f93b8dd96f49f, actionType:sns]]
action.repeatCount = -1.0
action.type = "Any"
action.enableRecovery = true
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
DeleteAlarm
API Request
URLs
DELETE zstack/v1/zwatch/alarms/{uuid}
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/zwatch/alarms/2aae360b1240374696d79a0cca10bf24
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 2.3 | |
| deleteMode | String | body | Optional. | 2.3 | |
| systemTags | List | body | Optional. The system tags. | 2.3 | |
| userTags | List | body | Optional. The user tags. | 2.3 |
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
DeleteAlarmAction action = new DeleteAlarmAction();
action.uuid = "2aae360b1240374696d79a0cca10bf24";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteAlarmAction.Result res = action.call();
Python SDK
action = DeleteAlarmAction()
action.uuid = "2aae360b1240374696d79a0cca10bf24"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
UpdateAlarm
API Request
URLs
PUT zstack/v1/zwatch/alarms/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
"updateAlarm": {
"name": "VM CPU Alarm",
"comparisonOperator": "LessThanOrEqualTo",
"period": 60.0,
"enableRecovery": true
},
"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 '{"updateAlarm":{"name":"VM CPU Alarm","comparisonOperator":"LessThanOrEqualTo","period":60.0,"enableRecovery":true}}' http://localhost:8080/zstack/v1/zwatch/alarms/28397feb3d083fdc9346edb066fbf589/actions
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 2.3 | |
| name | String | body (contained in the updateAlarm structure) | Optional. The resource name. | 2.3 | |
| description | String | body (contained in the updateAlarm structure) | Optional. The detailed description of the resource. | 2.3 | |
| comparisonOperator | String | body (contained in the updateAlarm structure) | Optional. The threshold comparison operator. |
|
2.3 |
| period | Integer | body (contained in the updateAlarm structure) | Optional. The threshold duration. | 2.3 | |
| threshold | Double | body (contained in the updateAlarm structure) | Optional. The threshold. | 2.3 | |
| repeatInterval | Integer | body (contained in the updateAlarm structure) | Optional. The alarm repeat interval. | 2.3 | |
| repeatCount | Integer | body (contained in the updateAlarm structure) | Optional. The alarm repeat count. | 3.3.0 | |
| systemTags | List | body | Optional. The system tags. | 2.3 | |
| userTags | List | body | Optional. The user tags. | 2.3 | |
| repeatCount | Integer | body (contained in the updateAlarm structure) | Optional. The alarm repeat count. | 3.2 | |
| enableRecovery | Boolean | body (contained in the updateAlarm structure) | Optional. Whether to enable the recovery notification. | 3.4.0 | |
| emergencyLevel | String | body (contained in the updateAlarm structure) | The alarm emergency level. |
|
3.8.0 |
API Response
Sample Response
{
"inventory": {
"uuid": "33e642a1eb3c4f27a7da7acc5891de0a",
"name": "VM CPU Alarm",
"comparisonOperator": "LessThanOrEqualTo",
"period": 60.0,
"namespace": "ZStack/VM",
"metricName": "org.zstack.zwatch.datatype.Metric@22c0dd63",
"threshold": 30.0,
"repeatInterval": 1800.0,
"repeatCount": -1.0,
"status": "Alarm",
"state": "Enabled",
"createDate": "Jan 8, 2019 4:11:27 PM",
"lastOpDate": "Jan 8, 2019 4:11:27 PM",
"labels": [
{
"uuid": "c4da2db2fa454368a3a05016ae8c8070",
"key": "VMUuid",
"operator": "\u003d",
"value": "396d863211e446938ea01eb10bc9fd18"
}
],
"actions": [
{
"alarmUuid": "0d18a844bbf544bb914ab9287651f59f",
"actionType": "sns",
"actionUuid": "17b884822b284e6e9a0b67307a28955c"
}
]
}
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.3 |
| inventory | AlarmInventory | See inventory. | 2.3 |
#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. | 2.3 |
| description | String | The brief description of the error. | 2.3 |
| details | String | The details about the error. | 2.3 |
| elaboration | String | The reserved field. Default value: null. | 2.3 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.3 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.3 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.3 |
| name | String | Th resource name. | 2.3 |
| description | String | The detailed description of the resource. | 2.3 |
| period | Integer | The threshold duration. | 2.3 |
| namespace | String | The namespace. | 2.3 |
| metricName | String | The metric name. | 2.3 |
| threshold | Double | The threshold. | 2.3 |
| repeatInterval | Integer | The alarm repeat interval. | 2.3 |
| enableRecovery | Boolean | Whether to enable the recovery notification. | 3.4.0 |
| createDate | Timestamp | The creation date. | 2.3 |
| lastOpDate | Timestamp | The last operation date. | 2.3 |
| comparisonOperator | ComparisonOperator | See comparisonOperator. | 2.3 |
| status | AlarmStatus | See status. | 2.3 |
| labels | List | See labels. | 2.3 |
| actions | List | See actions. | 2.3 |
#comparisonOperator
| Name | Type | Description | Starting Version |
|---|---|---|---|
| name | String | The resource name. | 2.3 |
| ordinal | int | The ordinal number. | 2.3 |
#status
| Name | Type | Description | Starting Version |
|---|---|---|---|
| OK | AlarmStatus | The alarm is in normal status. | 2.3 |
| Alarm | AlarmStatus | The alarm is triggered. | 2.3 |
| InsufficientData | AlarmStatus | The data is insufficient. | 2.3 |
#labels
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.3 |
| key | String | The label key. | 2.3 |
| operator | String | The comparison operator. | 2.3 |
| value | String | The label value. | 2.3 |
#actions
| Name | Type | Description | Starting Version |
|---|---|---|---|
| alarmUuid | String | The alarm UUID. | 2.3 |
| actionType | String | The action type. | 2.3 |
| actionUuid | String | The action UUID. | 2.3 |
SDK Sample
Java SDK
UpdateAlarmAction action = new UpdateAlarmAction();
action.uuid = "28397feb3d083fdc9346edb066fbf589";
action.name = "VM CPU Alarm";
action.comparisonOperator = "LessThanOrEqualTo";
action.period = 60.0;
action.enableRecovery = true;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateAlarmAction.Result res = action.call();
Python SDK
action = UpdateAlarmAction()
action.uuid = "28397feb3d083fdc9346edb066fbf589"
action.name = "VM CPU Alarm"
action.comparisonOperator = "LessThanOrEqualTo"
action.period = 60.0
action.enableRecovery = true
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
UpdateSubscribeEvent
API Request
URLs
PUT zstack/v1/zwatch/events/subscriptions/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
"updateSubscribeEvent": {
"emergencyLevel": "Emergent"
},
"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 '{"updateSubscribeEvent":{"emergencyLevel":"Emergent"}}' http://localhost:8080/zstack/v1/zwatch/events/subscriptions/37fc1fcc0fa93fb493702469039edbfb/actions
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | Optional. The event alarm UUID. | 3.8.0 | |
| emergencyLevel | String | body (contained in the updateSubscribeEvent structure) | Optional. The alarm emergency level. |
|
3.8.0 |
| systemTags | List | body | Optional. | 3.8.0 | |
| userTags | List | body | Optional. | 3.8.0 |
API Response
Sample Response
{
"inventory": {
"uuid": "d1b38b37691948218df07900a2c1c065",
"name": "vm_state_change_event",
"namespace": "ZStack/VM",
"eventName": "org.zstack.zwatch.datatype.EventFamily@35324244",
"state": "Enabled",
"actions": [
{
"subscriptionUuid": "30d1075270c94f6e9312c1a4404cc67a",
"actionType": "sns",
"actionUuid": "33308113390a472286df32a99cd477ef"
}
],
"labels": [
{
"uuid": "26246baade39495c99d018d826ae576e",
"key": "DestinationHostUuid",
"operator": "Equal",
"value": "79e249b6995a4c819d8e6cd33798135a"
}
],
"lastOpDate": "Jan 11, 2020 11:48:35 PM",
"createDate": "Jan 11, 2020 11:48:35 PM",
"emergencyLevel": "Emergent"
}
}
| 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.8.0 |
| inventory | EventSubscriptionInventory | See inventory. | 3.8.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.8.0 |
| description | String | The brief description of the error. | 3.8.0 |
| details | String | The details about the error. | 3.8.0 |
| elaboration | String | The reserved field. Default value: null. | 3.8.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 3.8.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.8.0 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 3.8.0 |
| name | String | The resource name. | 3.8.0 |
| namespace | String | The namespace. | 3.8.0 |
| eventName | String | The event name. | 3.8.0 |
| lastOpDate | Timestamp | The last operation date. | 3.8.0 |
| createDate | Timestamp | The creation date. | 3.8.0 |
| emergencyLevel | String | The arm emergency level. | 3.8.0 |
| state | EventSubscriptionState | See state. | 3.8.0 |
| actions | List | See actions. | 3.8.0 |
| labels | List | See labels. | 3.8.0 |
#state
| Name | Type | Description | Starting Version |
|---|---|---|---|
| name | String | The resource name. | 3.8.0 |
| ordinal | int | The ordinal number. | 3.8.0 |
#actions
| Name | Type | Description | Starting Version |
|---|---|---|---|
| subscriptionUuid | String | The event subscription UUID. | 3.8.0 |
| actionType | String | The action type. | 3.8.0 |
| actionUuid | String | The action UUID. | 3.8.0 |
#labels
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 3.8.0 |
| key | String | The label key. | 3.8.0 |
| value | String | The label value. | 3.8.0 |
| operator | Operator | See operator. | 3.8.0 |
#operator
| Name | Type | Description | Starting Version |
|---|---|---|---|
| op | String | The op. | 3.8.0 |
| name | String | The resource name. | 3.8.0 |
| ordinal | int | The ordinal number. | 3.8.0 |
SDK Sample
Java SDK
UpdateSubscribeEventAction action = new UpdateSubscribeEventAction();
action.uuid = "37fc1fcc0fa93fb493702469039edbfb";
action.emergencyLevel = "Emergent";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateSubscribeEventAction.Result res = action.call();
Python SDK
action = UpdateSubscribeEventAction()
action.uuid = "37fc1fcc0fa93fb493702469039edbfb"
action.emergencyLevel = "Emergent"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
AddActionToAlarm
API Request
URLs
POST zstack/v1/zwatch/alarms/{alarmUuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
"params": {
"actionUuid": "a48c9fa0454238a4b731279b92d8bad1",
"actionType": "sns"
},
"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":{"actionUuid":"a48c9fa0454238a4b731279b92d8bad1","actionType":"sns"}}' http://localhost:8080/zstack/v1/zwatch/alarms/3edde2bd29493568a2640f75d218ed05/actions
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| alarmUuid | String | url | The alarm UUID. | 2.3 | |
| actionUuid | String | body (contained in the params structure) | The action UUID. | 2.3 | |
| actionType | String | body (contained in the params structure) | The action type. | 2.3 | |
| systemTags | List | body | Optional. The system tags. | 2.3 | |
| userTags | List | body | Optional. The user tags. | 2.3 |
API Response
Sample Response
{
"inventory": {
"uuid": "6b9ce7e8a6c04476aa22ce6c851a7f80",
"name": "VM CPU Alarm",
"comparisonOperator": "LessThanOrEqualTo",
"period": 60.0,
"namespace": "ZStack/VM",
"metricName": "org.zstack.zwatch.datatype.Metric@565e1ebe",
"threshold": 30.0,
"repeatInterval": 1800.0,
"status": "Alarm",
"state": "Enabled",
"createDate": "Jul 6, 2018 1:50:39 PM",
"lastOpDate": "Jul 6, 2018 1:50:39 PM",
"labels": [
{
"uuid": "f183fec66c3d40938621568943f4c0bf",
"key": "VMUuid",
"operator": "\u003d",
"value": "7d46ab7f0f104ad0908f23d648bcaa9e"
}
],
"actions": [
{
"alarmUuid": "7379b3951c9f4c82a0571cc55ebc98b3",
"actionType": "sns",
"actionUuid": "27e18067eb614fd4bcb047c008e3a4c0"
}
]
}
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.3 |
| inventory | AlarmInventory | See inventory. | 2.3 |
#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. | 2.3 |
| description | String | The brief description of the error. | 2.3 |
| details | String | The details about the error. | 2.3 |
| elaboration | String | The reserved field. Default value: null. | 2.3 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.3 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.3 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.3 |
| name | String | Th resource name. | 2.3 |
| description | String | The detailed description of the resource. | 2.3 |
| period | Integer | The threshold duration. | 2.3 |
| namespace | String | The namespace. | 2.3 |
| metricName | String | The metric name. | 2.3 |
| threshold | Double | The threshold. | 2.3 |
| repeatInterval | Integer | The alarm repeat interval. | 2.3 |
| createDate | Timestamp | The creation date. | 2.3 |
| lastOpDate | Timestamp | The last operation date. | 2.3 |
| comparisonOperator | ComparisonOperator | See comparisonOperator. | 2.3 |
| status | AlarmStatus | See status. | 2.3 |
| labels | List | See labels. | 2.3 |
| actions | List | See actions. | 2.3 |
#comparisonOperator
| Name | Type | Description | Starting Version |
|---|---|---|---|
| name | String | The resource name. | 2.3 |
| ordinal | int | The ordinal number. | 2.3 |
#status
| Name | Type | Description | Starting Version |
|---|---|---|---|
| OK | AlarmStatus | The alarm is in normal status. | 2.3 |
| Alarm | AlarmStatus | The alarm is triggered. | 2.3 |
| InsufficientData | AlarmStatus | The data is insufficient. | 2.3 |
#labels
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.3 |
| key | String | The label key. | 2.3 |
| operator | String | The comparison operator. | 2.3 |
| value | String | The label value. | 2.3 |
#actions
| Name | Type | Description | Starting Version |
|---|---|---|---|
| alarmUuid | String | The alarm UUID. | 2.3 |
| actionType | String | The action type. | 2.3 |
| actionUuid | String | The action UUID. | 2.3 |
SDK Sample
Java SDK
AddActionToAlarmAction action = new AddActionToAlarmAction();
action.alarmUuid = "3edde2bd29493568a2640f75d218ed05";
action.actionUuid = "a48c9fa0454238a4b731279b92d8bad1";
action.actionType = "sns";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddActionToAlarmAction.Result res = action.call();
Python SDK
action = AddActionToAlarmAction()
action.alarmUuid = "3edde2bd29493568a2640f75d218ed05"
action.actionUuid = "a48c9fa0454238a4b731279b92d8bad1"
action.actionType = "sns"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
RemoveActionFromAlarm
API Request
URLs
DELETE zstack/v1/zwatch/alarms/{alarmUuid}/actions/{actionUuid}
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/zwatch/alarms/2c95bdf5490131bbb421622579b59eb8/actions/41c582ab1cea31d5addd02bb00bb173d
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| alarmUuid | String | url | The alarm UUID. | 2.3 | |
| actionUuid | String | url | The action UUID. | 2.3 | |
| deleteMode | String | body | Optional. The delete mode. | 2.3 | |
| systemTags | List | body | Optional. The system tags. | 2.3 | |
| userTags | List | body | Optional. The user tags. | 2.3 |
API Response
Sample Response
{
"inventory": {
"uuid": "3f753a2f9dd44becb0435b2a517fd5d4",
"name": "VM CPU Alarm",
"comparisonOperator": "LessThanOrEqualTo",
"period": 60.0,
"namespace": "ZStack/VM",
"metricName": "org.zstack.zwatch.datatype.Metric@565e1ebe",
"threshold": 30.0,
"repeatInterval": 1800.0,
"status": "Alarm",
"state": "Enabled",
"createDate": "Jul 6, 2018 1:50:59 PM",
"lastOpDate": "Jul 6, 2018 1:50:59 PM",
"labels": [
{
"uuid": "cf7ff04d570f4f509e6b22851ceb231d",
"key": "VMUuid",
"operator": "\u003d",
"value": "cda155f903f1417f951578ea74623f5e"
}
],
"actions": [
{
"alarmUuid": "5d2a502edc8d4c34b90ae499c7fdb437",
"actionType": "sns",
"actionUuid": "4b7903efe370462aab75bb5890971e6d"
}
]
}
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.3 |
| inventory | AlarmInventory | See inventory. | 2.3 |
#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. | 2.3 |
| description | String | The brief description of the error. | 2.3 |
| details | String | The details about the error. | 2.3 |
| elaboration | String | The reserved field. Default value: null. | 2.3 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.3 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.3 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.3 |
| name | String | Th resource name. | 2.3 |
| description | String | The detailed description of the resource. | 2.3 |
| period | Integer | The threshold duration. | 2.3 |
| namespace | String | The namespace. | 2.3 |
| metricName | String | The metric name. | 2.3 |
| threshold | Double | The threshold. | 2.3 |
| repeatInterval | Integer | The alarm repeat interval. | 2.3 |
| createDate | Timestamp | The creation date. | 2.3 |
| lastOpDate | Timestamp | The last operation date. | 2.3 |
| comparisonOperator | ComparisonOperator | See comparisonOperator. | 2.3 |
| status | AlarmStatus | See status. | 2.3 |
| labels | List | See labels. | 2.3 |
| actions | List | See actions. | 2.3 |
#comparisonOperator
| Name | Type | Description | Starting Version |
|---|---|---|---|
| name | String | The resource name. | 2.3 |
| ordinal | int | The ordinal number. | 2.3 |
#status
| Name | Type | Description | Starting Version |
|---|---|---|---|
| OK | AlarmStatus | The alarm is in normal status. | 2.3 |
| Alarm | AlarmStatus | The alarm is triggered. | 2.3 |
| InsufficientData | AlarmStatus | The data is insufficient. | 2.3 |
#labels
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.3 |
| key | String | The label key. | 2.3 |
| operator | String | The comparison operator. | 2.3 |
| value | String | The label value. | 2.3 |
#actions
| Name | Type | Description | Starting Version |
|---|---|---|---|
| alarmUuid | String | The alarm UUID. | 2.3 |
| actionType | String | The action type. | 2.3 |
| actionUuid | String | The action UUID. | 2.3 |
SDK Sample
Java SDK
RemoveActionFromAlarmAction action = new RemoveActionFromAlarmAction();
action.alarmUuid = "2c95bdf5490131bbb421622579b59eb8";
action.actionUuid = "41c582ab1cea31d5addd02bb00bb173d";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RemoveActionFromAlarmAction.Result res = action.call();
Python SDK
action = RemoveActionFromAlarmAction()
action.alarmUuid = "2c95bdf5490131bbb421622579b59eb8"
action.actionUuid = "41c582ab1cea31d5addd02bb00bb173d"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
AddLabelToAlarm
API Request
URLs
POST zstack/v1/zwatch/alarms/{alarmUuid}/labels
Headers
Authorization: OAuth the-session-uuid
Body
{
"params": {
"key": "VMUuid",
"value": "2840f151485641cca48b190ebb989cbf",
"operator": "Equal"
},
"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":{"key":"VMUuid","value":"165af818089b4e9f8c07691de549f8d4","operator":"Equal"}}' http://localhost:8080/zstack/v1/zwatch/alarms/00b90ca9d59d3f539530fbcc8572c403/labels
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| alarmUuid | String | url | The alarm UUID. | 2.3 | |
| key | String | body (contained in the params structure) | The label key. | 2.3 | |
| value | String | body (contained in the params structure) | The label value. | 2.3 | |
| operator | String | body (contained in the params structure) | The operator. |
|
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 |
API Response
Sample Response
{
"inventory": {
"uuid": "3f54b760c8d64e17bc282258335b718a",
"key": "VMUuid",
"operator": "\u003d",
"value": "dd5b28c103594573b7bb21a02cb000c4"
}
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.3 |
| inventory | AlarmInventory | See inventory. | 2.3 |
#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. | 2.3 |
| description | String | The brief description of the error. | 2.3 |
| details | String | The details about the error. | 2.3 |
| elaboration | String | The reserved field. Default value: null. | 2.3 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.3 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.3 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource The UUID.. | 2.3 |
| name | String | Th resource name. | 2.3 |
| description | String | The detailed description of the resource. | 2.3 |
| period | Integer | The threshold duration. | 2.3 |
| namespace | String | The namespace. | 2.3 |
| metricName | String | The metric name. | 2.3 |
| threshold | Double | The threshold. | 2.3 |
| repeatInterval | Integer | The alarm repeat interval. | 2.3 |
| createDate | Timestamp | The creation date. | 2.3 |
| lastOpDate | Timestamp | The last operation date. | 2.3 |
| comparisonOperator | ComparisonOperator | See comparisonOperator. | 2.3 |
| status | AlarmStatus | See status. | 2.3 |
| labels | List | See labels. | 2.3 |
| actions | List | See actions. | 2.3 |
#comparisonOperator
| Name | Type | Description | Starting Version |
|---|---|---|---|
| name | String | The resource name. | 2.3 |
| ordinal | int | The ordinal number. | 2.3 |
#status
| Name | Type | Description | Starting Version |
|---|---|---|---|
| OK | AlarmStatus | The alarm is in normal status. | 2.3 |
| Alarm | AlarmStatus | The alarm is triggered. | 2.3 |
| InsufficientData | AlarmStatus | The data is insufficient. | 2.3 |
#labels
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.3 |
| key | String | The label key. | 2.3 |
| operator | String | The comparison operator. | 2.3 |
| value | String | The label value. | 2.3 |
#actions
| Name | Type | Description | Starting Version |
|---|---|---|---|
| alarmUuid | String | The alarm UUID. | 2.3 |
| actionType | String | The action type. | 2.3 |
| actionUuid | String | The action UUID. | 2.3 |
SDK Sample
Java SDK
AddLabelToAlarmAction action = new AddLabelToAlarmAction();
action.alarmUuid = "00b90ca9d59d3f539530fbcc8572c403";
action.key = "VMUuid";
action.value = "bfaa02ec5c37490d829ae95bebf15b78";
action.operator = "Equal";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddLabelToAlarmAction.Result res = action.call();
Python SDK
action = AddLabelToAlarmAction()
action.alarmUuid = "00b90ca9d59d3f539530fbcc8572c403"
action.key = "VMUuid"
action.value = "b4eb5d369bfb45719fbe862484011563"
action.operator = "Equal"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
UpdateAlarmLabel
API Request
URLs
PUT zstack/v1/zwatch/alarms/labels/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
"updateAlarmLabel": {
"key": "VMUuid",
"value": "e9859e9eb51e4ea583a7c529407208a2",
"operator": "Equal"
},
"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 '{"updateAlarmLabel":{"key":"VMUuid","value":"59ab62f070784eb2b0d98f0d12386f0d","operator":"Equal"}}' http://localhost:8080/zstack/v1/zwatch/alarms/labels/3c228226ca213c18b54627668dd37d80/actions
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 3.3 | |
| key | String | body (contained in the updateAlarmLabel structure) | The label key. | 3.3 | |
| value | String | body (contained in the updateAlarmLabel structure) | The label value. | 3.3 | |
| operator | String | body (contained in the updateAlarmLabel structure) | The label operator. |
|
3.3 |
| systemTags | List | body | Optional. The system tags. | 3.3 | |
| userTags | List | body | Optional. The user tags. | 3.3 |
API Response
Sample Response
{
"inventory": {
"uuid": "5ea6d350f0e64d0b9467d033e9c6d052",
"key": "VMUuid",
"operator": "\u003d",
"value": "35956236f261467cb2cef1db8626024e"
}
}
| 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.3.0 |
| inventory | AlarmLabelInventory | See inventory. | 3.3.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.3.0 |
| description | String | The brief description of the error. | 3.3.0 |
| details | String | The details about the error. | 3.3.0 |
| elaboration | String | The reserved field. Default value: null. | 3.3.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 3.3.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.3.0 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 3.3.0 |
| key | String | The key. | 3.3.0 |
| operator | String | The operator. | 3.3.0 |
| value | String | The field value. | 3.3.0 |
SDK Sample
Java SDK
UpdateAlarmLabelAction action = new UpdateAlarmLabelAction();
action.uuid = "3c228226ca213c18b54627668dd37d80";
action.key = "VMUuid";
action.value = "1a33d5ce225241e0b2cbc80123e36351";
action.operator = "Equal";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateAlarmLabelAction.Result res = action.call();
Python SDK
action = UpdateAlarmLabelAction()
action.uuid = "3c228226ca213c18b54627668dd37d80"
action.key = "VMUuid"
action.value = "20034c6b21a24918912857c8ed923c6b"
action.operator = "Equal"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
RemoveLabelFromAlarm
API Request
URLs
DELETE zstack/v1/zwatch/alarms/labels/{uuid}
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/zwatch/alarms/labels/160037fc792d3815ba25fe8a48d1b237
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 2.3 | |
| deleteMode | String | body | Optional. The delete mode. | 2.3 | |
| systemTags | List | body | Optional. The system tags. | 2.3 | |
| userTags | List | body | Optional. The user tags. | 2.3 |
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
RemoveLabelFromAlarmAction action = new RemoveLabelFromAlarmAction();
action.uuid = "160037fc792d3815ba25fe8a48d1b237";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RemoveLabelFromAlarmAction.Result res = action.call();
Python SDK
action = RemoveLabelFromAlarmAction()
action.uuid = "160037fc792d3815ba25fe8a48d1b237"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
ChangeAlarmState
API Request
URLs
PUT zstack/v1/zwatch/alarms/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
"changeAlarmState": {
"stateEvent": "disable"
},
"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 '{"changeAlarmState":{"stateEvent":"disable"}}' http://localhost:8080/zstack/v1/zwatch/alarms/226149ca389f387e95d0f671bd6b551f/actions
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 2.3 | |
| stateEvent | String | body (contained in the changeAlarmState structure) | The state event. |
|
2.3 |
| systemTags | List | body | Optional. The system tags. | 2.3 | |
| userTags | List | body | Optional. The user tags. | 2.3 |
API Response
Sample Response
{
"inventory": {
"uuid": "3b57de3128b545a18bb7da2f086f6362",
"name": "VM CPU Alarm",
"comparisonOperator": "LessThanOrEqualTo",
"period": 60.0,
"namespace": "ZStack/VM",
"metricName": "org.zstack.zwatch.datatype.Metric@565e1ebe",
"threshold": 30.0,
"repeatInterval": 1800.0,
"status": "Alarm",
"state": "Enabled",
"createDate": "Jul 6, 2018 1:50:57 PM",
"lastOpDate": "Jul 6, 2018 1:50:57 PM",
"labels": [
{
"uuid": "61f43f3a05f74ef39b5b2c30354a5246",
"key": "VMUuid",
"operator": "\u003d",
"value": "23958e475ae34735a4ca0b808df0cf50"
}
],
"actions": [
{
"alarmUuid": "f01eb4d0ec1d4cdc81dc478c87f9fceb",
"actionType": "sns",
"actionUuid": "c9d79c14e37a4ebb83cf0d76fb7b8dbc"
}
]
}
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.3 |
| inventory | AlarmInventory | See inventory. | 2.3 |
#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. | 2.3 |
| description | String | The brief description of the error. | 2.3 |
| details | String | The details about the error. | 2.3 |
| elaboration | String | The reserved field. Default value: null. | 2.3 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.3 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.3 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.3 |
| name | String | Th resource name. | 2.3 |
| description | String | The detailed description of the resource. | 2.3 |
| period | Integer | The threshold duration. | 2.3 |
| namespace | String | The namespace. | 2.3 |
| metricName | String | The metric name. | 2.3 |
| threshold | Double | The threshold. | 2.3 |
| repeatInterval | Integer | The alarm repeat interval. | 2.3 |
| createDate | Timestamp | The creation date. | 2.3 |
| lastOpDate | Timestamp | The last operation date. | 2.3 |
| comparisonOperator | ComparisonOperator | See comparisonOperator. | 2.3 |
| status | AlarmStatus | See status. | 2.3 |
| labels | List | See labels. | 2.3 |
| actions | List | See actions. | 2.3 |
#comparisonOperator
| Name | Type | Description | Starting Version |
|---|---|---|---|
| name | String | The resource name. | 2.3 |
| ordinal | int | The ordinal number. | 2.3 |
#status
| Name | Type | Description | Starting Version |
|---|---|---|---|
| OK | AlarmStatus | The alarm is in normal status. | 2.3 |
| Alarm | AlarmStatus | The alarm is triggered. | 2.3 |
| InsufficientData | AlarmStatus | The data is insufficient. | 2.3 |
#labels
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.3 |
| key | String | The label key. | 2.3 |
| operator | String | The comparison operator. | 2.3 |
| value | String | The label value. | 2.3 |
#actions
| Name | Type | Description | Starting Version |
|---|---|---|---|
| alarmUuid | String | The alarm UUID. | 2.3 |
| actionType | String | The action type. | 2.3 |
| actionUuid | String | The action UUID. | 2.3 |
SDK Sample
Java SDK
ChangeAlarmStateAction action = new ChangeAlarmStateAction();
action.uuid = "226149ca389f387e95d0f671bd6b551f";
action.stateEvent = "disable";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeAlarmStateAction.Result res = action.call();
Python SDK
action = ChangeAlarmStateAction()
action.uuid = "226149ca389f387e95d0f671bd6b551f"
action.stateEvent = "disable"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
QueryAlarm
API Request
URLs
GET zstack/v1/zwatch/alarms
GET zstack/v1/zwatch/alarms/{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/zwatch/alarms?q=name=VM
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/alarms/572c61c4a1393b6ebce520a0102dc46c
Queryable Fields
You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryAlarm, and pressing the Tab key.
API Response
Sample Response
{
"inventories": [
{
"uuid": "5c9ef4b25c2a485da77eab50745d53cf",
"name": "VM CPU Alarm",
"comparisonOperator": "LessThanOrEqualTo",
"period": 60.0,
"namespace": "ZStack/VM",
"metricName": "org.zstack.zwatch.datatype.Metric@565e1ebe",
"threshold": 30.0,
"repeatInterval": 1800.0,
"status": "Alarm",
"state": "Enabled",
"createDate": "Jul 6, 2018 1:50:51 PM",
"lastOpDate": "Jul 6, 2018 1:50:51 PM",
"labels": [
{
"uuid": "5ab29656f8df43a3a78d672af8940896",
"key": "VMUuid",
"operator": "\u003d",
"value": "b128326b8b944c0499992c00cabd4711"
}
],
"actions": [
{
"alarmUuid": "2028f51e88b6449fb33442215810845f",
"actionType": "sns",
"actionUuid": "9486671b2f4c4413976f1d6938ac1d01"
}
]
}
]
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.3 |
| inventories | List | See inventories. | 2.3 |
#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. | 2.3 |
| description | String | The brief description of the error. | 2.3 |
| details | String | The details about the error. | 2.3 |
| elaboration | String | The reserved field. Default value: null. | 2.3 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.3 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.3 |
#inventories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.3 |
| name | String | Th resource name. | 2.3 |
| description | String | The detailed description of the resource. | 2.3 |
| period | Integer | The threshold duration. | 2.3 |
| namespace | String | The namespace. | 2.3 |
| metricName | String | The metric name. | 2.3 |
| threshold | Double | The threshold. | 2.3 |
| repeatInterval | Integer | The alarm repeat interval. | 2.3 |
| createDate | Timestamp | The creation date. | 2.3 |
| lastOpDate | Timestamp | The last operation date. | 2.3 |
| comparisonOperator | ComparisonOperator | See comparisonOperator. | 2.3 |
| status | AlarmStatus | See status. | 2.3 |
| labels | List | See labels. | 2.3 |
| actions | List | See actions. | 2.3 |
#comparisonOperator
| Name | Type | Description | Starting Version |
|---|---|---|---|
| name | String | The resource name. | 2.3 |
| ordinal | int | The ordinal number. | 2.3 |
#status
| Name | Type | Description | Starting Version |
|---|---|---|---|
| OK | AlarmStatus | The alarm is in normal status. | 2.3 |
| Alarm | AlarmStatus | The alarm is triggered. | 2.3 |
| InsufficientData | AlarmStatus | The data is insufficient. | 2.3 |
#labels
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.3 |
| key | String | The label key. | 2.3 |
| operator | String | The comparison operator. | 2.3 |
| value | String | The label value. | 2.3 |
#actions
| Name | Type | Description | Starting Version |
|---|---|---|---|
| alarmUuid | String | The alarm UUID. | 2.3 |
| actionType | String | The action type. | 2.3 |
| actionUuid | String | The action UUID. | 2.3 |
SDK Sample
Java SDK
QueryAlarmAction action = new QueryAlarmAction();
action.conditions = asList("name=VM");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryAlarmAction.Result res = action.call();
Python SDK
action = QueryAlarmAction()
action.conditions = ["name=VM"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
GetAlarmData
API Request
URLs
GET zstack/v1/zwatch/alarm-histories
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/zwatch/alarm-histories?startTime=1.596444525E9&endTime=1.596530925E9&limit=200.0&count=false&excludeOtherAccount=false&start=0.0
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| startTime | Long | query | Optional. The start time. | 2.3 | |
| endTime | Long | query | Optional. The end time. | 2.3 | |
| limit | Integer | query | Optional. The maximum number of returned records. | 2.3 | |
| conditions | List | query | Optional. The conditions to filter the results. | 2.3 | |
| count | boolean | query | Optional. Whether to query the message count. | 3.3.0 | |
| excludeOtherAccount | boolean | query | Optional. Whether to exclude messages other than the current account (only effective for SystemAdmin). | 3.3.0 | |
| endpointUuid | String | query | Optional. The endpoint UUID. | 3.10.0 | |
| systemTags | List | query | Optional. The system tags. | 2.3 | |
| userTags | List | query | Optional. The user tags. | 2.3 |
API Response
Sample Response
{
"histories": [
{
"alarmUuid": "143b24a12d193c1992c4774dc3b34fda",
"namespace": "ZStack/VM",
"metricName": "CPUUsedUtilization",
"accountUuid": "90aea7a1dfe93cf7bd3379254dddbdf9",
"resourceUuid": "4e6bb5390d3938cb9ce830a4766ee4d8",
"resourceType": "VmInstanceVO",
"alarmStatus": "Alarm",
"alarmName": "test-alarm",
"threshold": 90.0,
"labels": "VMUuid Equal 4e6bb5390d3938cb9ce830a4766ee4d8, CPUNum Equal 2",
"metricValue": 10.0,
"comparisonOperator": "LessThan",
"time": 1.510669257141E12
}
]
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.3 |
| histories | List | See histories. | 2.3 |
#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. | 2.3 |
| description | String | The brief description of the error. | 2.3 |
| details | String | The details about the error. | 2.3 |
| elaboration | String | The reserved field. Default value: null. | 2.3 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.3 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.3 |
#histories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| alarmUuid | String | The alarm UUID. | 2.3 |
| namespace | String | The namespace. | 2.3 |
| metricName | String | The metric name. | 2.3 |
| accountUuid | String | The account UUID. | 2.3 |
| resourceUuid | String | The resource UUID. | 2.3 |
| resourceType | String | The resource type. | 2.3 |
| alarmStatus | String | The alarm status. | 2.3 |
| alarmName | String | The alarm name. | 2.3 |
| threshold | Double | The alarm threshold. | 2.3 |
| period | Integer | The threshold duration. | 2.3 |
| labels | String | The label list. | 2.3 |
| metricValue | Double | The metric value. | 2.3 |
| time | long | The time that the alarm record was generated. | 2.3 |
SDK Sample
Java SDK
GetAlarmDataAction action = new GetAlarmDataAction();
action.startTime = 1.530856218E9;
action.endTime = 1.530942618E9;
action.limit = 200.0;
action.count = false;
action.excludeOtherAccount = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetAlarmDataAction.Result res = action.call();
Python SDK
action = GetAlarmDataAction()
action.startTime = 1.530856218E9
action.endTime = 1.530942618E9
action.limit = 200.0
action.count = false;
action.excludeOtherAccount = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
UpdateAlarmData
API Request
URLs
PUT zstack/v1/zwatch/alarm-histories/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
"updateAlarmData": {
"dataUuid": "514d4a1ed3573bf8a14ac350de0a2513",
"updateMode": "OnlyOne",
"readStatus": "Read"
},
"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 '{"updateAlarmData":{"dataUuid":"514d4a1ed3573bf8a14ac350de0a2513","updateMode":"OnlyOne","readStatus":"Read"}}' http://localhost:8080/zstack/v1/zwatch/alarm-histories/actions
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| dataUuid | String | body (contained in the updateAlarmData structure) | Optional. The resource UUID. | 3.3.0 | |
| dataStartTime | Long | body (contained in the updateAlarmData structure) | Optional. The start time of the target messages. Make sure that InRange is transferred to updateMode. | 3.3.0 | |
| dataEndTime | Long | body (contained in the updateAlarmData structure) | Optional. The end time of the target messages. Make sure that InRange is transferred to updateMode. | 3.3.0 | |
| updateMode | String | body (contained in the updateAlarmData structure) | The range of the target messages to be updated. Options:
|
|
3.3.0 |
| readStatus | String | body (contained in the updateAlarmData structure) | Optional. The read status of the updated messages. |
|
3.3.0 |
| systemTags | List | body | Optional. The system tags. | 3.3.0 | |
| userTags | List | body | Optional. The user tags. | 3.3.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
UpdateAlarmDataAction action = new UpdateAlarmDataAction();
action.dataUuid = "514d4a1ed3573bf8a14ac350de0a2513";
action.updateMode = "OnlyOne";
action.readStatus = "Read";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateAlarmDataAction.Result res = action.call();
Python SDK
action = UpdateAlarmDataAction()
action.dataUuid = "514d4a1ed3573bf8a14ac350de0a2513"
action.updateMode = "OnlyOne"
action.readStatus = "Read"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
GetZWatchAlertHistogram
API Request
URLs
GET zstack/v1/zwatch/alert-histories/histogram
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/zwatch/alert-histories/histogram?startTime=1.623414899E9&endTime=1.623501299E9&intervalHours=8.0&groupColumns=emergencyLevel
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| tableName | String | query | The message type. | 4.1.0 | |
| startTime | Long | query | The start time. | 4.1.0 | |
| endTime | Long | query | The end time. | 4.1.0 | |
| intervalHours | String | query | The interval (hour). | 4.1.0 | |
| groupColumns | List | query | Optional. The group attributes. | 4.1.0 | |
| systemTags | List | query | Optional. The system tags. | 4.1.0 | |
| userTags | List | query | Optional. The user tags. | 4.1.0 |
API Response
Sample Response
{
"histograms": [
{
"time": 1.510669257141E12,
"count": 50.0,
"tags": [
{
"name": "emergencyLevel",
"value": "Emergent"
}
]
}
]
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | Whether the operation succeeded. | 4.1.0 |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 4.1.0 |
| histograms | List | The histograms. | 4.1.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. | 4.1.0 |
| description | String | The brief description of the error. | 4.1.0 |
| details | String | The details about the error. | 4.1.0 |
| elaboration | String | The reserved field. Default value: null. | 4.1.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 4.1.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. | 4.1.0 |
#histories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| time | long | The time. | 4.1.0 |
| count | long | The count. | 4.1.0 |
| tags | List | See tags. | 4.1.0 |
#tags
| Name | Type | Description | Starting Version |
|---|---|---|---|
| name | String | The tag name. | 4.1.0 |
| value | String | The tag value. | 4.1.0 |
SDK Sample
Java SDK
GetZWatchAlertHistogramAction action = new GetZWatchAlertHistogramAction();
action.startTime = 1.623414899E9;
action.endTime = 1.623501299E9;
action.intervalHours = 8.0;
action.groupColumns = asList("emergencyLevel");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetZWatchAlertHistogramAction.Result res = action.call();
Python SDK
action = GetZWatchAlertHistogramAction()
action.startTime = 1.623414899E9
action.endTime = 1.623501299E9
action.intervalHours = 8.0
action.groupColumns = [emergencyLevel]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
QueryAlarmRecord
API Request
URLs
GET zstack/v1/zwatch/alarm-records
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/zwatch/alarm-records?q=dataUuid=f30e0a92898a3cf39b98c7b20d5d09d7
Queryable Fields
You can check all queryable fields and resource names that can be queried across tables by using the CLI tool, entering QueryAlarmRecord, and pressing the Tab key.
API Response
Sample Response
{
"inventories": [
{
"id": 1.0,
"createTime": 1.510669257141E12,
"accountUuid": "ce8e0ae7bfb93fb09c3339443fb79b5a",
"alarmName": "ZStack Primary Storage Physical Available Capacity Alarm",
"alarmStatus": "Alarm",
"alarmUuid": "701f9528318737bb9db81c4f9b5721a7",
"comparisonOperator": "LessThan",
"context": "{\"PrimaryStorageType\":\"LocalStorage\"}",
"dataUuid": "2e6afdb668443ef9a9a82fcba794d21b",
"emergencyLevel": "Emergent",
"metricName": "AvailablePhysicalCapacityInPercent",
"metricValue": 20.0,
"namespace": "ZStack/PrimaryStorage",
"period": 600.0,
"readStatus": false,
"resourceUuid": "8a596bd1689c3e83a408c2713d99fc6e",
"threshold": 21.0
}
]
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 4.1.0 |
| histograms | List | The histograms. | 4.1.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. | 4.1.0 |
| description | String | The brief description of the error. | 4.1.0 |
| details | String | The details about the error. | 4.1.0 |
| elaboration | String | The reserved field. Default value: null. | 4.1.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 4.1.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. | 4.1.0 |
#inventories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| id | long | The message ID. | 4.1.0 |
| createTime | long | The creation date. | 4.1.0 |
| accountUuid | String | The account UUID. | 4.1.0 |
| alarmName | String | The alarm name. | 4.1.0 |
| alarmStatus | String | The alarm status. | 4.1.0 |
| alarmUuid | String | The alarm UUID. | 4.1.0 |
| comparisonOperator | String | The threshold comparison operator. | 4.1.0 |
| context | String | The context. | 4.1.0 |
| dataUuid | String | The message UUID. | 4.1.0 |
| emergencyLevel | String | The emergency level of an alarm. | 4.1.0 |
| labels | String | The labels. | 4.1.0 |
| metricName | String | The metric name. | 4.1.0 |
| metricValue | Double | The metric value. | 4.1.0 |
| namespace | String | The namespace. | 4.1.0 |
| period | int | The threshold duration. | 4.1.0 |
| readStatus | Boolean | The read status. | 4.1.0 |
| resourceUuid | String | The resource UUID. | 4.1.0 |
| threshold | Double | The threshold. | 4.1.0 |
SDK Sample
Java SDK
QueryAlarmRecordAction action = new QueryAlarmRecordAction();
action.conditions = asList("dataUuid=8860f33a964e3141aee2c3ffde2918b7");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryAlarmRecordAction.Result res = action.call();
Python SDK
action = QueryAlarmRecordAction()
action.conditions = ["dataUuid=a83224ddc145340b9b7b12170ba614ba"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
UpdateActiveAlarmTemplate
API Request
URLs
PUT zstack/v1/zwatch/activealarms/templates/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
"updateActiveAlarmTemplate": {
"alarmName": "VM-CPUAverageUsedUtilization",
"comparisonOperator": "LessThanOrEqualTo",
"period": 60,
"threshold": 80.0,
"repeatInterval": 1800,
"repeatCount": -1,
"emergencyLevel": "Emergent"
},
"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 '{"updateActiveAlarmTemplate":{"alarmName":"VM-CPUAverageUsedUtilization","comparisonOperator":"LessThanOrEqualTo","period":60,"threshold":80.0,"repeatInterval":1800,"repeatCount":-1,"emergencyLevel":"Emergent"}}' http://localhost:8080/zstack/v1/zwatch/activealarms/templates/c3e82dade74732009d5f4fd0b462f65d/actions
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The template UUID. | 4.7.0 | |
| alarmName | String | body (contained in the updateActiveAlarmTemplate structure) | Optional. The template name. | 4.7.0 | |
| comparisonOperator | String | body (contained in the updateActiveAlarmTemplate structure) | Optional. The threshold comparison operator. |
|
4.7.0 |
| period | Integer | body (contained in the updateActiveAlarmTemplate structure) | Optional. The threshold comparison operator. | 4.7.0 | |
| threshold | Double | body (contained in the updateActiveAlarmTemplate structure) | Optional. The threshold. | 4.7.0 | |
| repeatInterval | Integer | body (contained in the updateActiveAlarmTemplate structure) | Optional. The alarm repeat interval. | 4.7.0 | |
| repeatCount | Integer | body (contained in the updateActiveAlarmTemplate structure) | Optional. The alarm repeat count. | 4.7.0 | |
| emergencyLevel | String | body (contained in the updateActiveAlarmTemplate structure) | Optional. The alarm emergency level. |
|
4.7.0 |
| labels | String | body (contained in the updateActiveAlarmTemplate structure) | Optional. | 4.7.0 | |
| systemTags | List | query | Optional. The system tags. | 4.7.0 | |
| userTags | List | query | Optional. The user tags. | 4.7.0 |
API Response
Sample Response
{
"inventory": {
"uuid": "ea8aa7b6b2e43d4a9f3a19ba121ab72a",
"alarmName": "VM CPU Alarm",
"comparisonOperator": "LessThanOrEqualTo",
"period": 60,
"repeatInterval": 60,
"repeatCount": -1,
"namespace": "zstack/VM",
"metricName": "CPUIdleUtilization",
"threshold": 30.0,
"emergencyLevel": "Emergent",
"labels": "[{\"uuid\":\"48cc4d3273a249009ea2166b71495785\",\"key\":\"VMUuid\",\"operator\":\"\u003d\",\"value\":\"c69d93586ca349b9a3bc074e2739e20a\"}]",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | Whether the operation succeeded. | 4.7.0 |
| inventory | ActiveAlarmTemplateInventory | See inventory. | 4.7.0 |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 4.7.0 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 4.7.0 |
| alarmName | String | The alarm name. | 4.7.0 |
| period | int | The period. | 4.7.0 |
| repeatInterval | int | The repeat interval. | 4.7.0 |
| repeatCount | int | The number of repeat. | 4.7.0 |
| namespace | String | The namespace. | 4.7.0 |
| metricName | String | The metric name. | 4.7.0 |
| threshold | double | The threshold. | 4.7.0 |
| labels | String | The labels. | 4.7.0 |
| createDate | Timestamp | The creation date. | 4.7.0 |
| lastOpDate | Timestamp | The last operation date. | 4.7.0 |
| comparisonOperator | ComparisonOperator | See comparisonOperator. | 4.7.0 |
| emergencyLevel | EmergencyLevel | See emergencyLevel. | 4.7.0 |
#comparisonOperator
| Name | Type | Description | Starting Version |
|---|---|---|---|
| GreaterThanOrEqualTo | ComparisonOperator | The GreaterThanOrEqualTo value. | 4.7.0 |
| GreaterThan | ComparisonOperator | The GreaterThan value. | 4.7.0 |
| LessThan | ComparisonOperator | The LessThan value. | 4.7.0 |
| LessThanOrEqualTo | ComparisonOperator | The LessThanOrEqualTo value. | 4.7.0 |
#emergencyLevel
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Emergent | EmergencyLevel | The Emergent value. | 4.7.0 |
| Important | EmergencyLevel | The Important value. | 4.7.0 |
| Normal | EmergencyLevel | The Normal value. | 4.7.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. | 4.7.0 |
| description | String | The brief description of the error. | 4.7.0 |
| details | String | The details about the error. | 4.7.0 |
| elaboration | String | The reserved field. Default value: null. | 4.7.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 4.7.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. | 4.7.0 |
SDK Sample
Java SDK
UpdateActiveAlarmTemplateAction action = new UpdateActiveAlarmTemplateAction();
action.uuid = "c3e82dade74732009d5f4fd0b462f65d";
action.alarmName = "VM-CPUAverageUsedUtilization";
action.comparisonOperator = "LessThanOrEqualTo";
action.period = 60;
action.threshold = 80.0;
action.repeatInterval = 1800;
action.repeatCount = -1;
action.emergencyLevel = "Emergent";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateActiveAlarmTemplateAction.Result res = action.call();
Python SDK
action = UpdateActiveAlarmTemplateAction()
action.uuid = "c3e82dade74732009d5f4fd0b462f65d"
action.alarmName = "VM-CPUAverageUsedUtilization"
action.comparisonOperator = "LessThanOrEqualTo"
action.period = 60
action.threshold = 80.0
action.repeatInterval = 1800
action.repeatCount = -1
action.emergencyLevel = "Emergent"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
ChangeEventSubscriptionState
API Request
URLs
PUT zstack/v1/zwatch/change/eventSubscription/{uuid}/state
Headers
Authorization: OAuth the-session-uuid
Body
{
"changeEventSubscriptionState": {
"state": "Disabled"
},
"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 '{"changeEventSubscriptionState":{"state":"Disabled"}}' http://localhost:8080/zstack/v1/zwatch/change/eventSubscription/2140655d1d183a6690c0eecdbc721ec0/state
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 4.7.0 | |
| state | String | body (contained in the changeEventSubscriptionState structure) | The event alarm state. |
|
4.7.0 |
| systemTags | List | query | Optional. The system tags. | 4.7.0 | |
| userTags | List | query | Optional. The user tags. | 4.7.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
ChangeEventSubscriptionStateAction action = new ChangeEventSubscriptionStateAction();
action.uuid = "2140655d1d183a6690c0eecdbc721ec0";
action.state = "Disabled";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeEventSubscriptionStateAction.Result res = action.call();
Python SDK
action = ChangeEventSubscriptionStateAction()
action.uuid = "2140655d1d183a6690c0eecdbc721ec0"
action.state = "Disabled"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
Event Subscription Operations
SubscribeEvent
API Request
URLs
POST zstack/v1/zwatch/events/subscriptions
Headers
Authorization: OAuth the-session-uuid
Body
{
"params": {
"namespace": "ZStack/VM",
"eventName": "VMUuid",
"actions": [
{
"actionUuid": "2fbeae18082445d09c890fa076ff9fd9",
"actionType": "sns"
}
],
"labels": [
{
"key": "VMUuid",
"value": "0c60949d81964f23a0d860b30472c51b",
"op": "Equal"
}
]
},
"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":{"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
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"
res = action.call()
UnsubscribeEvent
API Request
URLs
DELETE zstack/v1/zwatch/events/subscriptions/{uuid}
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/zwatch/events/subscriptions/298e2e2506163851a268907ed8ea7995
Request Parameters
| Name | Type | Location | Description | Optional | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 2.3 | |
| deleteMode | String | body | Optional. | 2.3 | |
| systemTags | List | body | Optional. The system tags. | 2.3 | |
| userTags | List | body | Optional. The user tags. | 2.3 |
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
UnsubscribeEventAction action = new UnsubscribeEventAction();
action.uuid = "298e2e2506163851a268907ed8ea7995";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UnsubscribeEventAction.Result res = action.call();
Python SDK
action = UnsubscribeEventAction()
action.uuid = "298e2e2506163851a268907ed8ea7995"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
QueryEventSubscription
API Request
URLs
GET zstack/v1/zwatch/events/subscriptions
GET zstack/v1/zwatch/events/subscriptions/{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/zwatch/events/subscriptions?q=name=test
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/events/subscriptions/57618e9763ce3b7e990870c3a7ae8c53
Queryable Fields
You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryEventSubscription, and pressing the Tab key.
API Response
Sample Response
{
"inventories": [
{
"uuid": "9404fe697a6b4d7dbac98065af20dc57",
"namespace": "ZStack/VM",
"eventName": "org.zstack.zwatch.datatype.EventFamily@80723ca",
"state": "Enabled",
"actions": [
{
"subscriptionUuid": "650cf6a269284671a42f93631c87dfec",
"actionType": "sns",
"actionUuid": "fe296dcbc31c4afa9f76494b1930c8cc"
}
],
"labels": [
{
"uuid": "d29fe54ca47540a9b20b308429f21434",
"key": "DestinationHostUuid",
"operator": "Equal",
"value": "733509c8c5684c678ffe99f59d4aba21"
}
],
"lastOpDate": "Jul 6, 2018 1:51:00 PM",
"createDate": "Jul 6, 2018 1:51:00 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. | 2.3.1 |
| inventories | List | See inventories. | 2.3.1 |
#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. | 2.3.1 |
| description | String | The brief description of the error. | 2.3.1 |
| details | String | The details about the error. | 2.3.1 |
| elaboration | String | The reserved field. Default value: null. | 2.3.1 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.3.1 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.3.1 |
#inventories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.3.1 |
| name | String | Th resource name. | 3.0.0 |
| namespace | String | The namespace. | 2.3.1 |
| eventName | String | The event name. | 2.3.1 |
| lastOpDate | Timestamp | The creation date. | 2.3.1 |
| createDate | Timestamp | The last operation date. | 2.3.1 |
| state | EventSubscriptionState | See state. | 2.3.1 |
| actions | List | See actions. | 2.3.1 |
| labels | List | See labels. | 2.3.1 |
#state
| Name | Type | Description | Starting Version |
|---|---|---|---|
| name | String | The resource name. | 2.3.1 |
| ordinal | int | The ordinal number. | 2.3.1 |
#actions
| Name | Type | Description | Starting Version |
|---|---|---|---|
| subscriptionUuid | String | The event subscription UUID. | 2.3.1 |
| actionType | String | The action type. | 2.3.1 |
| actionUuid | String | The action UUID. | 2.3.1 |
#labels
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.3.1 |
| key | String | The label key. | 2.3.1 |
| value | String | The label value. | 2.3.1 |
| operator | Operator | See operator. | 2.3.1 |
#operator
| Name | Type | Description | Starting Version |
|---|---|---|---|
| op | String | The op. | 2.3.1 |
| name | String | The resource name. | 2.3.1 |
| ordinal | int | The ordinal number. | 2.3.1 |
SDK Sample
Java SDK
QueryEventSubscriptionAction action = new QueryEventSubscriptionAction();
action.conditions = asList("name=test");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryEventSubscriptionAction.Result res = action.call();
Python SDK
action = QueryEventSubscriptionAction()
action.conditions = ["name=test"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
UpdateEventSubscriptionLabel
API Request
URLs
PUT zstack/v1/zwatch/events/subscriptions/labels/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
"updateEventSubscriptionLabel": {
"key": "VMUuid",
"value": "42c233c17c6e4907b7be1f11a41f3a17",
"operator": "Equal"
},
"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 '{"updateEventSubscriptionLabel":{"key":"VMUuid","value":"228fc2c5041248df9b0d317f6f7a8585","operator":"Equal"}}' http://localhost:8080/zstack/v1/zwatch/events/subscriptions/labels/cfb859d412933a1da57ae99e2aa442ce/actions
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The UUID of the event subscription. | 3.9.0 | |
| key | String | body (contained in the updateEventSubscriptionLabel structure) | The new name of the label. | 3.9.0 | |
| value | String | body (contained in the updateEventSubscriptionLabel structure) | The new value of the label. | 3.9.0 | |
| operator | String | body (contained in the updateEventSubscriptionLabel structure) | The new operator of the label. |
|
3.9.0 |
| systemTags | List | body | Optional. The system tags. | 3.9.0 | |
| userTags | List | body | Optional. The user tags. | 3.9.0 |
API Response
Sample Response
{
"inventory": {
"uuid": "d937a1c6d9de3f2285b0cb23316624a8",
"key": "VMUuid",
"operator": "Equal",
"value": "19cf33283b484ff6b73a6d98e1d762f5"
}
}
| 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.9.0 |
| inventory | EventSubscriptionLabelInventory | See inventory. | 3.9.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.9.0 |
| description | String | The brief description of the error. | 3.9.0 |
| details | String | The details about the error. | 3.9.0 |
| elaboration | String | The reserved field. Default value: null. | 3.9.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 3.9.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.9.0 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 3.9.0 |
| key | String | The label name. | 3.9.0 |
| value | String | The label key. | 3.9.0 |
| operator | Operator | See operator. | 3.9.0 |
#operator
| Name | Type | Description | Starting Version |
|---|---|---|---|
| op | String | The op. | 3.9.0 |
| name | String | The resource name. | 3.9.0 |
| ordinal | int | The ordinal number. | 3.9.0 |
SDK Sample
Java SDK
UpdateEventSubscriptionLabelAction action = new UpdateEventSubscriptionLabelAction();
action.uuid = "cfb859d412933a1da57ae99e2aa442ce";
action.key = "VMUuid";
action.value = "9d7099dd361049aaaf801ca6b17b2858";
action.operator = "Equal";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateEventSubscriptionLabelAction.Result res = action.call();
Python SDK
action = UpdateEventSubscriptionLabelAction()
action.uuid = "cfb859d412933a1da57ae99e2aa442ce"
action.key = "VMUuid"
action.value = "27e59f9fe7ed46118a2f6b8a383ce494"
action.operator = "Equal"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
Text Template Operations
CreateSNSTextTemplate
API Request
URLs
POST zstack/v1/zwatch/alarms/sns/text-templates
Headers
Authorization: OAuth the-session-uuid
Body
{
"params": {
"name": "email template",
"applicationPlatformType": "Email",
"subject": "Alarm ${ALARM_NAME} [${ALARM_METRIC} ${ALARM_COMPARISON_OPERATOR} threshold ${ALARM_THRESHOLD}] changes status to ${ALARM_CURRENT_STATUS}",
"recoverySubject": "Alarm ${ALARM_NAME} ${TITLE_ALARM_RESOURCE_NAME} changes status to ${ALARM_CURRENT_STATUS}",
"template": "Alarm ${ALARM_NAME} changes status to ${ALARM_CURRENT_STATUS}",
"recoveryTemplate": "Alarm ${ALARM_NAME} Resource ${ALARM_RESOURCE_NAME} changes status to ${ALARM_CURRENT_STATUS}",
"defaultTemplate": true
},
"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":"email template","applicationPlatformType":"Email","subject":"Alarm ${ALARM_NAME} [${ALARM_METRIC} ${ALARM_COMPARISON_OPERATOR} threshold ${ALARM_THRESHOLD}] changes status to ${ALARM_CURRENT_STATUS}","recoverySubject":"Alarm ${ALARM_NAME} ${TITLE_ALARM_RESOURCE_NAME} changes status to ${ALARM_CURRENT_STATUS}","template":"Alarm ${ALARM_NAME} changes status to ${ALARM_CURRENT_STATUS}","recoveryTemplate":"Alarm ${ALARM_NAME} Resource ${ALARM_RESOURCE_NAME} changes status to ${ALARM_CURRENT_STATUS}","defaultTemplate":true}}' http://localhost:8080/zstack/v1/zwatch/alarms/sns/text-templates
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| name | String | body (contained in the params structure) | The resource name. | 2.3 | |
| description | String | body (contained in the params structure) | Optional. The detailed description of the resource. | 2.3 | |
| applicationPlatformType | String | body (contained in the params structure) | The type of the SNS application platform. | 2.3 | |
| template | String | body (contained in the params structure) | The template text. | 2.3 | |
| recoveryTemplate | String | body (contained in the params structure) | The recovery template text, which is a string. | 3.4.0 | |
| defaultTemplate | Boolean | body (contained in the params structure) | Optional. Whether to set the template as the default template. | 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 | |
| type | String | body (contained in the params structure) | Optional. |
|
5.1.8 |
| tagUuids | List | body (contained in the params structure) | Optional. the tag UUID list. | 5.1.8 | |
| subject | String | body (contained in the params structure) | Optional. The subject. | 5.1.8 | |
| recoverySubject | String | body (contained in the params structure) | The recovery subject. | 5.1.8 |
API Response
Sample Response
{
"inventory": {
"uuid": "533c0a77d8694f068ea0425f587c9c2a",
"name": "email template",
"applicationPlatformType": "Email",
"subject": "Alarm ${ALARM_NAME} [${ALARM_METRIC} ${ALARM_COMPARISON_OPERATOR} threshold ${ALARM_THRESHOLD}] changes status to ${ALARM_CURRENT_STATUS}",
"recoverySubject": "Alarm ${ALARM_NAME} ${TITLE_ALARM_RESOURCE_NAME} changes status to ${ALARM_CURRENT_STATUS}",
"template": "Alarm ${ALARM_NAME} changes status to ${ALARM_CURRENT_STATUS}",
"recoveryTemplate": "Resource ${EVENT_RESOURCE_ID} changes status to ${ALARM_CURRENT_STATUS}",
"defaultTemplate": false,
"createDate": "Jun 13, 2024 5:26:38 PM",
"lastOpDate": "Jun 13, 2024 5:26:38 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. | 2.3 |
| inventory | SNSTextTemplateInventory | See inventory. | 2.3 |
#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. | 2.3 |
| name | String | Th resource name. | 2.3 |
| description | String | The detailed description of the resource. | 2.3 |
| applicationPlatformType | String | The application platform type. | 2.3 |
| template | String | The template text. | 2.3 |
| defaultTemplate | Boolean | Whether to set the template as the default template. | 2.3 |
| createDate | Timestamp | The creation date. | 2.3 |
| lastOpDate | Timestamp | The last operation date. | 2.3 |
SDK Sample
Java SDK
CreateSNSTextTemplateAction action = new CreateSNSTextTemplateAction();
action.name = "email template";
action.applicationPlatformType = "Email";
action.subject = "Alarm ${ALARM_NAME} [${ALARM_METRIC} ${ALARM_COMPARISON_OPERATOR} threshold ${ALARM_THRESHOLD}] changes status to ${ALARM_CURRENT_STATUS}";
action.recoverySubject = "Alarm ${ALARM_NAME} ${TITLE_ALARM_RESOURCE_NAME} changes status to ${ALARM_CURRENT_STATUS}";
action.template = "Alarm ${ALARM_NAME} changes status to ${ALARM_CURRENT_STATUS}";
action.recoveryTemplate = "Alarm ${ALARM_NAME} Resource ${ALARM_RESOURCE_NAME} changes status to ${ALARM_CURRENT_STATUS}";
action.defaultTemplate = true;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateSNSTextTemplateAction.Result res = action.call();
Python SDK
action = CreateSNSTextTemplateAction()
action.name = "email template"
action.applicationPlatformType = "Email"
action.subject = "Alarm ${ALARM_NAME} [${ALARM_METRIC} ${ALARM_COMPARISON_OPERATOR} threshold ${ALARM_THRESHOLD}] changes status to ${ALARM_CURRENT_STATUS}"
action.recoverySubject = "Alarm ${ALARM_NAME} ${TITLE_ALARM_RESOURCE_NAME} changes status to ${ALARM_CURRENT_STATUS}"
action.template = "Alarm ${ALARM_NAME} changes status to ${ALARM_CURRENT_STATUS}"
action.recoveryTemplate = "Alarm ${ALARM_NAME} Resource ${ALARM_RESOURCE_NAME} changes status to ${ALARM_CURRENT_STATUS}"
action.defaultTemplate = true
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
DeleteSNSTextTemplate
API Request
URLs
DELETE zstack/v1/zwatch/alarms/sns/text-templates/{uuid}?deleteMode={deleteMode}
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/zwatch/alarms/sns/text-templates/a4ce47e628303c4fa55743f1b84c61b4?deleteMode=Permissive
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 2.3 | |
| deleteMode | String | url | Optional. | 2.3 | |
| systemTags | List | body | Optional. The system tags. | 2.3 | |
| userTags | List | body | Optional. The user tags. | 2.3 |
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
DeleteSNSTextTemplateAction action = new DeleteSNSTextTemplateAction();
action.uuid = "a4ce47e628303c4fa55743f1b84c61b4";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteSNSTextTemplateAction.Result res = action.call();
Python SDK
action = DeleteSNSTextTemplateAction()
action.uuid = "a4ce47e628303c4fa55743f1b84c61b4"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
UpdateSNSTextTemplate
API Request
URLs
PUT zstack/v1/zwatch/alarms/sns/text-templates/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
"updateSNSTextTemplate": {
"name": "email template",
"template": "Alarm ${ALARM_NAME} changes status to ${ALARM_CURRENT_STATUS}",
"recoveryTemplate": "Alarm ${ALARM_NAME} Resource ${ALARM_RESOURCE_NAME} changes status to ${ALARM_CURRENT_STATUS}",
"defaultTemplate": true
},
"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 '{"updateSNSTextTemplate":{"name":"email template","template":"Alarm ${ALARM_NAME} changes status to ${ALARM_CURRENT_STATUS}","recoveryTemplate":"Alarm ${ALARM_NAME} Resource ${ALARM_RESOURCE_NAME} changes status to ${ALARM_CURRENT_STATUS}","defaultTemplate":true}}' http://localhost:8080/zstack/v1/zwatch/alarms/sns/text-templates/108482a9d3153463abd49712701ad937/actions
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 2.3 | |
| name | String | body (contained in the updateSNSTextTemplate structure) | Optional. The resource name. | 2.3 | |
| description | String | body (contained in the updateSNSTextTemplate structure) | Optional. The detailed description of the resource. | 2.3 | |
| template | String | body (contained in the updateSNSTextTemplate structure) | Optional. The template text. | 2.3 | |
| recoveryTemplate | String | body (contained in the updateSNSTextTemplate structure) | Optional. The recovery template text, which is a string. | 3.4.0 | |
| defaultTemplate | Boolean | body (contained in the updateSNSTextTemplate structure) | Optional. Whether to set the template as the default template. | 2.3 | |
| systemTags | List | body | Optional. The system tags. | 2.3 | |
| userTags | List | body | Optional. The user tags. | 2.3 |
API Response
Sample Response
{
"inventory": {
"uuid": "cc881c03f4c04ea9a0e0dda61f4c2f00",
"name": "email template",
"applicationPlatformType": "Email",
"template": "Alarm ${ALARM_NAME} changes status to ${ALARM_CURRENT_STATUS}",
"recoveryTemplate": "Alarm ${ALARM_NAME} Resource ${ALARM_RESOURCE_NAME} changes status to ${ALARM_CURRENT_STATUS}",
"defaultTemplate": false,
"createDate": "Jul 6, 2018 1:51:22 PM",
"lastOpDate": "Jul 6, 2018 1:51:22 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. | 2.3 |
| inventory | SNSTextTemplateInventory | See inventory. | 2.3 |
#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. | 2.3 |
| description | String | The brief description of the error. | 2.3 |
| details | String | The details about the error. | 2.3 |
| elaboration | String | The reserved field. Default value: null. | 2.3 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.3 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.3 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.3 |
| name | String | Th resource name. | 2.3 |
| description | String | The detailed description of the resource. | 2.3 |
| applicationPlatformType | String | The application platform type. | 2.3 |
| template | String | The template text. | 2.3 |
| recoveryTemplate | String | The recovery template text. | 3.4.0 |
| defaultTemplate | Boolean | Whether to set the template as the default template. | 2.3 |
| createDate | Timestamp | The creation date. | 2.3 |
| lastOpDate | Timestamp | The last operation date. | 2.3 |
SDK Sample
Java SDK
UpdateSNSTextTemplateAction action = new UpdateSNSTextTemplateAction();
action.uuid = "108482a9d3153463abd49712701ad937";
action.name = "email template";
action.template = "Alarm ${ALARM_NAME} changes status to ${ALARM_CURRENT_STATUS}";
action.recoveryTemplate = "Alarm ${ALARM_NAME} Resource ${ALARM_RESOURCE_NAME} changes status to ${ALARM_CURRENT_STATUS}";
action.defaultTemplate = true;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateSNSTextTemplateAction.Result res = action.call();
Python SDK
action = UpdateSNSTextTemplateAction()
action.uuid = "108482a9d3153463abd49712701ad937"
action.name = "email template"
action.template = "Alarm ${ALARM_NAME} changes status to ${ALARM_CURRENT_STATUS}"
action.recoveryTemplate = "Alarm ${ALARM_NAME} Resource ${ALARM_RESOURCE_NAME} changes status to ${ALARM_CURRENT_STATUS}"
action.defaultTemplate = true
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
QuerySNSTextTemplate
API Request
URLs
GET zstack/v1/zwatch/alarms/sns/text-templates
GET zstack/v1/zwatch/alarms/sns/text-templates/{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/zwatch/alarms/sns/text-templates?q=name=test
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/alarms/sns/text-templates/1dc97bd699e739c6968fb3e702ab4cb6
Queryable Fields
You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QuerySNSTextTemplate, and pressing the Tab key.
API Response
Sample Response
{
"inventories": [
{
"uuid": "c275ce35fae13a09bcd4c54a7406bd3e",
"name": "Test-SNS-Template",
"description": "sns text template",
"applicationPlatformType": "Email",
"template": "Alarm ${ALARM_NAME} status is changed to ${ALARM_CURRENT_STATUS}",
"defaultTemplate": false,
"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. | 2.3 |
| inventories | List | See inventories. | 2.3 |
#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. | 2.3 |
| description | String | The brief description of the error. | 2.3 |
| details | String | The details about the error. | 2.3 |
| elaboration | String | The reserved field. Default value: null. | 2.3 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.3 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.3 |
#inventories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.3 |
| name | String | Th resource name. | 2.3 |
| description | String | The detailed description of the resource. | 2.3 |
| applicationPlatformType | String | The application platform type. | 2.3 |
| template | String | The template text. | 2.3 |
| defaultTemplate | Boolean | Whether to set the template as the default template. | 2.3 |
| createDate | Timestamp | The creation date. | 2.3 |
| lastOpDate | Timestamp | The last operation date. | 2.3 |
SDK Sample
Java SDK
QuerySNSTextTemplateAction action = new QuerySNSTextTemplateAction();
action.conditions = asList("name=test");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QuerySNSTextTemplateAction.Result res = action.call();
Python SDK
action = QuerySNSTextTemplateAction()
action.conditions = ["name=test"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
CreateAliyunSmsSNSTextTemplate
API Request
URLs
POST zstack/v1/zwatch/alarms/sns/text-templates/aliyun-sms
Headers
Authorization: OAuth the-session-uuid
Body
{
"params": {
"sign": "Example",
"alarmTemplateCode": "SMS_153055065",
"eventTemplateCode": "SMS_153055066",
"eventTemplate": "Event ${EVENT_NAME} happend.",
"name": "aliyunSMS Template",
"applicationPlatformType": "AliyunSms",
"template": "Alarm ${ALARM_NAME} changes status to ${ALARM_CURRENT_STATUS}",
"defaultTemplate": true
},
"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":{"sign":"Example","alarmTemplateCode":"SMS_153055065","eventTemplateCode":"SMS_153055066","eventTemplate":"Event ${EVENT_NAME} happend.","name":"aliyunSMS Template","applicationPlatformType":"AliyunSms","template":"Alarm ${ALARM_NAME} changes status to ${ALARM_CURRENT_STATUS}","defaultTemplate":true}}' http://localhost:8080/zstack/v1/zwatch/alarms/sns/text-templates/aliyun-sms
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| sign | String | body (contained in the params structure) | The SMS signature. | 3.7.0 | |
| alarmTemplateCode | String | body (contained in the params structure) | The resource alarm template code. | 3.7.0 | |
| eventTemplateCode | String | body (contained in the params structure) | The event alarm template code. | 3.7.0 | |
| eventTemplate | String | body (contained in the params structure) | Optional. The event alarm template text. | 3.7.0 | |
| name | String | body (contained in the params structure) | The template name. | 3.7.0 | |
| description | String | body (contained in the params structure) | Optional. The detailed description of the template. | 3.7.0 | |
| applicationPlatformType | String | body (contained in the params structure) | The type of the SNS application platform. | 3.7.0 | |
| template | String | body (contained in the params structure) | The resource alarm template text. | 3.7.0 | |
| recoveryTemplate | String | body (contained in the params structure) | Optional. The recovery template text. | 3.7.0 | |
| defaultTemplate | Boolean | body (contained in the params structure) | Optional. Whether to set the template as the default template. | 3.7.0 | |
| resourceUuid | String | body (contained in the params structure) | Optional. | 3.7.0 | |
| tagUuids | List | body (contained in the params structure) | Optional. The tag UUID list. | 3.7.0 | |
| systemTags | List | body | Optional. The system tags. | 3.7.0 | |
| userTags | List | body | Optional. The user tags. | 3.7.0 |
API Response
Sample Response
{
"inventory": {
"uuid": "335d5580cfad41d98e699d5d80830818",
"name": "email template",
"applicationPlatformType": "Email",
"template": "Alarm ${ALARM_NAME} changes status to ${ALARM_CURRENT_STATUS}",
"recoveryTemplate": "Resource ${EVENT_RESOURCE_ID} changes status to ${ALARM_CURRENT_STATUS}",
"defaultTemplate": false,
"createDate": "Oct 8, 2019 5:31:52 PM",
"lastOpDate": "Oct 8, 2019 5:31:52 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.7.0 |
| inventory | SNSTextTemplateInventory | See inventory. | 3.7.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.7.0 |
| description | String | The brief description of the error. | 3.7.0 |
| details | String | The details about the error. | 3.7.0 |
| elaboration | String | The reserved field. Default value: null. | 3.7.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 3.7.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.7.0 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 3.7.0 |
| name | String | Th resource name. | 3.7.0 |
| description | String | The detailed description of the resource. | 3.7.0 |
| applicationPlatformType | String | The application platform type. | 3.7.0 |
| template | String | The template text. | 3.7.0 |
| recoveryTemplate | String | The recovery template text. | 3.7.0 |
| defaultTemplate | Boolean | Whether to set the template as the default template. | 3.7.0 |
| createDate | Timestamp | The creation date. | 3.7.0 |
| lastOpDate | Timestamp | The last operation date. | 3.7.0 |
SDK Sample
Java SDK
CreateAliyunSmsSNSTextTemplateAction action = new CreateAliyunSmsSNSTextTemplateAction();
action.sign = "Example";
action.alarmTemplateCode = "SMS_153055065";
action.eventTemplateCode = "SMS_153055066";
action.eventTemplate = "Event ${EVENT_NAME} happend.";
action.name = "aliyunSMS Template";
action.applicationPlatformType = "AliyunSms";
action.template = "Alarm ${ALARM_NAME} changes status to ${ALARM_CURRENT_STATUS}";
action.defaultTemplate = true;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateAliyunSmsSNSTextTemplateAction.Result res = action.call();
Python SDK
action = CreateAliyunSmsSNSTextTemplateAction()
action.sign = "Example"
action.alarmTemplateCode = "SMS_153055065"
action.eventTemplateCode = "SMS_153055066"
action.eventTemplate = "Event ${EVENT_NAME} happend."
action.name = "aliyunSMS Template"
action.applicationPlatformType = "AliyunSms"
action.template = "Alarm ${ALARM_NAME} changes status to ${ALARM_CURRENT_STATUS}"
action.defaultTemplate = true
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
UpdateAliyunSmsSNSTextTemplate
API Request
URLs
PUT zstack/v1/zwatch/alarms/sns/text-templates/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
"updateAliyunSmsSNSTextTemplate": {
"alarmTemplateCode": "SMS_123456789",
"sign": " Sample signature",
"eventTemplateCode": "SMS_987654321",
"eventTemplate": "your aliyun sms event template here",
"name": "aliyunSmsTemplate",
"description": "description",
"template": "your aliyun sms alarm template here",
"defaultTemplate": true
},
"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 '{"updateAliyunSmsSNSTextTemplate":{"alarmTemplateCode":"SMS_123456789","sign":" Sample signature","eventTemplateCode":"SMS_987654321","eventTemplate":"your aliyun sms event template here","name":"aliyunSmsTemplate","description":"description","template":"your aliyun sms alarm template here","defaultTemplate":true}}' http://localhost:8080/zstack/v1/zwatch/alarms/sns/text-templates/d7e89644ef273ca8baf451bf845553fd/actions
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| alarmTemplateCode | String | body (contained in the updateAliyunSmsSNSTextTemplate structure) | Optional. The resource alarm template code. | 3.7.0 | |
| sign | String | body (contained in the updateAliyunSmsSNSTextTemplate structure) | Optional. The SMS message signature. | 3.7.0 | |
| eventTemplateCode | String | body (contained in the updateAliyunSmsSNSTextTemplate structure) | Optional. The event template code. | 3.7.0 | |
| eventTemplate | String | body (contained in the updateAliyunSmsSNSTextTemplate structure) | Optional. The event alarm template text. | 3.7.0 | |
| uuid | String | url | The template UUID. | 3.7.0 | |
| name | String | body (contained in the updateAliyunSmsSNSTextTemplate structure) | Optional. The template name. | 3.7.0 | |
| description | String | body (contained in the updateAliyunSmsSNSTextTemplate structure) | Optional. The detailed description of the template. | 3.7.0 | |
| template | String | body (contained in the updateAliyunSmsSNSTextTemplate structure) | Optional. The resource alarm template text. | 3.7.0 | |
| recoveryTemplate | String | body (contained in the updateAliyunSmsSNSTextTemplate structure) | Optional. The recovery template text. | 3.7.0 | |
| defaultTemplate | Boolean | body (contained in the updateAliyunSmsSNSTextTemplate structure) | Optional. Whether to set the template as the default template. | 3.7.0 | |
| systemTags | List | body | Optional. The system tags. | 3.7.0 | |
| userTags | List | body | Optional. The user tags. | 3.7.0 |
API Response
Sample Response
{
"inventory": {
"alarmTemplateCode": "SMS_153055065",
"sign": " Sample signature",
"eventTemplateCode": "SMS_123456789",
"eventTemplate": "Event ${EVENT_NAME} had just happened",
"uuid": "f8b819b8af9c402fac43932ef95cb468",
"name": "email template",
"applicationPlatformType": "AliyunSms",
"template": "Alarm ${ALARM_NAME} changes status to ${ALARM_CURRENT_STATUS}",
"recoveryTemplate": "Resource ${EVENT_RESOURCE_ID} changes status to ${ALARM_CURRENT_STATUS}",
"defaultTemplate": false,
"createDate": "Oct 8, 2019 5:32:12 PM",
"lastOpDate": "Oct 8, 2019 5:32:12 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.7.0 |
| inventory | AliyunSmsSNSTextTemplateInventory | See inventory. | 3.7.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.7.0 |
| description | String | The brief description of the error. | 3.7.0 |
| details | String | The details about the error. | 3.7.0 |
| elaboration | String | The reserved field. Default value: null. | 3.7.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 3.7.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.7.0 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| alarmTemplateCode | String | The resource alarm template code. | 3.7.0 |
| sign | String | The SMS message signature. | 3.7.0 |
| eventTemplateCode | String | The event alarm template code. | 3.7.0 |
| eventTemplate | String | The event alarm template text. | 3.7.0 |
| uuid | String | The template UUID. | 3.7.0 |
| name | String | The template name. | 3.7.0 |
| description | String | The detailed description of the template. | 3.7.0 |
| applicationPlatformType | String | The application platform type. | 3.7.0 |
| template | String | The resource alarm template text. | 3.7.0 |
| recoveryTemplate | String | The recovery template text. | 3.7.0 |
| defaultTemplate | Boolean | Whether to set the template as the default template. | 3.7.0 |
| createDate | Timestamp | The creation date. | 3.7.0 |
| lastOpDate | Timestamp | The last operation date. | 3.7.0 |
SDK Sample
Java SDK
UpdateAliyunSmsSNSTextTemplateAction action = new UpdateAliyunSmsSNSTextTemplateAction();
action.alarmTemplateCode = "SMS_123456789";
action.sign = " Sample signature";
action.eventTemplateCode = "SMS_987654321";
action.eventTemplate = "your aliyun sms event template here";
action.uuid = "d7e89644ef273ca8baf451bf845553fd";
action.name = "aliyunSmsTemplate";
action.description = "description";
action.template = "your aliyun sms alarm template here";
action.defaultTemplate = true;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateAliyunSmsSNSTextTemplateAction.Result res = action.call();
Python SDK
action = UpdateAliyunSmsSNSTextTemplateAction()
action.alarmTemplateCode = "SMS_123456789"
action.sign = " Sample signature"
action.eventTemplateCode = "SMS_987654321"
action.eventTemplate = "your aliyun sms event template here"
action.uuid = "d7e89644ef273ca8baf451bf845553fd"
action.name = "aliyunSmsTemplate"
action.description = "description"
action.template = "your aliyun sms alarm template here"
action.defaultTemplate = true
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
QueryAliyunSmsSNSTextTemplate
API Request
URLs
GET zstack/v1/zwatch/alarms/sns/text-templates/aliyun-sms
GET zstack/v1/zwatch/alarms/sns/text-templates/aliyun-sms/{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/zwatch/alarms/sns/text-templates/aliyun-sms?q=smsTemplateCode=SMS_123456789
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/alarms/sns/text-templates/aliyun-sms/f7ffc76a46233bc590acd41e1954ed29
Queryable Fields
You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryAliyunSmsSNSTextTemplate, and pressing the Tab key.
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
QueryAliyunSmsSNSTextTemplateAction action = new QueryAliyunSmsSNSTextTemplateAction();
action.conditions = asList("smsTemplateCode=SMS_123456789");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryAliyunSmsSNSTextTemplateAction.Result res = action.call();
Python SDK
action = QueryAliyunSmsSNSTextTemplateAction()
action.conditions = ["smsTemplateCode=SMS_123456789"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
Audit Operations
GetAuditData
API Request
URLs
GET zstack/v1/zwatch/audits
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/zwatch/audits?startTime=1.557300700509E12&limit=50.0&auditType=Resource
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| startTime | Long | query | Optional. The start time. | 2.3 | |
| endTime | Long | query | Optional. The end time. | 2.3 | |
| limit | Integer | query | Optional. The maximum number of returned records. | 2.3 | |
| labels | List | query | Optional. The filter label list. | 2.3 | |
| auditType | AuditType | query | Optional. The audit type. |
|
3.5.0 |
| systemTags | List | query | Optional. The system tags. | 2.3 | |
| userTags | List | query | Optional. The user tags. | 2.3 |
API Response
Sample Response
{
"audits": [
{
"resourceUuid": "b1ca3fab6ebc4302ad9249d5402cb06c",
"resourceType": "VmInstanceVO",
"clientIp": "172.0.0.1",
"clientBrowser": "Chrome/69.0.3497.81",
"apiName": "org.zstack.header.vm.APISetVmRDPMsg",
"operatorAccountUuid": "36c27e8ff05c4780bf6d2fa65700f22e",
"duration": 22.0,
"requestUuid": "d78093c0b2fb3850b3ce563b3a0b029d",
"responseUuid": "08cf3fd2c4614811b4acc0620e20a98e",
"sessionUuid": "05e5c663eb794faab5c5606c38103a17",
"responseDump": "{\"success\":true}",
"time": 1.512037844556E12
}
]
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.3 |
| audits | List | See audits. | 2.3 |
#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 |
#audits
| Name | Type | Description | Starting Version |
|---|---|---|---|
| resourceUuid | String | The resource UUID. | 2.3 |
| resourceType | String | The resource type. | 2.3 |
| apiName | String | The API name. | 2.3 |
| error | String | The details about the error. | 2.3 |
| operatorAccountUuid | String | The UUID of the account that initiated the API. | 2.3 |
| duration | long | The API duration. | 2.3 |
| requestUuid | String | The API request UUID. | 2.3 |
| responseUuid | String | The API response UUID. | 2.3 |
| sessionUuid | String | The session UUID. | 2.3 |
| requestDump | String | The JSON archive of the API request. | 2.3 |
| responseDump | String | The JSON archive of the API response. | 2.3 |
| time | long | The time that the record was generated. | 2.3 |
SDK Sample
Java SDK
GetAuditDataAction action = new GetAuditDataAction();
action.startTime = 1.557300701132E12;
action.limit = 50.0;
action.conditions = asList("VMUuid=4ca37b1e21e846bf8d35b23d4138489c");
action.auditType = "Resource";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetAuditDataAction.Result res = action.call();
Python SDK
action = GetAuditDataAction()
action.startTime = 1.557300701178E12
action.limit = 50.0
action.conditions = [VMUuid=6623c395df0d44b6afc3732e76aac0ac]
action.auditType = "Resource"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
