Class: EUVD::Client
- Inherits:
-
Object
- Object
- EUVD::Client
- Defined in:
- lib/euvd/client.rb
Overview
Client for the EUVD API.
All endpoints are GET-only and require no authentication.
JSON responses are returned as rich Sawyer::Resource objects
(or Array of them), so you can access fields as methods
instead of hash keys.
Constant Summary collapse
- BASE_URL =
'https://euvdservices.enisa.europa.eu/api'
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
Instance Method Summary collapse
- #downloads ⇒ EUVD::API::Downloads
-
#get(path, params = {}) ⇒ Sawyer::Resource, ...
Make a GET request and return parsed response data.
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #inspect ⇒ Object
- #meta ⇒ EUVD::API::Meta
- #observations ⇒ EUVD::API::Observations
- #records ⇒ EUVD::API::Records
- #vulnerabilities ⇒ EUVD::API::Vulnerabilities
Constructor Details
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
30 31 32 |
# File 'lib/euvd/client.rb', line 30 def agent @agent end |
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
30 31 32 |
# File 'lib/euvd/client.rb', line 30 def base_url @base_url end |
Instance Method Details
#downloads ⇒ EUVD::API::Downloads
62 63 64 |
# File 'lib/euvd/client.rb', line 62 def downloads API::Downloads.new(self) end |
#get(path, params = {}) ⇒ Sawyer::Resource, ...
Make a GET request and return parsed response data.
44 45 46 47 48 49 |
# File 'lib/euvd/client.rb', line 44 def get(path, params = {}) response = @agent.call(:get, path, nil, query: params) response = handle_status(response) validate_content_type!(response) response.data end |
#inspect ⇒ Object
76 77 78 79 80 81 |
# File 'lib/euvd/client.rb', line 76 def inspect format('#<%<class_name>s:0x%<object_id>x %<url>s>', class_name: self.class, object_id: object_id * 2, url: @base_url) end |
#observations ⇒ EUVD::API::Observations
72 73 74 |
# File 'lib/euvd/client.rb', line 72 def observations API::Observations.new(self) end |
#records ⇒ EUVD::API::Records
57 58 59 |
# File 'lib/euvd/client.rb', line 57 def records API::Records.new(self) end |
#vulnerabilities ⇒ EUVD::API::Vulnerabilities
52 53 54 |
# File 'lib/euvd/client.rb', line 52 def vulnerabilities API::Vulnerabilities.new(self) end |