更新

Description 说明

object trigger.update(object/array **triggers**)

This method allows to update existing triggers. 此方法用于更新目前的触发器。

Parameters 参数

(object/array) Trigger properties to be updated. (object/array)需要更新的触发器属性。 The triggerid property must be defined for each trigger, all other properties are optional. Only the passed properties will be updated, all others will remain unchanged. triggerid属性必须在每个应用集中已定义,其他所有属性为可选项。只有传递过去的属性会被更新,其他所有属性仍然保持不变。 Additionally to the standard trigger properties the method accepts the following parameters. 除standard trigger properties之外,该方法接受以下参数。

Parameter 参数Type 类型Description 说明
dependenciesarray 数组Triggers that the trigger is dependent on. 依赖触发的触发器。

The triggers must have the triggerid property defined. 触发器必须已定义triggerid属性。
tagsarray 数组Trigger tags. 触发器标签。

The trigger expression has to be given in its expanded form. 指定的触发器表达式必须为展开式。

Return values 返回值

(object) Returns an object containing the IDs of the updated triggers under the triggerids property. (object)返回一个对象,该对象包含在triggerids属性中已更新触发器的ID。

Examples 范例

Enabling a trigger 启用触发器

Enable a trigger, that is, set its status to 0. 启用触发器,即将其状态设置为0。

Request 请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "trigger.update",
  4. "params": {
  5. "triggerid": "13938",
  6. "status": 0
  7. },
  8. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  9. "id": 1
  10. }

Response 响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "triggerids": [
  5. "13938"
  6. ]
  7. },
  8. "id": 1
  9. }

Replacing triggers tags 替换触发器标签

Replace tags for trigger. 为触发器替换标签。

Request 请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "trigger.update",
  4. "params": {
  5. "triggerid": "13938",
  6. "tags": [
  7. {
  8. "tag": "service",
  9. "value": "{{ITEM.VALUE}.regsub(\"Service (.*) has stopped\", \"\\1\")}"
  10. },
  11. {
  12. "tag": "error",
  13. "value": ""
  14. }
  15. ]
  16. },
  17. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  18. "id": 1
  19. }

Response 响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "triggerids": [
  5. "13938"
  6. ]
  7. },
  8. "id": 1
  9. }

See also 参考

Source 源码

CTrigger::update() in frontends/php/include/classes/api/services/CTrigger.php. CTrigger::update()方法可在frontends/php/include/classes/api/services/CTrigger.php中参考。