zabbixapi 0.5.0b3 → 0.5.0b4

Sign up to get free protection for your applications and to get access to all the features.
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: 0.5.0b3
4
+ version: 0.5.0b4
5
5
  prerelease: 5
6
6
  platform: ruby
7
7
  authors:
@@ -27,7 +27,6 @@ files:
27
27
  - Rakefile
28
28
  - lib/zabbixapi.rb
29
29
  - lib/zabbixapi/applications.rb
30
- - lib/zabbixapi/basic.rb
31
30
  - lib/zabbixapi/client.rb
32
31
  - lib/zabbixapi/errors.rb
33
32
  - lib/zabbixapi/graphs.rb
@@ -60,7 +59,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
59
  version: '0'
61
60
  segments:
62
61
  - 0
63
- hash: -542774389150189350
62
+ hash: 2258863443762518848
64
63
  required_rubygems_version: !ruby/object:Gem::Requirement
65
64
  none: false
66
65
  requirements:
@@ -1,109 +0,0 @@
1
- class ZabbixApi
2
- class Basic
3
-
4
- def initialize(client)
5
- @client = client
6
- end
7
-
8
- ####### Synonyms #########
9
- def add(data)
10
- create(data)
11
- end
12
-
13
- def destroy(data)
14
- delete(data)
15
- end
16
-
17
- def dump(data)
18
- get_full_data(data)
19
- end
20
-
21
- ##########################
22
-
23
- ####### Methods ##########
24
- def create_array(data)
25
- result = @client.api_request(:method => "#{api_method_name}.create", :params => [data])
26
- result.empty? ? nil : result[api_keys][0].to_i
27
- end
28
-
29
- def create(data)
30
- result = @client.api_request(:method => "#{api_method_name}.create", :params => data)
31
- result.empty? ? nil : result[api_keys][0].to_i
32
- end
33
-
34
- def delete_array(data)
35
- result = @client.api_request(:method => "#{api_method_name}.delete", :params => [data])
36
- result.empty? ? nil : result[api_keys][0].to_i
37
- end
38
-
39
- def delete_array_sym(data)
40
- result = @client.api_request(:method => "#{api_method_name}.delete", :params => [api_key.to_sym => data])
41
- result.empty? ? nil : result[api_keys][0].to_i
42
- end
43
-
44
- def delete(data)
45
- result = @client.api_request(:method => "#{api_method_name}.delete", :params => data)
46
- result.empty? ? nil : result[api_keys][0].to_i
47
- end
48
-
49
- def update(data)
50
- result = @client.api_request(:method => "#{api_method_name}.update", :params => data)
51
- result.empty? ? nil : result[api_keys][0].to_i
52
- end
53
-
54
- def get_full_data_filter(data)
55
- @client.api_request(:method => "#{api_method_name}.get", :params => {:filter => data, :output => "extend"})
56
- end
57
-
58
- def get_full_data_filter_array(data)
59
- @client.api_request(:method => "#{api_method_name}.get", :params => {:filter => [data[api_identify.to_sym]], :output => "extend"})
60
- end
61
-
62
- def get_id(data)
63
- result = get_full_data(data)
64
- id = nil
65
- result.each { |tmpl| id = tmpl[api_key].to_i if tmpl[api_identify] == data[api_identify.to_sym] }
66
- id
67
- end
68
-
69
- def get_or_create(data)
70
- id = get_id(data)
71
- if id.nil?
72
- id = create(data)
73
- end
74
- id
75
- end
76
-
77
- def create_or_update(data)
78
- id = get_id(api_identify.to_sym => data[api_identify.to_sym], :templateid => data[:templateid])
79
- id ? update(data.merge(api_key.to_sym => id)) : create(data)
80
- end
81
-
82
- def all
83
- result = {}
84
- @client.api_request(:method => "#{api_method_name}.get", :params => {:output => "extend"}).each do |tmpl|
85
- result[tmpl[api_identify]] = tmpl[api_key]
86
- end
87
- result
88
- end
89
-
90
- ##########################
91
-
92
- def api_method_name
93
- raise "Can't call here api_method_name"
94
- end
95
-
96
- def api_identify
97
- raise "Can't call here api_identify"
98
- end
99
-
100
- def api_keys
101
- api_key + "s"
102
- end
103
-
104
- def api_key
105
- api_method_name + "id"
106
- end
107
-
108
- end
109
- end