Class: Openlayer::Client
- Inherits:
-
Object
- Object
- Openlayer::Client
- Defined in:
- lib/openlayer/client.rb
Constant Summary collapse
- BASE_URL =
"https://api.openlayer.com/v1/"
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
- #connection ⇒ Object
- #inference_pipeline(inference_pipeline_id) ⇒ Object
-
#initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
constructor
A new instance of Client.
- #load_project(name:) ⇒ Object
- #load_project_version(id:, payload: {}) ⇒ Object
- #presigned_url(object_name: nil, workspace_id: nil) ⇒ Object
Constructor Details
#initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 |
# File 'lib/openlayer/client.rb', line 12 def initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil) @api_key = api_key @adapter = adapter @stubs = stubs end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
10 11 12 |
# File 'lib/openlayer/client.rb', line 10 def adapter @adapter end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
10 11 12 |
# File 'lib/openlayer/client.rb', line 10 def api_key @api_key end |
Instance Method Details
#connection ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/openlayer/client.rb', line 37 def connection @connection ||= Faraday.new do |conn| conn.url_prefix = BASE_URL conn.request :authorization, "Bearer", api_key conn.request :json conn.response :json, content_type: "application/json" conn.adapter adapter, @stubs end end |
#inference_pipeline(inference_pipeline_id) ⇒ Object
18 19 20 |
# File 'lib/openlayer/client.rb', line 18 def inference_pipeline(inference_pipeline_id) InferencePipeline.new(self, inference_pipeline_id) end |
#load_project(name:) ⇒ Object
22 23 24 |
# File 'lib/openlayer/client.rb', line 22 def load_project(name:) Project.from_response self, connection.get("projects", project_search_params(name: name)) end |
#load_project_version(id:, payload: {}) ⇒ Object
33 34 35 |
# File 'lib/openlayer/client.rb', line 33 def load_project_version(id:, payload: {}) ProjectVersion.from_response self, connection.post("projects/#{id}/versions", payload) end |
#presigned_url(object_name: nil, workspace_id: nil) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/openlayer/client.rb', line 26 def presigned_url(object_name: nil, workspace_id: nil) handle_response connection.post( "storage/presigned-url?objectName=staging", presigned_url_params(object_name: object_name, workspace_id: workspace_id) ) end |