Class: Nagios::Splunk::RestClient
- Inherits:
-
Object
- Object
- Nagios::Splunk::RestClient
- Defined in:
- lib/nagios/splunk/rest_client.rb
Overview
Rest client which communicates with Splunk via REST API
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Class Method Summary collapse
-
.debug(value = nil) ⇒ Object
turn on/off debugging.
Instance Method Summary collapse
-
#get(url) ⇒ Net::HTTPRespose
send HTTP request to the server.
-
#initialize(server_url) ⇒ RestClient
constructor
parse server url string and set up intance variables example: user:pass@localhost:8089/.
Constructor Details
#initialize(server_url) ⇒ RestClient
parse server url string and set up intance variables example: user:pass@localhost:8089/
21 22 23 24 25 26 27 |
# File 'lib/nagios/splunk/rest_client.rb', line 21 def initialize(server_url) uri = URI.parse(server_url) @host = uri.host @port = uri.port @username = uri.user @password = uri.password end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
9 10 11 |
# File 'lib/nagios/splunk/rest_client.rb', line 9 def token @token end |
Class Method Details
.debug(value = nil) ⇒ Object
turn on/off debugging
13 14 15 16 |
# File 'lib/nagios/splunk/rest_client.rb', line 13 def self.debug(value = nil) @debug = value if value @debug end |
Instance Method Details
#get(url) ⇒ Net::HTTPRespose
send HTTP request to the server
32 33 34 35 |
# File 'lib/nagios/splunk/rest_client.rb', line 32 def get(url) login unless token response = client.request(request(url, token)) end |