zabbixapi 4.1.2 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -0
  3. data/README.md +3 -5
  4. data/lib/zabbixapi.rb +6 -0
  5. data/lib/zabbixapi/basic/basic_alias.rb +0 -0
  6. data/lib/zabbixapi/basic/basic_func.rb +0 -0
  7. data/lib/zabbixapi/basic/basic_init.rb +0 -0
  8. data/lib/zabbixapi/basic/basic_logic.rb +0 -0
  9. data/lib/zabbixapi/classes/actions.rb +0 -0
  10. data/lib/zabbixapi/classes/applications.rb +0 -0
  11. data/lib/zabbixapi/classes/configurations.rb +0 -0
  12. data/lib/zabbixapi/classes/drules.rb +0 -0
  13. data/lib/zabbixapi/classes/errors.rb +0 -0
  14. data/lib/zabbixapi/classes/events.rb +17 -0
  15. data/lib/zabbixapi/classes/graphs.rb +0 -0
  16. data/lib/zabbixapi/classes/hostgroups.rb +0 -0
  17. data/lib/zabbixapi/classes/hosts.rb +0 -0
  18. data/lib/zabbixapi/classes/httptests.rb +0 -0
  19. data/lib/zabbixapi/classes/items.rb +2 -2
  20. data/lib/zabbixapi/classes/maintenance.rb +0 -0
  21. data/lib/zabbixapi/classes/mediatypes.rb +0 -0
  22. data/lib/zabbixapi/classes/proxies.rb +0 -0
  23. data/lib/zabbixapi/classes/screens.rb +0 -0
  24. data/lib/zabbixapi/classes/scripts.rb +0 -0
  25. data/lib/zabbixapi/classes/server.rb +1 -1
  26. data/lib/zabbixapi/classes/templates.rb +0 -0
  27. data/lib/zabbixapi/classes/triggers.rb +0 -0
  28. data/lib/zabbixapi/classes/unusable.rb +0 -0
  29. data/lib/zabbixapi/classes/usergroups.rb +12 -15
  30. data/lib/zabbixapi/classes/usermacros.rb +0 -0
  31. data/lib/zabbixapi/classes/users.rb +9 -7
  32. data/lib/zabbixapi/classes/valuemaps.rb +0 -0
  33. data/lib/zabbixapi/client.rb +11 -2
  34. data/lib/zabbixapi/version.rb +1 -1
  35. data/zabbixapi.gemspec +1 -1
  36. metadata +11 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d40b3de910c34c57086f5cb96a4d849327b66eff0ed3c90013f81f911efffd5
4
- data.tar.gz: 95ca03dc07172fb5d474992477e57847bf94925129316009b186bfc9ec44ecc6
3
+ metadata.gz: 58451fc1a06fa45c0ac63d0ec7d66c567455ae0eba7cc8a548cb223c8af3a987
4
+ data.tar.gz: 7574a95089d1a4c32bfb30273dfd731e726b2367e50edd849d8165e06e033868
5
5
  SHA512:
6
- metadata.gz: 4c877eb09fce12d6dc5b4698f647a5c082d42ecf6a2a2ea08057c40cde7c37613eed77477e26a1ca88b08786485e69fecb61994f153e94adb69a7fd295823caf
7
- data.tar.gz: b62ee57503a824904dda48b594ddb119a6977320dd0f46b549c251ccb6a97debb211a5ccd0d5c5457507b6d30fd54076bf516edd5423dedd0856ca3e3145eeb6
6
+ metadata.gz: 3d432eb203cfe6723dea2d47fbc4a0c064131e9e732e08f6c753e6ed567d29f83e307335ee52c670b4ab8fc4e22381dbee8c614957e710785816eaf5fad50857
7
+ data.tar.gz: 75cfa60403d32ab616e5caf6670c4b2a4bb3014606d6966a383a88e13e24284b49034fce287d0209a9e0637e53043b4235fe39ca70d194150c163924af32cd6f
@@ -1,5 +1,8 @@
1
1
  #CHANGELOG
2
2
 
