Class: Weaviate::Connection
- Inherits:
-
Object
- Object
- Weaviate::Connection
- Defined in:
- lib/weaviate/connection.rb,
sig/weaviate.rbs
Overview
A minimal HTTP client built on Net::HTTP
Defined Under Namespace
Constant Summary collapse
- METHODS =
{ get: Net::HTTP::Get, head: Net::HTTP::Head, post: Net::HTTP::Post, put: Net::HTTP::Put, patch: Net::HTTP::Patch, delete: Net::HTTP::Delete }
- ERRORS =
{ 400 => BadRequestError, 401 => UnauthorizedError, 403 => ForbiddenError, 404 => ResourceNotFound, 409 => ConflictError, 422 => UnprocessableEntityError }
- FILTERED_HEADERS =
/authorization|api-key|token|secret|access-key/i
Instance Attribute Summary collapse
-
#headers ⇒ Hash[String, String]
readonly
Returns the value of attribute headers.
-
#logger ⇒ Logger?
readonly
Returns the value of attribute logger.
-
#proxy ⇒ URI::Generic?
readonly
Returns the value of attribute proxy.
-
#timeouts ⇒ Hash[Symbol, Numeric]
readonly
Returns the value of attribute timeouts.
-
#url ⇒ String
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #delete {|arg0| ... } ⇒ Response
- #get {|arg0| ... } ⇒ Response
- #head {|arg0| ... } ⇒ Response
-
#initialize(url:, headers: {}, logger: nil, proxy: nil, open_timeout: nil, read_timeout: nil, write_timeout: nil) ⇒ Connection
constructor
A new instance of Connection.
- #patch {|arg0| ... } ⇒ Response
- #post {|arg0| ... } ⇒ Response
- #put {|arg0| ... } ⇒ Response
Constructor Details
#initialize(url:, headers: {}, logger: nil, proxy: nil, open_timeout: nil, read_timeout: nil, write_timeout: nil) ⇒ Connection
Returns a new instance of Connection.
40 41 42 43 44 45 46 |
# File 'lib/weaviate/connection.rb', line 40 def initialize(url:, headers: {}, logger: nil, proxy: nil, open_timeout: nil, read_timeout: nil, write_timeout: nil) @url = url.chomp("/") @headers = headers @logger = logger @proxy = proxy && URI(proxy) @timeouts = {open_timeout: open_timeout, read_timeout: read_timeout, write_timeout: write_timeout}.compact end |
Instance Attribute Details
#headers ⇒ Hash[String, String] (readonly)
Returns the value of attribute headers.
38 39 40 |
# File 'lib/weaviate/connection.rb', line 38 def headers @headers end |
#logger ⇒ Logger? (readonly)
Returns the value of attribute logger.
38 39 40 |
# File 'lib/weaviate/connection.rb', line 38 def logger @logger end |
#proxy ⇒ URI::Generic? (readonly)
Returns the value of attribute proxy.
38 39 40 |
# File 'lib/weaviate/connection.rb', line 38 def proxy @proxy end |
#timeouts ⇒ Hash[Symbol, Numeric] (readonly)
Returns the value of attribute timeouts.
38 39 40 |
# File 'lib/weaviate/connection.rb', line 38 def timeouts @timeouts end |
#url ⇒ String (readonly)
Returns the value of attribute url.
38 39 40 |
# File 'lib/weaviate/connection.rb', line 38 def url @url end |
Instance Method Details
#delete {|arg0| ... } ⇒ Response
144 |
# File 'sig/weaviate.rbs', line 144
def delete: (String path) ?{ (Request) -> void } -> Response
|
#get {|arg0| ... } ⇒ Response
139 |
# File 'sig/weaviate.rbs', line 139
def get: (String path) ?{ (Request) -> void } -> Response
|
#head {|arg0| ... } ⇒ Response
140 |
# File 'sig/weaviate.rbs', line 140
def head: (String path) ?{ (Request) -> void } -> Response
|
#patch {|arg0| ... } ⇒ Response
143 |
# File 'sig/weaviate.rbs', line 143
def patch: (String path) ?{ (Request) -> void } -> Response
|
#post {|arg0| ... } ⇒ Response
141 |
# File 'sig/weaviate.rbs', line 141
def post: (String path) ?{ (Request) -> void } -> Response
|
#put {|arg0| ... } ⇒ Response
142 |
# File 'sig/weaviate.rbs', line 142
def put: (String path) ?{ (Request) -> void } -> Response
|