Alarm Text Template (Text Template)
CreateSNSTextTemplate
API Request
URLs
POST zstack/v1/zwatch/alarms/sns/text-templatesHeaders
Authorization: OAuth the-session-uuidBody
Note: In the above example, the systemTags and userTags fields are optional. They are listed to indicate that the body can contain these two fields.
{
"params": {
"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": true
},
"systemTags": [],
"userTags": []
}
Note: In the above example, the systemTags and userTags fields are optional. They are listed to indicate that the body can contain these two fields.Curl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"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":true}}' http://localhost:8080/zstack/v1/zwatch/alarms/sns/text-templatesParameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| name | String | body (contained in the params structure) | The resource name | 2.3 | |
| description (Optional) | String | body (contained in the params structure) | The detailed description of the resource | 2.3 | |
| applicationPlatformType | String | body (contained in the params structure) | The SNS application platform type | 2.3 | |
| template | String | body (contained in the params structure) | The alarm message template text | 2.3 | |
| recoveryTemplate | String | body (contained in the params structure) | The recovery alarm template text | 3.4.0 | |
| defaultTemplate (Optional) | Boolean | body (contained in the params structure) | Whether to use as the default template | 2.3 | |
| resourceUuid (Optional) | String | body (contained in the params structure) | Optional. The resource UUID. | 2.3 | |
| systemTags (Optional) | List | body | System tags | 2.3 | |
| userTags (Optional) | List | body | User tags | 2.3 |
API Response
Response Example
{
"inventory": {
"uuid": "0b13c60e86c44fc08829f40ff73923f7",
"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:04 PM",
"lastOpDate": "Jul 6, 2018 1:51:04 PM"
}
}#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code number. A globally unique identifier for the error, such as SYS.1000, HOST.1001 | 0.6 |
| description | String | A brief description of the error | 0.6 |
| details | String | The detailed error information | 0.6 |
| elaboration | String | Reserved field. Default is null | 0.6 |
| opaque | LinkedHashMap | Reserved field. Default is null | 0.6 |
| cause | ErrorCode | The root error. The source error that caused the current error. This field is null if there is no root error | 0.6 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The UUID of the resource. Uniquely identifies the resource | 2.3 |
| name | String | The 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 it is the default template | 2.3 |
| createDate | Timestamp | The creation time | 2.3 |
| lastOpDate | Timestamp | The last modification time | 2.3 |
SDK Examples
Java
SDK
CreateSNSTextTemplateAction action = new CreateSNSTextTemplateAction();
action.name = "email template";
action.applicationPlatformType = "Email";
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
CreateSNSTextTemplateAction action = CreateSNSTextTemplateAction()
action.name = "email template"
action.applicationPlatformType = "Email"
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()DeleteSNSTextTemplate
Delete an alarm message template.
API Request
URLs
DELETE zstack/v1/zwatch/alarms/sns/text-templates/{uuid}?deleteMode={deleteMode}Headers
Authorization: OAuth the-session-uuidCurl Example
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=PermissiveParameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The UUID of the resource. Uniquely identifies the resource | 2.3 | |
| deleteMode (Optional) | String | url | Optional. The delete mode. | 2.3 | |
| systemTags (Optional) | List | body | System tags | 2.3 | |
| userTags (Optional) | List | body | User tags | 2.3 |
API Response
This API returns an empty JSON structure
{} on success. On failure, the returned JSON structure contains an error field. For example:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Examples
Java
SDK
DeleteSNSTextTemplateAction action = new DeleteSNSTextTemplateAction();
action.uuid = "a4ce47e628303c4fa55743f1b84c61b4";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteSNSTextTemplateAction.Result res = action.call();Python
SDK
DeleteSNSTextTemplateAction action = DeleteSNSTextTemplateAction()
action.uuid = "a4ce47e628303c4fa55743f1b84c61b4"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteSNSTextTemplateAction.Result res = action.call()QuerySNSTextTemplate
Query alarm message templates.
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-uuidCurl Example
Queryable Fieldscurl -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=testcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/alarms/sns/text-templates/1dc97bd699e739c6968fb3e702ab4cb6Run the CLI command line tool, enter QuerySNSTextTemplate and press Tab to view all queryable fields and the resource names available for cross-table queries.
API Response
Response Example
{
"inventories": [
{
"uuid": "c275ce35fae13a09bcd4c54a7406bd3e",
"name": "Test-SNS-Template",
"description": "sns text template",
"applicationPlatformType": "Email",
"template": "报警器 ${ALARM_NAME} 状态改变成 ${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 failed. This field is null on success. See error | 2.3 |
| inventories | List | See inventories | 2.3 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code number. A globally unique identifier for the error, such as SYS.1000, HOST.1001 | 2.3 |
| description | String | A brief description of the error | 2.3 |
| details | String | The detailed error information | 2.3 |
| elaboration | String | Reserved field. Default is null | 2.3 |
| opaque | LinkedHashMap | Reserved field. Default is null | 2.3 |
| cause | ErrorCode | The root error. The source error that caused the current error. This field is null if there is no root error | 2.3 |
#inventories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The UUID of the resource. Uniquely identifies the resource | 2.3 |
| name | String | The 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 it is the default template | 2.3 |
| createDate | Timestamp | The creation time | 2.3 |
| lastOpDate | Timestamp | The last modification time | 2.3 |
SDK Examples
Java
SDK
QuerySNSTextTemplateAction action = new QuerySNSTextTemplateAction();
action.conditions = asList("name=test");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QuerySNSTextTemplateAction.Result res = action.call();Python
SDK
QuerySNSTextTemplateAction action = QuerySNSTextTemplateAction()
action.conditions = ["name=test"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QuerySNSTextTemplateAction.Result res = action.call()GetTextTemplateArg
API Request
URLs
GET zstack/v1/zwatch/textTemplateArgHeaders
Authorization: OAuth the-session-uuidCurl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/textTemplateArgParameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| systemTags (Optional) | List | query | System tags | 4.2.0 | |
| userTags (Optional) | List | query | User tags | 4.2.0 |
API Response
Response Example
{
"defaultSupportedParams": {
"alarm": [
"ALARM_NAME",
"ALARM_UUID",
"ALARM_COMPARISON_OPERATOR",
"ALARM_COMPARISON_OPERATOR_REVERSE",
"ALARM_METRIC",
"ALARM_NAMESPACE",
"ALARM_THRESHOLD",
"ALARM_LABELS",
"ALARM_DURATION",
"ALARM_PREVIOUS_STATUS",
"ALARM_CURRENT_STATUS",
"ALARM_CURRENT_VALUE",
"ALARM_TIME",
"ALARM_RESOURCE_TYPE",
"ALARM_RESOURCE_ID",
"ALARM_RESOURCE_NAME",
"TITLE_ALARM_RESOURCE_NAME",
"ALARM_ACCOUNT_UUID",
"ALARM_DATA_UUID",
"ALARM_EMERGENCY_LEVEL",
"ALARM_RESOURCE_IP",
"ALARM_RESOURCE_CLUSTER_UUID",
"ALARM_RESOURCE_CLUSTER_NAME"
],
"event": [
"EVENT_NAMESPACE",
"EVENT_NAME",
"EVENT_LABELS",
"EVENT_EMERGENCY_LEVEL",
"EVENT_RESOURCE_ID",
"EVENT_RESOURCE_NAME",
"EVENT_ERROR",
"EVENT_TIME",
"EVENT_SUBSCRIPTION_UUID",
"EVENT_ACCOUNT_UUID",
"EVENT_DATA_UUID",
"EVENT_RESOURCE_IP",
"EVENT_RESOURCE_CLUSTER_UUID",
"EVENT_RESOURCE_CLUSTER_NAME"
]
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| defaultSupportedParams | Map | The list of default supported parameters | 4.2.0 |
| success | boolean | Whether the operation succeeded. | 4.2.0 |
| error | ErrorCode | The error code. If not null, the operation failed. This field is null on success. See error | 4.2.0 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code number. A globally unique identifier for the error, such as SYS.1000, HOST.1001 | 2.3 |
| description | String | A brief description of the error | 2.3 |
| details | String | The detailed error information | 2.3 |
| elaboration | String | Reserved field. Default is null | 2.3 |
| opaque | LinkedHashMap | Reserved field. Default is null | 2.3 |
| cause | ErrorCode | The root error. The source error that caused the current error. This field is null if there is no root error | 2.3 |
SDK Examples
Java
SDK
GetTextTemplateArgAction action = new GetTextTemplateArgAction();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetTextTemplateArgAction.Result res = action.call();Python
SDK
GetTextTemplateArgAction action = GetTextTemplateArgAction()
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetTextTemplateArgAction.Result res = action.call()UpdateSNSTextTemplate
Update an alarm message template.
API Request
URLs
PUT zstack/v1/zwatch/alarms/sns/text-templates/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
Note: In the above example, the systemTags and userTags fields are optional. They are listed to indicate that the body can contain these two fields.
{
"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": []
}
Note: In the above example, the systemTags and userTags fields are optional. They are listed to indicate that the body can contain these two fields.Curl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X 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/actionsParameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The UUID of the resource. Uniquely identifies the resource | 2.3 | |
| name (Optional) | String | body (contained in the updateSNSTextTemplate structure) | The resource name | 2.3 | |
| description (Optional) | String | body (contained in the updateSNSTextTemplate structure) | The detailed description of the resource | 2.3 | |
| template (Optional) | String | body (contained in the updateSNSTextTemplate structure) | The alarm message template text | 2.3 | |
| recoveryTemplate (Optional) | String | body (contained in the updateSNSTextTemplate structure) | The recovery alarm message template text | 3.4.0 | |
| defaultTemplate (Optional) | Boolean | body (contained in the updateSNSTextTemplate structure) | Whether it is the default template | 2.3 | |
| systemTags (Optional) | List | body | System tags | 2.3 | |
| userTags (Optional) | List | body | User tags | 2.3 |
API Response
Response Example
{
"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 failed. This field is null on success. See error | 2.3 |
| inventory | SNSTextTemplateInventory | See inventory | 2.3 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code number. A globally unique identifier for the error, such as SYS.1000, HOST.1001 | 2.3 |
| description | String | A brief description of the error | 2.3 |
| details | String | The detailed error information | 2.3 |
| elaboration | String | Reserved field. Default is null | 2.3 |
| opaque | LinkedHashMap | Reserved field. Default is null | 2.3 |
| cause | ErrorCode | The root error. The source error that caused the current error. This field is null if there is no root error | 2.3 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The UUID of the resource. Uniquely identifies the resource | 2.3 |
| name | String | The 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 template text | 3.4.0 |
| defaultTemplate | Boolean | Whether it is the default template | 2.3 |
| createDate | Timestamp | The creation time | 2.3 |
| lastOpDate | Timestamp | The last modification time | 2.3 |
SDK Examples
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
UpdateSNSTextTemplateAction 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"
UpdateSNSTextTemplateAction.Result res = action.call()