template.update
Opis
object template.update(object/array templates)
Ta metoda umożliwia aktualizację istniejących szablonów.
Ta metoda jest dostępna tylko dla użytkowników typu Admin i Super admin.Uprawnienia do wywołania tej metody mogą zostać odebrane w ustawieniach roli użytkownika.Zobacz Role użytkowników aby uzyskać więcej informacji.
Parametry
(object/array) Właściwości szablonów do zaktualizowania.
Właściwość templateid musi być zdefiniowana dla każdego szablonu, wszystkie inne
właściwości są opcjonalne. Tylko podane właściwości zostaną zaktualizowane, pozostałe
pozostaną niezmienione.
Oprócz standardowych właściwości szablonu, metoda akceptuje następujące parametry.
| Parametr | Typ | Opis |
|---|---|---|
| groups | object/array | Grupy hostów, które mają zastąpić bieżące grupy hostów, do których należą szablony. Grupy hostów muszą mieć zdefiniowaną właściwość groupid. |
| tags | object/array | Znaczniki szablonu, które mają zastąpić bieżące znaczniki szablonu. |
| macros | object/array | Makra użytkownika, które mają zastąpić bieżące makra użytkownika w podanych szablonach. |
| templates | object/array | Szablony, które mają zastąpić aktualnie połączone szablony. Szablony, które nie są przekazywane, są tylko odłączane. Szablony muszą mieć zdefiniowaną właściwość templateid. |
| templates_clear | object/array | Szablony, które mają zostać odłączone i wyczyszczone z podanych szablonów. Szablony muszą mieć zdefiniowaną właściwość templateid. |
Zwracane wartości
(object) Zwraca obiekt zawierający identyfikatory zaktualizowanych szablonów
we właściwości templateids.
Przykłady
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
}
Źródło
CTemplate::update() w ui/include/classes/api/services/CTemplate.php.