创建

Description 描述

object proxy.create(object/array **proxies**)

This method allows to create new proxies. 此方法用于创建新的代理

Parameters 参数

(object/array) Proxies to create. (object/array) 创建代理

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

ParameterTypeDescription
hostsarrayHosts 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属性
interfaceobjectHost interface to be created for the passive proxy.

Required for passive proxies. 创建主机接口用于被动代理

被动代理的需求

Return values 返回值

(object) Returns an object containing the IDs of the created proxies under the proxyids property. The order of the returned IDs matches the order of the passed proxies.

(object)返回一个对象,该对象包含在proxyids属性下创建的代理的id。返回的id的顺序与所传递的代理的顺序相匹配。

Examples 示例如下

Create an active proxy 创建一个主动的代理

Create an action proxy “Active proxy” and assign a host to be monitored by it. 创一个动作代理“Active proxy”,并分配一个由其监控的主机

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "proxy.create",
  4. "params": {
  5. "host": "Active proxy",
  6. "status": "5",
  7. "hosts": [
  8. {
  9. "hostid": "10279"
  10. }
  11. ]
  12. },
  13. "auth": "ab9638041ec6922cb14b07982b268f47",
  14. "id": 1
  15. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "proxyids": [
  5. "10280"
  6. ]
  7. },
  8. "id": 1
  9. }

Create a passive proxy 创建一个反向代理

Create a passive proxy “Passive proxy” and assign two hosts to be monitored by it. 创建一个反向代理“Passive proxy”,并分配2个由其监控的主机。

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "proxy.create",
  4. "params": {
  5. "host": "Passive proxy",
  6. "status": "6",
  7. "interface": {
  8. "ip": "127.0.0.1",
  9. "dns": "",
  10. "useip": "1",
  11. "port": "10051"
  12. },
  13. "hosts": [
  14. {
  15. "hostid": "10192"
  16. },
  17. {
  18. "hostid": "10139"
  19. }
  20. ]
  21. },
  22. "auth": "ab9638041ec6922cb14b07982b268f47",
  23. "id": 1
  24. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "proxyids": [
  5. "10284"
  6. ]
  7. },
  8. "id": 1
  9. }

See also

Source

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