integer/array service.get(object parameters)
The method allows to retrieve services according to the given 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 parentproperty. 返回parent属性中的硬依赖父服务。 | 
| selectDependencies | query 查询 R | turn child service dependencies in the dependenciesproperty. 返回在dependencies属性中有依赖的子服务。 | 
| selectParentDependencies | query 查询 R | turn parent service dependencies in the parentDependenciesproperty. 返回在parentDependencies属性中有依赖的父服务。 | 
| selectTimes | query 查询 R | turn service times in the timesproperty. 返回在times属性中的服务时间。 | 
| selectAlarms | query 查询 R | turn service alarms in the alarmsproperty. 返回在alarms属性中的服务告警。 | 
| selectTrigger | query 查询 R | turn the associated trigger in the triggerproperty. 返回在trigger属性中的关联触发器。 | 
| sortfield | string/array 字符串/数组 Sort | the result by the given properties. 按指定的属性对结果分类。 Possible values are: nameandsortorder. 许可值是:name和sortorder。 | 
| countOutput | boolean 布尔值 Th | se parameters being common for all getmethods 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 布尔值 :: | |
(integer/array) Returns either: 返回两者其中任一:
countOutput parameter has been used. 如果已经使用了countOutput参数,则检索对象的计数。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() in frontends/php/include/classes/api/services/CService.php. CService::get()方法可在frontends/php/include/classes/api/services/CService.php中参考。