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

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

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

`object hostinterface.replacehostinterfaces(object parameters)`

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

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

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

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

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

|パラメータ|[タイプ](/manual/api/reference_commentary#data_types)|説明|
|--|--|------|
|**hostid**<br>(必須)|string|更新するホストのID|
|**interfaces**<br>(必須)|object/array|置換後の[ホストインターフェース](/manual/api/reference/hostinterface/object)|

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

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

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

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

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

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

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

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

Request:

```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
        }
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

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

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