On this page
hostprototype.get
Descrizione
integer/array hostprototype.get(object parameters)
Il metodo consente di recuperare i prototipi di host in base ai parametri specificati.
Questo metodo è disponibile per utenti di qualsiasi tipo. Le autorizzazioni per chiamare il metodo possono essere revocate nelle impostazioni dei ruoli utente. Per ulteriori informazioni, vedere Ruoli utente.
Parametri
(object) Parametri che definiscono l'output desiderato.
Il metodo supporta i seguenti parametri.
| Parameter | Type | Description |
|---|---|---|
| hostids | ID/array | Restituisce solo i host prototype con gli ID specificati. |
| discoveryids | ID/array | Restituisce solo i host prototype che appartengono alle LLD rule specificate. |
| inherited | boolean | Se impostato su true, restituisce solo gli item ereditati da un template. |
| selectDiscoveryRule | query | Restituisce una proprietà discoveryRule con la LLD rule a cui appartiene l'host prototype. |
| selectInterfaces | query | Restituisce una proprietà interfaces con le interfacce personalizzate dell'host prototype. |
| selectGroupLinks | query | Restituisce una proprietà groupLinks con i collegamenti ai gruppi dell'host prototype. |
| selectGroupPrototypes | query | Restituisce una proprietà groupPrototypes con i group prototype dell'host prototype. |
| selectMacros | query | Restituisce una proprietà macros con le macro dell'host prototype. |
| selectParentHost | query | Restituisce una proprietà parentHost con l'host a cui appartiene l'host prototype. |
| selectTags | query | Restituisce una proprietà tags con i tag dell'host prototype. |
| selectTemplates | query | Restituisce una proprietà templates con i template collegati all'host prototype.Supporta count. |
| sortfield | string/array | Ordina il risultato in base alle proprietà specificate. Valori possibili: hostid, host, name, status, discovered. |
| countOutput | boolean | Questi parametri sono descritti nella reference commentary. |
| editable | boolean | |
| excludeSearch | boolean | |
| filter | object | |
| limit | integer | |
| output | query | |
| preservekeys | boolean | |
| search | object | |
| searchByAny | boolean | |
| searchWildcardsEnabled | boolean | |
| sortorder | string/array | |
| startSearch | boolean |
Valori restituiti
(integer/array) Restituisce uno dei seguenti:
- un array di oggetti;
- il numero di oggetti recuperati, se è stato utilizzato il parametro
countOutput.
Esempi
Recupero dei prototipi di host da una regola LLD
Recupera tutti i prototipi di host, i relativi collegamenti ai gruppi, i prototipi di gruppo e i tag da una regola LLD.
{
"jsonrpc": "2.0",
"method": "hostprototype.get",
"params": {
"output": "extend",
"selectInterfaces": "extend",
"selectGroupLinks": "extend",
"selectGroupPrototypes": "extend",
"selectTags": "extend",
"discoveryids": "23554"
},
"id": 1
}
Risposta:
{
"jsonrpc": "2.0",
"result": [
{
"hostid": "10092",
"host": "{#HV.UUID}",
"name": "{#HV.UUID}",
"status": "0",
"templateid": "0",
"discover": "0",
"custom_interfaces": "1",
"inventory_mode": "-1",
"groupLinks": [
{
"group_prototypeid": "4",
"hostid": "10092",
"groupid": "7",
"templateid": "0"
}
],
"groupPrototypes": [
{
"group_prototypeid": "7",
"hostid": "10092",
"name": "{#CLUSTER.NAME}",
"templateid": "0"
}
],
"tags": [
{
"tag": "datacenter",
"value": "{#DATACENTER.NAME}"
},
{
"tag": "instance-type",
"value": "{#INSTANCE_TYPE}"
}
],
"interfaces": [
{
"main": "1",
"type": "2",
"useip": "1",
"ip": "127.0.0.1",
"dns": "",
"port": "161",
"details": {
"version": "2",
"bulk": "1",
"community": "{$SNMP_COMMUNITY}",
"max_repetitions": "10"
}
}
]
}
],
"id": 1
}
Vedi anche
Sorgente
CHostPrototype::get() in ui/include/classes/api/services/CHostPrototype.php.