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.

ParameterTypeDescription
serviceidsstring/arrayReturn only services with the given IDs.
parentidsstring/arrayReturn only services with the given hard-dependent parent services.
childidsstring/arrayReturn only services that are hard-dependent on the given child services.
selectParentqueryReturn a parent property with the hard-dependent parent service.
selectDependenciesqueryReturn a dependencies property with child service dependencies.
selectParentDependenciesqueryReturn a parentDependencies property with parent service dependencies.
selectTimesqueryReturn a times property with service times.
selectAlarmsqueryReturn an alarms property with service alarms.
selectTriggerqueryReturn a trigger property with the associated trigger.
sortfieldstring/arraySort the result by the given properties.

Possible values are: name and sortorder.
countOutputbooleanThese parameters being common for all get methods are described in detail in the reference commentary.
editableboolean
excludeSearchboolean
filterobject
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

Return values

(integer/array) Returns either:

  • an array of objects;

  • the count of retrieved objects, if the countOutput parameter has been used.

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 ui/include/classes/api/services/CService.php.