更新

Description 描述

object proxy.update(object/array proxies)

This method allows to update existing proxies. 此方法允许更新已存在的代理

Parameters 参数

(object/array) Proxy properties to be updated. (object/array)代理参数被更新

The proxyid property must be defined for each proxy, all other properties are optional. Only the passed properties will be updated, all others will remain unchanged. 每个主机必须定义proxyid参数,其他参数是可选的。仅仅传递的参数会被更新,其他的参数将保持不变。

Additionally to the standard proxy properties, the method accepts the following parameters. 此外standard proxy properties,此方法接受以下参数

Parameter Type Description
hosts array Hosts to be monitored by the proxy. If a host is already monitored by a different proxy, it will be reassigned to the current proxy.

The hosts must have the hostid property defined. 代理监视的主机。如果一个主机已经被一个不同的代理监控,他将会重新分配到当前的代理
\\主机必须拥有hostid属性
interface object Host interface to replace the existing interface for the passive proxy. 主机接口将会替换已存在的主机接口用于被动代理

Return values 返回值

(object) Returns an object containing the IDs of the updated proxies under the proxyids property. (object)返回一个对象,该对象包含proxyids属性下更新的代理的id。

Examples 示例如下

Change hosts monitored by a proxy 改变一个主机的代理

Update the proxy to monitor the two given hosts.

Request:

{
           "jsonrpc": "2.0",
           "method": "proxy.update",
           "params": {
               "proxyid": "10293",
               "hosts": [
                   "10294",
                   "10295"
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "proxyids": [
                   "10293"
               ]
           },
           "id": 1
       }

Change proxy status 改变代理的状态

Change the proxy to an active proxy and rename it to "Active proxy". 改变代理的模式是主动模式,并且重命名为"Active proxy".

Request:

{
           "jsonrpc": "2.0",
           "method": "proxy.update",
           "params": {
               "proxyid": "10293",
               "host": "Active proxy",
               "status": "5"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "proxyids": [
                   "10293"
               ]
           },
           "id": 1
       }

See also

Source

CProxy::update() in frontends/php/include/classes/api/services/CProxy.php.