[comment]: # translation:outdated

[comment]: # ({25793162-25793162})
# hostinterface.get

[comment]: # ({/25793162-25793162})

[comment]: # ({a51d6fc5-29074792})
### 説明

`integer/array hostinterface.get(object parameters)`

このメソッドを使用では、指定されたパラメーターに従ってホストインターフェイスを取得できます。

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

[comment]: # ({/a51d6fc5-29074792})

[comment]: # ({fb61e763-a40e6018})
### パラメータ

`(object)` 希望する出力を定義するパラメータ

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

|パラメータ|[タイプ](/manual/api/reference_commentary#data_types)|説明|
|--|--|------|
|hostids|string/array|指定されたホストによって使用されるホストインターフェースのみを返します。|
|interfaceids|string/array|指定されたIDを持つホストインターフェースのみを返します。|
|itemids|string/array|指定されたアイテムで使用されるホストインターフェースのみを返します。|
|triggerids|string/array|指定されたトリガーのアイテムによって使用されるホストインターフェイスのみを返します。|
|selectItems|query|インターフェイスを使用するアイテムを含む[items](/manual/api/reference/host/object)プロパティを返します。<br><br>`count`をサポートします。|
|selectHosts|query|インターフェイスを使用するホストの配列を含む[hosts](/manual/api/reference/host/object)プロパティを返します。|
|limitSelects|integer|副選択によって返されるレコードの数を制限します。<br><br>次の副選択に適用されます：<br>`selectItems`|
|sortfield|string/array|指定されたプロパティで結果を並べ替えます。<br><br>指定可能な値は `interfaceid`、` dns`、`ip`です。|
|countOutput|boolean|すべての`get`メソッドに共通するこれらのパラメーターについては[リファレンス解説](/manual/api/reference_commentary#common_get_method_parameters)ページで詳しく説明されています。|
|editable|boolean|^|
|excludeSearch|boolean|^|
|filter|object|^|
|limit|integer|^|
|nodeids|string/array|^|
|output|query|^|
|preservekeys|boolean|^|
|search|object|^|
|searchByAny|boolean|^|
|searchWildcardsEnabled|boolean|^|
|sortorder|string/array|^|
|startSearch|boolean|^|

[comment]: # ({/fb61e763-a40e6018})

[comment]: # ({7223bab1-7223bab1})
### 戻り値

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

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

[comment]: # ({/7223bab1-7223bab1})

[comment]: # ({b41637d2-b41637d2})
### 例

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({2a18eac8-cbd2e952})
#### ホストインターフェースの取得

ホスト"30057"が使用するインターフェースに関するすべてのデータを取得します。

Request:

```json
{
    "jsonrpc": "2.0",
    "method": "hostinterface.get",
    "params": {
        "output": "extend",
        "hostids": "30057"
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "interfaceid": "50039",
            "hostid": "30057",
            "main": "1",
            "type": "1",
            "useip": "1",
            "ip": "::1",
            "dns": "",
            "port": "10050",
            "available": "0",
            "error": "",
            "errors_from": "0",
            "disable_until": "0",
            "details": []
        },
        {
            "interfaceid": "55082",
            "hostid": "30057",
            "main": "0",
            "type": "1",
            "useip": "1",
            "ip": "127.0.0.1",
            "dns": "",
            "port": "10051",
            "available": "0",
            "error": "",
            "errors_from": "0",
            "disable_until": "0",
            "details": {
                "version": "2",
                "bulk": "0",
                "community": "{$SNMP_COMMUNITY}"
            }
        }
    ],
    "id": 1
}
```

[comment]: # ({/2a18eac8-cbd2e952})

[comment]: # ({1c57700e-1c57700e})
### 参照

-   [Host](/manual/api/reference/host/object#host)
-   [Item](/manual/api/reference/item/object#item)

[comment]: # ({/1c57700e-1c57700e})

[comment]: # ({d0cee877-d0cee877})
### ソース

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

[comment]: # ({/d0cee877-d0cee877})
