Class: Tenable::Configuration
- Inherits:
-
Object
- Object
- Tenable::Configuration
- Defined in:
- lib/tenable/configuration.rb
Overview
Holds and validates all configuration options for the Tenable client.
Configuration values can be passed directly or read from environment variables (TENABLE_ACCESS_KEY, TENABLE_SECRET_KEY).
Constant Summary collapse
- DEFAULTS =
{ base_url: 'https://cloud.tenable.com', timeout: 30, open_timeout: 10, max_retries: 3 }.freeze
Instance Attribute Summary collapse
-
#access_key ⇒ String
readonly
The API access key.
-
#base_url ⇒ String
readonly
The API base URL.
-
#logger ⇒ Logger?
readonly
Optional logger instance.
-
#max_retries ⇒ Integer
readonly
The maximum number of retry attempts.
-
#open_timeout ⇒ Integer
readonly
The connection open timeout in seconds.
-
#secret_key ⇒ String
readonly
The API secret key.
-
#timeout ⇒ Integer
readonly
The request timeout in seconds.
Instance Method Summary collapse
-
#initialize(access_key: nil, secret_key: nil, base_url: nil, timeout: nil, open_timeout: nil, max_retries: nil, logger: nil) ⇒ Configuration
constructor
Creates a new Configuration instance.
Constructor Details
#initialize(access_key: nil, secret_key: nil, base_url: nil, timeout: nil, open_timeout: nil, max_retries: nil, logger: nil) ⇒ Configuration
Creates a new Configuration instance.
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/tenable/configuration.rb', line 47 def initialize(access_key: nil, secret_key: nil, base_url: nil, timeout: nil, open_timeout: nil, max_retries: nil, logger: nil) @access_key = access_key || ENV.fetch('TENABLE_ACCESS_KEY', nil) @secret_key = secret_key || ENV.fetch('TENABLE_SECRET_KEY', nil) @base_url = base_url || DEFAULTS[:base_url] @timeout = timeout || DEFAULTS[:timeout] @open_timeout = open_timeout || DEFAULTS[:open_timeout] @max_retries = max_retries.nil? ? DEFAULTS[:max_retries] : max_retries @logger = logger validate! freeze end |
Instance Attribute Details
#access_key ⇒ String (readonly)
Returns the API access key.
10 11 12 |
# File 'lib/tenable/configuration.rb', line 10 def access_key @access_key end |
#base_url ⇒ String (readonly)
Returns the API base URL.
16 17 18 |
# File 'lib/tenable/configuration.rb', line 16 def base_url @base_url end |
#logger ⇒ Logger? (readonly)
Returns optional logger instance.
28 29 30 |
# File 'lib/tenable/configuration.rb', line 28 def logger @logger end |
#max_retries ⇒ Integer (readonly)
Returns the maximum number of retry attempts.
25 26 27 |
# File 'lib/tenable/configuration.rb', line 25 def max_retries @max_retries end |
#open_timeout ⇒ Integer (readonly)
Returns the connection open timeout in seconds.
22 23 24 |
# File 'lib/tenable/configuration.rb', line 22 def open_timeout @open_timeout end |
#secret_key ⇒ String (readonly)
Returns the API secret key.
13 14 15 |
# File 'lib/tenable/configuration.rb', line 13 def secret_key @secret_key end |
#timeout ⇒ Integer (readonly)
Returns the request timeout in seconds.
19 20 21 |
# File 'lib/tenable/configuration.rb', line 19 def timeout @timeout end |