Class: Ragios::Client
- Inherits:
-
Object
- Object
- Ragios::Client
- Defined in:
- lib/ragios-client.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #all(limit = nil) ⇒ Object
- #all_events(limit = nil) ⇒ Object
- #create(monitor) ⇒ Object
- #delete(monitor_id) ⇒ Object
- #delete_event(event_id) ⇒ Object
- #events(monitor_id, startdate, enddate, limit = nil) ⇒ Object
- #events_by_state(monitor_id, state, startdate, enddate, limit = nil) ⇒ Object
- #events_by_type(monitor_id, type, startdate, enddate, limit = nil) ⇒ Object
- #find(monitor_id) ⇒ Object
- #find_event(event_id) ⇒ Object
-
#initialize(args = {}) ⇒ Client
constructor
A new instance of Client.
- #login(username, password) ⇒ Object
- #start(monitor_id) ⇒ Object
- #stop(monitor_id) ⇒ Object
- #test(monitor_id) ⇒ Object
- #update(monitor_id, options) ⇒ Object
- #where(options) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Client
Returns a new instance of Client.
15 16 17 18 19 20 |
# File 'lib/ragios-client.rb', line 15 def initialize(args = {}) @address = args.fetch(:address, 'http://127.0.0.1') @port = args.fetch(:port, '5041') @username = args.fetch(:username, nil) @password = args.fetch(:password, nil) end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
10 11 12 |
# File 'lib/ragios-client.rb', line 10 def address @address end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
13 14 15 |
# File 'lib/ragios-client.rb', line 13 def password @password end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
11 12 13 |
# File 'lib/ragios-client.rb', line 11 def port @port end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
12 13 14 |
# File 'lib/ragios-client.rb', line 12 def username @username end |
Instance Method Details
#all(limit = nil) ⇒ Object
34 35 36 37 |
# File 'lib/ragios-client.rb', line 34 def all(limit = nil) params = limit ? "?take=#{limit}" : "" api_request { RestClient.get "#{address_port}/monitors#{params}", } end |
#all_events(limit = nil) ⇒ Object
56 57 58 59 |
# File 'lib/ragios-client.rb', line 56 def all_events(limit = nil) params = limit ? "?take=#{limit}" : "" api_request { RestClient.get "#{address_port}/events#{params}", } end |
#create(monitor) ⇒ Object
28 29 30 |
# File 'lib/ragios-client.rb', line 28 def create(monitor) api_request { RestClient.post "#{address_port}/monitors/", generate_json(monitor), } end |
#delete(monitor_id) ⇒ Object
44 45 46 |
# File 'lib/ragios-client.rb', line 44 def delete(monitor_id) api_request { RestClient.delete "#{address_port}/monitors/#{monitor_id}", } end |
#delete_event(event_id) ⇒ Object
60 61 62 |
# File 'lib/ragios-client.rb', line 60 def delete_event(event_id) api_request { RestClient.delete "#{address_port}/events/#{event_id}", } end |
#events(monitor_id, startdate, enddate, limit = nil) ⇒ Object
63 64 65 |
# File 'lib/ragios-client.rb', line 63 def events(monitor_id, startdate, enddate, limit=nil) api_request { RestClient.get "#{address_port}/monitors/#{monitor_id}/events", (startdate, enddate, limit) } end |
#events_by_state(monitor_id, state, startdate, enddate, limit = nil) ⇒ Object
69 70 71 |
# File 'lib/ragios-client.rb', line 69 def events_by_state(monitor_id, state, startdate, enddate, limit=nil) api_request { RestClient.get "#{address_port}/monitors/#{monitor_id}/events_by_state/#{state}", (startdate, enddate, limit) } end |
#events_by_type(monitor_id, type, startdate, enddate, limit = nil) ⇒ Object
66 67 68 |
# File 'lib/ragios-client.rb', line 66 def events_by_type(monitor_id, type, startdate, enddate, limit=nil) api_request { RestClient.get "#{address_port}/monitors/#{monitor_id}/events_by_type/#{type}", (startdate, enddate, limit) } end |
#find(monitor_id) ⇒ Object
31 32 33 |
# File 'lib/ragios-client.rb', line 31 def find(monitor_id) api_request { RestClient.get "#{address_port}/monitors/#{monitor_id}/", } end |
#find_event(event_id) ⇒ Object
53 54 55 |
# File 'lib/ragios-client.rb', line 53 def find_event(event_id) api_request { RestClient.get "#{address_port}/events/#{event_id}/", } end |
#login(username, password) ⇒ Object
22 23 24 25 26 |
# File 'lib/ragios-client.rb', line 22 def login(username,password) @username = username @password = password auth_session end |
#start(monitor_id) ⇒ Object
41 42 43 |
# File 'lib/ragios-client.rb', line 41 def start(monitor_id) api_request { RestClient.put "#{address_port}/monitors/#{monitor_id}",{:status => "active"}, } end |
#stop(monitor_id) ⇒ Object
38 39 40 |
# File 'lib/ragios-client.rb', line 38 def stop(monitor_id) api_request { RestClient.put "#{address_port}/monitors/#{monitor_id}",{:status => "stopped"}, } end |
#test(monitor_id) ⇒ Object
72 73 74 |
# File 'lib/ragios-client.rb', line 72 def test(monitor_id) api_request { RestClient.post "#{address_port}/tests", {:id => monitor_id}, } end |
#update(monitor_id, options) ⇒ Object
50 51 52 |
# File 'lib/ragios-client.rb', line 50 def update(monitor_id, ) api_request { RestClient.put "#{address_port}/monitors/#{monitor_id}",generate_json(), } end |
#where(options) ⇒ Object
47 48 49 |
# File 'lib/ragios-client.rb', line 47 def where() api_request { RestClient.get "#{address_port}/monitors/attributes?#{URI.encode_www_form()}", } end |