httptest.get

Descrizione

integer/array httptest.get(object parameters)

Questo metodo consente di recuperare gli scenari web in base ai parametri forniti.

Questo metodo è disponibile per utenti di qualsiasi tipo. I permessi per chiamare il metodo possono essere revocati nelle impostazioni del ruolo utente. Per ulteriori informazioni, vedere User roles.

Parametri

(object) Parametri che definiscono l'output desiderato.

Il metodo supporta i seguenti parametri.

Parametro Tipo Descrizione
groupids ID/array Restituisce solo gli scenari web che appartengono ai gruppi di host specificati.
hostids ID/array Restituisce solo gli scenari web che appartengono agli host specificati.
httptestids ID/array Restituisce solo gli scenari web con gli ID specificati.
inherited boolean Se impostato su true, restituisce solo gli scenari web ereditati da un template.
monitored boolean Se impostato su true, restituisce solo gli scenari web abilitati che appartengono a host monitorati.
templated boolean Se impostato su true, restituisce solo gli scenari web che appartengono ai template.
templateids ID/array Restituisce solo gli scenari web che appartengono ai template specificati.
expandName flag Espande le macro nel nome dello scenario web.
expandStepName flag Espande le macro nei nomi dei passaggi dello scenario.
evaltype integer Metodo di valutazione dei tag.

Valori possibili:
0 - (predefinito) And/Or;
2 - Or.
tags array Restituisce solo gli scenari web con i tag specificati.
Formato: [{"tag": "<tag>", "value": "<value>", "operator": "<operator>"}, ...].
Un array vuoto restituisce tutti gli scenari web.

Valori possibili per l'operatore:
0 - (predefinito) Contiene;
1 - Uguale;
2 - Non contiene;
3 - Non è uguale;
4 - Esiste;
5 - Non esiste.
selectHosts query Restituisce gli host a cui appartiene lo scenario web come array nella proprietà hosts.
selectSteps query Restituisce i passaggi dello scenario web nella proprietà steps.

Supporta count.
selectTags query Restituisce i tag dello scenario web nella proprietà tags.
sortfield string/array Ordina il risultato in base alle proprietà specificate.

Valori possibili: httptestid, name.
countOutput boolean Questi parametri sono descritti nel commento di riferimento.
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 di uno scenario web

Recupera tutti i dati relativi allo scenario web "9".

Richiesta:

{
    "jsonrpc": "2.0",
    "method": "httptest.get",
    "params": {
        "output": "extend",
        "selectSteps": "extend",
        "httptestids": "9"
    },
    "id": 1
}

Risposta:

{
    "jsonrpc": "2.0",
    "result": [
        {
            "httptestid": "9",
            "name": "Homepage check",
            "delay": "1m",
            "status": "0",
            "variables": [],
            "agent": "Zabbix",
            "authentication": "0",
            "http_user": "",
            "http_password": "",
            "hostid": "10084",
            "templateid": "0",
            "http_proxy": "",
            "retries": "1",
            "ssl_cert_file": "",
            "ssl_key_file": "",
            "ssl_key_password": "",
            "verify_peer": "0",
            "verify_host": "0",
            "headers": [],
            "steps": [
                {
                    "httpstepid": "36",
                    "httptestid": "9",
                    "name": "Homepage",
                    "no": "1",
                    "url": "http://example.com",
                    "timeout": "15s",
                    "posts": "",
                    "required": "",
                    "status_codes": "200",
                    "variables": [
                        {
                            "name":"{var}",
                            "value":"12"
                        }
                    ],
                    "follow_redirects": "1",
                    "retrieve_mode": "0",
                    "headers": [],
                    "query_fields": []
                },
                {
                    "httpstepid": "37",
                    "httptestid": "9",
                    "name": "Homepage / About",
                    "no": "2",
                    "url": "http://example.com/about",
                    "timeout": "15s",
                    "posts": "",
                    "required": "",
                    "status_codes": "200",
                    "variables": [],
                    "follow_redirects": "1",
                    "retrieve_mode": "0",
                    "headers": [],
                    "query_fields": []
                }
            ]
        }
    ],
    "id": 1
}

Vedi anche

Fonte

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