zabbixapi 2.4.5 → 2.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25ba28c4faff22b396e0e768792448a75ca4e637
4
- data.tar.gz: 788a52dbb357ab631f7a2029a6485c41d0d49ca1
3
+ metadata.gz: 215112a4983ad12bbe114bf2b884a99e165fc0f8
4
+ data.tar.gz: 0d3d0c9eba2992c8dc6ac34145657773bd90ccbe
5
5
  SHA512:
6
- metadata.gz: 78dd6e98b5a32bb724259b3e34c29e509cbba0fcb5c9decbdc8a9aeca25adf1f3a3692d661de57ce76c3be2c3d4607624d3addf346c123a911a9a8c4b3b629df
7
- data.tar.gz: 0b5ff259f158b439285c080de706336847e52c554e3dd4f4a214fc02ce877b178717c81e99b038fcd64b1bb589698b82698c447f18060af5abf58a45d47f0b1e
6
+ metadata.gz: e46a3e882b2d4abefdd27d62e8839dc85f8ecc8485905e385e4fd396d914d547119c3f44ba66e27aae1d3244215189419fc62f3f0e5edbcc27f05bec5ffef01f
7
+ data.tar.gz: bfca90c6b3676e1ff1dd10874ab70fceb43a464c41eb7220bbbf9e5341c7aab2e150f571431a315f72f6fe61a641e5d1b020c932f1966a0fea91673a70fe5eb7
data/.rspec CHANGED
@@ -1 +1 @@
1
- --color --format nested
1
+ --color --format documentation
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.4.6
2
+
3
+ [PR #39](https://github.com/express42/zabbixapi/issues/39) Add support for maintenance API
4
+
1
5
  ## 2.4.5
2
6
 
3
7
  [PR #33](https://github.com/express42/zabbixapi/issues/33) Typed exceptions
data/README.md CHANGED
@@ -227,11 +227,11 @@ zbx.graphs.delete(zbx.graphs.get_id(:name => "graph"))
227
227
  ### Get all templates linked with host
228
228
  ```ruby
229
229
  zbx.templates.get_ids_by_host( :hostids => [zbx.hosts.get_id(:host => "hostname")] )
230
- #returned hash:
231
- #{
232
- # "Templatename" => "10",
233
- # "Templatename" => "1021"
234
- #}
230
+ #returned array:
231
+ #[
232
+ # "10",
233
+ # "1021"
234
+ #]
235
235
  ```
236
236
 
237
237
  ### Mass (Un)Link host with templates
@@ -324,7 +324,7 @@ zbx.usergroups.add_user(
324
324
  :userids => [zbx.users.get_id(:alias => "user")]
325
325
  )
326
326
  # set write and read permissions for UserGroup on all hostgroups
327
- zbx.usergroups.set_perm(
327
+ zbx.usergroups.set_perms(
328
328
  :usrgrpid => zbx.usergroups.get_or_create(:name => "Some user group"),
329
329
  :hostgroupids => zbx.hostgroups.all.values, # kind_of Array
330
330
  :permission => 3 # 2- read (by default) and 3 - write and read
data/lib/zabbixapi.rb CHANGED
@@ -10,6 +10,7 @@ require "zabbixapi/classes/applications"
10
10
  require "zabbixapi/classes/errors"
11
11
  require "zabbixapi/classes/graphs"
12
12
  require "zabbixapi/classes/hostgroups"
13
+ require "zabbixapi/classes/maintenance"
13
14
  require "zabbixapi/classes/hosts"
14
15
  require "zabbixapi/classes/items"
15
16
  require "zabbixapi/classes/mediatypes"
@@ -72,6 +73,10 @@ class ZabbixApi
72
73
  @hostgroups ||= HostGroups.new(@client)
73
74
  end
74
75
 
76
+ def maintenance
77
+ @maintenance ||= Maintenance.new(@client)
78
+ end
79
+
75
80
  def triggers
76
81
  @triggers ||= Triggers.new(@client)
77
82
  end
@@ -0,0 +1,13 @@
1
+ class ZabbixApi
2
+ class Maintenance < Basic
3
+
4
+ def method_name
5
+ "maintenance"
6
+ end
7
+
8
+ def indentify
9
+ "name"
10
+ end
11
+
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  class ZabbixApi
2
- VERSION = "2.4.5"
2
+ VERSION = "2.4.6"
3
3
  end
@@ -0,0 +1,81 @@
1
+ #encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'maintenance' do
6
+ context 'when not exists' do
7
+ before :all do
8
+ @hostgroupid = zbx.hostgroups.create(:name => "hostgroup_#{rand(1_000_000)}")
9
+ end
10
+
11
+ describe 'create' do
12
+ it "should return integer id after creation" do
13
+ maintenanceid = zbx.maintenance.create(:name => "maintenance_#{rand(1_000_000)}",
14
+ :groupids => [ @hostgroupid ],
15
+ :active_since => 1358844540,
16
+ :active_till => 1390466940,
17
+ :timeperiods => [ :timeperiod_type => 3, :every => 1, :dayofweek => 64, :start_time => 64800, :period => 3600 ]
18
+ )
19
+ expect(maintenanceid).to be_kind_of(Integer)
20
+ zbx.maintenance.delete(maintenanceid)
21
+ end
22
+ end
23
+
24
+ after :all do
25
+ zbx.hostgroups.delete(@hostgroupid)
26
+ end
27
+
28
+ end
29
+
30
+ context 'when exists' do
31
+ before :all do
32
+ @hostgroupid_when_exists = zbx.hostgroups.create(:name => "hostgroup_#{rand(1_000_000)}")
33
+ @maintenance = gen_name('maintenance')
34
+ @maintenanceid = zbx.maintenance.create(:name => @maintenance,
35
+ :groupids => [ @hostgroupid_when_exists ],
36
+ :active_since => 1358844540,
37
+ :active_till => 1390466940,
38
+ :timeperiods => [ :timeperiod_type => 3, :every => 1, :dayofweek => 64, :start_time => 64800, :period => 3600 ]
39
+ )
40
+ end
41
+
42
+ describe 'get_id' do
43
+ it "should return id" do
44
+ zbx.maintenance.get_id(:name => @maintenance).should eq @maintenanceid
45
+ end
46
+
47
+ it "should return nil for not existing group" do
48
+ zbx.maintenance.get_id(:name => "#{@maintenance}______").should be_kind_of(NilClass)
49
+ end
50
+ end
51
+
52
+ describe 'get_or_create' do
53
+ it "should return id of existing maintenance" do
54
+ zbx.maintenance.get_or_create(:name => @maintenance).should eq @maintenanceid
55
+ end
56
+ end
57
+
58
+ describe 'create_or_update' do
59
+ it "should return id of maintenance" do
60
+ zbx.maintenance.create_or_update(:name => @maintenance).should eq @maintenanceid
61
+ end
62
+ end
63
+
64
+ describe 'all' do
65
+ it "should contains created maintenance" do
66
+ zbx.maintenance.all.should include(@maintenance => @maintenanceid.to_s)
67
+ end
68
+ end
69
+
70
+ describe "delete" do
71
+ it "shold return id" do
72
+ zbx.maintenance.delete(@maintenanceid).should eq @maintenanceid
73
+ end
74
+ end
75
+
76
+ after :all do
77
+ zbx.hostgroups.delete(@hostgroupid_when_exists)
78
+ end
79
+
80
+ end
81
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zabbixapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.5
4
+ version: 2.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasiliev D.V.
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-08 00:00:00.000000000 Z
12
+ date: 2016-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -60,6 +60,7 @@ files:
60
60
  - lib/zabbixapi/classes/hostgroups.rb
61
61
  - lib/zabbixapi/classes/hosts.rb
62
62
  - lib/zabbixapi/classes/items.rb
63
+ - lib/zabbixapi/classes/maintenance.rb
63
64
  - lib/zabbixapi/classes/mediatypes.rb
64
65
  - lib/zabbixapi/classes/proxies.rb
65
66
  - lib/zabbixapi/classes/screens.rb
@@ -79,6 +80,7 @@ files:
79
80
  - spec/host.rb
80
81
  - spec/hostgroup.rb
81
82
  - spec/item.rb
83
+ - spec/maintenance.rb
82
84
  - spec/mediatype.rb
83
85
  - spec/query.rb
84
86
  - spec/screen.rb
@@ -121,6 +123,7 @@ test_files:
121
123
  - spec/host.rb
122
124
  - spec/hostgroup.rb
123
125
  - spec/item.rb
126
+ - spec/maintenance.rb
124
127
  - spec/mediatype.rb
125
128
  - spec/query.rb
126
129
  - spec/screen.rb