zabbix-api-simple 0.1.4 → 0.1.5

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: 83cbdecabffb3046fa59ff7ea1a9efb65142a16ca9da0f137f26b9397b0ead51
4
- data.tar.gz: '05248676c6c183f45d84dcddc96a77b8f648e9e8ee7cb72cf8a25857fa65f5a5'
3
+ metadata.gz: 29edc33eb38ffc5637044d089db8de87c61188c9b939610f35fa17371cd68e54
4
+ data.tar.gz: 8695fad3a891752d7baae725742f816614e11259cc30977c1278db86c4598299
5
5
  SHA512:
6
- metadata.gz: b4eb92bcf16a9417ebe88ce91c84fea41855993d2f4e4f6b3b6df5f9a1783c7fb4c9260fe877d94f31eacdfe857a6f7c95294725d479b7ea1806f109432bb49e
7
- data.tar.gz: 344de35efbf3c28ed1bbcb7e0ed7724709bec88233edb260ba617f4c3b2575bf7366a4c239f3e7a2c4c0c57a1fd284b3486dfb9ea49b4a93d593d3a9d0c5d81f
6
+ metadata.gz: 43e8c89766180de14705412c8c4983fe941d26782d05ccca9b215d7511e093f82ea0f16416e4025db9165cc40bd418d218f0e17882fbcdf0d03dd6e907a97b84
7
+ data.tar.gz: 78b1efab5a179280b9372758e70d9d0a040dbbb746c39b2e28b2c65d1069d16273ef47da075fbcf37d67cb4136c320058be621ec5e0f123c1ef3c5e989a4ce46
data/CHANGELOG.md CHANGED
@@ -1,2 +1,9 @@
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
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
- binding.pry
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
@@ -4,6 +4,7 @@ module Zabbix
4
4
  require 'faraday'
5
5
  require 'json'
6
6
  require 'set'
7
+ require 'amazing_print'
7
8
  require 'pry'
8
9
 
9
10
  module FaradayMiddleware
@@ -26,7 +27,11 @@ module Zabbix
26
27
  end
27
28
 
28
29
  def on_complete(env)
29
- env[:response_body] = JSON.parse(env[:response_body])
30
+ begin
31
+ env[:response_body] = JSON.parse(env[:response_body])
32
+ rescue JSON::ParserError => e
33
+ env[:response_body] = {error: e,note: 'Check api web configuration (e.g. url, PHP memory, etc)'}
34
+ end
30
35
  end
31
36
 
32
37
  end
@@ -36,6 +41,41 @@ module Zabbix
36
41
  end # module FaradayMiddleware
37
42
 
38
43
 
44
+
45
+ ##
46
+ # Subclass of OpenStruct adds some niceties for REPL etc
47
+ #
48
+ class OpenStruct < OpenStruct
49
+
50
+ ##
51
+ # If true, inspect returns awesome_inspect instead of default
52
+ @@prettymode = false
53
+
54
+ class << self
55
+ ##
56
+ # returns current value of prettymode
57
+ #
58
+ def prettymode
59
+ @@prettymode
60
+ end
61
+ ##
62
+ # sets prettymod to aBool
63
+ #
64
+ def prettymode=(aBool)
65
+ @@prettymode = aBool
66
+ end
67
+ end
68
+
69
+ def inspect
70
+ if @@prettymode
71
+ awesome_inspect
72
+ else
73
+ super
74
+ end
75
+ end
76
+
77
+ end
78
+
39
79
  ##
40
80
  # Each instance of this class acts as a connection Zabbix's API
41
81
  class Client
@@ -120,7 +160,12 @@ module Zabbix
120
160
  # results are returned as instances of OpenStruct. If you need this to be
121
161
  # a hash just do to_h to the returned object.
122
162
  def call(name, *args, &block)
163
+ res = nil
164
+ if name == 'apiinfo.version'
165
+ res = post(method: "#{name}", params: args.first, id: '1').body
166
+ else
123
167
  res = post(method: "#{name}", params: args.first, id: '1', auth: @token).body
168
+ end
124
169
  raise res['error'].awesome_inspect(plain: true) if res.has_key?('error')
125
170
  if res.has_key?('result') and res['result'].class == Array
126
171
  res = res['result'].collect{|each| OpenStruct.new(each)}
@@ -130,6 +175,14 @@ module Zabbix
130
175
  return res
131
176
  end
132
177
 
178
+ ##
179
+ # just handy if you're doing a REPL (e.g. zapishell.rb) Returns
180
+ # list of zabbix objects the api currently is aware of
181
+ #
182
+ def known_objects
183
+ @@zabbix_objects
184
+ end
185
+
133
186
 
134
187
  ##
135
188
  # this override of method_missing is the trick that lets zabbix-api-simple
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Zabbix
4
4
  module Api
5
- VERSION = "0.1.4"
5
+ VERSION = "0.1.5"
6
6
  end
7
7
  end
data/lib/zabbix/api.rb CHANGED
@@ -3,9 +3,3 @@
3
3
  require_relative "api/version"
4
4
  require_relative "api/client"
5
5
 
