service.get

Description说明

integer/array service.get(object parameters)

The method allows to retrieve services according to the given parameters该方法允许根据给定的参数检索服务.

Parameters参数

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

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

Parameter参数 Type类型 Description说明
serviceids string/array Return only services with the given IDs只返回具有指定ID的服务.
parentids string/array Return only services with the given hard-dependent parent services只返回服务与给定硬依赖的父级服务.
childids string/array Return only services that are hard-dependent on the given child services仅返回对给定的子服务强依赖的服务.
selectParent query

Examples范例

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. }

Source源码

CService::get() in frontends/php/include/classes/api/services/CService.php.