object script.update(object/array scripts)
此方法允许update现有脚本.
此方法仅适用于超级管理员用户类型. 调用该方法的权限可在用户角色设置中撤销. 详见 User roles 获取更多信息.
(object/array)
脚本 需要被更新.
每个脚本必须定义 scriptid
属性,其他所有 属性都是可选的。只有传递的属性会被更新,所有 其他属性将保持不变。例外情况是 type
属性从 5 (Webhook) 更改为其他值: parameters
属性将被清除。
(object)
返回一个包含更新脚本ID的object 该ID位于scriptids
属性下
将脚本命令修改为 "/bin/ping -c 10 {HOST.CONN} 2>&1".
执行请求:
{
"jsonrpc": "2.0",
"method": "script.update",
"params": {
"scriptid": "1",
"command": "/bin/ping -c 10 {HOST.CONN} 2>&1"
},
"id": 1
}
响应:
将脚本命令修改为 "/bin/ping -c {MANUALINPUT} {HOST.CONN} 2>&1".
执行请求:
{
"jsonrpc": "2.0",
"method": "script.update",
"params": {
"scriptid": "1",
"command": "/bin/ping -c {MANUALINPUT} {HOST.CONN} 2>&1",
"manualinput": "1",
"manualinput_prompt": "Specify the number of ICMP packets to send with the ping command",
"manualinput_validator": "^(?:[1-9]|10)$",
"manualinput_validator_type": "0",
"manualinput_default_value": "10"
},
"id": 1
}
响应:
CScript::update() 位于 ui/include/classes/api/services/CScript.php 文件中。