zbx 1.1.2 → 1.1.3
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.
- data/README.md +2 -2
- data/lib/zbx.rb +29 -2
- data/lib/zbx/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -39,12 +39,12 @@ end
|
|
39
39
|
|
40
40
|
|
41
41
|
ZBX.client do
|
42
|
-
set
|
42
|
+
set user: user, password: password
|
43
43
|
set api_url: 'http://api_url'
|
44
44
|
host.get hostids: 10160
|
45
45
|
end
|
46
46
|
|
47
|
-
client = ZBX.client(
|
47
|
+
client = ZBX.client(user, password, api_url)
|
48
48
|
client.host.get hostids: 10160
|
49
49
|
|
50
50
|
host_api = client.host
|
data/lib/zbx.rb
CHANGED
@@ -7,7 +7,34 @@ require 'json'
|
|
7
7
|
require 'net/http'
|
8
8
|
|
9
9
|
module ZBX
|
10
|
-
|
11
|
-
API
|
10
|
+
class << self
|
11
|
+
# zbx module API, user should call this method to initialize a
|
12
|
+
# zabbxi-api client.
|
13
|
+
def client user=nil, password=nil, api_url=nil, &block
|
14
|
+
API.new(user || configuration.user,
|
15
|
+
password || configuration.password,
|
16
|
+
api_url || configuration.api_url,
|
17
|
+
&block)
|
18
|
+
end
|
19
|
+
|
20
|
+
# configuration
|
21
|
+
def config
|
22
|
+
yield(configuration)
|
23
|
+
configuration
|
24
|
+
end
|
25
|
+
|
26
|
+
def reset_configuration!
|
27
|
+
@configuration = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def configuration
|
33
|
+
@configuration ||= Struct.new(:user, :password, :api_url) {
|
34
|
+
def [] option
|
35
|
+
__send__ option
|
36
|
+
end
|
37
|
+
}.new
|
38
|
+
end
|
12
39
|
end
|
13
40
|
end
|
data/lib/zbx/version.rb
CHANGED