This is a translation of the original English documentation page. Help us make it better.

template.update

説明

object template.update(object/array templates)

このメソッドで、既存のテンプレートを更新できます。

このメソッドはAdminおよびSuper adminユーザータイプでのみ使用できます。 メソッドを呼び出す権限は、ユーザーロール設定で取り消すことができます。 詳細についてはユーザーの役割を参照してください。

パラメータ

(object/array) 更新するテンプレート プロパティ

テンプレートごとに templateid プロパティを定義する必要があります。すべてのプロパティはオプションです。 指定されたプロパティのみが更新され、他のプロパティは変更されません。

このメソッドは標準のテンプレート プロパティに加えて、次のパラメーターを受け入れます。

パラメータ タイプ 説明
groups object/array ホストグループを使用して、テンプレートが属する現在のホスト グループを置き換えます。

ホストグループにはgroupid プロパティが定義されている必要があります。
tags object/array テンプレートタグを使用して、現在のテンプレート タグを置き換えます。
macros object/array ユーザー マクロを使用して、特定のテンプレートの現在のユーザー マクロを置き換えます。
templates object/array テンプレート を使用して、現在リンクされているテンプレートを置き換えます。リンクが渡されなかったテンプレートは、リンクのみ解除されます。

テンプレートには templateid プロパティが定義されている必要があります。
templates_clear object/array テンプレートで指定されたテンプレートからリンクを解除してクリアします。

テンプレートには templateid プロパティが定義されている必要があります。

戻り値

(object) templateids プロパティの下で更新されたテンプレートの ID を含むオブジェクトを返します。

標準テンプレートのプロパティの変更

テンプレートの技術名を "Linux by Zabbix agent Custom" に、表示名を "My template"に変更し、テンプレートの説明を更新します。

リクエスト:

{
           "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."
           },
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "templateids": [
                   "10086"
               ]
           },
           "id": 1
       }

テンプレートグループの更新

指定されたテンプレートのすべてのテンプレートグループを別のテンプレートグループに置き換えます。

リクエスト:

{
           "jsonrpc": "2.0",
           "method": "template.update",
           "params": {
               "templateid": "10086",
               "groups": [
                   {
                       "groupid": "24"
                   } 
               ]
           },
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "templateids": [
                   "10086"
               ]
           },
           "id": 1
       }

テンプレートタグの更新

すべてのテンプレート タグを新しいものに置き換えます

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": {
               "hostids": [
                   "10086"
               ]
           },
           "id": 1
       }

テンプレートマクロの更新

すべてのテンプレートマクロを別のマクロに置き換えます。

リクエスト:

{
           "jsonrpc": "2.0",
           "method": "template.update",
           "params": {
               "templateid": "10086",
               "macros": [
                   {
                       "macro": "{$MY_MACRO}",
                       "value": "new_value"
                   }
               ]
           },
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "templateids": [
                   "10086"
               ]
           },
           "id": 1
       }

テンプレートにリンクされたテンプレートの更新

指定されたテンプレートからすべてのテンプレートのリンクを解除(クリアせず)し、別のテンプレートをそのテンプレートにリンクします。

リクエスト:

{
           "jsonrpc": "2.0",
           "method": "template.update",
           "params": {
               "templateid": "10086",
               "templates": [
                   {
                       "templateid": "10087"
                   }
               ]
           },
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "templateids": [
                   "10086"
               ]
           },
           "id": 1
       }

テンプレートにリンクされたテンプレートのクリア

指定されたテンプレートを、特定のリンクされたテンプレートからリンク解除してクリアします。

リクエスト:

{
           "jsonrpc": "2.0",
           "method": "template.update",
           "params": {
               "templateid": "10086",
               "templates_clear": [
                   {
                       "templateid": "10087"
                   }
               ]
           },
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "templateids": [
                   "10086"
               ]
           },
           "id": 1
       }

ソース

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