graphprototype.get

Description

integer/array graphprototype.get(object **parameters**)

The method allows to retrieve graph prototypes 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.

ParameterTypeDescription
discoveryidsstring/arrayReturn only graph prototypes that belong to the given discovery rules.
graphidsstring/arrayReturn only graph prototypes with the given IDs.
groupidsstring/arrayReturn only graph prototypes that belong to hosts in the given host groups.
hostidsstring/arrayReturn only graph prototypes that belong to the given hosts.
inheritedbooleanIf set to true return only graph prototypes inherited from a template.
itemidsstring/arrayReturn only graph prototypes that contain the given item prototypes.
templatedbooleanIf set to true return only graph prototypes that belong to templates.
templateidsstring/arrayReturn only graph prototypes that belong to the given templates.
selectDiscoveryRulequeryReturn a discoveryRule property with the LLD rule that the graph prototype belongs to.
selectGraphItemsqueryReturn a gitems property with the graph items used in the graph prototype.
selectGroupsqueryReturn a groups property with the host groups that the graph prototype belongs to.
selectHostsqueryReturn a hosts property with the hosts that the graph prototype belongs to.
selectItemsqueryReturn an items property with the items and item prototypes used in the graph prototype.
selectTemplatesqueryReturn a templates property with the templates that the graph prototype belongs to.
filterobjectReturn only those results that exactly match the given filter.

Accepts an array, where the keys are property names, and the values are either a single value or an array of values to match against.

Supports additional filters:
host - technical name of the host that the graph prototype belongs to;
hostid - ID of the host that the graph prototype belongs to.
sortfieldstring/arraySort the result by the given properties.

Possible values are: graphid, name and graphtype.
countOutputbooleanThese parameters being common for all get methods are described in detail in the reference commentary.
editableboolean
excludeSearchboolean
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 graph prototypes from a LLD rule

Retrieve all graph prototypes from an LLD rule.

Request:

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

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "graphid": "1017",
  6. "parent_itemid": "27426",
  7. "name": "Disk space usage {#FSNAME}",
  8. "width": "600",
  9. "height": "340",
  10. "yaxismin": "0.0000",
  11. "yaxismax": "0.0000",
  12. "templateid": "442",
  13. "show_work_period": "0",
  14. "show_triggers": "0",
  15. "graphtype": "2",
  16. "show_legend": "1",
  17. "show_3d": "1",
  18. "percent_left": "0.0000",
  19. "percent_right": "0.0000",
  20. "ymin_type": "0",
  21. "ymax_type": "0",
  22. "ymin_itemid": "0",
  23. "ymax_itemid": "0",
  24. "discover": "0"
  25. }
  26. ],
  27. "id": 1
  28. }

See also

Source

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