获取

描述

integer/array proxy.get(object parameters)

该方法允许根据给定的参数查询代理。

参数

(object)定义所需输出的参数。

此方法支持一下参数。

Parameter Type Description
proxyids string/array 仅返回所给ID的代理
selectHosts query 返回在hosts属性中代理监控的主机
selectInterface query 返回在interface属性中被动代理使用代理接口
sortfield string/array 根据所给的属性进行排序

可能的值:hostid, hoststatus.
countOutput boolean 改参数适用于所有的get方法,详细描述是在reference commentary
editable boolean
excludeSearch boolean
filter object
limit integer
output query
preservekeys boolean
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch boolean

返回值

(integer/array) Returns either:

  • 一个对象数组
  • 搜索到对象的数量,如果countOutput对象被使用

示例如下

检索所有的代理

检索所有配置的代理和他们的接口

Request:

{
    "jsonrpc": "2.0",
    "method": "proxy.get",
    "params": {
        "output": "extend",
        "selectInterface": "extend"
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}

Response:

{
    "jsonrpc": "2.0",
    "result": [
        {
            "host": "Active proxy",
            "status": "5",
            "lastaccess": "0",
            "description": "",
            "tls_connect": "1",
            "tls_accept": "1",
            "tls_issuer": "",
            "tls_subject": "",
            "tls_psk_identity": "",
            "tls_psk": "",
            "proxy_address": "",
            "auto_compress": "0",
            "proxyid": "30091",
            "interface": []
        },
        {
            "host": "Passive proxy",
            "status": "6",
            "lastaccess": "0",
            "description": "",
            "tls_connect": "1",
            "tls_accept": "1",
            "tls_issuer": "",
            "tls_subject": "",
            "tls_psk_identity": "",
            "tls_psk": "",
            "proxy_address": "",
            "auto_compress": "0",
            "proxyid": "30092",
            "interface": {
                "interfaceid": "30109",
                "hostid": "30092",
                "useip": "1",
                "ip": "127.0.0.1",
                "dns": "",
                "port": "10051"
            ]
        }
    ],
    "id": 1
}

See also

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