zabbix-api-simple 0.1.3 → 0.1.4

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: 35647dac01d85faed96daeacd718c183ffb90ee374f97e93a1b8108408def350
4
- data.tar.gz: 6ad7fc1f2fa168f35fce665da63d156a163e81705c42a33059081b96adb72e15
3
+ metadata.gz: 83cbdecabffb3046fa59ff7ea1a9efb65142a16ca9da0f137f26b9397b0ead51
4
+ data.tar.gz: '05248676c6c183f45d84dcddc96a77b8f648e9e8ee7cb72cf8a25857fa65f5a5'
5
5
  SHA512:
6
- metadata.gz: 187014b38f74a272f2f90a7fae4dfe2a17bb772f842a2f12001bfca4eba135e0f4edebfa5f361a3e131361597d1181f7cee402e09bb525f6ea038fc52e6f816b
7
- data.tar.gz: 94a0eae1c0d62056128f6c2a55eee1418c5e516ff475fda580a941a8ba9c0e0a5da4402db3eb6c1cc0f365d1782305765ed666749d81328b968bc0d636353f54
6
+ metadata.gz: b4eb92bcf16a9417ebe88ce91c84fea41855993d2f4e4f6b3b6df5f9a1783c7fb4c9260fe877d94f31eacdfe857a6f7c95294725d479b7ea1806f109432bb49e
7
+ data.tar.gz: 344de35efbf3c28ed1bbcb7e0ed7724709bec88233edb260ba617f4c3b2575bf7366a4c239f3e7a2c4c0c57a1fd284b3486dfb9ea49b4a93d593d3a9d0c5d81f
data/.gitignore CHANGED
@@ -1,7 +1,7 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
3
  /_yardoc/
4
- /Gemfile.lock/
4
+ Gemfile.lock
5
5
  /coverage/
6
6
  /doc/
7
7
  /pkg/
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,12 @@
1
+ image: alpine:latest
2
+
3
+ pages:
4
+ stage: deploy
5
+ script:
6
+ - echo 'Nothing to do...'
7
+ artifacts:
8
+ paths:
9
+ - public
10
+ expire_in: never
11
+ only:
12
+ - master
data/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ # 0.1.4
2
+ - Just doc changes
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ gemspec
8
8
  group :development do
9
9
  gem 'irb'
10
10
  gem 'pry'
11
+ gem 'yard'
11
12
  end
12
13
 
13
14
  gem "rake", "~> 13.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 David Parker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Zabbix::Api
1
+ # Zabbix::Api [![Gem Version](https://badge.fury.io/rb/zabbix-api-simple.svg)](https://badge.fury.io/rb/zabbix-api-simple)
2
2
 
3
3
  This zabbix api implementation for Ruby strives for three things:
4
4
 
@@ -8,7 +8,11 @@ This zabbix api implementation for Ruby strives for three things:
8
8
 
