zabbix_api_gem 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -0
- data/README.md +7 -4
- data/Rakefile +8 -0
- data/bin/cc-test-reporter.exe +0 -0
- data/lib/zabbix/authentication.rb +4 -4
- data/lib/zabbix/client.rb +9 -8
- data/lib/zabbix/error.rb +3 -0
- data/lib/zabbix/version.rb +1 -1
- data/zabbix.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2931f6d3227276d1c3120dfc210eae257e5224898a6374964eeb54b7a3644b0d
|
4
|
+
data.tar.gz: 397ac9e648e3c451bbc3a3334a1672067fbfa4fc271e00dff774bdf103aa8af2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2daaeb129b09004f106f296cee34f9137ad856b02e60c862697ce66b424ea770b6572cbc169d0b1c46023947988ff38055eed9ee1a56fd723290b8e2809458e
|
7
|
+
data.tar.gz: 0ea22a6f6b11afa5fd5499aac69bc425bed70a23710a669878a44789ef82aaa8440835bb37254de0144dbdeccc3a337ddae8ee68a2268e08a8cb459102f4c3d9
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
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/
|
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
|
-
#
|
7
|
-
#
|
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
|
9
|
+
raise ConfigurationError, "Accesstoken/api-key not set" unless access_token
|
10
10
|
# only bearer token needed
|
11
|
-
# will do
|
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
|
-
|
28
|
-
def_rpc_call
|
29
|
-
def_rpc_call
|
30
|
-
def_rpc_call
|
31
|
-
def_rpc_call
|
32
|
-
def_rpc_call
|
33
|
-
def_rpc_call
|
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
|
data/lib/zabbix/version.rb
CHANGED
data/zabbix.gemspec
CHANGED
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.
|
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-
|
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
|