更新

Description 说明

object triggerprototype.update(object/array triggerPrototypes)

This method allows to update existing trigger prototypes. 此方法允许更新已有的触发器原型。

Parameters 参数

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

Parameter 参数 T pe 类型 Des ription 说明
dependencies array 数组 T iggers and trigger prototypes that the trigger prototype is dependent on. 依赖触发器原型的触发器和触发器原型。

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

The trigger expression has to be given in its expanded form and must contain at least one item prototype. 指定的触发器表达式必须为展开式,并且必须包含至少一个监控项原型。

Return values 返回值

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

Examples 范例

Enabling a trigger prototype 启用触发器原型

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

Request 请求:

{
           "jsonrpc": "2.0",
           "method": "triggerprototype.update",
           "params": {
               "triggerid": "13938",
               "status": 0
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response 响应:

{
           "jsonrpc": "2.0",
           "result": {
               "triggerids": [
                   "13938"
               ]
           },
           "id": 1
       }

Replacing trigger prototype tags 替换触发器原型标签

Replace tags for one trigger prototype. 为触发器原型替换标签。

Request 请求:

{
           "jsonrpc": "2.0",
           "method": "triggerprototype.update",
           "params": {
               "triggerid": "17373",
               "tags": [
                   {
                       "tag": "volume",
                       "value": "{#FSNAME}"
                   },
                   {
                       "tag": "type",
                       "value": "{#FSTYPE}"
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response 响应:

{
           "jsonrpc": "2.0",
           "result": {
               "triggerids": [
                   "17373"
               ]
           },
           "id": 1
       }

Source 源码

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