Class: Zabbix::Client
Overview
Note:
All methods have been separated into modules and follow the same grouping used in api docs
Wrapper for the Zabbix REST API
Constant Summary
Constants included from Request::JSONRPC2
Request::JSONRPC2::ZABBIX_ENDPOINT
Class Method Summary collapse
- .def_rpc_call(method, rpc_method, id_field = nil) ⇒ Object
- .singular_method(method, rpc_method, id_field) ⇒ Object
Methods inherited from API
#config, #initialize, #zabbix_clock
Methods included from Authentication
Methods included from Request::JSONRPC2
Constructor Details
This class inherits a constructor from Zabbix::API
Class Method Details
.def_rpc_call(method, rpc_method, id_field = nil) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/zabbix/client.rb', line 11 def self.def_rpc_call(method, rpc_method, id_field = nil) self.send(:define_method, method) do |params = nil| rpc_call(rpc_method, params) end # singular by stripping last trailing 's' self.singular_method(method.to_s.chop.to_sym, rpc_method, id_field) if id_field end |
.singular_method(method, rpc_method, id_field) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/zabbix/client.rb', line 19 def self.singular_method(method, rpc_method, id_field) self.send(:define_method, method) do |ids, params = nil| if ids.is_a?(Array) rpc_call(rpc_method, { "#{id_field}": ids}.merge(params || { })) else rpc_call(rpc_method, { "#{id_field}": [ids]}.merge(params || { })).first end end end |