api:trigger:create

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

api:trigger:create [2014/09/25 14:40]
sasha Page moved from 1.8:api:trigger:create to api:trigger:create
api:trigger:create [2019/01/28 14:45]
sasha <code js> => <code java>
Line 1: Line 1:
-===== create() ===== 
-This function allows you to create a trigger as defined by the **trigger data** array. 
  
-==== Parameters ==== 
-^Parameter ​      ​^Type ​              ​^Optional^Description^Details^ 
-|**trigger data**|//​array or object//​| ​       |Array of Trigger objects or a single object|**triggerid** shouldn'​t be specified | 
- 
-====Returns==== 
-^Parameter ^Description^ 
-|**result**|Operation successful. Result will contain array of created Trigger IDs. **triggerid** are assigned to each Trigger object | 
-|**error** |In case of any errors| 
-==== Example ==== 
-Create new trigger for host "​ZABBIX-Server"​ and enable it 
-<code js> 
-{ 
-"​jsonrpc":​ "​2.0",​ 
-"​method":​ "​trigger.create",​ 
-"​params":​ [{ 
- "​description":​ "​TEST_MACRO",​ 
- "​expression":​ "​{ZABBIX-Server:​vfs.fs.inode[/,​{$MACRO}].max(\"​{$MACRO2}\"​)}={$MACRO3}",​ 
- "​status":​ 0 
-}], 
-"​auth":​ "​038e1d7b1735c6a5436ee9eae095879e",​ 
-"​id":​ 2 
-} 
-</​code>​ 
- 
-Trigger created successfully:​ 
-<code js> 
-{ 
-"​jsonrpc":​ "​2.0",​ 
-"​result":​ { 
-   "​triggerids":​ ["​100100000214797"​] 
-}, 
-"​id":​ 2 
-} 
-</​code>​ 
- 
-Trigger already exists: 
-<code js> 
-{ 
-"​jsonrpc":​ "​2.0",​ 
-"​error":​ { 
-      "​code":​ -32602, 
-      "​message":​ "​Invalid params.",​ 
-      "​data":​ "[ CTrigger::​create ] Cannot create Trigger"​ 
-}, 
-"​id":​ 2 
-} 
-</​code>​