Module: Zabbix::Request::JSONRPC2

Included in:
API
Defined in:
lib/zabbix/request.rb

Overview

JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol. Primarily this specification defines several data structures and the rules around their processing. It is transport agnostic in that the concepts can be used within the same process, over sockets, over http, or in many various message passing environments. It uses JSON (RFC 4627) as data format.

www.jsonrpc.org/specification

Constant Summary collapse

ZABBIX_ENDPOINT =
'/zabbix/api_jsonrpc.php'
@@id =
1

Instance Method Summary collapse

Instance Method Details

#rpc_call(method, params = nil) ⇒ Object

Raises:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/zabbix/request.rb', line 17

def rpc_call(method, params = nil)
  options = {
    "jsonrpc": "2.0",
    "method": method,
    "params": {
      "output": "extend"
    },
    "id": @@id += 1
  }

  options[:params] = params if params
  result = post( ZABBIX_ENDPOINT, options )
  raise RPCError, result.body['error'] if result.body['error']

  WrAPI::Request::Entity.create(result.body['result'])
end