zabbixapi 0.4.9 → 0.5.0a
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -2
- data/lib/zabbixapi/usergroups.rb +5 -4
- data/lib/zabbixapi/version.rb +1 -1
- data/spec/localhost.rb +5 -4
- data/spec/run.rb +5 -4
- metadata +5 -5
data/README.md
CHANGED
@@ -219,14 +219,14 @@ zbx.screens.get_or_create_for_host(
|
|
219
219
|
|
220
220
|
### Create UserGroup, add user and add rights ###
|
221
221
|
```ruby
|
222
|
-
zbx.usergroups.
|
222
|
+
zbx.usergroups.get_or_create(:name => "Some user group")
|
223
223
|
zbx.usergroups.add_user(
|
224
224
|
:usrgrpids => [zbx.usergroups.get_id(:name => "Some user group")],
|
225
225
|
:userids => [zbx.users.get_id(:name => "Some user")]
|
226
226
|
)
|
227
227
|
# get read permissions for UserGroup on all hostgroup
|
228
228
|
zbx.usergroups.set_perm_read(
|
229
|
-
:
|
229
|
+
:usrgrpid => zbx.usergroups.get_or_create(:name => "Some user group"),
|
230
230
|
:hostgroupids => zbx.hostgroups.all.values
|
231
231
|
)
|
232
232
|
```
|
data/lib/zabbixapi/usergroups.rb
CHANGED
@@ -87,18 +87,19 @@ class ZabbixApi
|
|
87
87
|
usrgrpid
|
88
88
|
end
|
89
89
|
|
90
|
-
# Set
|
90
|
+
# Set permission for usrgrp on some hostgroup
|
91
91
|
#
|
92
92
|
# * *Args* :
|
93
|
-
# - +data+ -> Hash with :usrgrpids => id, :hostgroupids => []
|
93
|
+
# - +data+ -> Hash with :usrgrpids => id, :hostgroupids => [], :permission => 2,3 (read and read write)
|
94
94
|
# * *Returns* :
|
95
95
|
# - Integer
|
96
|
-
def
|
96
|
+
def set_perm(data)
|
97
|
+
permission = data[:permission] || 2
|
97
98
|
result = @client.api_request(
|
98
99
|
:method => "usergroup.massAdd",
|
99
100
|
:params => {
|
100
101
|
:usrgrpids => [data[:usrgrpids]],
|
101
|
-
:rights => data[:hostgroupids].map { |t| {:permission =>
|
102
|
+
:rights => data[:hostgroupids].map { |t| {:permission => permission, :id => t} }
|
102
103
|
}
|
103
104
|
)
|
104
105
|
result ? result['usrgrpids'][0].to_i : nil
|
data/lib/zabbixapi/version.rb
CHANGED
data/spec/localhost.rb
CHANGED
@@ -373,10 +373,11 @@ describe ZabbixApi, "test_api" do
|
|
373
373
|
).should be_kind_of(Integer)
|
374
374
|
end
|
375
375
|
|
376
|
-
it "USERGROUPS: Set UserGroup read perm" do
|
377
|
-
puts zbx.usergroups.
|
378
|
-
:
|
379
|
-
:hostgroupids => zbx.hostgroups.all.values
|
376
|
+
it "USERGROUPS: Set UserGroup read & write perm" do
|
377
|
+
puts zbx.usergroups.set_perm(
|
378
|
+
:usrgrpid => zbx.usergroups.get_or_create(:name => usergroup).to_s,
|
379
|
+
:hostgroupids => zbx.hostgroups.all.values,
|
380
|
+
:permission => 3
|
380
381
|
)
|
381
382
|
end
|
382
383
|
|
data/spec/run.rb
CHANGED
@@ -370,10 +370,11 @@ describe ZabbixApi, "test_api" do
|
|
370
370
|
).should be_kind_of(Integer)
|
371
371
|
end
|
372
372
|
|
373
|
-
it "USERGROUPS: Set UserGroup read perm" do
|
374
|
-
puts zbx.usergroups.
|
375
|
-
:
|
376
|
-
:hostgroupids => zbx.hostgroups.all.values
|
373
|
+
it "USERGROUPS: Set UserGroup read & write perm" do
|
374
|
+
puts zbx.usergroups.set_perm(
|
375
|
+
:usrgrpid => zbx.usergroups.get_or_create(:name => usergroup).to_s,
|
376
|
+
:hostgroupids => zbx.hostgroups.all.values,
|
377
|
+
:permission => 3
|
377
378
|
)
|
378
379
|
end
|
379
380
|
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zabbixapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.0a
|
5
|
+
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Vasiliev D.V.
|
@@ -58,13 +58,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
58
|
version: '0'
|
59
59
|
segments:
|
60
60
|
- 0
|
61
|
-
hash:
|
61
|
+
hash: -2374189325789372111
|
62
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
64
64
|
requirements:
|
65
|
-
- - ! '
|
65
|
+
- - ! '>'
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
67
|
+
version: 1.3.1
|
68
68
|
requirements: []
|
69
69
|
rubyforge_project: zabbixapi
|
70
70
|
rubygems_version: 1.8.24
|