ragios-client 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/ragios-client.rb +23 -11
- data/ragios-client.gemspec +3 -3
- data/spec/ragios-client_spec.rb +15 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94a6de0be7af241876c75561127cc5a7a052d1d9
|
4
|
+
data.tar.gz: 827f4091bcadbbfbd5a3e65efa654500b71ce8d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b1a9ec6cc9000930cffb6437bb3dd5780ba2a08d72068f25f4f3be8f1e5b40675764a607e1442ef84fbf88ea491102d043d093525f6b4596f63302f271097dd
|
7
|
+
data.tar.gz: f794a28bc5baee99daa9624c7fbb548a7fc3c23ea5dbfaa7bf163fd1735fe45fa714bfff4fb259330f960383ab97b81a9c6983935a893ccad0dd6c9bad9a6a4f
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
data/lib/ragios-client.rb
CHANGED
@@ -50,14 +50,24 @@ module Ragios
|
|
50
50
|
def update(monitor_id, options)
|
51
51
|
api_request { RestClient.put "#{address_port}/monitors/#{monitor_id}",generate_json(options), http_request_options }
|
52
52
|
end
|
53
|
+
def find_event(event_id)
|
54
|
+
api_request { RestClient.get "#{address_port}/events/#{event_id}/", auth_cookie }
|
55
|
+
end
|
56
|
+
def all_events(limit = nil)
|
57
|
+
params = limit ? "?take=#{limit}" : ""
|
58
|
+
api_request { RestClient.get "#{address_port}/events#{params}", auth_cookie }
|
59
|
+
end
|
60
|
+
def delete_event(event_id)
|
61
|
+
api_request { RestClient.delete "#{address_port}/events/#{event_id}", auth_cookie }
|
62
|
+
end
|
53
63
|
def events(monitor_id, startdate, enddate, limit=nil)
|
54
|
-
api_request { RestClient.get "#{address_port}/monitors/#{monitor_id}/events",
|
64
|
+
api_request { RestClient.get "#{address_port}/monitors/#{monitor_id}/events", options(startdate, enddate, limit) }
|
55
65
|
end
|
56
66
|
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}",
|
67
|
+
api_request { RestClient.get "#{address_port}/monitors/#{monitor_id}/events_by_type/#{type}", options(startdate, enddate, limit) }
|
58
68
|
end
|
59
69
|
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}",
|
70
|
+
api_request { RestClient.get "#{address_port}/monitors/#{monitor_id}/events_by_state/#{state}", options(startdate, enddate, limit) }
|
61
71
|
end
|
62
72
|
def test(monitor_id)
|
63
73
|
api_request { RestClient.post "#{address_port}/tests", {:id => monitor_id}, http_request_options }
|
@@ -65,11 +75,13 @@ module Ragios
|
|
65
75
|
|
66
76
|
private
|
67
77
|
def options(startdate, enddate, limit = nil)
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
78
|
+
params = {}
|
79
|
+
params[:start_date] = startdate
|
80
|
+
params[:end_date] = enddate
|
81
|
+
params[:take] = limit if limit
|
82
|
+
query_options = auth_cookie
|
83
|
+
query_options[:params] = params
|
84
|
+
query_options
|
73
85
|
end
|
74
86
|
def api_request
|
75
87
|
response = yield
|
@@ -83,12 +95,12 @@ private
|
|
83
95
|
end
|
84
96
|
|
85
97
|
def auth_cookie
|
86
|
-
{:cookies => {:
|
98
|
+
{:cookies => {:RagiosAuthSession => auth_session}}
|
87
99
|
end
|
88
100
|
|
89
101
|
def http_request_options
|
90
102
|
{:content_type => :json,
|
91
|
-
:cookies => {:
|
103
|
+
:cookies => {:RagiosAuthSession => auth_session}
|
92
104
|
}
|
93
105
|
end
|
94
106
|
|
@@ -108,7 +120,7 @@ private
|
|
108
120
|
return "" if [@username, @password].any? { |e| e.nil? }
|
109
121
|
auth = RestClient.post "#{address_port}/session", { :username=> @username, :password => @password}
|
110
122
|
hash = parse_json(auth)
|
111
|
-
hash[:
|
123
|
+
hash[:RagiosAuthSession]
|
112
124
|
rescue => e
|
113
125
|
raise_error(e)
|
114
126
|
end
|
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.7 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.7"
|
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 = "
|
14
|
+
s.date = "2015-01-19"
|
15
15
|
s.description = "ruby client for ragios"
|
16
16
|
s.email = "obioraakubue@yahoo.com"
|
17
17
|
s.extra_rdoc_files = [
|
data/spec/ragios-client_spec.rb
CHANGED
@@ -30,16 +30,27 @@ describe "Ragios Client" do
|
|
30
30
|
end
|
31
31
|
describe "#events" do
|
32
32
|
it "returns all events by monitor" do
|
33
|
-
|
34
|
-
|
33
|
+
sleep 2
|
34
|
+
events = @ragios.events(@query_monitor_id, "1980","2040")
|
35
|
+
events.should_not == 0
|
36
|
+
first_id = events.first[:monitor][:_id]
|
35
37
|
@query_monitor_id.should == first_id
|
36
|
-
@ragios.events(@query_monitor_id, "1980","
|
38
|
+
@ragios.events(@query_monitor_id, "1980","2040", 1).count.should == 1
|
37
39
|
end
|
38
40
|
end
|
39
41
|
describe "#events_by_state" do
|
40
42
|
it "returns a monitor's events by specified state" do
|
41
43
|
sleep 1
|
42
|
-
@ragios.events_by_state(@query_monitor_id, "passed", "1980","
|
44
|
+
@ragios.events_by_state(@query_monitor_id, "passed", "1980","2040",1).count.should == 1
|
45
|
+
end
|
46
|
+
end
|
47
|
+
describe "more events API" do
|
48
|
+
it "returns all events" do
|
49
|
+
event = @ragios.all_events(1).first
|
50
|
+
new_event = @ragios.find_event(event[:_id])
|
51
|
+
new_event.should == event
|
52
|
+
@ragios.delete_event(event[:_id])
|
53
|
+
expect { @ragios.find_event(event[:_id]) }.to raise_error(Ragios::ClientException)
|
43
54
|
end
|
44
55
|
end
|
45
56
|
after(:each) do
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- obi-a
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|