zabbixapi 0.5.0 → 0.5.1a

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,48 +0,0 @@
1
- class ZabbixApi
2
- class Triggers
3
-
4
- def initialize(client)
5
- @client = client
6
- end
7
-
8
- def create(data)
9
- result = @client.api_request(:method => "trigger.create", :params => [data])
10
- result.empty? ? nil : result['triggerids'][0].to_i
11
- end
12
-
13
- def add(data)
14
- create(data)
15
- end
16
-
17
- def delete(data)
18
- result = @client.api_request(:method => "trigger.delete", :params => [data])
19
- result.empty? ? nil : result['triggerids'][0].to_i
20
- end
21
-
22
- def destroy(data)
23
- delete(data)
24
- end
25
-
26
- def update(data)
27
- result = @client.api_request(:method => "trigger.update", :params => data)
28
- result.empty? ? nil : result['triggerids'][0].to_i
29
- end
30
-
31
- def create_or_update(data)
32
- triggerid = get_id(:description => data[:description], :templateid => data[:templateid])
33
- triggerid ? update(data.merge(:triggerid => triggerid)) : create(data)
34
- end
35
-
36
- def get_full_data(data)
37
- @client.api_request(:method => "trigger.get", :params => {:filter => data, :output => "extend"})
38
- end
39
-
40
- def get_id(data)
41
- result = get_full_data(data)
42
- triggerid = nil
43
- result.each { |template| triggerid = template['triggerid'].to_i if template['name'] == data[:name] }
44
- triggerid
45
- end
46
-
47
- end
48
- end
@@ -1,67 +0,0 @@
1
- class ZabbixApi
2
- class Users
3
-
4
- def initialize(client)
5
- @client = client
6
- end
7
-
8
- def create(data)
9
- result = @client.api_request(:method => "user.create", :params => data)
10
- result ? result['userids'][0].to_i : nil
11
- end
12
-
13
- def add(data)
14
- create(data)
15
- end
16
-
17
- def delete(data)
18
- result = @client.api_request(:method => "user.delete", :params => [:userid => data])
19
- result ? result['userids'][0].to_i : nil
20
- end
21
-
22
- def get_full_data(data)
23
- @client.api_request(
24
- :method => "user.get",
25
- :params => {
26
- :filter => {
27
- :name => data[:name]
28
- },
29
- :output => "extend"
30
- }
31
- )
32
- end
33
-
34
- def get(data)
35
- get_full_data(data)
36
- end
37
-
38
- def create_or_update(data)
39
- userid = get_id(:name => data[:name])
40
- userid ? update(data.merge(:userid => userid)) : create(data)
41
- end
42
-
43
- def add_medias(data)
44
- result = @client.api_request(
45
- :method => "user.addMedia",
46
- :params => {
47
- :users => data[:userids].map { |t| {:userid => t} },
48
- :medias => data[:media]
49
- }
50
- )
51
- result ? result['userids'][0].to_i : nil
52
- end
53
-
54
- def get_id(data)
55
- result = get_full_data(data)
56
- userid = nil
57
- result.each { |usr| userid = usr['userid'].to_i if usr['name'] == data[:name] }
58
- userid
59
- end
60
-
61
- def update(data)
62
- result = @client.api_request(:method => "user.update", :params => data)
63
- result ? result['userids'][0].to_i : nil
64
- end
65
-
66
- end
67
- end