Class: SolidLog::UI::ApiClient
- Inherits:
-
Object
- Object
- SolidLog::UI::ApiClient
- Defined in:
- lib/solid_log/ui/api_client.rb
Defined Under Namespace
Classes: AuthenticationError, ConnectionError, NotFoundError, ParseError, RequestError, ServerError
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#all_facets ⇒ Object
GET /api/v1/facets/all.
-
#entries(params = {}) ⇒ Object
GET /api/v1/entries.
-
#entry(id) ⇒ Object
GET /api/v1/entries/:id.
-
#facets(field) ⇒ Object
GET /api/v1/facets.
-
#health ⇒ Object
GET /api/v1/health.
-
#initialize(base_url: nil, token: nil) ⇒ ApiClient
constructor
A new instance of ApiClient.
-
#job_timeline(job_id) ⇒ Object
GET /api/v1/timelines/job/:job_id.
-
#request_timeline(request_id) ⇒ Object
GET /api/v1/timelines/request/:request_id.
-
#search(query, params = {}) ⇒ Object
POST /api/v1/search.
Constructor Details
#initialize(base_url: nil, token: nil) ⇒ ApiClient
Returns a new instance of ApiClient.
10 11 12 13 14 15 16 |
# File 'lib/solid_log/ui/api_client.rb', line 10 def initialize(base_url: nil, token: nil) @base_url = base_url || SolidLog::UI.configuration.service_url @token = token || SolidLog::UI.configuration.service_token raise ArgumentError, "base_url required for API client" if @base_url.blank? raise ArgumentError, "token required for API client" if @token.blank? end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
8 9 10 |
# File 'lib/solid_log/ui/api_client.rb', line 8 def base_url @base_url end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
8 9 10 |
# File 'lib/solid_log/ui/api_client.rb', line 8 def token @token end |
Instance Method Details
#all_facets ⇒ Object
GET /api/v1/facets/all
39 40 41 |
# File 'lib/solid_log/ui/api_client.rb', line 39 def all_facets get("/api/v1/facets/all") end |
#entries(params = {}) ⇒ Object
GET /api/v1/entries
19 20 21 |
# File 'lib/solid_log/ui/api_client.rb', line 19 def entries(params = {}) get("/api/v1/entries", params) end |
#entry(id) ⇒ Object
GET /api/v1/entries/:id
24 25 26 |
# File 'lib/solid_log/ui/api_client.rb', line 24 def entry(id) get("/api/v1/entries/#{id}") end |
#facets(field) ⇒ Object
GET /api/v1/facets
34 35 36 |
# File 'lib/solid_log/ui/api_client.rb', line 34 def facets(field) get("/api/v1/facets", { field: field }) end |
#health ⇒ Object
GET /api/v1/health
54 55 56 |
# File 'lib/solid_log/ui/api_client.rb', line 54 def health get("/api/v1/health") end |
#job_timeline(job_id) ⇒ Object
GET /api/v1/timelines/job/:job_id
49 50 51 |
# File 'lib/solid_log/ui/api_client.rb', line 49 def job_timeline(job_id) get("/api/v1/timelines/job/#{job_id}") end |
#request_timeline(request_id) ⇒ Object
GET /api/v1/timelines/request/:request_id
44 45 46 |
# File 'lib/solid_log/ui/api_client.rb', line 44 def request_timeline(request_id) get("/api/v1/timelines/request/#{request_id}") end |
#search(query, params = {}) ⇒ Object
POST /api/v1/search
29 30 31 |
# File 'lib/solid_log/ui/api_client.rb', line 29 def search(query, params = {}) post("/api/v1/search", { q: query }.merge(params)) end |