service.get

描述

integer/array service.get(object parameters)

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

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

Parameters 参数

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

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

Parameter 参数 Tpe 类型 Desription 说明
serviceidsstring/array 字符串/数组 Retun only services with the given IDs. 仅返回拥有指定ID的服务。
parentidsstring/array 字符串/数组 Retun only services with the given hard-dependent parent services. 仅返回拥有指定硬依赖父服务的服务。
childidsstring/array 字符串/数组 Retun only services that are hard-dependent on the given child services. 仅返回在指定子服务上有硬依赖的服务。
selectParentquery 查询 Rturn the hard-dependent parent service in the parent property. 返回parent属性中的硬依赖父服务。
selectDependenciesquery 查询 Rturn child service dependencies in the dependencies property. 返回在dependencies属性中有依赖的子服务。
selectParentDependenciesquery 查询 Rturn parent service dependencies in the parentDependencies property. 返回在parentDependencies属性中有依赖的父服务。
selectTimesquery 查询 Rturn service times in the times property. 返回在times属性中的服务时间。
selectAlarmsquery 查询 Rturn service alarms in the alarms property. 返回在alarms属性中的服务告警。
selectTriggerquery 查询 Rturn the associated trigger in the trigger property. 返回在trigger属性中的关联触发器。
sortfieldstring/array 字符串/数组 Sortthe result by the given properties. 按指定的属性对结果分类。

Possible values are: name and sortorder. 许可值是:namesortorder
countOutputboolean 布尔值 Thse parameters being common for all get methods are described in detail in the reference commentary. 这些参数非常普遍,适用于所有get方法,具体描述详见于reference commentary
editableboolean 布尔值 ::
excludeSearchboolean 布尔值 ::
filterobject 对象 ::
limitinteger 整数型 ::
outputquery 查询 ::
preservekeysboolean 布尔值 ::
searchobject 对象 ::
searchByAnyboolean 布尔值 ::
searchWildcardsEnabledboolean 布尔值 ::
sortorderstring/array 字符串/数组 :::
startSearchboolean 布尔值 ::

返回值

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

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

示例

Retrieving all services 检索所有服务

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

Request 请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "service.get",
  4. "params": {
  5. "output": "extend",
  6. "selectDependencies": "extend"
  7. },
  8. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  9. "id": 1
  10. }

Response 响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "serviceid": "2",
  6. "name": "Server 1",
  7. "status": "0",
  8. "algorithm": "1",
  9. "triggerid": "0",
  10. "showsla": "1",
  11. "goodsla": "99.9000",
  12. "sortorder": "0",
  13. "dependencies": []
  14. },
  15. {
  16. "serviceid": "3",
  17. "name": "Data center 1",
  18. "status": "0",
  19. "algorithm": "1",
  20. "triggerid": "0",
  21. "showsla": "1",
  22. "goodsla": "99.9000",
  23. "sortorder": "0",
  24. "dependencies": [
  25. {
  26. "linkid": "11",
  27. "serviceupid": "3",
  28. "servicedownid": "2",
  29. "soft": "0",
  30. "sortorder": "0",
  31. "serviceid": "2"
  32. },
  33. {
  34. "linkid": "10",
  35. "serviceupid": "3",
  36. "servicedownid": "5",
  37. "soft": "0",
  38. "sortorder": "1",
  39. "serviceid": "5"
  40. }
  41. ]
  42. },
  43. {
  44. "serviceid": "5",
  45. "name": "Server 2",
  46. "status": "0",
  47. "algorithm": "1",
  48. "triggerid": "0",
  49. "showsla": "1",
  50. "goodsla": "99.9900",
  51. "sortorder": "1",
  52. "dependencies": []
  53. }
  54. ],
  55. "id": 1
  56. }

来源

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