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.

ParameterTypeDescription
templates
(required)
object/arrayTemplates to be updated.

The templates must have the templateid property defined.
groupsobject/arrayHost groups to replace the current host groups the templates belong to.

The host groups must have the groupid property defined.
macrosobject/arrayUser macros to replace the current user macros on the given templates.
templates_clearobject/arrayTemplates to unlink and clear from the given templates.

The templates must have the templateid property defined.
templates_linkobject/arrayTemplates to replace the currently linked templates.

The templates must have the templateid property defined.

Return values

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

Examples

Replacing host groups

Unlink and clear template “10091” from the given templates.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "template.massupdate",
  4. "params": {
  5. "templates": [
  6. {
  7. "templateid": "10085"
  8. },
  9. {
  10. "templateid": "10086"
  11. }
  12. ],
  13. "templates_clear": [
  14. {
  15. "templateid": "10091"
  16. }
  17. ]
  18. },
  19. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  20. "id": 1
  21. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "templateids": [
  5. "10085",
  6. "10086"
  7. ]
  8. },
  9. "id": 1
  10. }

See also

Source

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