host.massremove
描述
object host.massremove(object parameters)
此方法允许从多个 主机 中移除相关的 objects。
此方法仅对 Admin 和 Super admin 用户类型可用。调用该方法的权限可以在用户角色设置中撤销。更多信息请参见 User roles。
参数
(object) 包含要更新的主机 ID 以及应移除的对象的参数。
| Parameter | Type | Description |
|---|---|---|
| hostids | ID/array | 要更新的主机 ID。 Parameter behavior: - required |
| groupids | ID/array | 要将给定主机从中移除的主机组 ID。 |
| interfaces | object/array | 要从给定主机中移除的主机接口。 主机接口对象只能定义 ip、dns 和 port 属性。 |
| macros | string/array | 要从给定主机中删除的用户宏。 |
| templateids | ID/array | 要从给定主机取消关联的模板 ID。 |
| templateids_clear | ID/array | 要从给定主机取消关联并清除的模板 ID。 |
返回值
(object) 返回一个 object,其中包含更新后的 主机 的 ID,这些 ID 位于 hostids 属性下。
示例
解除模板关联
从两个 主机 和 delete 解除模板链接,并解除所有模板实体的链接。
执行请求:
{
"jsonrpc": "2.0",
"method": "host.massremove",
"params": {
"hostids": ["69665", "69666"],
"templateids_clear": "325"
},
"id": 1
}
响应:
{
"jsonrpc": "2.0",
"result": {
"hostids": [
"69665",
"69666"
]
},
"id": 1
}
另请参阅
来源
CHost::massRemove() 在 ui/include/classes/api/services/CHost.php 中。