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.

ParameterTypeDescription
preprocessingarrayItem prototype preprocessing options to replace the current preprocessing options.
tagsarrayItem 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:

  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

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:

  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

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. }

Updating item preprocessing options

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

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "itemprototype.update",
  4. "params": {
  5. "itemid": "44211",
  6. "preprocessing": [
  7. {
  8. "type": "1",
  9. "params": "4",
  10. "error_handler": "2",
  11. "error_handler_params": "5"
  12. }
  13. ]
  14. },
  15. "auth": "700ca65537074ec963db7efabda78259",
  16. "id": 1
  17. }

Response:

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

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:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "itemprototype.update",
  4. "params": {
  5. "itemid": "23865",
  6. "parameters": [],
  7. "script": "Zabbix.Log(3, 'Log test');\nreturn 1;"
  8. },
  9. "auth": "700ca65537074ec963db7efabda78259",
  10. "id": 1
  11. }

Response:

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

Source

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