hostprototype.get

Description

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

The method allows to retrieve host prototypes according to the given parameters.

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

ParameterTypeDescription
hostidsstring/arrayReturn only host prototypes with the given IDs.
discoveryidsstring/arrayReturn only host prototype that belong to the given LLD rules.
inheritedbooleanIf set to true return only items inherited from a template.
selectDiscoveryRulequeryReturn a discoveryRule property with the LLD rule that the host prototype belongs to.
selectGroupLinksqueryReturn a groupLinks property with the group links of the host prototype.
selectGroupPrototypesqueryReturn a groupPrototypes property with the group prototypes of the host prototype.
selectMacrosqueryReturn a macros property with host prototype macros.
selectParentHostqueryReturn a parentHost property with the host that the host prototype belongs to.
selectTemplatesqueryReturn a templates property with the templates linked to the host prototype.

Supports count.
sortfieldstring/arraySort the result by the given properties.

Possible values are: hostid, host, name and status.
countOutputbooleanThese parameters being common for all get methods are described in detail on the Generic Zabbix API information page.
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 host prototypes from an LLD rule

Retrieve all host prototypes and their group links and group prototypes from an LLD rule.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "hostprototype.get",
  4. "params": {
  5. "output": "extend",
  6. "selectGroupLinks": "extend",
  7. "selectGroupPrototypes": "extend",
  8. "discoveryids": "23554"
  9. },
  10. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  11. "id": 1
  12. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "hostid": "10092",
  6. "host": "{#HV.UUID}",
  7. "status": "0",
  8. "name": "{#HV.NAME}",
  9. "templateid": "0",
  10. "discover": "0",
  11. "groupLinks": [
  12. {
  13. "group_prototypeid": "4",
  14. "hostid": "10092",
  15. "groupid": "7",
  16. "templateid": "0"
  17. }
  18. ],
  19. "groupPrototypes": [
  20. {
  21. "group_prototypeid": "7",
  22. "hostid": "10092",
  23. "name": "{#CLUSTER.NAME}",
  24. "templateid": "0"
  25. }
  26. ]
  27. }
  28. ],
  29. "id": 1
  30. }

See also

Source

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