[comment]: # ({430777c9-2898fc4b})
# 替换

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

[comment]: # ({7c738b10-78fb71d9})
### 描述

`object hostinterface.replacehostinterfaces(object parameters)`

此方法允许给指定主机替换所有主机接口.

[comment]: # ({/7c738b10-78fb71d9})

[comment]: # ({ef4152c3-acfbccf8})
### 参数

`(对象)` 包含要更新的主机ID和新主机接口的参数.

|参数              类|描述|<|
|-----------------------|------|-|
|**hostid**<br>(必选)|字符串      要更|主机的ID.|
|**interfaces**<br>(必须)|对象/数组   替换当|主机接口的主机接口.|

[comment]: # ({/ef4152c3-acfbccf8})

[comment]: # ({25d573ed-88283807})
### 返回值

`(对象)` 在`interfaceids`属性中返回已创建主机接口ID的对象.

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

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

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

[comment]: # ({f3f2b942-98e67db1})
#### 更换主机接口

用单个代理接口替换所有主机接口.

请求:

``` {.java}
{
    "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
}
```

响应:

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

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

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

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

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

[comment]: # ({e0325c6c-64281193})
### 来源

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

[comment]: # ({/e0325c6c-64281193})