9
9
  It accomplishes these goals primarily by deferring (via Faraday) to the Zabbix API itself for just about everything - it does not attempt to re-create or otherwise "fancy-up" the API. The reasoning behind this is that the zabbix api itself is complex enough, and the Zabbix project can alter the specifics of the api at any time. This library just provides Ruby semantics that closely follow the API specification. The advantage to you is that you do not need to wrap your head around two APIs (the Zabbix API proper, and the API library's API)
10
10
 
11
- **NOTE:** This thing is brand new, and it works for me. I'm certain I'm far from done adding stuff to it, but as it is at this moment it's good enough for me. While I doubt it, there may be breaking changes going forward, so just "buyer beware". I'll remove this note once I feel it's more or less stable.
11
+ **Detailed documentation for this library is [>>HERE<<](https://svdasein.gitlab.io/zabbix-api)**
12
+
13
+ **Source repository is [>>HERE<<](https://gitlab.com/svdasein/zabbix-api)**
14
+
15
+ If you need to send data into Zabbix via the "Zabbix trapper" protocol, you might also be interested in [zabbix_sender_api](https://svdasein.gitlab.io/zabbix_sender_api)
12
16
 
13
17
  ## Installation
14
18
 
data/Rakefile CHANGED
@@ -1,4 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
- task default: %i[]
4
+ desc "Generate yard docs in public"
5
+ task :gendocs do
6
+ puts %x(yard -o public --files CHANGELOG.md,LICENSE.txt)
7
+ puts %x(git add public/*)
8
+ end
9
+ desc "Generate docs and run :build"
10
+ task :buildall => [ :gendocs, :build ]
11
+ task default: :buildall
@@ -8,6 +8,10 @@ module Zabbix
8
8
 
9
9
  module FaradayMiddleware
10
10
 
11
+ ##
12
+ # this middleware adapter does zabbix api essential things
13
+ # at the REST level, and hendles serializing/de-serializing
14
+ # ruby objects.
11
15
  class ZabbixApiRequest < Faraday::Middleware
12
16
 
13
17
  def initialize(app)
@@ -32,8 +36,8 @@ module Zabbix
32
36
  end # module FaradayMiddleware
33
37
 
34
38
 
35
-
36
-
39
+ ##
40
+ # Each instance of this class acts as a connection Zabbix's API
37
41
  class Client
38
42
 
39
43
  class << self
@@ -43,6 +47,11 @@ module Zabbix
43
47
 
44
48
  @@apiurl = 'api_jsonrpc.php'
45
49
 
50
+ ##
51
+ # This is a list (as of zabbix 5.0) of top-level zabbix API calls
52
+ # that the client will understand via method_missing. If they
53
+ # add new things to the api they need to be added here as well
54
+ # *if* you intend on using the method_missing syntax.
46
55
  @@zabbix_objects = [:action,:alert,:apiinfo,:application,:configuration,
47
56
  :correlation,:dashboard,:dhost,:dservice,:dcheck,
48
57
  :drule,:event,:graph,:graphitem,:graphprototype,
@@ -59,6 +68,10 @@ module Zabbix
59
68
  attr_accessor :zabobject
60
69
 
61
70
 
71
+ ##
72
+ # :url is required. You do not need to add 'api_jsonrpc.php' - this will
73
+ # happen automagically. You can alter request timeout if needed by passing
74
+ # :timeout - the default is 60 secs
62
75
  def initialize(url: nil,timeout: 60)
63
76
  @conn = Faraday.new(
64
77
  url: url,
@@ -70,6 +83,9 @@ module Zabbix
70
83
  @zabobject = nil
71
84
  end
72
85
 
86
+ ##
87
+ # This method posts a list of params to @conn/@@apiurl. You likely won't
88
+ # have need to call this directly.
73
89
  def post(args)
74
90
  args[:params] = [] if not args.has_key?(:params) or args[:params].nil?
75
91
  last = @conn.post(@@apiurl, args)
@@ -77,16 +93,32 @@ module Zabbix
77
93
  return last
78
94
  end
79
95
 
96
+ ##
97
+ # both :user and :pass are required. This method calls user.logic
98
+ # abd stores the returned auth token for future calls to the api
80
99
  def login(user: nil,pass: nil)
81
100
  res =post(method: 'user.login', params: {user: user, password:pass}, auth:nil)
82
101
  @token = res.body['result']
83
102
  OpenStruct.new(res.body)
84
103
  end
85
104
 
105
+ ##
106
+ # calls user.logout for the @token session. You really should pay
107
+ # attention to ensuring that this gets called, else you'll find over time
108
+ # that your sessions table is getting quite large and will start slowing
109
+ # down lots of stuff in zabbix.
86
110
  def logout
87
111
  OpenStruct.new(post(method: 'user.logout', params: [], auth: @token).body)
88
112
  end
89
113
 
114
+ ##
115
+ # this is the method that method_missing calls to peform the actual work.
116
+ # The first parameter is the top-level api call (e.g. those listed in
117
+ # @@zabbix_objects. Args is a hash containing the particulars for the call.
118
+ # You can call this directly if you don't want to rely on method_missing.
119
+ #
120
+ # results are returned as instances of OpenStruct. If you need this to be
121
+ # a hash just do to_h to the returned object.
90
122
  def call(name, *args, &block)
91
123
  res = post(method: "#{name}", params: args.first, id: '1', auth: @token).body
92
124
  raise res['error'].awesome_inspect(plain: true) if res.has_key?('error')
@@ -99,6 +131,15 @@ module Zabbix
99
131
  end
100
132
 
101
133
 
134
+ ##
135
+ # this override of method_missing is the trick that lets zabbix-api-simple
136
+ # look quite a lot like the zabbix api documentation. If it finds that the
137
+ # method name you were trying to call is in @@zabbix_objects, then it constructs
138
+ # a call to that top level api entity using the parameters as arguments to the call.
139
+ #
140
+ # this is really just here as syntactical sugar - you don't *have* to use it, but
141
+ # if you do you'll find that you need do essentially zero mental translation between
142
+ # the zabbix api documentation and your code.
102
143
  def method_missing(name, *args, &block)
103
144
  if @@zabbix_objects.include?(name)
104
145
  # Clone self cuz we want to be thread safe/recursable. This will pop off the
@@ -114,6 +155,8 @@ module Zabbix
114
155
  end
115
156
  end
116
157
 
158
+ ##
159
+ # returns the last response the client got from the server
117
160
  def last
118
161
  Client.last
119
162
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Zabbix
4
4
  module Api
5
- VERSION = "0.1.3"
5
+ VERSION = "0.1.4"
6
6
  end
7
7
  end
@@ -0,0 +1,1027 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: Zabbix::Api::Client
8
+
9
+ &mdash; Documentation by YARD 0.9.26
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "Zabbix::Api::Client";
19
+ relpath = '../../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../../_index.html">Index (C)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../Zabbix.html" title="Zabbix (module)">Zabbix</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Api.html" title="Zabbix::Api (module)">Api</a></span></span>
41
+ &raquo;
42
+ <span class="title">Client</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: Zabbix::Api::Client
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">Zabbix::Api::Client</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>lib/zabbix/api/client.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+
105
+ <p>Each instance of this class acts as a connection Zabbix&#39;s API</p>
106
+
107
+
108
+ </div>
109
+ </div>
110
+ <div class="tags">
111
+
112
+
113
+ </div>
114
+
115
+ <h2>
116
+ Constant Summary
117
+ <small><a href="#" class="constants_summary_toggle">collapse</a></small>
118
+ </h2>
119
+
120
+ <dl class="constants">
121
+
122
+ <dt id="apiurl-classvariable" class="">@@apiurl =
123
+
124
+ </dt>
125
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>api_jsonrpc.php</span><span class='tstring_end'>&#39;</span></span></pre></dd>
126
+
127
+ <dt id="zabbix_objects-classvariable" class="">@@zabbix_objects =
128
+ <div class="docstring">
129
+ <div class="discussion">
130
+
131
+ <p>This is a list (as of zabbix 5.0) of top-level zabbix API calls that the client will understand via method_missing. If they add new things to the api they need to be added here as well <strong>if</strong> you intend on using the method_missing syntax.</p>
132
+
133
+
134
+ </div>
135
+ </div>
136
+ <div class="tags">
137
+
138
+
139
+ </div>
140
+ </dt>
141
+ <dd><pre class="code"><span class='lbracket'>[</span><span class='symbol'>:action</span><span class='comma'>,</span><span class='symbol'>:alert</span><span class='comma'>,</span><span class='symbol'>:apiinfo</span><span class='comma'>,</span><span class='symbol'>:application</span><span class='comma'>,</span><span class='symbol'>:configuration</span><span class='comma'>,</span>
142
+ <span class='symbol'>:correlation</span><span class='comma'>,</span><span class='symbol'>:dashboard</span><span class='comma'>,</span><span class='symbol'>:dhost</span><span class='comma'>,</span><span class='symbol'>:dservice</span><span class='comma'>,</span><span class='symbol'>:dcheck</span><span class='comma'>,</span>
143
+ <span class='symbol'>:drule</span><span class='comma'>,</span><span class='symbol'>:event</span><span class='comma'>,</span><span class='symbol'>:graph</span><span class='comma'>,</span><span class='symbol'>:graphitem</span><span class='comma'>,</span><span class='symbol'>:graphprototype</span><span class='comma'>,</span>
144
+ <span class='symbol'>:history</span><span class='comma'>,</span><span class='symbol'>:host</span><span class='comma'>,</span><span class='symbol'>:hostgroup</span><span class='comma'>,</span><span class='symbol'>:hostinterface</span><span class='comma'>,</span>
145
+ <span class='symbol'>:hostprototype</span><span class='comma'>,</span><span class='symbol'>:iconmap</span><span class='comma'>,</span><span class='symbol'>:image</span><span class='comma'>,</span><span class='symbol'>:item</span><span class='comma'>,</span><span class='symbol'>:itemprototype</span><span class='comma'>,</span>
146
+ <span class='symbol'>:discoveryrule</span><span class='comma'>,</span><span class='symbol'>:maintenance</span><span class='comma'>,</span><span class='symbol'>:map</span><span class='comma'>,</span><span class='symbol'>:mediatype</span><span class='comma'>,</span><span class='symbol'>:problem</span><span class='comma'>,</span>
147
+ <span class='symbol'>:proxy</span><span class='comma'>,</span><span class='symbol'>:screen</span><span class='comma'>,</span><span class='symbol'>:screenitem</span><span class='comma'>,</span><span class='symbol'>:script</span><span class='comma'>,</span><span class='symbol'>:service</span><span class='comma'>,</span><span class='symbol'>:task</span><span class='comma'>,</span>
148
+ <span class='symbol'>:template</span><span class='comma'>,</span><span class='symbol'>:templatescreen</span><span class='comma'>,</span><span class='symbol'>:templatescreenitem</span><span class='comma'>,</span>
149
+ <span class='symbol'>:trend</span><span class='comma'>,</span><span class='symbol'>:trigger</span><span class='comma'>,</span><span class='symbol'>:triggerprototype</span><span class='comma'>,</span><span class='symbol'>:user</span><span class='comma'>,</span><span class='symbol'>:usergroup</span><span class='comma'>,</span>
150
+ <span class='symbol'>:usermacro</span><span class='comma'>,</span><span class='symbol'>:valuemap</span><span class='comma'>,</span><span class='symbol'>:httptest</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_set'>to_set</span></pre></dd>
151
+
152
+ </dl>
153
+
154
+
155
+
156
+
157
+
158
+ <h2>Class Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
159
+ <ul class="summary">
160
+
161
+ <li class="public ">
162
+ <span class="summary_signature">
163
+
164
+ <a href="#last-class_method" title="last (class method)">.<strong>last</strong> &#x21d2; Object </a>
165
+
166
+
167
+
168
+ </span>
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+ <span class="summary_desc"><div class='inline'>
182
+ <p>Returns the value of attribute last.</p>
183
+ </div></span>
184
+
185
+ </li>
186
+
187
+
188
+ </ul>
189
+
190
+ <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
191
+ <ul class="summary">
192
+
193
+ <li class="public ">
194
+ <span class="summary_signature">
195
+
196
+ <a href="#conn-instance_method" title="#conn (instance method)">#<strong>conn</strong> &#x21d2; Object </a>
197
+
198
+
199
+
200
+ </span>
201
+
202
+
203
+
204
+
205
+ <span class="note title readonly">readonly</span>
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+
215
+ <span class="summary_desc"><div class='inline'>
216
+ <p>Returns the value of attribute conn.</p>
217
+ </div></span>
218
+
219
+ </li>
220
+
221
+
222
+ <li class="public ">
223
+ <span class="summary_signature">
224
+
225
+ <a href="#token-instance_method" title="#token (instance method)">#<strong>token</strong> &#x21d2; Object </a>
226
+
227
+
228
+
229
+ </span>
230
+
231
+
232
+
233
+
234
+ <span class="note title readonly">readonly</span>
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+ <span class="summary_desc"><div class='inline'>
245
+ <p>Returns the value of attribute token.</p>
246
+ </div></span>
247
+
248
+ </li>
249
+
250
+
251
+ <li class="public ">
252
+ <span class="summary_signature">
253
+
254
+ <a href="#zabobject-instance_method" title="#zabobject (instance method)">#<strong>zabobject</strong> &#x21d2; Object </a>
255
+
256
+
257
+
258
+ </span>
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+ <span class="summary_desc"><div class='inline'>
272
+ <p>Returns the value of attribute zabobject.</p>
273
+ </div></span>
274
+
275
+ </li>
276
+
277
+
278
+ </ul>
279
+
280
+
281
+
282
+
283
+
284
+ <h2>
285
+ Instance Method Summary
286
+ <small><a href="#" class="summary_toggle">collapse</a></small>
287
+ </h2>
288
+
289
+ <ul class="summary">
290
+
291
+ <li class="public ">
292
+ <span class="summary_signature">
293
+
294
+ <a href="#call-instance_method" title="#call (instance method)">#<strong>call</strong>(name, *args, &amp;block) &#x21d2; Object </a>
295
+
296
+
297
+
298
+ </span>
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+ <span class="summary_desc"><div class='inline'>
309
+ <p>this is the method that method_missing calls to peform the actual work.</p>
310
+ </div></span>
311
+
312
+ </li>
313
+
314
+
315
+ <li class="public ">
316
+ <span class="summary_signature">
317
+
318
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(url: nil, timeout: 60) &#x21d2; Client </a>
319
+
320
+
321
+
322
+ </span>
323
+
324
+
325
+ <span class="note title constructor">constructor</span>
326
+
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+ <span class="summary_desc"><div class='inline'>
335
+ <p>:url is required.</p>
336
+ </div></span>
337
+
338
+ </li>
339
+
340
+
341
+ <li class="public ">
342
+ <span class="summary_signature">
343
+
344
+ <a href="#last-instance_method" title="#last (instance method)">#<strong>last</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>returns the last response the client got from the server.</p>
360
+ </div></span>
361
+
362
+ </li>
363
+
364
+
365
+ <li class="public ">
366
+ <span class="summary_signature">
367
+
368
+ <a href="#login-instance_method" title="#login (instance method)">#<strong>login</strong>(user: nil, pass: nil) &#x21d2; Object </a>
369
+
370
+
371
+
372
+ </span>
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+ <span class="summary_desc"><div class='inline'>
383
+ <p>both :user and :pass are required.</p>
384
+ </div></span>
385
+
386
+ </li>
387
+
388
+
389
+ <li class="public ">
390
+ <span class="summary_signature">
391
+
392
+ <a href="#logout-instance_method" title="#logout (instance method)">#<strong>logout</strong> &#x21d2; Object </a>
393
+
394
+
395
+
396
+ </span>
397
+
398
+
399
+
400
+
401
+
402
+
403
+
404
+
405
+
406
+ <span class="summary_desc"><div class='inline'>
407
+ <p>calls user.logout for the @token session.</p>
408
+ </div></span>
409
+
410
+ </li>
411
+
412
+
413
+ <li class="public ">
414
+ <span class="summary_signature">
415
+
416
+ <a href="#method_missing-instance_method" title="#method_missing (instance method)">#<strong>method_missing</strong>(name, *args, &amp;block) &#x21d2; Object </a>
417
+
418
+
419
+
420
+ </span>
421
+
422
+
423
+
424
+
425
+
426
+
427
+
428
+
429
+
430
+ <span class="summary_desc"><div class='inline'>
431
+ <p>this override of method_missing is the trick that lets zabbix-api-simple look quite a lot like the zabbix api documentation.</p>
432
+ </div></span>
433
+
434
+ </li>
435
+
436
+
437
+ <li class="public ">
438
+ <span class="summary_signature">
439
+
440
+ <a href="#post-instance_method" title="#post (instance method)">#<strong>post</strong>(args) &#x21d2; Object </a>
441
+
442
+
443
+
444
+ </span>
445
+
446
+
447
+
448
+
449
+
450
+
451
+
452
+
453
+
454
+ <span class="summary_desc"><div class='inline'>
455
+ <p>This method posts a list of params to @conn/@@apiurl.</p>
456
+ </div></span>
457
+
458
+ </li>
459
+
460
+
461
+ </ul>
462
+
463
+
464
+ <div id="constructor_details" class="method_details_list">
465
+ <h2>Constructor Details</h2>
466
+
467
+ <div class="method_details first">
468
+ <h3 class="signature first" id="initialize-instance_method">
469
+
470
+ #<strong>initialize</strong>(url: nil, timeout: 60) &#x21d2; <tt><span class='object_link'><a href="" title="Zabbix::Api::Client (class)">Client</a></span></tt>
471
+
472
+
473
+
474
+
475
+
476
+ </h3><div class="docstring">
477
+ <div class="discussion">
478
+
479
+ <p>:url is required. You do not need to add &#39;api_jsonrpc.php&#39; - this will happen automagically. You can alter request timeout if needed by passing :timeout - the default is 60 secs</p>
480
+
481
+
482
+ </div>
483
+ </div>
484
+ <div class="tags">
485
+
486
+
487
+ </div><table class="source_code">
488
+ <tr>
489
+ <td>
490
+ <pre class="lines">
491
+
492
+
493
+ 75
494
+ 76
495
+ 77
496
+ 78
497
+ 79
498
+ 80
499
+ 81
500
+ 82
501
+ 83
502
+ 84</pre>
503
+ </td>
504
+ <td>
505
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 75</span>
506
+
507
+ <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
+ <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>
509
+ <span class='label'>url:</span> <span class='id identifier rubyid_url'>url</span><span class='comma'>,</span>
510
+ <span class='label'>headers:</span> <span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Content-Type</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>application/json-rpc</span><span class='tstring_end'>&#39;</span></span><span class='rbrace'>}</span><span class='comma'>,</span>
511
+ <span class='label'>request:</span> <span class='lbrace'>{</span> <span class='label'>timeout:</span> <span class='id identifier rubyid_timeout'>timeout</span> <span class='rbrace'>}</span>
512
+ <span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_conn'>conn</span><span class='op'>|</span>
513
+ <span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_request'>request</span> <span class='symbol'>:zabbix_api_request</span>
514
+ <span class='kw'>end</span>
515
+ <span class='ivar'>@zabobject</span> <span class='op'>=</span> <span class='kw'>nil</span>
516
+ <span class='kw'>end</span></pre>
517
+ </td>
518
+ </tr>
519
+ </table>
520
+ </div>
521
+
522
+ </div>
523
+ <div id="method_missing_details" class="method_details_list">
524
+ <h2>Dynamic Method Handling</h2>
525
+ <p class="notice this">
526
+ This class handles dynamic methods through the <tt>method_missing</tt> method
527
+
528
+ </p>
529
+
530
+ <div class="method_details first">
531
+ <h3 class="signature first" id="method_missing-instance_method">
532
+
533
+ #<strong>method_missing</strong>(name, *args, &amp;block) &#x21d2; <tt>Object</tt>
534
+
535
+
536
+
537
+
538
+
539
+ </h3><div class="docstring">
540
+ <div class="discussion">
541
+
542
+ <p>this override of method_missing is the trick that lets zabbix-api-simple look quite a lot like the zabbix api documentation. If it finds that the method name you were trying to call is in @@zabbix_objects, then it constructs a call to that top level api entity using the parameters as arguments to the call.</p>
543
+
544
+ <p>this is really just here as syntactical sugar - you don&#39;t <strong>have</strong> to use it, but if you do you&#39;ll find that you need do essentially zero mental translation between the zabbix api documentation and your code.</p>
545
+
546
+
547
+ </div>
548
+ </div>
549
+ <div class="tags">
550
+
551
+
552
+ </div><table class="source_code">
553
+ <tr>
554
+ <td>
555
+ <pre class="lines">
556
+
557
+
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>
572
+ </td>
573
+ <td>
574
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 143</span>
575
+
576
+ <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
+ <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>
578
+ <span class='comment'># Clone self cuz we want to be thread safe/recursable. This will pop off the
579
+ </span> <span class='comment'># stack after it&#39;s no longer referenced (and @zabobject will never change in the
580
+ </span> <span class='comment'># original client instance)
581
+ </span> <span class='id identifier rubyid_newcli'>newcli</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_clone'>clone</span>
582
+ <span class='id identifier rubyid_newcli'>newcli</span><span class='period'>.</span><span class='id identifier rubyid_zabobject'>zabobject</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span>
583
+ <span class='kw'>return</span> <span class='id identifier rubyid_newcli'>newcli</span>
584
+ <span class='kw'>elsif</span> <span class='ivar'>@zabobject</span>
585
+ <span class='kw'>return</span> <span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='ivar'>@zabobject</span><span class='embexpr_end'>}</span><span class='tstring_content'>.</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='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='rparen'>)</span>
586
+ <span class='kw'>else</span>
587
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Unknown zabbix object given: </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>
588
+ <span class='kw'>end</span>
589
+ <span class='kw'>end</span></pre>
590
+ </td>
591
+ </tr>
592
+ </table>
593
+ </div>
594
+
595
+ </div>
596
+
597
+ <div id="class_attr_details" class="attr_details">
598
+ <h2>Class Attribute Details</h2>
599
+
600
+
601
+ <span id="last=-class_method"></span>
602
+ <div class="method_details first">
603
+ <h3 class="signature first" id="last-class_method">
604
+
605
+ .<strong>last</strong> &#x21d2; <tt>Object</tt>
606
+
607
+
608
+
609
+
610
+
611
+ </h3><div class="docstring">
612
+ <div class="discussion">
613
+
614
+ <p>Returns the value of attribute last.</p>
615
+
616
+
617
+ </div>
618
+ </div>
619
+ <div class="tags">
620
+
621
+
622
+ </div><table class="source_code">
623
+ <tr>
624
+ <td>
625
+ <pre class="lines">
626
+
627
+
628
+ 44
629
+ 45
630
+ 46</pre>
631
+ </td>
632
+ <td>
633
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 44</span>
634
+
635
+ <span class='kw'>def</span> <span class='id identifier rubyid_last'>last</span>
636
+ <span class='ivar'>@last</span>
637
+ <span class='kw'>end</span></pre>
638
+ </td>
639
+ </tr>
640
+ </table>
641
+ </div>
642
+
643
+ </div>
644
+
645
+ <div id="instance_attr_details" class="attr_details">
646
+ <h2>Instance Attribute Details</h2>
647
+
648
+
649
+ <span id=""></span>
650
+ <div class="method_details first">
651
+ <h3 class="signature first" id="conn-instance_method">
652
+
653
+ #<strong>conn</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
654
+
655
+
656
+
657
+
658
+
659
+ </h3><div class="docstring">
660
+ <div class="discussion">
661
+
662
+ <p>Returns the value of attribute conn.</p>
663
+
664
+
665
+ </div>
666
+ </div>
667
+ <div class="tags">
668
+
669
+
670
+ </div><table class="source_code">
671
+ <tr>
672
+ <td>
673
+ <pre class="lines">
674
+
675
+
676
+ 67
677
+ 68
678
+ 69</pre>
679
+ </td>
680
+ <td>
681
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 67</span>
682
+
683
+ <span class='kw'>def</span> <span class='id identifier rubyid_conn'>conn</span>
684
+ <span class='ivar'>@conn</span>
685
+ <span class='kw'>end</span></pre>
686
+ </td>
687
+ </tr>
688
+ </table>
689
+ </div>
690
+
691
+
692
+ <span id=""></span>
693
+ <div class="method_details ">
694
+ <h3 class="signature " id="token-instance_method">
695
+
696
+ #<strong>token</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
697
+
698
+
699
+
700
+
701
+
702
+ </h3><div class="docstring">
703
+ <div class="discussion">
704
+
705
+ <p>Returns the value of attribute token.</p>
706
+
707
+
708
+ </div>
709
+ </div>
710
+ <div class="tags">
711
+
712
+
713
+ </div><table class="source_code">
714
+ <tr>
715
+ <td>
716
+ <pre class="lines">
717
+
718
+
719
+ 67
720
+ 68
721
+ 69</pre>
722
+ </td>
723
+ <td>
724
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 67</span>
725
+
726
+ <span class='kw'>def</span> <span class='id identifier rubyid_token'>token</span>
727
+ <span class='ivar'>@token</span>
728
+ <span class='kw'>end</span></pre>
729
+ </td>
730
+ </tr>
731
+ </table>
732
+ </div>
733
+
734
+
735
+ <span id="zabobject=-instance_method"></span>
736
+ <div class="method_details ">
737
+ <h3 class="signature " id="zabobject-instance_method">
738
+
739
+ #<strong>zabobject</strong> &#x21d2; <tt>Object</tt>
740
+
741
+
742
+
743
+
744
+
745
+ </h3><div class="docstring">
746
+ <div class="discussion">
747
+
748
+ <p>Returns the value of attribute zabobject.</p>
749
+
750
+
751
+ </div>
752
+ </div>
753
+ <div class="tags">
754
+
755
+
756
+ </div><table class="source_code">
757
+ <tr>
758
+ <td>
759
+ <pre class="lines">
760
+
761
+
762
+ 68
763
+ 69
764
+ 70</pre>
765
+ </td>
766
+ <td>
767
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 68</span>
768
+
769
+ <span class='kw'>def</span> <span class='id identifier rubyid_zabobject'>zabobject</span>
770
+ <span class='ivar'>@zabobject</span>
771
+ <span class='kw'>end</span></pre>
772
+ </td>
773
+ </tr>
774
+ </table>
775
+ </div>
776
+
777
+ </div>
778
+
779
+
780
+ <div id="instance_method_details" class="method_details_list">
781
+ <h2>Instance Method Details</h2>
782
+
783
+
784
+ <div class="method_details first">
785
+ <h3 class="signature first" id="call-instance_method">
786
+
787
+ #<strong>call</strong>(name, *args, &amp;block) &#x21d2; <tt>Object</tt>
788
+
789
+
790
+
791
+
792
+
793
+ </h3><div class="docstring">
794
+ <div class="discussion">
795
+
796
+ <p>this is the method that method_missing calls to peform the actual work. The first parameter is the top-level api call (e.g. those listed in @@zabbix_objects. Args is a hash containing the particulars for the call. You can call this directly if you don&#39;t want to rely on method_missing.</p>
797
+
798
+ <p>results are returned as instances of OpenStruct. If you need this to be a hash just do to_h to the returned object.</p>
799
+
800
+
801
+ </div>
802
+ </div>
803
+ <div class="tags">
804
+
805
+
806
+ </div><table class="source_code">
807
+ <tr>
808
+ <td>
809
+ <pre class="lines">
810
+
811
+
812
+ 122
813
+ 123
814
+ 124
815
+ 125
816
+ 126
817
+ 127
818
+ 128
819
+ 129
820
+ 130
821
+ 131</pre>
822
+ </td>
823
+ <td>
824
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 122</span>
825
+
826
+ <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>
827
+ <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>
828
+ <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
+ <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>
831
+ <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>
833
+ <span class='kw'>end</span>
834
+ <span class='kw'>return</span> <span class='id identifier rubyid_res'>res</span>
835
+ <span class='kw'>end</span></pre>
836
+ </td>
837
+ </tr>
838
+ </table>
839
+ </div>
840
+
841
+ <div class="method_details ">
842
+ <h3 class="signature " id="last-instance_method">
843
+
844
+ #<strong>last</strong> &#x21d2; <tt>Object</tt>
845
+
846
+
847
+
848
+
849
+
850
+ </h3><div class="docstring">
851
+ <div class="discussion">
852
+
853
+ <p>returns the last response the client got from the server</p>
854
+
855
+
856
+ </div>
857
+ </div>
858
+ <div class="tags">
859
+
860
+
861
+ </div><table class="source_code">
862
+ <tr>
863
+ <td>
864
+ <pre class="lines">
865
+
866
+
867
+ 160
868
+ 161
869
+ 162</pre>
870
+ </td>
871
+ <td>
872
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 160</span>
873
+
874
+ <span class='kw'>def</span> <span class='id identifier rubyid_last'>last</span>
875
+ <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>
876
+ <span class='kw'>end</span></pre>
877
+ </td>
878
+ </tr>
879
+ </table>
880
+ </div>
881
+
882
+ <div class="method_details ">
883
+ <h3 class="signature " id="login-instance_method">
884
+
885
+ #<strong>login</strong>(user: nil, pass: nil) &#x21d2; <tt>Object</tt>
886
+
887
+
888
+
889
+
890
+
891
+ </h3><div class="docstring">
892
+ <div class="discussion">
893
+
894
+ <p>both :user and :pass are required. This method calls user.logic abd stores the returned auth token for future calls to the api</p>
895
+
896
+
897
+ </div>
898
+ </div>
899
+ <div class="tags">
900
+
901
+
902
+ </div><table class="source_code">
903
+ <tr>
904
+ <td>
905
+ <pre class="lines">
906
+
907
+
908
+ 99
909
+ 100
910
+ 101
911
+ 102
912
+ 103</pre>
913
+ </td>
914
+ <td>
915
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 99</span>
916
+
917
+ <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
+ <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
+ <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>
921
+ <span class='kw'>end</span></pre>
922
+ </td>
923
+ </tr>
924
+ </table>
925
+ </div>
926
+
927
+ <div class="method_details ">
928
+ <h3 class="signature " id="logout-instance_method">
929
+
930
+ #<strong>logout</strong> &#x21d2; <tt>Object</tt>
931
+
932
+
933
+
934
+
935
+
936
+ </h3><div class="docstring">
937
+ <div class="discussion">
938
+
939
+ <p>calls user.logout for the @token session. You really should pay attention to ensuring that this gets called, else you&#39;ll find over time that your sessions table is getting quite large and will start slowing down lots of stuff in zabbix.</p>
940
+
941
+
942
+ </div>
943
+ </div>
944
+ <div class="tags">
945
+
946
+
947
+ </div><table class="source_code">
948
+ <tr>
949
+ <td>
950
+ <pre class="lines">
951
+
952
+
953
+ 110
954
+ 111
955
+ 112</pre>
956
+ </td>
957
+ <td>
958
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 110</span>
959
+
960
+ <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>
962
+ <span class='kw'>end</span></pre>
963
+ </td>
964
+ </tr>
965
+ </table>
966
+ </div>
967
+
968
+ <div class="method_details ">
969
+ <h3 class="signature " id="post-instance_method">
970
+
971
+ #<strong>post</strong>(args) &#x21d2; <tt>Object</tt>
972
+
973
+
974
+
975
+
976
+
977
+ </h3><div class="docstring">
978
+ <div class="discussion">
979
+
980
+ <p>This method posts a list of params to @conn/@@apiurl. You likely won&#39;t have need to call this directly.</p>
981
+
982
+
983
+ </div>
984
+ </div>
985
+ <div class="tags">
986
+
987
+
988
+ </div><table class="source_code">
989
+ <tr>
990
+ <td>
991
+ <pre class="lines">
992
+
993
+
994
+ 89
995
+ 90
996
+ 91
997
+ 92
998
+ 93
999
+ 94</pre>
1000
+ </td>
1001
+ <td>
1002
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 89</span>
1003
+
1004
+ <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
+ <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>
1006
+ <span class='id identifier rubyid_last'>last</span> <span class='op'>=</span> <span class='ivar'>@conn</span><span class='period'>.</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='cvar'>@@apiurl</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
1007
+ <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> <span class='op'>=</span> <span class='id identifier rubyid_last'>last</span>
1008
+ <span class='kw'>return</span> <span class='id identifier rubyid_last'>last</span>
1009
+ <span class='kw'>end</span></pre>
1010
+ </td>
1011
+ </tr>
1012
+ </table>
1013
+ </div>
1014
+
1015
+ </div>
1016
+
1017
+ </div>
1018
+
1019
+ <div id="footer">
1020
+ Generated on Sat Sep 11 20:08:37 2021 by
1021
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1022
+ 0.9.26 (ruby-2.7.4).
1023
+ </div>
1024
+
1025
+ </div>
1026
+ </body>
1027
+ </html>