You are viewing documentation for the development version, it may be incomplete.
Join our translation project and help translate Zabbix documentation into your native language.

template.massupdate

Description

object template.massupdate(object parameters)

This method allows to simultaneously replace or remove related objects and update properties on multiple templates.

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) Parameters containing the IDs of the templates to update and the objects to replace for the templates.

The method accepts the following parameters.

Parameter Type Description
templates object/array Templates to be updated.

The templates must have only the templateid property defined.

Parameter behavior:
- required
groups object/array Template groups to replace the current template groups the templates belong to.

The template groups must have only the groupid property defined.
macros object/array User macros to replace all of the current user macros on the given templates.
templates_clear object/array Templates to unlink and clear from the given templates.

The templates must have only the templateid property defined.
templates_link object/array Templates to replace the currently linked templates.

The templates must have only the templateid property defined.

Return values

(object) Returns an object containing the IDs of the updated templates under the templateids property.

Examples

Unlinking a template

Unlink and clear template "10091" from the given templates.

Request:

{
           "jsonrpc": "2.0",
           "method": "template.massupdate",
           "params": {
               "templates": [
                   {
                       "templateid": "10085"
                   },
                   {
                       "templateid": "10086"
                   }
               ],
               "templates_clear": [
                   {
                       "templateid": "10091"
                   }
               ]
           },
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "templateids": [
                   "10085",
                   "10086"
               ]
           },
           "id": 1
       }

Replacing user macros

Replace all user macros with the given user macro on multiple templates.

Request:

{
           "jsonrpc": "2.0",
           "method": "template.massupdate",
           "params": {
               "templates": [
                   {
                       "templateid": "10074"
                   },
                   {
                       "templateid": "10075"
                   },
                   {
                       "templateid": "10076"
                   },
                   {
                       "templateid": "10077"
                   }
               ],
               "macros": [
                   {
                       "macro": "{$AGENT.TIMEOUT}",
                       "value": "5m",
                       "description": "Timeout after which agent is considered unavailable. Works only for agents reachable from Zabbix server/proxy (passive mode)."
                   }
               ]
           },
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "templateids": [
                   "10074",
                   "10075",
                   "10076",
                   "10077"
               ]
           },
           "id": 1
       }

See also

Source

CTemplate::massUpdate() in ui/include/classes/api/services/CTemplate.php.