3
+ ## 4.2.0
4
+ [PR #102](https://github.com/express42/zabbixapi/pull/102) Add events get method method. Fixed all testing failures. (Thanks @kevin-j-smith)
5
+
3
6
  ## 4.1.2
4
7
  [PR #99](https://github.com/express42/zabbixapi/pull/99) Patch addressing log error function not found
5
8
 
data/README.md CHANGED
@@ -36,12 +36,10 @@ We support only two last versions of zabbix (4.0 and 4.2), so you should conside
36
36
  This library aims to support and is [tested against][travis] the following Ruby
37
37
  versions:
38
38
 
39
- * Ruby 2.0
40
- * Ruby 2.1
41
- * Ruby 2.2
42
- * Ruby 2.3
43
39
  * Ruby 2.4
44
- * JRuby 9.1.6.0
40
+ * Ruby 2.5
41
+ * Ruby 2.6
42
+ * JRuby 9.2.10.0
45
43
 
46
44
  If something doesn't work on one of these versions, it's a bug.
47
45
 
@@ -10,6 +10,7 @@ require 'zabbixapi/classes/actions'
10
10
  require 'zabbixapi/classes/applications'
11
11
  require 'zabbixapi/classes/configurations'
12
12
  require 'zabbixapi/classes/errors'
13
+ require 'zabbixapi/classes/events'
13
14
  require 'zabbixapi/classes/graphs'
14
15
  require 'zabbixapi/classes/hostgroups'
15
16
  require 'zabbixapi/classes/hosts'
@@ -84,6 +85,11 @@ class ZabbixApi
84
85
  @configurations ||= Configurations.new(@client)
85
86
  end
86
87
 
88
+ # @return [ZabbixApi::Events]
89
+ def events
90
+ @events ||= Events.new(@client)
91
+ end
92
+
87
93
  # @return [ZabbixApi::Graphs]
88
94
  def graphs
89
95
  @graphs ||= Graphs.new(@client)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,17 @@
1
+ class ZabbixApi
2
+ class Events < Basic
3
+ # The method name used for interacting with Events via Zabbix API
4
+ #
5
+ # @return [String]
6
+ def method_name
7
+ 'event'
8
+ end
9
+
10
+ # The id field name used for identifying specific Event objects via Zabbix API
11
+ #
12
+ # @return [String]
13
+ def indentify
14
+ 'name'
15
+ end
16
+ end
17
+ end
File without changes
File without changes
File without changes
File without changes
@@ -23,7 +23,7 @@ class ZabbixApi
23
23
  key_: nil,
24
24
  hostid: nil,
25
25
  delay: 60,
26
- history: 60,
26
+ history: 3600,
27
27
  status: 0,
28
28
  type: 7,
29
29
  snmp_community: '',
@@ -40,7 +40,7 @@ class ZabbixApi
40
40
  snmpv3_authpassphrase: '',
41
41
  snmpv3_privpassphrase: '',
42
42
  formula: 0,
43
- trends: 365,
43
+ trends: 86400,
44
44
  logtimefmt: '',
45
45
  valuemapid: 0,
46
46
  delay_flex: '',
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -10,7 +10,7 @@ class ZabbixApi
10
10
  # @return [String] Zabbix API version number
11
11
  def initialize(client)
12
12
  @client = client
13
- @api_version = @client.api_request(method: 'apiinfo.version', params: {})
13
+ @version = @client.api_version()
14
14
  end
15
15
  end
16
16
  end
File without changes
File without changes
File without changes
@@ -30,9 +30,9 @@ class ZabbixApi
30
30
  def permissions(data)
31
31
  permission = data[:permission] || 2
32
32
  result = @client.api_request(
33
- method: 'usergroup.massAdd',
33
+ method: 'usergroup.update',
34
34
  params: {
35
- usrgrpids: [data[:usrgrpid]],
35
+ usrgrpid: data[:usrgrpid],
36
36
  rights: data[:hostgroupids].map { |t| { permission: permission, id: t } }
37
37
  }
38
38
  )
@@ -41,19 +41,13 @@ class ZabbixApi
41
41
 
42
42
  # Add users to usergroup using Zabbix API
43
43
  #
44
+ # @deprecated Zabbix has removed massAdd in favor of update.
44
45
  # @param data [Hash] Needs to include userids and usrgrpids to mass add users to groups
45
46
  # @raise [ApiError] Error returned when there is a problem with the Zabbix API call.
46
47
  # @raise [HttpError] Error raised when HTTP status from Zabbix Server response is not a 200 OK.
47
48
  # @return [Integer] Zabbix object id (usergroup)
48
49
  def add_user(data)
49
- result = @client.api_request(
50
- method: 'usergroup.massAdd',
51
- params: {
52
- usrgrpids: data[:usrgrpids],
53
- userids: data[:userids]
54
- }
55
- )
56
- result ? result['usrgrpids'][0].to_i : nil
50
+ update_users(data)
57
51
  end
58
52
 
59
53
  # Update users in usergroups using Zabbix API
@@ -63,12 +57,15 @@ class ZabbixApi
63
57
  # @raise [HttpError] Error raised when HTTP status from Zabbix Server response is not a 200 OK.
64
58
  # @return [Integer] Zabbix object id (usergroup)
65
59
  def update_users(data)
66
- result = @client.api_request(
67
- method: 'usergroup.massUpdate',
68
- params: {
69
- usrgrpids: data[:usrgrpids],
70
- userids: data[:userids]
60
+ user_groups = data[:usrgrpids].map do |t|
61
+ {
62
+ usrgrpid: t,
63
+ userids: data[:userids],
71
64
  }
65
+ end
66
+ result = @client.api_request(
67
+ method: 'usergroup.update',
68
+ params: user_groups,
72
69
  )
73
70
  result ? result['usrgrpids'][0].to_i : nil
74
71
  end
File without changes
@@ -31,12 +31,14 @@ class ZabbixApi
31
31
  def medias_helper(data, action)
32
32
  result = @client.api_request(
33
33
  method: "user.#{action}",
34
- params: {
35
- users: data[:userids].map { |t| { userid: t } },
36
- medias: data[:media]
37
- }
34
+ params: data[:userids].map do |t|
35
+ {
36
+ userid: t,
37
+ user_medias: data[:media],
38
+ }
39
+ end,
38
40
  )
39
- result ? result['mediaids'][0].to_i : nil
41
+ result ? result['userids'][0].to_i : nil
40
42
  end
41
43
 
42
44
  # Add media to users using Zabbix API
@@ -46,7 +48,7 @@ class ZabbixApi
46
48
  # @raise [HttpError] Error raised when HTTP status from Zabbix Server response is not a 200 OK.
47
49
  # @return [Integer] Zabbix object id (media)
48
50
  def add_medias(data)
49
- medias_helper(data, 'addMedia')
51
+ medias_helper(data, 'update')
50
52
  end
51
53
 
52
54
  # Update media for users using Zabbix API
@@ -56,7 +58,7 @@ class ZabbixApi
56
58
  # @raise [HttpError] Error raised when HTTP status from Zabbix Server response is not a 200 OK.
57
59
  # @return [Integer] Zabbix object id (user)
58
60
  def update_medias(data)
59
- medias_helper(data, 'updateMedia')
61
+ medias_helper(data, 'update')
60
62
  end
61
63
  end
62
64
  end
File without changes
@@ -18,6 +18,7 @@ class ZabbixApi
18
18
  # @return [String]
19
19
  def api_version
20
20
  @api_version ||= api_request(method: 'apiinfo.version', params: {})
21
+ @api_version
21
22
  end
22
23
 
23
24
  # Log in to the Zabbix Server and generate an auth token using the API
@@ -33,6 +34,13 @@ class ZabbixApi
33
34
  )
34
35
  end
35
36
 
37
+ # ZabbixApi::Basic.log does not like @client.options[:debug]
38
+ #
39
+ # @return [boolean]
40
+ def debug?
41
+ return ! @options || @options[:debug]
42
+ end
43
+
36
44
  # Initializes a new Client object
37
45
  #
38
46
  # @param options [Hash]
@@ -52,8 +60,9 @@ class ZabbixApi
52
60
  @proxy_port = @proxy_uri.port
53
61
  @proxy_user, @proxy_pass = @proxy_uri.userinfo.split(/:/) if @proxy_uri.userinfo
54
62
  end
55
- unless api_version =~ %r{^4.[0|2]\.\d+$}
56
- puts "[WARN] Zabbix API version: #{api_version} is not supported by this version of zabbixapi"
63
+ unless api_version =~ %r{^4.[0|4]\.\d+$}
64
+ message = "Zabbix API version: #{api_version} is not supported by this version of zabbixapi"
65
+ raise ZabbixApi::ApiError.new(message)
57
66
  end
58
67
 
59
68
  @auth_hash = auth
@@ -1,3 +1,3 @@
1
1
  class ZabbixApi
2
- VERSION = '4.1.2'.freeze
2
+ VERSION = '4.2.0'.freeze
3
3
  end
@@ -9,7 +9,7 @@ require 'zabbixapi/version'
9
9
  Gem::Specification.new do |spec|
10
10
  spec.add_dependency 'http', '~> 2.0'
11
11
  spec.add_dependency 'json', '~> 2.0'
12
- spec.add_development_dependency 'bundler', '~> 1.0'
12
+ spec.add_development_dependency 'bundler'
13
13
 
14
14
  spec.name = 'zabbixapi'
15
15
  spec.version = ZabbixApi::VERSION
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zabbixapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.2
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasiliev D.V.
8
8
  - Ivan Evtuhovich
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-10-25 00:00:00.000000000 Z
12
+ date: 2020-08-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: http
@@ -43,16 +43,16 @@ dependencies:
43
43
  name: bundler
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: '1.0'
48
+ version: '0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: '1.0'
55
+ version: '0'
56
56
  description: Allows you to work with zabbix api from ruby.
57
57
  email:
58
58
  - vadv.mkn@gmail.com
@@ -74,6 +74,7 @@ files:
74
74
  - lib/zabbixapi/classes/configurations.rb
75
75
  - lib/zabbixapi/classes/drules.rb
76
76
  - lib/zabbixapi/classes/errors.rb
77
+ - lib/zabbixapi/classes/events.rb
77
78
  - lib/zabbixapi/classes/graphs.rb
78
79
  - lib/zabbixapi/classes/hostgroups.rb
79
80
  - lib/zabbixapi/classes/hosts.rb
@@ -99,7 +100,7 @@ homepage: https://github.com/express42/zabbixapi
99
100
  licenses:
100
101
  - MIT
101
102
  metadata: {}
102
- post_install_message:
103
+ post_install_message:
103
104
  rdoc_options: []
104
105
  require_paths:
105
106
  - lib
@@ -114,8 +115,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
115
  - !ruby/object:Gem::Version
115
116
  version: '0'
116
117
  requirements: []
117
- rubygems_version: 3.0.3
118
- signing_key:
118
+ rubygems_version: 3.1.2
119
+ signing_key:
119
120
  specification_version: 4
120
121
  summary: Simple and lightweight ruby module for working with the Zabbix API
121
122
  test_files: []