zabbix_api_gem 0.2.0 → 0.3.0

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
  SHA256:
3
- metadata.gz: b0dc1d0b264ed6c36ccbf9253f530dfdd2fc7ff2eaa7c060dc9324944f00384f
4
- data.tar.gz: 482565767d3e1a484223b28330f271ce9ab7ab51177b615f619a46c71199f227
3
+ metadata.gz: 2931f6d3227276d1c3120dfc210eae257e5224898a6374964eeb54b7a3644b0d
4
+ data.tar.gz: 397ac9e648e3c451bbc3a3334a1672067fbfa4fc271e00dff774bdf103aa8af2
5
5
  SHA512:
6
- metadata.gz: 37ac9b890f3a197fb09a746dbd1e027a0b2a43b81feeb7ff8e03a9a1a302d47f213ed0a3e15a1464ba2a93181f0d290763a498df09c1bae36d212040066b94e4
7
- data.tar.gz: '09094378b9e9616719bce054bced52e39ea3718abec9f9031cc0a78c8bdc2c6600617dc7989177c1a59125cc79a317962b61ff98ba7719dfc41f7ecef2016ecf'
6
+ metadata.gz: f2daaeb129b09004f106f296cee34f9137ad856b02e60c862697ce66b424ea770b6572cbc169d0b1c46023947988ff38055eed9ee1a56fd723290b8e2809458e
7
+ data.tar.gz: 0ea22a6f6b11afa5fd5499aac69bc425bed70a23710a669878a44789ef82aaa8440835bb37254de0144dbdeccc3a337ddae8ee68a2268e08a8cb459102f4c3d9
data/CHANGELOG.md CHANGED
@@ -5,3 +5,7 @@
5
5
 
6
6
  ## [0.2.0] - 2024-02-12
7
7
  - Include events and method to get object by id
8
+
9
+ ## [0.3.0] - 2024-02-20
10
+ - ConfigurationError raised if not configured properly
11
+
data/Gemfile CHANGED
@@ -7,4 +7,5 @@ gemspec
7
7
 
8
8
  gem 'rake', '~> 13.0'
9
9
  gem 'rubocop', '~> 1.7'
10
+ gem 'simplecov', require: false, group: :test
10
11
  gem 'wrapi'
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
1
  # Zabbix API
