template.update
Description
object template.update(object/array templates)
This method allows to update existing 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/array) Template properties to be updated.
The templateid property must be defined for each template, all other
properties are optional. Only the given properties will be updated, all
others will remain unchanged.
Additionally to the standard template properties, the method accepts the following parameters.
| Parameter | Type | Description |
|---|---|---|
| groups | object/array | Host groups to replace the current host groups the templates belong to. The host groups must have the groupid property defined. |
| tags | object/array | Template tags to replace the current template tags. |
| macros | object/array | User macros to replace the current user macros on the given templates. |
| templates | object/array | Templates to replace the currently linked templates. Templates that are not passed are only unlinked. The templates must have the templateid property defined. |
| templates_clear | object/array | Templates to unlink and clear from the given 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
Changing the standard template properties
Change the technical name of the template to "Linux by Zabbix agent Custom", the visible name to "My template", and update the template description.
Request:
{
"jsonrpc": "2.0",
"method": "template.update",
"params": {
"templateid": "10086",
"host": "Linux by Zabbix agent Custom",
"name": "My template",
"description": "This is a custom Linux template."
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": {
"templateids": [
"10086"
]
},
"id": 1
}
Updating template groups
Replace all template groups for the given template with a different one.
Request:
{
"jsonrpc": "2.0",
"method": "template.update",
"params": {
"templateid": "10086",
"groups": [
{
"groupid": "24"
}
]
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": {
"templateids": [
"10086"
]
},
"id": 1
}
Updating template tags
Replace all template tags with a different one.
Request:
{
"jsonrpc": "2.0",
"method": "template.update",
"params": {
"templateid": "10086",
"tags": [
{
"tag": "Host name",
"value": "{HOST.NAME}"
}
]
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": {
"templateids": [
"10086"
]
},
"id": 1
}
Updating template macros
Replace all template macros with a different one.
Request:
{
"jsonrpc": "2.0",
"method": "template.update",
"params": {
"templateid": "10086",
"macros": [
{
"macro": "{$MY_MACRO}",
"value": "new_value"
}
]
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": {
"templateids": [
"10086"
]
},
"id": 1
}
Updating template linked templates
Unlink (without clearing) all templates from the given template and link a different one to it.
Request:
{
"jsonrpc": "2.0",
"method": "template.update",
"params": {
"templateid": "10086",
"templates": [
{
"templateid": "10087"
}
]
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": {
"templateids": [
"10086"
]
},
"id": 1
}
Clearing template linked templates
Unlink and clear the given template from a specific linked template.
Request:
{
"jsonrpc": "2.0",
"method": "template.update",
"params": {
"templateid": "10086",
"templates_clear": [
{
"templateid": "10087"
}
]
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": {
"templateids": [
"10086"
]
},
"id": 1
}
Fonte
CTemplate::update() in ui/include/classes/api/services/CTemplate.php.