获取

描述

integer/array templategroup.get(object parameters)

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

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

参数

(object) 用于定义所需输出的参数。

该方法支持以下参数。

参数 类型 描述
graphids ID/array 仅返回包含具有给定图形的模板的模板组。
groupids ID/array 仅返回具有给定模板组 ID 的模板组。
templateids ID/array 仅返回包含给定模板的模板组。
triggerids ID/array 仅返回包含具有给定触发器的模板的模板组。
with_graphs boolean 仅返回包含带有图形的模板的模板组。
with_graph_prototypes boolean 仅返回包含带有图形原型的模板的模板组。
with_httptests boolean 仅返回包含带有 Web 场景的模板的模板组。
with_items boolean 仅返回包含带有监控项的模板的模板组。

会覆盖 with_simple_graph_items 参数。
with_item_prototypes boolean 仅返回包含带有监控项原型的模板的模板组。

会覆盖 with_simple_graph_item_prototypes 参数。
with_simple_graph_item_prototypes boolean 仅返回包含带有监控项原型的模板的模板组,这些原型已启用创建且信息类型为数值型。
with_simple_graph_items boolean 仅返回包含带有数值型监控项的模板的模板组。
with_templates boolean 仅返回包含模板的模板组。
with_triggers boolean 仅返回包含带有触发器的模板的模板组。
selectTemplates query 返回属于该模板组的 templates 属性。

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

适用于以下子选择:
selectTemplates - 结果将按 template 排序。
sortfield string/array 按给定属性对结果进行排序。

可选值:groupidname
countOutput boolean 这些参数在参考说明中有描述。
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.