Class: Zabbix::API

Inherits:
Object
  • Object
show all
Includes:
WrAPI::Authentication, WrAPI::Connection, WrAPI::Request, Authentication, Request::JSONRPC2
Defined in:
lib/zabbix/api.rb

Direct Known Subclasses

Client

Constant Summary

Constants included from Request::JSONRPC2

Request::JSONRPC2::ZABBIX_ENDPOINT

Instance Method Summary collapse

Methods included from Authentication

#login

Methods included from Request::JSONRPC2

#rpc_call

Constructor Details

#initialize(options = {}) ⇒ API

Creates a new API and copies settings from singleton



13
14
15
16
17
18
# File 'lib/zabbix/api.rb', line 13

def initialize(options = {})
  options = Zabbix.options.merge(options)
  WrAPI::Configuration::VALID_OPTIONS_KEYS.each do |key|
    send("#{key}=", options[key])
  end
end

Instance Method Details

#configObject



20
21
22
23
24
25
26
# File 'lib/zabbix/api.rb', line 20

def config
  conf = {}
  WrAPI::Configuration::VALID_OPTIONS_KEYS.each do |key|
    conf[key] = send key
  end
  conf
end

#zabbix_clock(secs) ⇒ Object

Convert zabbix clock to datetime



29
30
31
# File 'lib/zabbix/api.rb', line 29

def zabbix_clock secs
  Time.at( secs.to_i ).to_datetime
end