Sidebar

2022 Zabbix中国峰会
2022 Zabbix中国峰会

template.massadd

Description说明

object template.massadd(object parameters)

This method allows to simultaneously add multiple related objects to the given templates该方法允许同时向给定的模板添加多个相关对象。.

Parameters参数

(object) Parameters containing the IDs of the templates to update and the objects to add to the templates包含要更新的模板的ID和要添加到模板的对象的参数.

The method accepts the following parameters该方法接受以下参数.

Parameter参数 T pe类型 Des ription说明
templates
(required)
object/array Templates to be updated要更新的模板.

The templates must have the templateid property defined模板必须定义templateid属性.
groups object/array Host groups to add the given templates to主机组添加指定的模板.

The host groups must have the groupid property defined主机组必须定义groupid属性.
hosts object/array Hosts and templates to link the given templates to将给定模板链接到的主机和模板.

The hosts must have the hostid property defined主机必须定义groupid属性.
macros object/array User macros to be created for the given templates为给定的模板创建用户宏.
templates_link object/array Templates to link to the given templates链接到给定模板的模板.

The templates must have the templateid property defined模板必须定义templateid属性.

Return values返回值

(object) Returns an object containing the IDs of the updated templates under the templateids property. (object)返回一个对象,它包含templateids属性下更新的模板的ID

Examples范例

Adding templates to a group将模板添加到组

Add two templates to the host group "2"将两个模板添加到主机组"2".

Request请求:

{
           "jsonrpc": "2.0",
           "method": "template.massadd",
           "params": {
               "templates": [
                   {
                       "templateid": "10085"
                   },
                   {
                       "templateid": "10086"
                   }
               ],
               "groups": [
                   {
                       "groupid": "2"
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response响应:

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

Linking a template to hosts将模板链接到主机

Link template "10073" to two hosts链接模板"10073"到两个主机。.

Request请求:

{
           "jsonrpc": "2.0",
           "method": "template.massadd",
           "params": {
               "templates": [
                   {
                       "templateid": "10073"
                   }
               ],
               "hosts": [
                   {
                       "hostid": "10106"
                   },
                   {
                       "hostid": "10104"
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response响应:

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

See also参考

Source来源

CTemplate::massAdd() in frontends/php/include/classes/api/services/CTemplate.php.