itemprototype.update

Description

object itemprototype.update(object/array itemPrototypes)

This method allows to update existing item prototypes.

This method is only available to Admin and Super admin user types. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object/array) Item prototype properties to be updated.

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.

Additionally to the standard item prototype properties, the method accepts the following parameters.

Parameter Type Description
preprocessing array Item prototype preprocessing options to replace the current preprocessing options.

Parameter behavior:
- read-only for inherited objects
tags array Item prototype tags.

Return values

(object) Returns an object containing the IDs of the updated item prototypes under the itemids property.

Examples

Changing the interface of an item prototype

Change the host interface that will be used by discovered items.

Request:

{
           "jsonrpc": "2.0",
           "method": "itemprototype.update",
           "params": {
               "itemid": "27428",
               "interfaceid": "132"
           },
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "itemids": [
                   "27428"
               ]
           },
           "id": 1
       }

Update dependent 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.

Request:

{
           "jsonrpc": "2.0",
           "method": "itemprototype.update",
           "params": {
               "master_itemid": "25570",
               "itemid": "189030"
           },
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "itemids": [
                   "189030"
               ]
           },
           "id": 1
       }

Update HTTP agent item prototype

Change query fields and remove all custom headers.

Request:

{
           "jsonrpc": "2.0",
           "method": "itemprototype.update",
           "params": {
               "itemid":"28305",
               "query_fields": [
                   {
                       "random": "qwertyuiopasdfghjklzxcvbnm"
                   }
               ],
               "headers": []
           }
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "itemids": [
                   "28305"
               ]
           },
           "id": 1
       }

Updating item preprocessing options

Update an item prototype with item preprocessing rule “Custom multiplier”.

Request:

{
           "jsonrpc": "2.0",
           "method": "itemprototype.update",
           "params": {
               "itemid": "44211",
               "preprocessing": [
                   {
                       "type": 1,
                       "params": "4",
                       "error_handler": 2,
                       "error_handler_params": "5"
                   }
               ]
           },
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "itemids": [
                   "44211"
               ]
           },
           "id": 1
       }

Updating a script item prototype

Update a script item prototype with a different script and remove unnecessary parameters that were used by previous script.

Request:

{
           "jsonrpc": "2.0",
           "method": "itemprototype.update",
           "params": {
               "itemid": "23865",
               "parameters": [],
               "script": "Zabbix.log(3, 'Log test');\nreturn 1;"
           },
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "itemids": [
                   "23865"
               ]
           },
           "id": 1
       }

Source

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