httptest.get

説明

integer/array httptest.get(object parameters)

このメソッドを使用すると、指定されたパラメーターに従ってWebシナリオを取得できます。

このメソッドはどのタイプのユーザーでも利用可能です。このメソッドを呼び出す権限は、ユーザーロール設定で取り消すことができます。詳しくはユーザーの役割を参照してください。

パラメータ

(object) 目的の出力を定義するパラメータ

このメソッドは、次のパラメーターをサポートします。

パラメータ タイプ 説明
groupids string/array 指定されたホストグループに属するWebシナリオのみを返します
hostids string/array 指定されたホストに属するWebシナリオのみを返します
httptestids string/array 指定されたIDを持つWebシナリオのみを返します
inherited boolean trueに設定すると、テンプレートから継承されたWebシナリオのみが返されます
monitored boolean trueに設定すると、監視対象ホストに属する有効なWebシナリオのみが返されます
templated boolean trueに設定すると、テンプレートに属するWebシナリオのみが返されます
templateids string/array 指定されたテンプレートに属するWebシナリオのみを返します。
expandName flag Webシナリオの名前でマクロを展開します
expandStepName flag シナリオステップの名前でマクロを展開します
evaltype integer タグ検索ルール。

可能な値:
0 -(デフォルト)And/Or
2 - Or
tags array of objects 指定されたタグを持つWebシナリオのみを返します。タグによる完全一致または演算子値に応じた大文字と小文字を区別する検索または大文字と小文字を区別しない検索。
フォーマット:[{"tag": "<tag>", "value": "<value>", "operator": "<operator>"}, ...]
何も指定しない場合、すべてのWebシナリオを返します。

利用可能な演算子:
0 - (デフォルト) Like;
1 - Equal;
2 - Not like;
3 - Not equal
4 - Exists;
5 - Not exists.
selectHosts query Webシナリオが属するホストをhostsプロパティの配列として返します。
selectSteps query stepsプロパティでWebシナリオのステップを返します。

countをサポートします
selectTags query tagsプロパティでWebシナリオタグを返します。
sortfield string/array 指定されたプロパティで結果を並べ替えます。

指定可能な値はhttptestidnameです
countOutput boolean すべてのgetメソッドに共通するこれらのパラメーターについてはリファレンス解説ページで詳しく説明されています。
editable boolean
excludeSearch boolean
filter object
limit integer
output query
preservekeys boolean
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch boolean

戻り値

(integer/array) 次のいずれかを返します:

  • オブジェクトの配列
  • countOutputパラメータが使用されている場合、取得されたオブジェクトの数

Webシナリオの取得

Webシナリオ"4"に関するすべてのデータを取得します

Request:

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

Response:

{
    "jsonrpc": "2.0",
    "result": [
        {
            "httptestid": "9",
            "name": "Homepage check",
            "nextcheck": "0",
            "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
}

参照

ソース

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