Class: GraylogAPI::Client
- Inherits:
-
Object
- Object
- GraylogAPI::Client
- Defined in:
- lib/graylogapi/client.rb,
lib/graylogapi/client/response.rb
Overview
The client is the entry point to the api
Defined Under Namespace
Classes: Response
Constant Summary collapse
- METHODS =
{ delete: Net::HTTP::Delete, get: Net::HTTP::Get, post: Net::HTTP::Post, put: Net::HTTP::Put }.freeze
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Options of object [Hash].
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ GraylogAPI::Client
constructor
Initializes a new Client object.
-
#json_request(method, path, params = {}) ⇒ Object
Make request to the API.
Constructor Details
#initialize(options = {}) ⇒ GraylogAPI::Client
Initializes a new Client object
22 23 24 25 26 |
# File 'lib/graylogapi/client.rb', line 22 def initialize( = {}) @options = uri = URI.parse([:base_url]) @http = Net::HTTP.new(uri.host, uri.port) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns options of object [Hash].
16 17 18 |
# File 'lib/graylogapi/client.rb', line 16 def @options end |
Instance Method Details
#json_request(method, path, params = {}) ⇒ Object
Make request to the API
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/graylogapi/client.rb', line 34 def json_request(method, path, params = {}) request = request(method, path, params) request.basic_auth([:user], [:pass]) request.add_field('Content-Type', 'application/json') response = @http.request(request) Response.new(response) rescue response end |