תבנית.עדכון
תיאור
object template.update(object/array templates)
שיטה זו מאפשרת לעדכן תבניות קיימות.
שיטה זו זמינה רק ל-Admin ו-Super Admin סוגי משתמשים. ניתן לבטל הרשאות לקרוא לשיטה בתפקיד משתמש הגדרות. ראה משתמש תפקידים למידע נוסף.
פרמטרים
(אובייקט/מערך) מאפייני תבנית שיש לעדכן.
יש להגדיר את המאפיין 'templateid' עבור כל תבנית, כל השאר נכסים הם אופציונליים. רק המאפיינים הנתונים יעודכנו, כולם אחרים יישארו ללא שינוי.
בנוסף למאפייני תבנית סטנדרטיים, ה- השיטה מקבלת את הפרמטרים הבאים.
| פרמטר | סוג | תיאור |
|---|---|---|
| groups | object/array | מארח קבוצות כדי להחליף את הקבוצות המארחות הנוכחיות שאליהן שייכות התבניות. לקבוצות המארחות חייבות להיות המאפיין groupid מוגדר. |
| tags | object/array | תבנית tags כדי להחליף את תגי התבנית הנוכחיים. |
| macros | object/array | פקודות מאקרו משתמש כדי להחליף את פקודות המאקרו הנוכחיות של המשתמש בתבניות הנתונות. |
| templates | object/array | Templates כדי להחליף את התבניות המקושרות כעת. תבניות שאינן עוברות מנותקות רק. תבניות חייבות להיות מוגדרות המאפיין 'templateid'. |
| templates_clear | object/array | Templates כדי לבטל קישור ולנקות מהתבניות הנתונות. לתבניות חייבות להיות מוגדרות המאפיין 'templateid'. |
החזר ערכים
(אובייקט) מחזירה אובייקט המכיל את המזהים של התבניות המעודכנות
תחת המאפיין 'templateids'.
דוגמאות
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
}
מקור
CTemplate::update() בתוך ui/include/classes/api/services/CTemplate.php.