template.massremove

Description

object template.massremove(object parameters)

This method allows to remove related objects from 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 that should be removed.

ParameterTypeDescription
templateids
(required)
string/arrayIDs of the templates to be updated.
groupidsstring/arrayHost groups to remove the given templates from.
macrosstring/arrayUser macros to delete from the given templates.
templateids_clearstring/arrayTemplates to unlink and clear from the given templates (upstream).
templateids_linkstring/arrayTemplates to unlink from the given templates (upstream).

Return values

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

Examples

Removing templates from a group

Remove two templates from group “2”.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "template.massremove",
  4. "params": {
  5. "templateids": [
  6. "10085",
  7. "10086"
  8. ],
  9. "groupids": "2"
  10. },
  11. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  12. "id": 1
  13. }

Response:

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

Unlinking templates from a host

Unlink templates “10106”, “10104” from template “10085”.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "template.massremove",
  4. "params": {
  5. "templateids": "10085",
  6. "templateids_link": [
  7. "10106",
  8. "10104"
  9. ]
  10. },
  11. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  12. "id": 1
  13. }

Response:

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

See also

Source

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