Create Alarm Message Template

POST/zstack/v1/zwatch/alarms/sns/text-templates

Headers

Authorization: OAuth the-session-uuid

Body

{
  "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": []
}

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-templates

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
nameStringbody (contained in the params structure)The resource name 2.3
description (Optional)Stringbody (contained in the params structure)The detailed description of the resource 2.3
applicationPlatformTypeStringbody (contained in the params structure)The SNS application platform type 2.3
templateStringbody (contained in the params structure)The alarm message template text 2.3
recoveryTemplateStringbody (contained in the params structure)The recovery alarm template text 3.4.0
defaultTemplate (Optional)Booleanbody (contained in the params structure)Whether to use as the default template 2.3
resourceUuid (Optional)Stringbody (contained in the params structure)  2.3
systemTags (Optional)ListbodySystem tags 2.3
userTags (Optional)ListbodyUser 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"
  }
}
NameTypeDescriptionStarting Version
errorErrorCodeThe error code. If not null, the operation failed. This field is null on success. See error2.3
inventorySNSTextTemplateInventorySee inventory2.3

error

NameTypeDescriptionStarting Version
codeStringThe error code number. A globally unique identifier for the error, such as SYS.1000, HOST.10010.6
descriptionStringA brief description of the error0.6
detailsStringThe detailed error information0.6
elaborationStringReserved field. Default is null0.6
opaqueLinkedHashMapReserved field. Default is null0.6
causeErrorCodeThe root error. The source error that caused the current error. This field is null if there is no root error0.6

inventory

NameTypeDescriptionStarting Version
uuidStringThe UUID of the resource. Uniquely identifies the resource2.3
nameStringThe resource name2.3
descriptionStringThe detailed description of the resource2.3
applicationPlatformTypeStringThe application platform type2.3
templateStringThe template text2.3
defaultTemplateBooleanWhether it is the default template2.3
createDateTimestampThe creation time2.3
lastOpDateTimestampThe last modification time2.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()