Class: Zabbix::API
- Inherits:
-
Object
- Object
- Zabbix::API
- Includes:
- WrAPI::Authentication, WrAPI::Connection, WrAPI::Request, Authentication, Request::JSONRPC2
- Defined in:
- lib/zabbix/api.rb
Overview
Note:
This class includes connection, request handling, JSON-RPC 2.0 support, and authentication from WrAPI.
This class is the core API client that interfaces with Zabbix. It manages configuration options, API connections, and helper utilities.
Direct Known Subclasses
Constant Summary
Constants included from Request::JSONRPC2
Request::JSONRPC2::ZABBIX_ENDPOINT
Instance Method Summary collapse
-
#config ⇒ Hash
Retrieve the current configuration for the API client.
-
#initialize(options = {}) ⇒ API
constructor
Initialize a new Zabbix::API instance and copy settings from the singleton configuration.
-
#zabbix_clock(secs) ⇒ DateTime
Convert a Zabbix clock timestamp to a Ruby DateTime object.
Methods included from Authentication
Methods included from Request::JSONRPC2
Constructor Details
#initialize(options = {}) ⇒ API
Initialize a new Zabbix::API instance and copy settings from the singleton configuration.
33 34 35 36 37 38 |
# File 'lib/zabbix/api.rb', line 33 def initialize( = {}) = Zabbix..merge() # Merge provided options with default options WrAPI::Configuration::VALID_OPTIONS_KEYS.each do |key| send("#{key}=", [key]) # Assign each configuration option dynamically end end |
Instance Method Details
#config ⇒ Hash
Retrieve the current configuration for the API client.
46 47 48 49 50 51 52 |
# File 'lib/zabbix/api.rb', line 46 def config conf = {} WrAPI::Configuration::VALID_OPTIONS_KEYS.each do |key| conf[key] = send(key) # Build a hash of current configuration values end conf end |
#zabbix_clock(secs) ⇒ DateTime
Convert a Zabbix clock timestamp to a Ruby DateTime object.
61 62 63 |
# File 'lib/zabbix/api.rb', line 61 def zabbix_clock(secs) Time.at(secs.to_i).to_datetime # Convert seconds since Unix epoch to DateTime end |