[comment]: # ({2898fc4b-2898fc4b})
# hostinterface.replacehostinterfaces

[comment]: # ({/2898fc4b-2898fc4b})

[comment]: # ({e440e997-f14e7778})
### 説明

`object hostinterface.replacehostinterfaces(object parameters)`

このメソッドを使用すると、指定したホスト上のすべてのホストインターフェースを置き換えることができます。

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

[comment]: # ({/e440e997-f14e7778})

[comment]: # ({ad328eba-f5cf0b40})
### パラメータ

更新するホストのIDと新しいホストインターフェースを含む`(object)`パラメータ。

|パラメータ|[Type](/manual/api/reference_commentary#data-types)|説明|
|--|--|------|
|interfaces|object/array|現在のホストインターフェースを置き換える[ホストインターフェース](/manual/api/reference/hostinterface/object)。<br><br>[パラメータの動作](/manual/api/reference_commentary#parameter-behavior):<br>- *必須*|
|hostid|ID|更新するホストのID。<br><br>[パラメータの動作](/manual/api/reference_commentary#parameter-behavior):<br>- *必須*|

[comment]: # ({/ad328eba-f5cf0b40})

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

`(object)` `interfaceids`プロパティの下で作成されたホストインターフェイスのIDを含むオブジェクトを返します。

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

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

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

[comment]: # ({01fd5e38-98e67db1})
#### ホストインターフェースの置き換え

すべてのホストインターフェースを単一のエージェントインターフェースに置き換えます。

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

```json
{
    "jsonrpc": "2.0",
    "method": "hostinterface.replacehostinterfaces",
    "params": {
        "hostid": "30052",
        "interfaces": {
            "dns": "",
            "ip": "127.0.0.1",
            "main": 1,
            "port": "10050",
            "type": 1,
            "useip": 1
        }
    },
    "id": 1
}
```

レスポンス:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "interfaceids": [
            "30081"
        ]
    },
    "id": 1
}
```

[comment]: # ({/01fd5e38-98e67db1})

[comment]: # ({272c42ef-272c42ef})
### 参照

-   [host.update](/manual/api/reference/host/update)
-   [host.massupdate](/manual/api/reference/host/massupdate)

[comment]: # ({/272c42ef-272c42ef})

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

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

[comment]: # ({/9d1e0b55-9d1e0b55})
