template.update
Leírás
object template.update(object/array templates)
Ez a módszer lehetővé teszi a meglévő sablonok frissítését.
Ez a módszer csak az Admin és a Kiemelt rendszergazda számára érhető el felhasználói típusok. A metódus meghívására vonatkozó engedélyek felhasználói szerepkörben visszavonhatók beállítások. Lásd: User roles további információért.
Paraméterek
(objektum/tömb) Frissítendő sablontulajdonságok.
A "templateid" tulajdonságot minden sablonhoz meg kell határozni, az összes többihez a tulajdonságok nem kötelezőek. Csak a megadott tulajdonságok frissülnek, az összes a többi változatlan marad.
A standard sablon tulajdonságok mellett a metódus a következő paramétereket fogadja el.
| Paraméter | Típus | Leírás |
|---|---|---|
| groups | object/array | Host groups a jelenlegi gazdagépcsoportok lecseréléséhez, amelyekhez a sablonok tartoznak. A gazdagépcsoportoknak rendelkezniük kell a "groupid" tulajdonsággal meghatározott. |
| tags | object/array | Sablon címkék az aktuális sabloncímkék cseréjéhez. |
| macros | object/array | Felhasználói makrók a jelenlegi felhasználói makrók lecseréléséhez az adott sablonokon. |
| sablonok | object/array | Sablonok a jelenleg csatolt sablonok lecseréléséhez. A nem átadott sablonokat a rendszer csak leválasztja. A sablonoknak meg kell adni a "templateid" tulajdonságot. |
| templates_clear | object/array | Sablonok az adott sablonok összekapcsolásának megszüntetéséhez és törléséhez. A sablonoknak rendelkezniük kell a "templateid" tulajdonsággal. |
Visszatérési értékek
(object) A frissített sablonok azonosítóit tartalmazó objektumot ad vissza
a templateids tulajdonság alatt.
Példák
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
}
Forrás
CTemplate::update() az ui/include/classes/api/services/CTemplate.php-ban.