This is a translation of the original English documentation page. Help us make it better.

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
(required)
object/array Templates to be updated.

The templates must have the templateid property defined.
groups object/array Host groups to replace the current host groups the templates belong to.

The host groups must have the groupid property defined.
macros object/array User macros to replace 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 the templateid property defined.
templates_link object/array Templates to replace the currently linked templates.

The templates must have the templateid property defined.

Valori di ritorno

(object) Restituisce un oggetto contenente gli ID dei modelli aggiornati sotto la proprietà templateids.

Esempi

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 host groups

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"
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

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

Guarda anche

Fonte

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