6
- module Zabbix
7
- module Api
8
- class Error < StandardError; end
9
- # Your code goes here...
10
- end
11
- end
@@ -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> &#x21d2; 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&#39;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
- 75
494
- 76
495
- 77
496
- 78
497
- 79
498
- 80
499
- 81
500
- 82
501
- 83
502
- 84</pre>
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 75</span>
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
- 143
559
- 144
560
- 145
561
- 146
562
- 147
563
- 148
564
- 149
565
- 150
566
- 151
567
- 152
568
- 153
569
- 154
570
- 155
571
- 156</pre>
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 143</span>
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'>&amp;</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
- 44
629
- 45
630
- 46</pre>
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 44</span>
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
- 67
677
- 68
678
- 69</pre>
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 67</span>
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
- 67
720
- 68
721
- 69</pre>
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 67</span>
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
- 68
763
- 69
764
- 70</pre>
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 68</span>
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
- 122
813
- 123
814
- 124
815
- 125
816
- 126
817
- 127
818
- 128
819
- 129
820
- 130
821
- 131</pre>
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 122</span>
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'>&amp;</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'>&#39;</span><span class='tstring_content'>apiinfo.version</span><span class='tstring_end'>&#39;</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'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</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'>&#39;</span><span class='tstring_content'>1</span><span class='tstring_end'>&#39;</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'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</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'>&#39;</span><span class='tstring_content'>1</span><span class='tstring_end'>&#39;</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'>&#39;</span><span class='tstring_content'>error</span><span class='tstring_end'>&#39;</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'>&#39;</span><span class='tstring_content'>error</span><span class='tstring_end'>&#39;</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'>&#39;</span><span class='tstring_content'>result</span><span class='tstring_end'>&#39;</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'>&#39;</span><span class='tstring_content'>result</span><span class='tstring_end'>&#39;</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'>&#39;</span><span class='tstring_content'>result</span><span class='tstring_end'>&#39;</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'>&#39;</span><span class='tstring_content'>result</span><span class='tstring_end'>&#39;</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> &#x21d2; <tt>Object</tt>
879
+
880
+
881
+
882
+
883
+
884
+ </h3><div class="docstring">
885
+ <div class="discussion">
886
+
887
+ <p>just handy if you&#39;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
- 160
868
- 161
869
- 162</pre>
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 160</span>
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
- 99
909
- 100
910
- 101
911
- 102
912
- 103</pre>
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 99</span>
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'>&#39;</span><span class='tstring_content'>user.login</span><span class='tstring_end'>&#39;</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'>&#39;</span><span class='tstring_content'>result</span><span class='tstring_end'>&#39;</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
- 110
954
- 111
955
- 112</pre>
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 110</span>
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'>&#39;</span><span class='tstring_content'>user.logout</span><span class='tstring_end'>&#39;</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'>&#39;</span><span class='tstring_content'>user.logout</span><span class='tstring_end'>&#39;</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
- 89
995
- 90
996
- 91
997
- 92
998
- 93
999
- 94</pre>
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 89</span>
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 Sat Sep 11 20:08:37 2021 by
1095
+ Generated on Sat Sep 18 20:44:22 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>
@@ -230,13 +230,13 @@
230
230
  <pre class="lines">
231
231
 
232
232
 
233
- 17
234
233
  18
235
234
  19
236
- 20</pre>
235
+ 20
236
+ 21</pre>
237
237
  </td>
238
238
  <td>
239
- <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 17</span>
239
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 18</span>
240
240
 
241
241
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_app'>app</span><span class='rparen'>)</span>
242
242
  <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_app'>app</span><span class='rparen'>)</span>
@@ -269,15 +269,23 @@
269
269
  <pre class="lines">
270
270
 
271
271
 
272
- 28
273
272
  29
274
- 30</pre>
273
+ 30
274
+ 31
275
+ 32
276
+ 33
277
+ 34
278
+ 35</pre>
275
279
  </td>
276
280
  <td>
277
- <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 28</span>
281
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 29</span>
278
282
 
279
283
  <span class='kw'>def</span> <span class='id identifier rubyid_on_complete'>on_complete</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
280
- <span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='symbol'>:response_body</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='symbol'>:response_body</span><span class='rbracket'>]</span><span class='rparen'>)</span>
284
+ <span class='kw'>begin</span>
285
+ <span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='symbol'>:response_body</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='symbol'>:response_body</span><span class='rbracket'>]</span><span class='rparen'>)</span>
286
+ <span class='kw'>rescue</span> <span class='const'>JSON</span><span class='op'>::</span><span class='const'>ParserError</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
287
+ <span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='symbol'>:response_body</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='label'>error:</span> <span class='id identifier rubyid_e'>e</span><span class='comma'>,</span><span class='label'>note:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Check api web configuration (e.g. url, PHP memory, etc)</span><span class='tstring_end'>&#39;</span></span><span class='rbrace'>}</span>
288
+ <span class='kw'>end</span>
281
289
  <span class='kw'>end</span></pre>
282
290
  </td>
283
291
  </tr>
@@ -299,14 +307,14 @@
299
307
  <pre class="lines">
300
308
 
301
309
 
302
- 22
303
310
  23
304
311
  24
305
312
  25
306
- 26</pre>
313
+ 26
314
+ 27</pre>
307
315
  </td>
308
316
  <td>
309
- <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 22</span>
317
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 23</span>
310
318
 
311
319
  <span class='kw'>def</span> <span class='id identifier rubyid_on_request'>on_request</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
312
320
  <span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='symbol'>:request_body</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:jsonrpc</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2.0</span><span class='tstring_end'>&quot;</span></span>
@@ -323,7 +331,7 @@
323
331
  </div>
324
332
 
325
333
  <div id="footer">
326
- Generated on Sat Sep 11 20:08:37 2021 by
334
+ Generated on Sat Sep 18 20:44:22 2021 by
327
335
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
328
336
  0.9.26 (ruby-2.7.4).
329
337
  </div>
@@ -105,7 +105,7 @@
105
105
  </div>
106
106
 
107
107
  <div id="footer">
108
- Generated on Sat Sep 11 20:08:37 2021 by
108
+ Generated on Sat Sep 18 20:44:22 2021 by
109
109
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
110
110
  0.9.26 (ruby-2.7.4).
111
111
  </div>