Class: Algolia::Configuration
- Inherits:
-
Object
- Object
- Algolia::Configuration
- Defined in:
- lib/algolia/configuration.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#app_id ⇒ Object
Returns the value of attribute app_id.
-
#client_side_validation ⇒ true, false
Set this to false to skip client side validation in the operation.
-
#compression_type ⇒ Object
Returns the value of attribute compression_type.
-
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
-
#header_params ⇒ Object
Returns the value of attribute header_params.
-
#hosts ⇒ Object
Returns the value of attribute hosts.
-
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
-
#request_id_enabled ⇒ true, ...
Whether the transport sends a Request-ID header, minted once per call and reused across its retry attempts.
-
#requester ⇒ Object
Returns the value of attribute requester.
-
#transformation_options ⇒ Object
Returns the value of attribute transformation_options.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
-
#write_timeout ⇒ Object
Returns the value of attribute write_timeout.
Class Method Summary collapse
-
.default ⇒ Object
The default Configuration object.
Instance Method Summary collapse
- #add_user_agent_segment(segment, version = nil) ⇒ Object
-
#initialize(app_id, api_key, hosts, client_name, opts = {}) {|_self| ... } ⇒ Configuration
constructor
A new instance of Configuration.
- #set_client_api_key(api_key) ⇒ Object
Constructor Details
#initialize(app_id, api_key, hosts, client_name, opts = {}) {|_self| ... } ⇒ Configuration
Returns a new instance of Configuration.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/algolia/configuration.rb', line 30 def initialize(app_id, api_key, hosts, client_name, opts = {}) @hosts = hosts @app_id = app_id @api_key = api_key @client_side_validation = opts[:client_side_validation].nil? ? true : opts[:client_side_validation] @connect_timeout = opts[:connect_timeout] @read_timeout = opts[:read_timeout] @write_timeout = opts[:write_timeout] @compression_type = opts[:compression_type] || "none" @requester = opts[:requester] @transformation_options = opts[:transformation_options] @request_id_enabled = opts[:request_id_enabled] @user_agent = UserAgent.new.add(client_name, VERSION) if opts[:user_agent_segments] opts[:user_agent_segments].each do |segment| @user_agent.add(segment) end end @header_params = { "X-Algolia-Application-Id" => app_id, "X-Algolia-API-Key" => api_key, "Content-Type" => "application/json", "User-Agent" => @user_agent.value } @header_params.transform_keys!(&:downcase) yield(self) if block_given? end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
3 4 5 |
# File 'lib/algolia/configuration.rb', line 3 def api_key @api_key end |
#app_id ⇒ Object
Returns the value of attribute app_id.
3 4 5 |
# File 'lib/algolia/configuration.rb', line 3 def app_id @app_id end |
#client_side_validation ⇒ true, false
Set this to false to skip client side validation in the operation. Default to true.
20 21 22 |
# File 'lib/algolia/configuration.rb', line 20 def client_side_validation @client_side_validation end |
#compression_type ⇒ Object
Returns the value of attribute compression_type.
3 4 5 |
# File 'lib/algolia/configuration.rb', line 3 def compression_type @compression_type end |
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
3 4 5 |
# File 'lib/algolia/configuration.rb', line 3 def connect_timeout @connect_timeout end |
#header_params ⇒ Object
Returns the value of attribute header_params.
3 4 5 |
# File 'lib/algolia/configuration.rb', line 3 def header_params @header_params end |
#hosts ⇒ Object
Returns the value of attribute hosts.
3 4 5 |
# File 'lib/algolia/configuration.rb', line 3 def hosts @hosts end |
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
3 4 5 |
# File 'lib/algolia/configuration.rb', line 3 def read_timeout @read_timeout end |
#request_id_enabled ⇒ true, ...
Whether the transport sends a Request-ID header, minted once per call and reused across its retry attempts. When nil, each generated client applies its per-client default (on for the search, recommend and composition APIs, off elsewhere); an explicit true or false always wins and may be flipped at any time. A caller-supplied Request-ID is never overwritten.
28 29 30 |
# File 'lib/algolia/configuration.rb', line 28 def request_id_enabled @request_id_enabled end |
#requester ⇒ Object
Returns the value of attribute requester.
3 4 5 |
# File 'lib/algolia/configuration.rb', line 3 def requester @requester end |
#transformation_options ⇒ Object
Returns the value of attribute transformation_options.
3 4 5 |
# File 'lib/algolia/configuration.rb', line 3 def @transformation_options end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
3 4 5 |
# File 'lib/algolia/configuration.rb', line 3 def user_agent @user_agent end |
#write_timeout ⇒ Object
Returns the value of attribute write_timeout.
3 4 5 |
# File 'lib/algolia/configuration.rb', line 3 def write_timeout @write_timeout end |
Class Method Details
.default ⇒ Object
The default Configuration object.
71 72 73 |
# File 'lib/algolia/configuration.rb', line 71 def self.default @@default ||= Configuration.new end |
Instance Method Details
#add_user_agent_segment(segment, version = nil) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/algolia/configuration.rb', line 75 def add_user_agent_segment(segment, version = nil) @user_agent.add(segment, version) @header_params["user-agent"] = @user_agent.value self end |
#set_client_api_key(api_key) ⇒ Object
63 64 65 66 67 68 |
# File 'lib/algolia/configuration.rb', line 63 def set_client_api_key(api_key) @api_key = api_key @header_params["X-Algolia-API-Key"] = api_key self end |