zabbix-api-simple 0.1.4 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +3 -7
- data/exe/zapishell.rb +15 -1
- data/images/2021-09-19_09-38.png +0 -0
- data/images/2021-09-19_09-40.png +0 -0
- data/images/zabbix-api-simple-simplicity.png +0 -0
- data/lib/zabbix/api/client.rb +57 -2
- data/lib/zabbix/api/version.rb +1 -1
- data/lib/zabbix/api.rb +0 -6
- data/public/Zabbix/Api/Client.html +154 -79
- data/public/Zabbix/Api/FaradayMiddleware/ZabbixApiRequest.html +19 -11
- data/public/Zabbix/Api/FaradayMiddleware.html +1 -1
- data/public/Zabbix/Api/OpenStruct.html +384 -0
- data/public/Zabbix/Api/ZabbixStruct.html +384 -0
- data/public/Zabbix/Api.html +5 -5
- data/public/Zabbix.html +3 -3
- data/public/_index.html +7 -7
- data/public/class_list.html +1 -1
- data/public/file.CHANGELOG.html +15 -1
- data/public/file.LICENSE.html +1 -1
- data/public/file.README.html +4 -8
- data/public/images/zabbix-api-simple-simplicity.png +0 -0
- data/public/index.html +4 -8
- data/public/method_list.html +32 -0
- data/public/top-level-namespace.html +1 -1
- data/zabbix-api.gemspec +4 -2
- metadata +39 -5
- data/public/Zabbix/Api/Error.html +0 -124
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46064cab99de1a18915c05f63d2101160a28ef67a4d6c32b612e1467894b1fa6
|
4
|
+
data.tar.gz: 8dff176c2e45d4a440344af791faa95b9d4f99b77bc8da215fb9341a3db6b6cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fc06be35eac88c1566c6b6d4a3735f69feec302506173a1c491d3e11fc43d51fe9c291bd5be34eed8e2d5bea215f99e01b96da187d402e2fa627fe01300609b
|
7
|
+
data.tar.gz: 39fe035780ffa88b348a8d77ee50fa94a94607d0f82ea4e240874de7be3e6787023ee0f3e9d3617ac201cd625cc19be6387a013cedfa2613c05ff5d23ab25960
|
data/CHANGELOG.md
CHANGED
@@ -1,2 +1,15 @@
|
|
1
1
|
# 0.1.4
|
2
2
|
- Just doc changes
|
3
|
+
# 0.1.5
|
4
|
+
- deps fix for pry
|
5
|
+
- add known_objects method
|
6
|
+
- add exception trap for json parse issues w/ note about php memory
|
7
|
+
- change zapishell.rb to start in the api context
|
8
|
+
- add exception for apiinfo.version (refuses auth token for some reason)
|
9
|
+
- add pretty inspection mode to zapishell.rb
|
10
|
+
# 0.1.6
|
11
|
+
- force faraday 1.8 - 2.0 appears to break things
|
12
|
+
# 0.2.0
|
13
|
+
- changes to support faraday 2.0. Note that faraday < 2.0 is incompatible with 2.0+ - when you install zabbix-api-simple 0.2.0 it will install faraday 2.0
|
14
|
+
# 0.2.1
|
15
|
+
- another faraday fix
|
data/README.md
CHANGED
@@ -36,6 +36,8 @@ Once you have an authenticated instance of the client, syntax is basically alway
|
|
36
36
|
|
37
37
|
`clientinstance.object.verb(<param kv pairs>)`
|
38
38
|
|
39
|
+
![simple translation](images/zabbix-api-simple-simplicity.png)
|
40
|
+
|
39
41
|
If "object" is unknown, "Unknown zabbix object given" will be raised.
|
40
42
|
|
41
43
|
If this call results in an error from the API, a RuntimeError will be raised indicating the specifics.
|
@@ -106,12 +108,6 @@ It attempts to authenticate you to the given server, and then drops you to a pry
|
|
106
108
|
|
107
109
|
Refer to the API documentation for your version of Zabbix for the particulars.
|
108
110
|
|
109
|
-
## Development
|
110
|
-
|
111
|
-
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
112
|
-
|
113
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
114
|
-
|
115
111
|
## Contributing
|
116
112
|
|
117
|
-
Bug reports and pull requests are welcome on
|
113
|
+
Bug reports and pull requests are welcome on GitLab at https://gitlab.com/svdasein/zabbix-api
|
data/exe/zapishell.rb
CHANGED
@@ -12,12 +12,26 @@ opts = Optimist::options do
|
|
12
12
|
opt :pass, "Pass to auth user with", type: :string, required: true
|
13
13
|
end
|
14
14
|
|
15
|
+
|
16
|
+
|
17
|
+
Zabbix::Api::OpenStruct.prettymode = true
|
18
|
+
|
15
19
|
print "user.login: "
|
16
20
|
api = Zabbix::Api::Client.new(url: opts[:url])
|
17
21
|
|
18
22
|
ap api.login(user: opts[:user],pass:opts[:pass])
|
19
23
|
|
20
|
-
|
24
|
+
puts <<-END
|
25
|
+
|
26
|
+
Enter api commands e.g. host.get
|
27
|
+
|
28
|
+
execute known_objects for a list of known zabbix object types
|
29
|
+
|
30
|
+
quit to exit - your session will be logged out for you
|
31
|
+
|
32
|
+
END
|
33
|
+
|
34
|
+
api.pry
|
21
35
|
|
22
36
|
print "user.logout: "
|
23
37
|
ap api.logout
|
Binary file
|
Binary file
|
Binary file
|
data/lib/zabbix/api/client.rb
CHANGED
@@ -2,8 +2,10 @@ module Zabbix
|
|
2
2
|
module Api
|
3
3
|
|
4
4
|
require 'faraday'
|
5
|
+
require 'faraday/net_http'
|
5
6
|
require 'json'
|
6
7
|
require 'set'
|
8
|
+
require 'amazing_print'
|
7
9
|
require 'pry'
|
8
10
|
|
9
11
|
module FaradayMiddleware
|
@@ -26,16 +28,55 @@ module Zabbix
|
|
26
28
|
end
|
27
29
|
|
28
30
|
def on_complete(env)
|
29
|
-
|
31
|
+
begin
|
32
|
+
env[:response_body] = JSON.parse(env[:response_body])
|
33
|
+
rescue JSON::ParserError => e
|
34
|
+
env[:response_body] = {error: e,note: 'Check api web configuration (e.g. url, PHP memory, etc)'}
|
35
|
+
end
|
30
36
|
end
|
31
37
|
|
32
38
|
end
|
33
39
|
|
34
|
-
Faraday::Request.register_middleware
|
40
|
+
Faraday::Request.register_middleware(zabbix_api_request: ZabbixApiRequest)
|
35
41
|
|
36
42
|
end # module FaradayMiddleware
|
37
43
|
|
38
44
|
|
45
|
+
|
46
|
+
##
|
47
|
+
# Subclass of OpenStruct adds some niceties for REPL etc
|
48
|
+
#
|
49
|
+
class OpenStruct < OpenStruct
|
50
|
+
|
51
|
+
##
|
52
|
+
# If true, inspect returns awesome_inspect instead of default
|
53
|
+
@@prettymode = false
|
54
|
+
|
55
|
+
class << self
|
56
|
+
##
|
57
|
+
# returns current value of prettymode
|
58
|
+
#
|
59
|
+
def prettymode
|
60
|
+
@@prettymode
|
61
|
+
end
|
62
|
+
##
|
63
|
+
# sets prettymod to aBool
|
64
|
+
#
|
65
|
+
def prettymode=(aBool)
|
66
|
+
@@prettymode = aBool
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def inspect
|
71
|
+
if @@prettymode
|
72
|
+
awesome_inspect
|
73
|
+
else
|
74
|
+
super
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
39
80
|
##
|
40
81
|
# Each instance of this class acts as a connection Zabbix's API
|
41
82
|
class Client
|
@@ -73,6 +114,7 @@ module Zabbix
|
|
73
114
|
# happen automagically. You can alter request timeout if needed by passing
|
74
115
|
# :timeout - the default is 60 secs
|
75
116
|
def initialize(url: nil,timeout: 60)
|
117
|
+
Faraday.default_adapter = :net_http
|
76
118
|
@conn = Faraday.new(
|
77
119
|
url: url,
|
78
120
|
headers: {'Content-Type' => 'application/json-rpc'},
|
@@ -120,7 +162,12 @@ module Zabbix
|
|
120
162
|
# results are returned as instances of OpenStruct. If you need this to be
|
121
163
|
# a hash just do to_h to the returned object.
|
122
164
|
def call(name, *args, &block)
|
165
|
+
res = nil
|
166
|
+
if name == 'apiinfo.version'
|
167
|
+
res = post(method: "#{name}", params: args.first, id: '1').body
|
168
|
+
else
|
123
169
|
res = post(method: "#{name}", params: args.first, id: '1', auth: @token).body
|
170
|
+
end
|
124
171
|
raise res['error'].awesome_inspect(plain: true) if res.has_key?('error')
|
125
172
|
if res.has_key?('result') and res['result'].class == Array
|
126
173
|
res = res['result'].collect{|each| OpenStruct.new(each)}
|
@@ -130,6 +177,14 @@ module Zabbix
|
|
130
177
|
return res
|
131
178
|
end
|
132
179
|
|
180
|
+
##
|
181
|
+
# just handy if you're doing a REPL (e.g. zapishell.rb) Returns
|
182
|
+
# list of zabbix objects the api currently is aware of
|
183
|
+
#
|
184
|
+
def known_objects
|
185
|
+
@@zabbix_objects
|
186
|
+
end
|
187
|
+
|
133
188
|
|
134
189
|
##
|
135
190
|
# this override of method_missing is the trick that lets zabbix-api-simple
|
data/lib/zabbix/api/version.rb
CHANGED
data/lib/zabbix/api.rb
CHANGED
@@ -335,6 +335,30 @@
|
|
335
335
|
<p>:url is required.</p>
|
336
336
|
</div></span>
|
337
337
|
|
338
|
+
</li>
|
339
|
+
|
340
|
+
|
341
|
+
<li class="public ">
|
342
|
+
<span class="summary_signature">
|
343
|
+
|
344
|
+
<a href="#known_objects-instance_method" title="#known_objects (instance method)">#<strong>known_objects</strong> ⇒ Object </a>
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
</span>
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
<span class="summary_desc"><div class='inline'>
|
359
|
+
<p>just handy if you're doing a REPL (e.g. zapishell.rb) Returns list of zabbix objects the api currently is aware of.</p>
|
360
|
+
</div></span>
|
361
|
+
|
338
362
|
</li>
|
339
363
|
|
340
364
|
|
@@ -490,19 +514,19 @@
|
|
490
514
|
<pre class="lines">
|
491
515
|
|
492
516
|
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
517
|
+
115
|
518
|
+
116
|
519
|
+
117
|
520
|
+
118
|
521
|
+
119
|
522
|
+
120
|
523
|
+
121
|
524
|
+
122
|
525
|
+
123
|
526
|
+
124</pre>
|
503
527
|
</td>
|
504
528
|
<td>
|
505
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
529
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 115</span>
|
506
530
|
|
507
531
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='label'>url:</span> <span class='kw'>nil</span><span class='comma'>,</span><span class='label'>timeout:</span> <span class='int'>60</span><span class='rparen'>)</span>
|
508
532
|
<span class='ivar'>@conn</span> <span class='op'>=</span> <span class='const'>Faraday</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
|
@@ -555,23 +579,23 @@
|
|
555
579
|
<pre class="lines">
|
556
580
|
|
557
581
|
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
582
|
+
196
|
583
|
+
197
|
584
|
+
198
|
585
|
+
199
|
586
|
+
200
|
587
|
+
201
|
588
|
+
202
|
589
|
+
203
|
590
|
+
204
|
591
|
+
205
|
592
|
+
206
|
593
|
+
207
|
594
|
+
208
|
595
|
+
209</pre>
|
572
596
|
</td>
|
573
597
|
<td>
|
574
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
598
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 196</span>
|
575
599
|
|
576
600
|
<span class='kw'>def</span> <span class='id identifier rubyid_method_missing'>method_missing</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
577
601
|
<span class='kw'>if</span> <span class='cvar'>@@zabbix_objects</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
|
@@ -625,12 +649,12 @@
|
|
625
649
|
<pre class="lines">
|
626
650
|
|
627
651
|
|
628
|
-
|
629
|
-
|
630
|
-
|
652
|
+
84
|
653
|
+
85
|
654
|
+
86</pre>
|
631
655
|
</td>
|
632
656
|
<td>
|
633
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
657
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 84</span>
|
634
658
|
|
635
659
|
<span class='kw'>def</span> <span class='id identifier rubyid_last'>last</span>
|
636
660
|
<span class='ivar'>@last</span>
|
@@ -673,12 +697,12 @@
|
|
673
697
|
<pre class="lines">
|
674
698
|
|
675
699
|
|
676
|
-
|
677
|
-
|
678
|
-
|
700
|
+
107
|
701
|
+
108
|
702
|
+
109</pre>
|
679
703
|
</td>
|
680
704
|
<td>
|
681
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
705
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 107</span>
|
682
706
|
|
683
707
|
<span class='kw'>def</span> <span class='id identifier rubyid_conn'>conn</span>
|
684
708
|
<span class='ivar'>@conn</span>
|
@@ -716,12 +740,12 @@
|
|
716
740
|
<pre class="lines">
|
717
741
|
|
718
742
|
|
719
|
-
|
720
|
-
|
721
|
-
|
743
|
+
107
|
744
|
+
108
|
745
|
+
109</pre>
|
722
746
|
</td>
|
723
747
|
<td>
|
724
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
748
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 107</span>
|
725
749
|
|
726
750
|
<span class='kw'>def</span> <span class='id identifier rubyid_token'>token</span>
|
727
751
|
<span class='ivar'>@token</span>
|
@@ -759,12 +783,12 @@
|
|
759
783
|
<pre class="lines">
|
760
784
|
|
761
785
|
|
762
|
-
|
763
|
-
|
764
|
-
|
786
|
+
108
|
787
|
+
109
|
788
|
+
110</pre>
|
765
789
|
</td>
|
766
790
|
<td>
|
767
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
791
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 108</span>
|
768
792
|
|
769
793
|
<span class='kw'>def</span> <span class='id identifier rubyid_zabobject'>zabobject</span>
|
770
794
|
<span class='ivar'>@zabobject</span>
|
@@ -809,33 +833,84 @@
|
|
809
833
|
<pre class="lines">
|
810
834
|
|
811
835
|
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
836
|
+
162
|
837
|
+
163
|
838
|
+
164
|
839
|
+
165
|
840
|
+
166
|
841
|
+
167
|
842
|
+
168
|
843
|
+
169
|
844
|
+
170
|
845
|
+
171
|
846
|
+
172
|
847
|
+
173
|
848
|
+
174
|
849
|
+
175
|
850
|
+
176</pre>
|
822
851
|
</td>
|
823
852
|
<td>
|
824
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
853
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 162</span>
|
825
854
|
|
826
855
|
<span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
856
|
+
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
857
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>apiinfo.version</span><span class='tstring_end'>'</span></span>
|
858
|
+
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='label'>method:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>params:</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='comma'>,</span> <span class='label'>id:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span>
|
859
|
+
<span class='kw'>else</span>
|
827
860
|
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='label'>method:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>params:</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='comma'>,</span> <span class='label'>id:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>auth:</span> <span class='ivar'>@token</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span>
|
861
|
+
<span class='kw'>end</span>
|
828
862
|
<span class='id identifier rubyid_raise'>raise</span> <span class='id identifier rubyid_res'>res</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>error</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_awesome_inspect'>awesome_inspect</span><span class='lparen'>(</span><span class='label'>plain:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>error</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
829
863
|
<span class='kw'>if</span> <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>result</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='kw'>and</span> <span class='id identifier rubyid_res'>res</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>result</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span> <span class='op'>==</span> <span class='const'>Array</span>
|
830
|
-
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='id identifier rubyid_res'>res</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>result</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_each'>each</span><span class='op'>|</span> <span class='const'>OpenStruct</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_each'>each</span><span class='rparen'>)</span><span class='rbrace'>}</span>
|
864
|
+
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='id identifier rubyid_res'>res</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>result</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_each'>each</span><span class='op'>|</span> <span class='const'><span class='object_link'><a href="OpenStruct.html" title="Zabbix::Api::OpenStruct (class)">OpenStruct</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_each'>each</span><span class='rparen'>)</span><span class='rbrace'>}</span>
|
831
865
|
<span class='kw'>else</span>
|
832
|
-
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='const'>OpenStruct</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='rparen'>)</span>
|
866
|
+
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="OpenStruct.html" title="Zabbix::Api::OpenStruct (class)">OpenStruct</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='rparen'>)</span>
|
833
867
|
<span class='kw'>end</span>
|
834
868
|
<span class='kw'>return</span> <span class='id identifier rubyid_res'>res</span>
|
835
869
|
<span class='kw'>end</span></pre>
|
836
870
|
</td>
|
837
871
|
</tr>
|
838
872
|
</table>
|
873
|
+
</div>
|
874
|
+
|
875
|
+
<div class="method_details ">
|
876
|
+
<h3 class="signature " id="known_objects-instance_method">
|
877
|
+
|
878
|
+
#<strong>known_objects</strong> ⇒ <tt>Object</tt>
|
879
|
+
|
880
|
+
|
881
|
+
|
882
|
+
|
883
|
+
|
884
|
+
</h3><div class="docstring">
|
885
|
+
<div class="discussion">
|
886
|
+
|
887
|
+
<p>just handy if you're doing a REPL (e.g. zapishell.rb) Returns list of zabbix objects the api currently is aware of</p>
|
888
|
+
|
889
|
+
|
890
|
+
</div>
|
891
|
+
</div>
|
892
|
+
<div class="tags">
|
893
|
+
|
894
|
+
|
895
|
+
</div><table class="source_code">
|
896
|
+
<tr>
|
897
|
+
<td>
|
898
|
+
<pre class="lines">
|
899
|
+
|
900
|
+
|
901
|
+
182
|
902
|
+
183
|
903
|
+
184</pre>
|
904
|
+
</td>
|
905
|
+
<td>
|
906
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 182</span>
|
907
|
+
|
908
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_known_objects'>known_objects</span>
|
909
|
+
<span class='cvar'>@@zabbix_objects</span>
|
910
|
+
<span class='kw'>end</span></pre>
|
911
|
+
</td>
|
912
|
+
</tr>
|
913
|
+
</table>
|
839
914
|
</div>
|
840
915
|
|
841
916
|
<div class="method_details ">
|
@@ -864,12 +939,12 @@
|
|
864
939
|
<pre class="lines">
|
865
940
|
|
866
941
|
|
867
|
-
|
868
|
-
|
869
|
-
|
942
|
+
213
|
943
|
+
214
|
944
|
+
215</pre>
|
870
945
|
</td>
|
871
946
|
<td>
|
872
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
947
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 213</span>
|
873
948
|
|
874
949
|
<span class='kw'>def</span> <span class='id identifier rubyid_last'>last</span>
|
875
950
|
<span class='const'><span class='object_link'><a href="" title="Zabbix::Api::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_last'><span class='object_link'><a href="#last-class_method" title="Zabbix::Api::Client.last (method)">last</a></span></span>
|
@@ -905,19 +980,19 @@
|
|
905
980
|
<pre class="lines">
|
906
981
|
|
907
982
|
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
983
|
+
139
|
984
|
+
140
|
985
|
+
141
|
986
|
+
142
|
987
|
+
143</pre>
|
913
988
|
</td>
|
914
989
|
<td>
|
915
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
990
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 139</span>
|
916
991
|
|
917
992
|
<span class='kw'>def</span> <span class='id identifier rubyid_login'>login</span><span class='lparen'>(</span><span class='label'>user:</span> <span class='kw'>nil</span><span class='comma'>,</span><span class='label'>pass:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
918
993
|
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='label'>method:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>user.login</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>params:</span> <span class='lbrace'>{</span><span class='label'>user:</span> <span class='id identifier rubyid_user'>user</span><span class='comma'>,</span> <span class='label'>password:</span><span class='id identifier rubyid_pass'>pass</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='label'>auth:</span><span class='kw'>nil</span><span class='rparen'>)</span>
|
919
994
|
<span class='ivar'>@token</span> <span class='op'>=</span> <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>result</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span>
|
920
|
-
<span class='const'>OpenStruct</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span><span class='rparen'>)</span>
|
995
|
+
<span class='const'><span class='object_link'><a href="OpenStruct.html" title="Zabbix::Api::OpenStruct (class)">OpenStruct</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span><span class='rparen'>)</span>
|
921
996
|
<span class='kw'>end</span></pre>
|
922
997
|
</td>
|
923
998
|
</tr>
|
@@ -950,15 +1025,15 @@
|
|
950
1025
|
<pre class="lines">
|
951
1026
|
|
952
1027
|
|
953
|
-
|
954
|
-
|
955
|
-
|
1028
|
+
150
|
1029
|
+
151
|
1030
|
+
152</pre>
|
956
1031
|
</td>
|
957
1032
|
<td>
|
958
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
1033
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 150</span>
|
959
1034
|
|
960
1035
|
<span class='kw'>def</span> <span class='id identifier rubyid_logout'>logout</span>
|
961
|
-
<span class='const'>OpenStruct</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='label'>method:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>user.logout</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>params:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>auth:</span> <span class='ivar'>@token</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span><span class='rparen'>)</span>
|
1036
|
+
<span class='const'><span class='object_link'><a href="OpenStruct.html" title="Zabbix::Api::OpenStruct (class)">OpenStruct</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='label'>method:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>user.logout</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>params:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>auth:</span> <span class='ivar'>@token</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span><span class='rparen'>)</span>
|
962
1037
|
<span class='kw'>end</span></pre>
|
963
1038
|
</td>
|
964
1039
|
</tr>
|
@@ -991,15 +1066,15 @@
|
|
991
1066
|
<pre class="lines">
|
992
1067
|
|
993
1068
|
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1069
|
+
129
|
1070
|
+
130
|
1071
|
+
131
|
1072
|
+
132
|
1073
|
+
133
|
1074
|
+
134</pre>
|
1000
1075
|
</td>
|
1001
1076
|
<td>
|
1002
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
1077
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 129</span>
|
1003
1078
|
|
1004
1079
|
<span class='kw'>def</span> <span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
1005
1080
|
<span class='id identifier rubyid_args'>args</span><span class='lbracket'>[</span><span class='symbol'>:params</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='kw'>not</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='symbol'>:params</span><span class='rparen'>)</span> <span class='kw'>or</span> <span class='id identifier rubyid_args'>args</span><span class='lbracket'>[</span><span class='symbol'>:params</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
@@ -1017,7 +1092,7 @@
|
|
1017
1092
|
</div>
|
1018
1093
|
|
1019
1094
|
<div id="footer">
|
1020
|
-
Generated on
|
1095
|
+
Generated on Sun Sep 19 10:15:06 2021 by
|
1021
1096
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1022
1097
|
0.9.26 (ruby-2.7.4).
|
1023
1098
|
</div>
|