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.
-
#request(method, path, params = {}) ⇒ GraylogAPI::Client::Response
Make request to the API.
Constructor Details
#initialize(options = {}) ⇒ GraylogAPI::Client
Initializes a new Client object
28 29 30 31 32 |
# File 'lib/graylogapi/client.rb', line 28 def initialize( = {}) @options = @options[:base_url] = [:base_url].chomp('/') @http = http_client(URI.parse([:base_url]), ) 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
#request(method, path, params = {}) ⇒ GraylogAPI::Client::Response
Make request to the API
40 41 42 43 44 45 46 47 |
# File 'lib/graylogapi/client.rb', line 40 def request(method, path, params = {}) request = make_request(method, path, params) request.add_field('Content-Type', 'application/json') request.basic_auth(username, password) response = @http.request(request) Response.new(response) end |