zabbix-api-simple 0.1.1 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1102 @@
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="#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
+
362
+ </li>
363
+
364
+
365
+ <li class="public ">
366
+ <span class="summary_signature">
367
+
368
+ <a href="#last-instance_method" title="#last (instance method)">#<strong>last</strong> &#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>returns the last response the client got from the server.</p>
384
+ </div></span>
385
+
386
+ </li>
387
+
388
+
389
+ <li class="public ">
390
+ <span class="summary_signature">
391
+
392
+ <a href="#login-instance_method" title="#login (instance method)">#<strong>login</strong>(user: nil, pass: nil) &#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>both :user and :pass are required.</p>
408
+ </div></span>
409
+
410
+ </li>
411
+
412
+
413
+ <li class="public ">
414
+ <span class="summary_signature">
415
+
416
+ <a href="#logout-instance_method" title="#logout (instance method)">#<strong>logout</strong> &#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>calls user.logout for the @token session.</p>
432
+ </div></span>
433
+
434
+ </li>
435
+
436
+
437
+ <li class="public ">
438
+ <span class="summary_signature">
439
+
440
+ <a href="#method_missing-instance_method" title="#method_missing (instance method)">#<strong>method_missing</strong>(name, *args, &amp;block) &#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 override of method_missing is the trick that lets zabbix-api-simple look quite a lot like the zabbix api documentation.</p>
456
+ </div></span>
457
+
458
+ </li>
459
+
460
+
461
+ <li class="public ">
462
+ <span class="summary_signature">
463
+
464
+ <a href="#post-instance_method" title="#post (instance method)">#<strong>post</strong>(args) &#x21d2; Object </a>
465
+
466
+
467
+
468
+ </span>
469
+
470
+
471
+
472
+
473
+
474
+
475
+
476
+
477
+
478
+ <span class="summary_desc"><div class='inline'>
479
+ <p>This method posts a list of params to @conn/@@apiurl.</p>
480
+ </div></span>
481
+
482
+ </li>
483
+
484
+
485
+ </ul>
486
+
487
+
488
+ <div id="constructor_details" class="method_details_list">
489
+ <h2>Constructor Details</h2>
490
+
491
+ <div class="method_details first">
492
+ <h3 class="signature first" id="initialize-instance_method">
493
+
494
+ #<strong>initialize</strong>(url: nil, timeout: 60) &#x21d2; <tt><span class='object_link'><a href="" title="Zabbix::Api::Client (class)">Client</a></span></tt>
495
+
496
+
497
+
498
+
499
+
500
+ </h3><div class="docstring">
501
+ <div class="discussion">
502
+
503
+ <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>
504
+
505
+
506
+ </div>
507
+ </div>
508
+ <div class="tags">
509
+
510
+
511
+ </div><table class="source_code">
512
+ <tr>
513
+ <td>
514
+ <pre class="lines">
515
+
516
+
517
+ 115
518
+ 116
519
+ 117
520
+ 118
521
+ 119
522
+ 120
523
+ 121
524
+ 122
525
+ 123
526
+ 124</pre>
527
+ </td>
528
+ <td>
529
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 115</span>
530
+
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>
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>
533
+ <span class='label'>url:</span> <span class='id identifier rubyid_url'>url</span><span class='comma'>,</span>
534
+ <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>
535
+ <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>
536
+ <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>
537
+ <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>
538
+ <span class='kw'>end</span>
539
+ <span class='ivar'>@zabobject</span> <span class='op'>=</span> <span class='kw'>nil</span>
540
+ <span class='kw'>end</span></pre>
541
+ </td>
542
+ </tr>
543
+ </table>
544
+ </div>
545
+
546
+ </div>
547
+ <div id="method_missing_details" class="method_details_list">
548
+ <h2>Dynamic Method Handling</h2>
549
+ <p class="notice this">
550
+ This class handles dynamic methods through the <tt>method_missing</tt> method
551
+
552
+ </p>
553
+
554
+ <div class="method_details first">
555
+ <h3 class="signature first" id="method_missing-instance_method">
556
+
557
+ #<strong>method_missing</strong>(name, *args, &amp;block) &#x21d2; <tt>Object</tt>
558
+
559
+
560
+
561
+
562
+
563
+ </h3><div class="docstring">
564
+ <div class="discussion">
565
+
566
+ <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>
567
+
568
+ <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>
569
+
570
+
571
+ </div>
572
+ </div>
573
+ <div class="tags">
574
+
575
+
576
+ </div><table class="source_code">
577
+ <tr>
578
+ <td>
579
+ <pre class="lines">
580
+
581
+
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>
596
+ </td>
597
+ <td>
598
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 196</span>
599
+
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>
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>
602
+ <span class='comment'># Clone self cuz we want to be thread safe/recursable. This will pop off the
603
+ </span> <span class='comment'># stack after it&#39;s no longer referenced (and @zabobject will never change in the
604
+ </span> <span class='comment'># original client instance)
605
+ </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>
606
+ <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>
607
+ <span class='kw'>return</span> <span class='id identifier rubyid_newcli'>newcli</span>
608
+ <span class='kw'>elsif</span> <span class='ivar'>@zabobject</span>
609
+ <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>
610
+ <span class='kw'>else</span>
611
+ <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>
612
+ <span class='kw'>end</span>
613
+ <span class='kw'>end</span></pre>
614
+ </td>
615
+ </tr>
616
+ </table>
617
+ </div>
618
+
619
+ </div>
620
+
621
+ <div id="class_attr_details" class="attr_details">
622
+ <h2>Class Attribute Details</h2>
623
+
624
+
625
+ <span id="last=-class_method"></span>
626
+ <div class="method_details first">
627
+ <h3 class="signature first" id="last-class_method">
628
+
629
+ .<strong>last</strong> &#x21d2; <tt>Object</tt>
630
+
631
+
632
+
633
+
634
+
635
+ </h3><div class="docstring">
636
+ <div class="discussion">
637
+
638
+ <p>Returns the value of attribute last.</p>
639
+
640
+
641
+ </div>
642
+ </div>
643
+ <div class="tags">
644
+
645
+
646
+ </div><table class="source_code">
647
+ <tr>
648
+ <td>
649
+ <pre class="lines">
650
+
651
+
652
+ 84
653
+ 85
654
+ 86</pre>
655
+ </td>
656
+ <td>
657
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 84</span>
658
+
659
+ <span class='kw'>def</span> <span class='id identifier rubyid_last'>last</span>
660
+ <span class='ivar'>@last</span>
661
+ <span class='kw'>end</span></pre>
662
+ </td>
663
+ </tr>
664
+ </table>
665
+ </div>
666
+
667
+ </div>
668
+
669
+ <div id="instance_attr_details" class="attr_details">
670
+ <h2>Instance Attribute Details</h2>
671
+
672
+
673
+ <span id=""></span>
674
+ <div class="method_details first">
675
+ <h3 class="signature first" id="conn-instance_method">
676
+
677
+ #<strong>conn</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
678
+
679
+
680
+
681
+
682
+
683
+ </h3><div class="docstring">
684
+ <div class="discussion">
685
+
686
+ <p>Returns the value of attribute conn.</p>
687
+
688
+
689
+ </div>
690
+ </div>
691
+ <div class="tags">
692
+
693
+
694
+ </div><table class="source_code">
695
+ <tr>
696
+ <td>
697
+ <pre class="lines">
698
+
699
+
700
+ 107
701
+ 108
702
+ 109</pre>
703
+ </td>
704
+ <td>
705
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 107</span>
706
+
707
+ <span class='kw'>def</span> <span class='id identifier rubyid_conn'>conn</span>
708
+ <span class='ivar'>@conn</span>
709
+ <span class='kw'>end</span></pre>
710
+ </td>
711
+ </tr>
712
+ </table>
713
+ </div>
714
+
715
+
716
+ <span id=""></span>
717
+ <div class="method_details ">
718
+ <h3 class="signature " id="token-instance_method">
719
+
720
+ #<strong>token</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
721
+
722
+
723
+
724
+
725
+
726
+ </h3><div class="docstring">
727
+ <div class="discussion">
728
+
729
+ <p>Returns the value of attribute token.</p>
730
+
731
+
732
+ </div>
733
+ </div>
734
+ <div class="tags">
735
+
736
+
737
+ </div><table class="source_code">
738
+ <tr>
739
+ <td>
740
+ <pre class="lines">
741
+
742
+
743
+ 107
744
+ 108
745
+ 109</pre>
746
+ </td>
747
+ <td>
748
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 107</span>
749
+
750
+ <span class='kw'>def</span> <span class='id identifier rubyid_token'>token</span>
751
+ <span class='ivar'>@token</span>
752
+ <span class='kw'>end</span></pre>
753
+ </td>
754
+ </tr>
755
+ </table>
756
+ </div>
757
+
758
+
759
+ <span id="zabobject=-instance_method"></span>
760
+ <div class="method_details ">
761
+ <h3 class="signature " id="zabobject-instance_method">
762
+
763
+ #<strong>zabobject</strong> &#x21d2; <tt>Object</tt>
764
+
765
+
766
+
767
+
768
+
769
+ </h3><div class="docstring">
770
+ <div class="discussion">
771
+
772
+ <p>Returns the value of attribute zabobject.</p>
773
+
774
+
775
+ </div>
776
+ </div>
777
+ <div class="tags">
778
+
779
+
780
+ </div><table class="source_code">
781
+ <tr>
782
+ <td>
783
+ <pre class="lines">
784
+
785
+
786
+ 108
787
+ 109
788
+ 110</pre>
789
+ </td>
790
+ <td>
791
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 108</span>
792
+
793
+ <span class='kw'>def</span> <span class='id identifier rubyid_zabobject'>zabobject</span>
794
+ <span class='ivar'>@zabobject</span>
795
+ <span class='kw'>end</span></pre>
796
+ </td>
797
+ </tr>
798
+ </table>
799
+ </div>
800
+
801
+ </div>
802
+
803
+
804
+ <div id="instance_method_details" class="method_details_list">
805
+ <h2>Instance Method Details</h2>
806
+
807
+
808
+ <div class="method_details first">
809
+ <h3 class="signature first" id="call-instance_method">
810
+
811
+ #<strong>call</strong>(name, *args, &amp;block) &#x21d2; <tt>Object</tt>
812
+
813
+
814
+
815
+
816
+
817
+ </h3><div class="docstring">
818
+ <div class="discussion">
819
+
820
+ <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>
821
+
822
+ <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>
823
+
824
+
825
+ </div>
826
+ </div>
827
+ <div class="tags">
828
+
829
+
830
+ </div><table class="source_code">
831
+ <tr>
832
+ <td>
833
+ <pre class="lines">
834
+
835
+
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>
851
+ </td>
852
+ <td>
853
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 162</span>
854
+
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>
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>
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>
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>
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>
865
+ <span class='kw'>else</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>
867
+ <span class='kw'>end</span>
868
+ <span class='kw'>return</span> <span class='id identifier rubyid_res'>res</span>
869
+ <span class='kw'>end</span></pre>
870
+ </td>
871
+ </tr>
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>
914
+ </div>
915
+
916
+ <div class="method_details ">
917
+ <h3 class="signature " id="last-instance_method">
918
+
919
+ #<strong>last</strong> &#x21d2; <tt>Object</tt>
920
+
921
+
922
+
923
+
924
+
925
+ </h3><div class="docstring">
926
+ <div class="discussion">
927
+
928
+ <p>returns the last response the client got from the server</p>
929
+
930
+
931
+ </div>
932
+ </div>
933
+ <div class="tags">
934
+
935
+
936
+ </div><table class="source_code">
937
+ <tr>
938
+ <td>
939
+ <pre class="lines">
940
+
941
+
942
+ 213
943
+ 214
944
+ 215</pre>
945
+ </td>
946
+ <td>
947
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 213</span>
948
+
949
+ <span class='kw'>def</span> <span class='id identifier rubyid_last'>last</span>
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>
951
+ <span class='kw'>end</span></pre>
952
+ </td>
953
+ </tr>
954
+ </table>
955
+ </div>
956
+
957
+ <div class="method_details ">
958
+ <h3 class="signature " id="login-instance_method">
959
+
960
+ #<strong>login</strong>(user: nil, pass: nil) &#x21d2; <tt>Object</tt>
961
+
962
+
963
+
964
+
965
+
966
+ </h3><div class="docstring">
967
+ <div class="discussion">
968
+
969
+ <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>
970
+
971
+
972
+ </div>
973
+ </div>
974
+ <div class="tags">
975
+
976
+
977
+ </div><table class="source_code">
978
+ <tr>
979
+ <td>
980
+ <pre class="lines">
981
+
982
+
983
+ 139
984
+ 140
985
+ 141
986
+ 142
987
+ 143</pre>
988
+ </td>
989
+ <td>
990
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 139</span>
991
+
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>
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>
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>
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>
996
+ <span class='kw'>end</span></pre>
997
+ </td>
998
+ </tr>
999
+ </table>
1000
+ </div>
1001
+
1002
+ <div class="method_details ">
1003
+ <h3 class="signature " id="logout-instance_method">
1004
+
1005
+ #<strong>logout</strong> &#x21d2; <tt>Object</tt>
1006
+
1007
+
1008
+
1009
+
1010
+
1011
+ </h3><div class="docstring">
1012
+ <div class="discussion">
1013
+
1014
+ <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>
1015
+
1016
+
1017
+ </div>
1018
+ </div>
1019
+ <div class="tags">
1020
+
1021
+
1022
+ </div><table class="source_code">
1023
+ <tr>
1024
+ <td>
1025
+ <pre class="lines">
1026
+
1027
+
1028
+ 150
1029
+ 151
1030
+ 152</pre>
1031
+ </td>
1032
+ <td>
1033
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 150</span>
1034
+
1035
+ <span class='kw'>def</span> <span class='id identifier rubyid_logout'>logout</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>
1037
+ <span class='kw'>end</span></pre>
1038
+ </td>
1039
+ </tr>
1040
+ </table>
1041
+ </div>
1042
+
1043
+ <div class="method_details ">
1044
+ <h3 class="signature " id="post-instance_method">
1045
+
1046
+ #<strong>post</strong>(args) &#x21d2; <tt>Object</tt>
1047
+
1048
+
1049
+
1050
+
1051
+
1052
+ </h3><div class="docstring">
1053
+ <div class="discussion">
1054
+
1055
+ <p>This method posts a list of params to @conn/@@apiurl. You likely won&#39;t have need to call this directly.</p>
1056
+
1057
+
1058
+ </div>
1059
+ </div>
1060
+ <div class="tags">
1061
+
1062
+
1063
+ </div><table class="source_code">
1064
+ <tr>
1065
+ <td>
1066
+ <pre class="lines">
1067
+
1068
+
1069
+ 129
1070
+ 130
1071
+ 131
1072
+ 132
1073
+ 133
1074
+ 134</pre>
1075
+ </td>
1076
+ <td>
1077
+ <pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 129</span>
1078
+
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>
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>
1081
+ <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>
1082
+ <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>
1083
+ <span class='kw'>return</span> <span class='id identifier rubyid_last'>last</span>
1084
+ <span class='kw'>end</span></pre>
1085
+ </td>
1086
+ </tr>
1087
+ </table>
1088
+ </div>
1089
+
1090
+ </div>
1091
+
1092
+ </div>
1093
+
1094
+ <div id="footer">
1095
+ Generated on Sat Sep 18 20:44:22 2021 by
1096
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1097
+ 0.9.26 (ruby-2.7.4).
1098
+ </div>
1099
+
1100
+ </div>
1101
+ </body>
1102
+ </html>