Class: IcingaRest::Request
- Inherits:
-
Object
- Object
- IcingaRest::Request
- Defined in:
- lib/icinga_rest/request.rb
Overview
Wrapper to simplify constructing the http GET request to access the Icinga REST API
Instance Attribute Summary collapse
-
#authkey ⇒ Object
The Icinga server.
-
#count_column ⇒ Object
The Icinga server.
-
#filter ⇒ Object
The Icinga server.
-
#host ⇒ Object
The Icinga server.
-
#output ⇒ Object
The Icinga server.
-
#target ⇒ Object
The Icinga server.
Instance Method Summary collapse
-
#get ⇒ Object
The standard URI library blows up with the malformed URLs required to access the Icinga REST API, but addressable works fine.
-
#initialize(params) ⇒ Request
constructor
A new instance of Request.
- #to_url ⇒ Object
Constructor Details
#initialize(params) ⇒ Request
Returns a new instance of Request.
11 12 13 14 15 16 17 18 |
# File 'lib/icinga_rest/request.rb', line 11 def initialize(params) @host = params[:host] @target = params[:target] @filter = params[:filter] @count_column = params[:count_column] @authkey = params[:authkey] @output = params[:output] end |
Instance Attribute Details
#authkey ⇒ Object
The Icinga server
4 5 6 |
# File 'lib/icinga_rest/request.rb', line 4 def authkey @authkey end |
#count_column ⇒ Object
The Icinga server
4 5 6 |
# File 'lib/icinga_rest/request.rb', line 4 def count_column @count_column end |
#filter ⇒ Object
The Icinga server
4 5 6 |
# File 'lib/icinga_rest/request.rb', line 4 def filter @filter end |
#host ⇒ Object
The Icinga server
4 5 6 |
# File 'lib/icinga_rest/request.rb', line 4 def host @host end |
#output ⇒ Object
The Icinga server
4 5 6 |
# File 'lib/icinga_rest/request.rb', line 4 def output @output end |
#target ⇒ Object
The Icinga server
4 5 6 |
# File 'lib/icinga_rest/request.rb', line 4 def target @target end |
Instance Method Details
#get ⇒ Object
The standard URI library blows up with the malformed URLs required to access the Icinga REST API, but addressable works fine.
23 24 25 26 27 |
# File 'lib/icinga_rest/request.rb', line 23 def get uri = Addressable::URI.parse to_url r = Net::HTTP.get_response uri.normalize r.code == '200' ? r.body : '' end |
#to_url ⇒ Object
29 30 31 |
# File 'lib/icinga_rest/request.rb', line 29 def to_url "http://%s/icinga-web/web/api/%s/%s/authkey=%s/%s" % [host, target, , authkey, output] end |