service.get

描述

integer/array service.get(object parameters)

此方法允许根据给定的参数检索服务。

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

Parameters 参数

(object) Parameters defining the desired output. (object)定义所需输出的参数。

The method supports the following parameters. 该方法支持以下参数。

Parameter 参数 T pe 类型 Des ription 说明
serviceids string/array 字符串/数组 Retu n only services with the given IDs. 仅返回拥有指定ID的服务。
parentids string/array 字符串/数组 Retu n only services with the given hard-dependent parent services. 仅返回拥有指定硬依赖父服务的服务。
childids string/array 字符串/数组 Retu n only services that are hard-dependent on the given child services. 仅返回在指定子服务上有硬依赖的服务。
selectParent query 查询 R turn the hard-dependent parent service in the parent property. 返回parent属性中的硬依赖父服务。
selectDependencies query 查询 R turn child service dependencies in the dependencies property. 返回在dependencies属性中有依赖的子服务。
selectParentDependencies query 查询 R turn parent service dependencies in the parentDependencies property. 返回在parentDependencies属性中有依赖的父服务。
selectTimes query 查询 R turn service times in the times property. 返回在times属性中的服务时间。
selectAlarms query 查询 R turn service alarms in the alarms property. 返回在alarms属性中的服务告警。
selectTrigger query 查询 R turn the associated trigger in the trigger property. 返回在trigger属性中的关联触发器。
sortfield string/array 字符串/数组 Sort the result by the given properties. 按指定的属性对结果分类。

Possible values are: name and sortorder. 许可值是:namesortorder
countOutput boolean 布尔值 Th se parameters being common for all get methods are described in detail in the reference commentary. 这些参数非常普遍,适用于所有get方法,具体描述详见于reference commentary
editable boolean 布尔值 ::
excludeSearch boolean 布尔值 ::
filter object 对象 : :
limit integer 整数型 ::
output query 查询 : :
preservekeys boolean 布尔值 ::
search object 对象 : :
searchByAny boolean 布尔值 ::
searchWildcardsEnabled boolean 布尔值 ::
sortorder string/array 字符串/数组 :::
startSearch boolean 布尔值 ::

返回值

(整型/数组) 返回其中之一:

  • 一个对象数组;
  • 如果使用countOutput参数,被检索对象的数量。

示例

Retrieving all services 检索所有服务

Retrieve all data about all services and their dependencies. 检索有关所有服务及其依赖关系的所有数据。

Request 请求:

{
    "jsonrpc": "2.0",
    "method": "service.get",
    "params": {
        "output": "extend",
        "selectDependencies": "extend"
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}

Response 响应:

{
    "jsonrpc": "2.0",
    "result": [
        {
            "serviceid": "2",
            "name": "Server 1",
            "status": "0",
            "algorithm": "1",
            "triggerid": "0",
            "showsla": "1",
            "goodsla": "99.9000",
            "sortorder": "0",
            "dependencies": []
        },
        {
            "serviceid": "3",
            "name": "Data center 1",
            "status": "0",
            "algorithm": "1",
            "triggerid": "0",
            "showsla": "1",
            "goodsla": "99.9000",
            "sortorder": "0",
            "dependencies": [
                {
                    "linkid": "11",
                    "serviceupid": "3",
                    "servicedownid": "2",
                    "soft": "0",
                    "sortorder": "0",
                    "serviceid": "2"
                },
                {
                    "linkid": "10",
                    "serviceupid": "3",
                    "servicedownid": "5",
                    "soft": "0",
                    "sortorder": "1",
                    "serviceid": "5"
                }
            ]
        },
        {
            "serviceid": "5",
            "name": "Server 2",
            "status": "0",
            "algorithm": "1",
            "triggerid": "0",
            "showsla": "1",
            "goodsla": "99.9900",
            "sortorder": "1",
            "dependencies": []
        }
    ],
    "id": 1
}

来源

CService::get() 在ui/include/classes/api/services/CService.php