itemprototype.update

Description

说明

object itemprototype.update(object/array **itemPrototypes**)

This method allows to update existing item prototypes. 此方法允许更新存在的item prototypes(监控项原型)。

Parameters

参数

(object/array) Item prototype properties to be updated.Item prototype 要更新的属性。

The itemid property must be defined for each item prototype, all other properties are optional. Only the passed properties will be updated, all others will remain unchanged.Item prototype 的 itemid的属性必须定义,所有其他属性为可选。只用被传递的属性才会被更新,所有其他未被传递的属性保持不变。

Additionally to the standard item prototype properties, the method accepts the following parameters.此方法接受如下参数。

ParameterTypeDescription 说明
applicationsarrayIDs of the applications to replace the current applications. 要替换当前应用程序的应用程序的IDS。
applicationPrototypesarrayNames of the application prototypes to replace the current application prototypes. 要替换当前应用程序原型的应用程序原型名称。
preprocessingarrayItem prototype preprocessing options to replace the current preprocessing options. 要替换当前预处理选项的item prototype的预处理选项。

Return values

返回值

(object) Returns an object containing the IDs of the updated item prototypes under the itemids property. (object)itemids属性中返回一个包含已被更新的item prototypes的IDs对象。

Examples

示例

Changing the interface of an item prototype

改变 item prototype 的接口

Change the host interface that will be used by discovered items. 改变将被用于发现监控项的主机接口。

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "itemprototype.update",
  4. "params": {
  5. "itemid": "27428",
  6. "interfaceid": "132"
  7. },
  8. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  9. "id": 1
  10. }

Response:

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

Update dependent item prototype

更新依赖的item prototype

Update Dependent item prototype with new Master item prototype ID. Only dependencies on same host (template/discovery rule) are allowed, therefore Master and Dependent item should have same hostid and ruleid. 以新的主item prototype的ID来更新依赖的 item prototype。只有在相同host(template/discovery rule)的依赖才允许,因此主监控项和依赖监控项应有相同hostid和ruleid。

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "itemprototype.update",
  4. "params": {
  5. "master_itemid": "25570",
  6. "itemid": "189030"
  7. },
  8. "auth": "700ca65537074ec963db7efabda78259",
  9. "id": 1
  10. }

Response:

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

Update HTTP agent item prototype

更新 HTTP agent item prototype

Change query fields and remove all custom headers. 改变查询字段并移除所有自定义请求头。

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "itemprototype.update",
  4. "params": {
  5. "itemid":"28305",
  6. "query_fields": [
  7. {
  8. "random": "qwertyuiopasdfghjklzxcvbnm"
  9. }
  10. ],
  11. "headers": []
  12. }
  13. "auth": "700ca65537074ec963db7efabda78259",
  14. "id": 1
  15. }

Response:

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

Source

CItemPrototype::update() in frontends/php/include/classes/api/services/CItemPrototype.php.