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

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

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

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

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

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

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

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

`(object)` 必要な出力を定義するパラメータ。

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

|パラメータ|[Type](/manual/api/reference_commentary#data-types)|説明|
|--|--|------|
|hostids|ID/array|指定したホストで使用されているホストインターフェースのみを返します。|
|interfaceids|ID/array|指定したIDを持つホストインターフェースのみを返します。|
|itemids|ID/array|指定したアイテムで使用されているホストインターフェースのみを返します。|
|triggerids|ID/array|指定したトリガー内のアイテムで使用されているホストインターフェースのみを返します。|
|selectItems|query|インターフェースを使用しているアイテムを含む [`items`](/manual/api/reference/item/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|これらのパラメータについては、[reference commentary](/manual/api/reference_commentary#common-get-method-parameters) を参照してください。|
|editable|boolean|^|
|excludeSearch|boolean|^|
|filter|object|^|
|limit|integer|^|
|output|query|^|
|preservekeys|boolean|^|
|search|object|^|
|searchByAny|boolean|^|
|searchWildcardsEnabled|boolean|^|
|sortorder|string/array|^|
|startSearch|boolean|^|

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

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

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

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

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

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

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

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

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

[リクエスト](/manual/api#performing-requests):

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

レスポンス:

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

[comment]: # ({/d7de2fbf-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})
