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

templategroup.get

描述

integer/array templategroup.get(object parameters)

该方法允许根据给定的参数检索模板组.

任何类型的用户都可以使用此方法。可以在用户角色设置中撤销调用该方法的权限. 更多信息请查看用户角色.

参数

(object) 定义所需输出的参数.

该方法支持以下参数.

参数 类型 描述
graphids ID/array 仅返回包含给定图形模板的模板组.
groupids ID/array 仅返回具有给定模板组ID的模板组.
templateids ID/array 仅返回包含给定模板的模板组.
triggerids ID/array 仅返回包含给定触发器的模板的模板组.
with_graphs flag 仅返回包含图形的模板的模板组.
with_graph_prototypes flag 仅返回包含图形原型的模板的模板组.
with_httptests flag 仅返回包含网页测试的模板的模板组.
with_items flag 仅返回包含监控项的模板的模板组.

覆盖 with_simple_graph_items 参数.
with_item_prototypes flag 仅返回包含监控项原型的模板的模板组.

覆盖 with_simple_graph_item_prototypes 参数.
with_simple_graph_item_prototypes flag 仅返回包含启用了创建功能且具有数值类型信息的监控项原型的模板的模板组.
with_simple_graph_items flag 仅返回包含数值类型监控项的模板的模板组.
with_templates flag 仅返回包含有模板的模板组.
with_triggers flag 仅返回包含触发器的模板的模板组.
selectTemplates query 返回此模板组中的模板templates 的属性.

支持 count.
limitSelects integer 限制子选择返回的记录数.

适用于以下子选项:
selectTemplates - 结果按照template排序.
sortfield string/array 根据给定的属性进行排序.

可能的值: groupid, name.
countOutput boolean 这些参数对于所有get方法都是通用的,在参考注释 中有详细描述.
editable boolean
excludeSearch boolean
filter object
limit integer
output query
preservekeys boolean
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch boolean

返回值

(integer/array) 返回两者其一:

  • 一个对象数组;
  • 如果使用了'countOutput'参数,则对检索对象进行计数。

示例

按照名字检索模板组

检索名为 "Templates/Databases"和 "Templates/Modules"的两个模板组的数据.

请求:

{
           "jsonrpc": "2.0",
           "method": "templategroup.get",
           "params": {
               "output": "extend",
               "filter": {
                   "name": [
                       "Templates/Databases",
                       "Templates/Modules"
                   ]
               }
           },
           "id": 1
       }

响应:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "groupid": "13",
                   "name": "Templates/Databases",
                   "uuid": "748ad4d098d447d492bb935c907f652f"
               },
               {
                   "groupid": "8",
                   "name": "Templates/Modules",
                   "uuid": "57b7ae836ca64446ba2c296389c009b7"
               }
           ],
           "id": 1
       }

参阅

来源

CTemplateGroup::get() in ui/include/classes/api/services/CTemplateGroup.php.