2
+ [![Version](https://img.shields.io/gem/v/zabbix_api_gem.svg)](https://rubygems.org/gems/zabbix_api_gem)
3
+ [![Maintainability](https://api.codeclimate.com/v1/badges/de2999161abdc8179fde/maintainability)](https://codeclimate.com/github/jancotanis/zabbix/maintainability)
4
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/de2999161abdc8179fde/test_coverage)](https://codeclimate.com/github/jancotanis/zabbix/test_coverage)
2
5
 
3
6
  This is a wrapper for the Zabix rest API. You can see the API endpoints here https://www.zabbix.com/documentation/current/en/manual/api/reference/
4
7
 
@@ -24,7 +27,7 @@ Or install it yourself as:
24
27
 
25
28
  Before you start making the requests to API provide the client id and client secret and email/password using the configuration wrapping.
26
29
 
27
- ```
30
+ ```ruby
28
31
  require 'zabbix_api_gem'
29
32
 
30
33
  # use do block
@@ -47,7 +50,7 @@ end
47
50
 
48
51
  ## Resources
49
52
  ### Authentication
50
- ```
53
+ ```ruby
51
54
  # setup configuration
52
55
  #
53
56
  client.login
@@ -59,7 +62,7 @@ client.login
59
62
 
60
63
  ### Server settings
61
64
  Return zabbix server settings
62
- ```
65
+ ```ruby
63
66
  puts client.settings.default_theme
64
67
  ```
65
68
 
@@ -93,7 +96,7 @@ end
93
96
 
94
97
  ## Contributing
95
98
 
96
- Bug reports and pull requests are welcome on GitHub at https://github.com/jancotanis/veeam.
99
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jancotanis/zabbix.
97
100
 
98
101
  ## License
99
102
 
data/Rakefile CHANGED
@@ -1,12 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'bundler/gem_tasks'
4
+ require 'dotenv'
4
5
  require 'rake/testtask'
5
6
 
7
+ Dotenv.load
8
+
9
+ system './bin/cc-test-reporter before-build'
10
+
6
11
  Rake::TestTask.new(:test) do |t|
7
12
  t.libs << 'test'
8
13
  t.libs << 'lib'
9
14
  t.test_files = FileList['test/**/*_test.rb']
15
+ at_exit do
16
+ system './bin/cc-test-reporter after-build'
17
+ end
10
18
  end
11
19
 
12
20
  require 'rubocop/rake_task'
Binary file
@@ -3,12 +3,12 @@ module Zabbix
3
3
  # Deals with authentication flow and stores it within global configuration
4
4
  module Authentication
5
5
 
6
- # https://helpcenter.veeam.com/docs/vac/rest/reference/vspc-rest.html?ver=80#tag/Authentication
7
- # Authorize to the Veeam portal and return access_token
6
+ # Authorize to the Zabbix portal using the access_token
7
+ # @see https://www.zabbix.com/documentation/current/en/manual/api
8
8
  def login(options = {})
9
- raise ArgumentError, "Accesstoken/api-key not set" unless access_token
9
+ raise ConfigurationError, "Accesstoken/api-key not set" unless access_token
10
10
  # only bearer token needed
11
- # will do sanitty check if token if valid
11
+ # will do sanity check if token if valid
12
12
  rpc_call('settings.get')
13
13
  rescue RPCError => e
14
14
  raise AuthenticationError, e
data/lib/zabbix/client.rb CHANGED
@@ -6,7 +6,7 @@ module Zabbix
6
6
  # @note All methods have been separated into modules and follow the same grouping used in api docs
7
7
  # @see https://www.zabbix.com/documentation/current/en/manual/api
8
8
  class Client < API
9
-
9
+ private
10
10
  def self.def_rpc_call(method, rpc_method, id_field = nil)
11
11
  self.send(:define_method, method) do |params = nil|
12
12
  rpc_call(rpc_method, params)
@@ -24,13 +24,14 @@ module Zabbix
24
24
  end
25
25
  end
26
26
 
27
- def_rpc_call(:api_info, 'api.info')
28
- def_rpc_call(:settings, 'settings.get')
29
- def_rpc_call(:hostgroups, 'hostgroup.get', 'groupids')
30
- def_rpc_call(:hosts, 'host.get', 'hostids')
31
- def_rpc_call(:problems, 'problem.get', 'problemids')
32
- def_rpc_call(:events, 'event.get', 'eventids')
33
- def_rpc_call(:acknowledge_events, 'event.acknowledge')
27
+ public
28
+ def_rpc_call :api_info, 'api.info'
29
+ def_rpc_call :settings, 'settings.get'
30
+ def_rpc_call :hostgroups, 'hostgroup.get', 'groupids'
31
+ def_rpc_call :hosts, 'host.get', 'hostids'
32
+ def_rpc_call :problems, 'problem.get', 'problemids'
33
+ def_rpc_call :events, 'event.get', 'eventids'
34
+ def_rpc_call :acknowledge_events, 'event.acknowledge'
34
35
 
35
36
  end
36
37
  end
data/lib/zabbix/error.rb CHANGED
@@ -6,6 +6,9 @@ module Zabbix
6
6
  # Raised when Zabbix RPC protocol returns error object
7
7
  class RPCError < ZabbixError; end
8
8
 
9
+ # Raised when Zabbix not configured correctly
10
+ class ConfigurationError < ZabbixError; end
11
+
9
12
  # Error when authentication fails
10
13
  class AuthenticationError < ZabbixError; end
11
14
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zabbix
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
data/zabbix.gemspec CHANGED
@@ -33,4 +33,5 @@ Gem::Specification.new do |s|
33
33
  s.add_development_dependency 'dotenv'
34
34
  s.add_development_dependency 'minitest'
35
35
  s.add_development_dependency 'rubocop'
36
+ s.add_development_dependency 'simplecov'
36
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zabbix_api_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janco Tanis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-12 00:00:00.000000000 Z
11
+ date: 2024-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description:
84
98
  email: gems@jancology.com
85
99
  executables: []
@@ -92,6 +106,7 @@ files:
92
106
  - Gemfile
93
107
  - README.md
94
108
  - Rakefile
109
+ - bin/cc-test-reporter.exe
95
110
  - lib/zabbix.rb
96
111
  - lib/zabbix/api.rb
97
112
  - lib/zabbix/authentication.rb