Class: Latitude::API::Configuration
- Inherits:
-
Object
- Object
- Latitude::API::Configuration
- Defined in:
- lib/latitude/api/configuration.rb
Constant Summary collapse
- DEFAULT_API_BASE =
"https://api.latitude.sh"- DEFAULT_OPEN_TIMEOUT =
30- DEFAULT_READ_TIMEOUT =
80- DEFAULT_WRITE_TIMEOUT =
30- DEFAULT_MAX_NETWORK_RETRIES =
0- DEFAULT_INITIAL_NETWORK_RETRY_DELAY =
0.5
- DEFAULT_MAX_NETWORK_RETRY_DELAY =
5.0- DEFAULT_SENSITIVE_FIELDS =
%w[ authorization public_key private_key password api_key token kubeconfig credentials ipmi_password ].freeze
Instance Attribute Summary collapse
-
#api_base ⇒ Object
Returns the value of attribute api_base.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_version ⇒ Object
Returns the value of attribute api_version.
-
#app_info ⇒ Object
Returns the value of attribute app_info.
-
#ca_bundle_path ⇒ Object
Returns the value of attribute ca_bundle_path.
-
#ca_store ⇒ Object
Returns the value of attribute ca_store.
-
#enable_telemetry ⇒ Object
Returns the value of attribute enable_telemetry.
-
#initial_network_retry_delay ⇒ Object
Returns the value of attribute initial_network_retry_delay.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_network_retries ⇒ Object
Returns the value of attribute max_network_retries.
-
#max_network_retry_delay ⇒ Object
Returns the value of attribute max_network_retry_delay.
-
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
-
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
-
#sensitive_fields ⇒ Object
Returns the value of attribute sensitive_fields.
-
#verify_ssl_certs ⇒ Object
Returns the value of attribute verify_ssl_certs.
-
#write_timeout ⇒ Object
Returns the value of attribute write_timeout.
Instance Method Summary collapse
- #api_base_uri ⇒ Object
- #dup_with(**overrides) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate_api_key! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/latitude/api/configuration.rb', line 44 def initialize @api_key = nil @api_base = DEFAULT_API_BASE @api_version = nil @open_timeout = DEFAULT_OPEN_TIMEOUT @read_timeout = DEFAULT_READ_TIMEOUT @write_timeout = DEFAULT_WRITE_TIMEOUT @max_network_retries = DEFAULT_MAX_NETWORK_RETRIES @initial_network_retry_delay = DEFAULT_INITIAL_NETWORK_RETRY_DELAY @max_network_retry_delay = DEFAULT_MAX_NETWORK_RETRY_DELAY @proxy = nil @verify_ssl_certs = true @ca_bundle_path = nil @ca_store = nil @logger = nil @log_level = :info @app_info = nil @enable_telemetry = true @sensitive_fields = DEFAULT_SENSITIVE_FIELDS.dup end |
Instance Attribute Details
#api_base ⇒ Object
Returns the value of attribute api_base.
25 26 27 |
# File 'lib/latitude/api/configuration.rb', line 25 def api_base @api_base end |
#api_key ⇒ Object
Returns the value of attribute api_key.
25 26 27 |
# File 'lib/latitude/api/configuration.rb', line 25 def api_key @api_key end |
#api_version ⇒ Object
Returns the value of attribute api_version.
25 26 27 |
# File 'lib/latitude/api/configuration.rb', line 25 def api_version @api_version end |
#app_info ⇒ Object
Returns the value of attribute app_info.
25 26 27 |
# File 'lib/latitude/api/configuration.rb', line 25 def app_info @app_info end |
#ca_bundle_path ⇒ Object
Returns the value of attribute ca_bundle_path.
25 26 27 |
# File 'lib/latitude/api/configuration.rb', line 25 def ca_bundle_path @ca_bundle_path end |
#ca_store ⇒ Object
Returns the value of attribute ca_store.
25 26 27 |
# File 'lib/latitude/api/configuration.rb', line 25 def ca_store @ca_store end |
#enable_telemetry ⇒ Object
Returns the value of attribute enable_telemetry.
25 26 27 |
# File 'lib/latitude/api/configuration.rb', line 25 def enable_telemetry @enable_telemetry end |
#initial_network_retry_delay ⇒ Object
Returns the value of attribute initial_network_retry_delay.
25 26 27 |
# File 'lib/latitude/api/configuration.rb', line 25 def initial_network_retry_delay @initial_network_retry_delay end |
#log_level ⇒ Object
Returns the value of attribute log_level.
25 26 27 |
# File 'lib/latitude/api/configuration.rb', line 25 def log_level @log_level end |
#logger ⇒ Object
Returns the value of attribute logger.
25 26 27 |
# File 'lib/latitude/api/configuration.rb', line 25 def logger @logger end |
#max_network_retries ⇒ Object
Returns the value of attribute max_network_retries.
25 26 27 |
# File 'lib/latitude/api/configuration.rb', line 25 def max_network_retries @max_network_retries end |
#max_network_retry_delay ⇒ Object
Returns the value of attribute max_network_retry_delay.
25 26 27 |
# File 'lib/latitude/api/configuration.rb', line 25 def max_network_retry_delay @max_network_retry_delay end |
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
25 26 27 |
# File 'lib/latitude/api/configuration.rb', line 25 def open_timeout @open_timeout end |
#proxy ⇒ Object
Returns the value of attribute proxy.
25 26 27 |
# File 'lib/latitude/api/configuration.rb', line 25 def proxy @proxy end |
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
25 26 27 |
# File 'lib/latitude/api/configuration.rb', line 25 def read_timeout @read_timeout end |
#sensitive_fields ⇒ Object
Returns the value of attribute sensitive_fields.
25 26 27 |
# File 'lib/latitude/api/configuration.rb', line 25 def sensitive_fields @sensitive_fields end |
#verify_ssl_certs ⇒ Object
Returns the value of attribute verify_ssl_certs.
25 26 27 |
# File 'lib/latitude/api/configuration.rb', line 25 def verify_ssl_certs @verify_ssl_certs end |
#write_timeout ⇒ Object
Returns the value of attribute write_timeout.
25 26 27 |
# File 'lib/latitude/api/configuration.rb', line 25 def write_timeout @write_timeout end |
Instance Method Details
#api_base_uri ⇒ Object
74 75 76 77 78 |
# File 'lib/latitude/api/configuration.rb', line 74 def api_base_uri URI.parse(@api_base) rescue URI::InvalidURIError => e raise ConfigurationError, "api_base is not a valid URL: #{@api_base.inspect} (#{e.message})" end |
#dup_with(**overrides) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/latitude/api/configuration.rb', line 65 def dup_with(**overrides) copy = Configuration.new instance_variables.each do |ivar| copy.instance_variable_set(ivar, instance_variable_get(ivar)) end overrides.each { |k, v| copy.public_send("#{k}=", v) } copy end |
#validate_api_key! ⇒ Object
80 81 82 83 84 85 |
# File 'lib/latitude/api/configuration.rb', line 80 def validate_api_key! return unless @api_key.nil? || @api_key.to_s.empty? raise ConfigurationError, "No API key provided. Set it via Latitude.api_key = '...' or pass api_key: in request options." end |