zabbix-api-simple 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8f4e84a0886f658f05bd62ffbe03f0586006a7a1aff9b97a7915c900e2edc6e
4
- data.tar.gz: d0cd327492b60c398a23d4e4885fa6445e9c4ea1e6b4aff02b264d9c529a8072
3
+ metadata.gz: 35647dac01d85faed96daeacd718c183ffb90ee374f97e93a1b8108408def350
4
+ data.tar.gz: 6ad7fc1f2fa168f35fce665da63d156a163e81705c42a33059081b96adb72e15
5
5
  SHA512:
6
- metadata.gz: a997c5ceaa9730a349965dab37bf09435d723641ad2a8649a848e347673ff317ae90f8eaa1ceb65378b54a1e3eacf7974d2ec6565bd1edb64f458e9a30f43351
7
- data.tar.gz: 7bc895f73dd85e5a2e1e9ebcd4774d1ba9b4ca911c1abf394825d267dbb27ed2690993c6afcd0fee5d02617959b1bab042403edf306c0aa3a220ee62b4bcee47
6
+ metadata.gz: 187014b38f74a272f2f90a7fae4dfe2a17bb772f842a2f12001bfca4eba135e0f4edebfa5f361a3e131361597d1181f7cee402e09bb525f6ea038fc52e6f816b
7
+ data.tar.gz: 94a0eae1c0d62056128f6c2a55eee1418c5e516ff475fda580a941a8ba9c0e0a5da4402db3eb6c1cc0f365d1782305765ed666749d81328b968bc0d636353f54
data/README.md CHANGED
@@ -55,7 +55,7 @@ opts = Optimist::options do
55
55
  opt :hostname, "Host name to search for", type: :string, required: true
56
56
  end
57
57
 
58
- api = Zabbix::Api::Client.new(opts[:url])
58
+ api = Zabbix::Api::Client.new(url: opts[:url])
59
59
 
60
60
  api.login(user: opts[:user],pass:opts[:pass])
61
61
 
data/bin/zapishell.rb CHANGED
@@ -26,4 +26,4 @@ end
26
26
  require "rubygems"
27
27
  require "bundler/setup"
28
28
 
29
- load Gem.bin_path("zabbix-api", "zapishell.rb")
29
+ load Gem.bin_path("zabbix-api-simple", "zapishell.rb")
@@ -87,6 +87,17 @@ module Zabbix
87
87
  OpenStruct.new(post(method: 'user.logout', params: [], auth: @token).body)
88
88
  end
89
89
 
90
+ def call(name, *args, &block)
91
+ res = post(method: "#{name}", params: args.first, id: '1', auth: @token).body
92
+ raise res['error'].awesome_inspect(plain: true) if res.has_key?('error')
93
+ if res.has_key?('result') and res['result'].class == Array
94
+ res = res['result'].collect{|each| OpenStruct.new(each)}
95
+ else
96
+ res = OpenStruct.new(res)
97
+ end
98
+ return res
99
+ end
100
+
90
101
 
91
102
  def method_missing(name, *args, &block)
92
103
  if @@zabbix_objects.include?(name)
@@ -97,15 +108,7 @@ module Zabbix
97
108
  newcli.zabobject = name
98
109
  return newcli
99
110
  elsif @zabobject
100
- object = @zabobject
101
- res = post(method: "#{object}.#{name}", params: args.first, id: '1', auth: @token).body
102
- raise res['error'].awesome_inspect(plain: true) if res.has_key?('error')
103
- if res.has_key?('result') and res['result'].class == Array
104
- res = res['result'].collect{|each| OpenStruct.new(each)}
105
- else
106
- res = OpenStruct.new(res)
107
- end
108
- return res
111
+ return call("#{@zabobject}.#{name}",args.first)
109
112
  else
110
113
  raise "Unknown zabbix object given: #{name}"
111
114
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Zabbix
4
4
  module Api
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zabbix-api-simple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Parker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-23 00:00:00.000000000 Z
11
+ date: 2021-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday