service.get

Description

integer/array service.get(object parameters)

The method allows to retrieve services according to the given parameters.

This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

ParameterType
serviceidsstring/arrayReturn only services with the given IDs.
parentidsstring/arrayReturn only services that are linked to the given parent services.
deep_parentidsflagReturn all direct and indirect child services. Used together with parentids.
childidsstring/arrayReturn only services that are linked to the given child services.
evaltypeintegerRules for tag searching.

Possible values:
0 - (default) And/Or;
2 - Or.
tagsobject/array of objectsReturn only services with given tags. Exact match by tag and case-sensitive or case-insensitive search by tag value depending on operator value.
Format: [{“tag”: “<tag>”, “value”: “<value>”, “operator”: “<operator>”}, …].
An empty array returns all services.

Possible operator values:
0 - (default) Contains;
1 - Equals;
2 - Does not contain;
3 - Does not equal;
4 - Exists;
5 - Does not exist.
problem_tagsobject/array of objectsReturn only services with given problem tags. Exact match by tag and case-sensitive or case-insensitive search by tag value depending on operator value.
Format: [{“tag”: “<tag>”, “value”: “<value>”, “operator”: “<operator>”}, …].
An empty array returns all services.

Possible operator values:
0 - (default) Contains;
1 - Equals;
2 - Does not contain;
3 - Does not equal;
4 - Exists;
5 - Does not exist.
without_problem_tagsflagReturn only services without problem tags.
slaidsstring/arrayReturn only services that are linked to the specific SLA(s).
selectChildrenqueryReturn a children property with the child services.

Supports count.
selectParentsqueryReturn a parents property with the parent services.

Supports count.
selectTagsqueryReturn a tags property with service tags.

Supports count.
selectProblemEventsqueryReturn a problem_events property with an array of problem event objects.

The problem event object has the following properties:
eventid - (string) Event ID;
severity - (string) Current event severity;
name - (string) Resolved event name.

Supports count.
selectProblemTagsqueryReturn a problem_tags property with problem tags.

Supports count.
selectStatusRulesqueryReturn a status_rules property with status rules.

Supports count.
selectStatusTimelineobject/array of objectsReturn a status_timeline property containing service state changes for given periods.

Format [{“period_from”: “<period_from>”, “period_to”: “<period_to>”}, …] - period_from being a starting date (inclusive; integer timestamp) and period_to being an ending date (exclusive; integer timestamp) for the period you’re interested in.

Returns an array of entries containing a start_value property and an alarms array for the state changes within specified periods.
sortfieldstring/arraySort the result by the given properties.

Possible values are: serviceid, name, status, sortorder and ‘created_at. | | countOutput | boolean | These parameters being common for allget` 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. "selectChildren": "extend",
  7. "selectParents": "extend"
  8. },
  9. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  10. "id": 1
  11. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "serviceid": "1",
  6. "name": "My Service - 0001",
  7. "status": "-1",
  8. "algorithm": "2",
  9. "sortorder": "0",
  10. "weight": "0",
  11. "propagation_rule": "0",
  12. "propagation_value": "0",
  13. "description": "My Service Description 0001.",
  14. "uuid": "dfa4daeaea754e3a95c04d6029182681",
  15. "created_at": "946684800",
  16. "readonly": false,
  17. "parents": [],
  18. "children": []
  19. },
  20. {
  21. "serviceid": "2",
  22. "name": "My Service - 0002",
  23. "status": "-1",
  24. "algorithm": "2",
  25. "sortorder": "0",
  26. "weight": "0",
  27. "propagation_rule": "0",
  28. "propagation_value": "0",
  29. "description": "My Service Description 0002.",
  30. "uuid": "20ea0d85212841219130abeaca28c065",
  31. "created_at": "946684800",
  32. "readonly": false,
  33. "parents": [],
  34. "children": []
  35. }
  36. ],
  37. "id": 1
  38. }

Source

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