zabbix_api_gem 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6c8f297f2139a9f7c49a789f9e1ffd4600e5912d9e0b1a63330f761752fcd1e
4
- data.tar.gz: 50b8942c322c9875c94c28a75080feb1b72f93910511e2bfa10c3353740577d7
3
+ metadata.gz: b0dc1d0b264ed6c36ccbf9253f530dfdd2fc7ff2eaa7c060dc9324944f00384f
4
+ data.tar.gz: 482565767d3e1a484223b28330f271ce9ab7ab51177b615f619a46c71199f227
5
5
  SHA512:
6
- metadata.gz: ba97284983467df1d8b2ead9f52b04883f5978bf78c38d0d0c3fc229cbc5a07ce81cb3ec8d79c5332ec591e6c0f7943f60d7cea4c29a57d0650c8e6a764bfc08
7
- data.tar.gz: 28858aaa64c5fb2e9666949d83108e1751192d64042023afb6e7800ff037fe6e810f972692e8e5179c0fd89d0d5e506e03b56c762821a2162ab1f5a026f6a757
6
+ metadata.gz: 37ac9b890f3a197fb09a746dbd1e027a0b2a43b81feeb7ff8e03a9a1a302d47f213ed0a3e15a1464ba2a93181f0d290763a498df09c1bae36d212040066b94e4
7
+ data.tar.gz: '09094378b9e9616719bce054bced52e39ea3718abec9f9031cc0a78c8bdc2c6600617dc7989177c1a59125cc79a317962b61ff98ba7719dfc41f7ecef2016ecf'
data/CHANGELOG.md CHANGED
@@ -2,3 +2,6 @@
2
2
 
3
3
  ## [0.1.0] - 2024-02-09
4
4
  - Initial release
5
+
6
+ ## [0.2.0] - 2024-02-12
7
+ - Include events and method to get object by id
data/README.md CHANGED
@@ -84,9 +84,10 @@ end
84
84
 
85
85
  |Resource|API endpoint|
86
86
  |:--|:--|
87
- |.hostgroups|hostgroup.get|
88
- |.hosts|hosts.get|
89
- |.problems|problems.get|
87
+ |hostgroups, hostgroup(hostgroup_id)|hostgroup.get|
88
+ |.hosts, host(host_id)|hosts.get|
89
+ |.problems, problem(event_id)|problems.get|
90
+ |.events, event(event_id)|problems.get|
90
91
 
91
92
 
92
93
 
data/lib/zabbix/client.rb CHANGED
@@ -7,17 +7,30 @@ module Zabbix
7
7
  # @see https://www.zabbix.com/documentation/current/en/manual/api
8
8
  class Client < API
9
9
 
10
- def self.def_rpc_call(method, rpc_method)
10
+ def self.def_rpc_call(method, rpc_method, id_field = nil)
11
11
  self.send(:define_method, method) do |params = nil|
12
12
  rpc_call(rpc_method, params)
13
13
  end
14
+ if id_field
15
+ # strip trailing 's'
16
+ singular = method.to_s.chop.to_sym
17
+ self.send(:define_method, singular) do |ids,params = nil|
18
+ if ids.is_a?(Array)
19
+ rpc_call(rpc_method, {"#{id_field}":ids}.merge(params || {}))
20
+ else
21
+ rpc_call(rpc_method, {"#{id_field}":[ids]}.merge(params || {})).first
22
+ end
23
+ end
24
+ end
14
25
  end
15
26
 
16
27
  def_rpc_call(:api_info, 'api.info')
17
28
  def_rpc_call(:settings, 'settings.get')
18
- def_rpc_call(:hostgroups, 'hostgroup.get')
19
- def_rpc_call(:hosts, 'host.get')
20
- def_rpc_call(:problems, 'problem.get')
29
+ def_rpc_call(:hostgroups, 'hostgroup.get', 'groupids')
30
+ def_rpc_call(:hosts, 'host.get', 'hostids')
31
+ def_rpc_call(:problems, 'problem.get', 'problemids')
32
+ def_rpc_call(:events, 'event.get', 'eventids')
33
+ def_rpc_call(:acknowledge_events, 'event.acknowledge')
21
34
 
22
35
  end
23
36
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zabbix
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zabbix_api_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janco Tanis