ragios-client 0.0.5 → 0.0.6
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 +4 -4
- data/README.rdoc +7 -1
- data/VERSION +1 -1
- data/lib/ragios-client.rb +22 -6
- data/ragios-client.gemspec +4 -4
- data/spec/ragios-client_spec.rb +51 -18
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08914572074ac34b5f24ea0b94c3f685627b7219
|
4
|
+
data.tar.gz: d3f6e3ff19d467df4ec5ba74479b2610ccf2542e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf423af3019cf3d6a3e3fdfdf0321e26de72bdb5abad9de4e00871703c7abbc5f74d8987dfef9d152129dbdb9b49dd92e6a2c4138b621a3137ff183661408f15
|
7
|
+
data.tar.gz: e36d0cb2c2dc0f176cfeac80477484c0876519e69b25c7c18e4dbe55cc3158da6676b23aa37724e02363e03de66060624654055c3249932156402bd586f9ef43
|
data/README.rdoc
CHANGED
@@ -23,7 +23,7 @@
|
|
23
23
|
plugin: "url_monitor"
|
24
24
|
}
|
25
25
|
|
26
|
-
ragios.
|
26
|
+
ragios.create monitor
|
27
27
|
|
28
28
|
ragios.find(monitor_id)
|
29
29
|
|
@@ -41,6 +41,12 @@
|
|
41
41
|
|
42
42
|
ragios.test(monitor_id)
|
43
43
|
|
44
|
+
ragios.events(monitor_id, start_date, end_date, limit)
|
45
|
+
|
46
|
+
ragios.events_by_type(monitor_id, event_type, start_date, end_date, limit)
|
47
|
+
|
48
|
+
ragios.events_by_state(monitor_id, state, start_date, end_date, limit)
|
49
|
+
|
44
50
|
ragios.address
|
45
51
|
#=> http://localhost
|
46
52
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/lib/ragios-client.rb
CHANGED
@@ -25,36 +25,52 @@ module Ragios
|
|
25
25
|
auth_session
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
28
|
+
def create(monitor)
|
29
29
|
api_request { RestClient.post "#{address_port}/monitors/", generate_json(monitor), http_request_options }
|
30
30
|
end
|
31
31
|
def find(monitor_id)
|
32
32
|
api_request { RestClient.get "#{address_port}/monitors/#{monitor_id}/", auth_cookie }
|
33
33
|
end
|
34
|
-
def all
|
35
|
-
|
34
|
+
def all(limit = nil)
|
35
|
+
params = limit ? "?take=#{limit}" : ""
|
36
|
+
api_request { RestClient.get "#{address_port}/monitors#{params}", auth_cookie }
|
36
37
|
end
|
37
38
|
def stop(monitor_id)
|
38
39
|
api_request { RestClient.put "#{address_port}/monitors/#{monitor_id}",{:status => "stopped"}, http_request_options }
|
39
40
|
end
|
40
|
-
def
|
41
|
+
def start(monitor_id)
|
41
42
|
api_request { RestClient.put "#{address_port}/monitors/#{monitor_id}",{:status => "active"},http_request_options }
|
42
43
|
end
|
43
44
|
def delete(monitor_id)
|
44
45
|
api_request { RestClient.delete "#{address_port}/monitors/#{monitor_id}", auth_cookie }
|
45
46
|
end
|
46
47
|
def where(options)
|
47
|
-
api_request { RestClient.get "#{address_port}/monitors?#{URI.encode_www_form(options)}", auth_cookie }
|
48
|
+
api_request { RestClient.get "#{address_port}/monitors/attributes?#{URI.encode_www_form(options)}", auth_cookie }
|
48
49
|
end
|
49
50
|
def update(monitor_id, options)
|
50
51
|
api_request { RestClient.put "#{address_port}/monitors/#{monitor_id}",generate_json(options), http_request_options }
|
51
52
|
end
|
52
|
-
|
53
|
+
def events(monitor_id, startdate, enddate, limit=nil)
|
54
|
+
api_request { RestClient.get "#{address_port}/monitors/#{monitor_id}/events", {params: options(startdate, enddate, limit)} }
|
55
|
+
end
|
56
|
+
def events_by_type(monitor_id, type, startdate, enddate, limit=nil)
|
57
|
+
api_request { RestClient.get "#{address_port}/monitors/#{monitor_id}/events_by_type/#{type}", {params: options(startdate, enddate, limit)} }
|
58
|
+
end
|
59
|
+
def events_by_state(monitor_id, state, startdate, enddate, limit=nil)
|
60
|
+
api_request { RestClient.get "#{address_port}/monitors/#{monitor_id}/events_by_state/#{state}", {params: options(startdate, enddate, limit)} }
|
61
|
+
end
|
53
62
|
def test(monitor_id)
|
54
63
|
api_request { RestClient.post "#{address_port}/tests", {:id => monitor_id}, http_request_options }
|
55
64
|
end
|
56
65
|
|
57
66
|
private
|
67
|
+
def options(startdate, enddate, limit = nil)
|
68
|
+
options = {}
|
69
|
+
options[:start_date] = startdate
|
70
|
+
options[:end_date] = enddate
|
71
|
+
options[:take] = limit if limit
|
72
|
+
options
|
73
|
+
end
|
58
74
|
def api_request
|
59
75
|
response = yield
|
60
76
|
parse_json(response)
|
data/ragios-client.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: ragios-client 0.0.
|
5
|
+
# stub: ragios-client 0.0.6 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "ragios-client"
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.6"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["obi-a"]
|
14
|
-
s.date = "2014-
|
14
|
+
s.date = "2014-12-27"
|
15
15
|
s.description = "ruby client for ragios"
|
16
16
|
s.email = "obioraakubue@yahoo.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
]
|
33
33
|
s.homepage = "http://github.com/obi-a/ragios-client"
|
34
34
|
s.licenses = ["MIT"]
|
35
|
-
s.rubygems_version = "2.
|
35
|
+
s.rubygems_version = "2.4.3"
|
36
36
|
s.summary = "Ruby client for ragios"
|
37
37
|
|
38
38
|
if s.respond_to? :specification_version then
|
data/spec/ragios-client_spec.rb
CHANGED
@@ -16,8 +16,38 @@ describe "Ragios Client" do
|
|
16
16
|
#@ragios = Ragios::Client.new(username: admin, password: password)
|
17
17
|
@ragios = Ragios::Client.new
|
18
18
|
end
|
19
|
-
describe "
|
20
|
-
|
19
|
+
describe "queries" do
|
20
|
+
before(:each) do
|
21
|
+
monitor = {
|
22
|
+
monitor: "Google",
|
23
|
+
url: "http://google.com",
|
24
|
+
every: "5m",
|
25
|
+
contact: "admin@mail.com",
|
26
|
+
via: ["gmail_notifier","twitter_notifier"],
|
27
|
+
plugin: plugin
|
28
|
+
}
|
29
|
+
@query_monitor_id = @ragios.create(monitor)[:_id]
|
30
|
+
end
|
31
|
+
describe "#events" do
|
32
|
+
it "returns all events by monitor" do
|
33
|
+
@ragios.events(@query_monitor_id, "1980","2015").should_not == 0
|
34
|
+
first_id = @ragios.events(@query_monitor_id, "1980","2015").first[:monitor][:_id]
|
35
|
+
@query_monitor_id.should == first_id
|
36
|
+
@ragios.events(@query_monitor_id, "1980","2015", 1).count.should == 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
describe "#events_by_state" do
|
40
|
+
it "returns a monitor's events by specified state" do
|
41
|
+
sleep 1
|
42
|
+
@ragios.events_by_state(@query_monitor_id, "passed", "1980","2015",1).count.should == 1
|
43
|
+
end
|
44
|
+
end
|
45
|
+
after(:each) do
|
46
|
+
@ragios.delete(@query_monitor_id)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
describe "#create" do
|
50
|
+
it "creates a monitor" do
|
21
51
|
monitor = {
|
22
52
|
monitor: "Google",
|
23
53
|
url: "http://google.com",
|
@@ -27,7 +57,7 @@ describe "Ragios Client" do
|
|
27
57
|
plugin: plugin
|
28
58
|
}
|
29
59
|
|
30
|
-
returned_monitor = @ragios.
|
60
|
+
returned_monitor = @ragios.create(monitor)
|
31
61
|
returned_monitor.should include(monitor)
|
32
62
|
monitor_id = returned_monitor[:_id]
|
33
63
|
|
@@ -35,7 +65,7 @@ describe "Ragios Client" do
|
|
35
65
|
@ragios.delete(monitor_id)
|
36
66
|
end
|
37
67
|
|
38
|
-
it "cannot
|
68
|
+
it "cannot create a monitor with no plugin" do
|
39
69
|
monitor = {
|
40
70
|
monitor: "Google",
|
41
71
|
url: "http://google.com",
|
@@ -44,14 +74,14 @@ describe "Ragios Client" do
|
|
44
74
|
via: "gmail_notifier"
|
45
75
|
}
|
46
76
|
begin
|
47
|
-
@ragios.
|
77
|
+
@ragios.create monitor
|
48
78
|
rescue => e
|
49
79
|
e.should be_an_instance_of Ragios::ClientException
|
50
80
|
e.message.should include("No Plugin Found")
|
51
81
|
end
|
52
82
|
end
|
53
83
|
|
54
|
-
it "cannot
|
84
|
+
it "cannot create a monitor with no notifier" do
|
55
85
|
monitor = {
|
56
86
|
monitor: "Google",
|
57
87
|
url: "http://google.com",
|
@@ -60,15 +90,15 @@ describe "Ragios Client" do
|
|
60
90
|
plugin: plugin
|
61
91
|
}
|
62
92
|
begin
|
63
|
-
@ragios.
|
93
|
+
@ragios.create monitor
|
64
94
|
rescue Exception => e
|
65
95
|
e.should be_an_instance_of Ragios::ClientException
|
66
96
|
e.message.should include("No Notifier Found")
|
67
97
|
end
|
68
98
|
end
|
69
99
|
|
70
|
-
it "cannot
|
71
|
-
expect{@ragios.
|
100
|
+
it "cannot create a badly formed monitor" do
|
101
|
+
expect{@ragios.create("bad data")}.to raise_error(JSON::GeneratorError)
|
72
102
|
end
|
73
103
|
end
|
74
104
|
describe "More API calls" do
|
@@ -84,7 +114,7 @@ describe "Ragios Client" do
|
|
84
114
|
tag: "test"
|
85
115
|
}
|
86
116
|
|
87
|
-
returned_monitor = @ragios.
|
117
|
+
returned_monitor = @ragios.create(@monitor)
|
88
118
|
@monitor_id = returned_monitor[:_id]
|
89
119
|
end
|
90
120
|
describe "#find" do
|
@@ -130,7 +160,7 @@ describe "Ragios Client" do
|
|
130
160
|
end
|
131
161
|
describe "#delete" do
|
132
162
|
it "deletes a monitor" do
|
133
|
-
new_monitor_id = @ragios.
|
163
|
+
new_monitor_id = @ragios.create(@monitor)[:_id]
|
134
164
|
@ragios.delete(new_monitor_id).should == {ok: true}
|
135
165
|
end
|
136
166
|
it "cannot delete a monitor that doesnt exist" do
|
@@ -156,23 +186,23 @@ describe "Ragios Client" do
|
|
156
186
|
expect { @ragios.stop(this_monitor_id) }.to raise_error(Ragios::ClientException, generate_json(error: "No monitor found with id = #{this_monitor_id}"))
|
157
187
|
end
|
158
188
|
end
|
159
|
-
describe "#
|
160
|
-
it "
|
189
|
+
describe "#start" do
|
190
|
+
it "starts a stopped monitor" do
|
161
191
|
@ragios.stop(@monitor_id)
|
162
192
|
stopped_monitor = @ragios.find(@monitor_id)
|
163
193
|
stopped_monitor[:status_].should == "stopped"
|
164
194
|
|
165
|
-
@ragios.
|
195
|
+
@ragios.start(@monitor_id).should == {ok: true}
|
166
196
|
|
167
197
|
active_monitor = @ragios.find(@monitor_id)
|
168
198
|
active_monitor[:status_].should == "active"
|
169
199
|
|
170
|
-
#
|
171
|
-
@ragios.
|
200
|
+
#start monitor is idempotent
|
201
|
+
@ragios.start(@monitor_id).should == {ok: true}
|
172
202
|
end
|
173
|
-
it "cannot
|
203
|
+
it "cannot start a monitor that dont exist" do
|
174
204
|
this_monitor_id = "dont_exist"
|
175
|
-
expect { @ragios.
|
205
|
+
expect { @ragios.start(this_monitor_id) }.to raise_error(Ragios::ClientException, generate_json(error: "No monitor found with id = #{this_monitor_id}"))
|
176
206
|
end
|
177
207
|
end
|
178
208
|
describe "#all" do
|
@@ -181,6 +211,9 @@ describe "Ragios Client" do
|
|
181
211
|
retrieved_monitors.should_not be_empty
|
182
212
|
retrieved_monitors.should be_an_instance_of Array
|
183
213
|
end
|
214
|
+
it "can limit the number of monitors retrieved" do
|
215
|
+
@ragios.all(limit = 1).count.should == 1
|
216
|
+
end
|
184
217
|
end
|
185
218
|
after(:each) do
|
186
219
|
@ragios.delete(@monitor_id)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ragios-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- obi-a
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
148
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.
|
149
|
+
rubygems_version: 2.4.3
|
150
150
|
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: Ruby client for ragios
|