Class: Pvectl::Config::Models::ResolvedConfig
- Inherits:
-
Object
- Object
- Pvectl::Config::Models::ResolvedConfig
- Defined in:
- lib/pvectl/config/models/resolved_config.rb
Overview
Represents the final resolved configuration ready for use.
ResolvedConfig is an immutable value object containing all settings needed to connect to a Proxmox server. It is created by merging configuration from file, environment variables, and CLI options.
Constant Summary collapse
- DEFAULT_TIMEOUT =
Default values for retry/timeout settings
30- DEFAULT_RETRY_COUNT =
3- DEFAULT_RETRY_DELAY =
1- DEFAULT_MAX_RETRY_DELAY =
30- DEFAULT_RETRY_WRITES =
false
Instance Attribute Summary collapse
-
#auth_type ⇒ Symbol
readonly
Authentication type (:token or :password).
-
#certificate_authority ⇒ String?
readonly
Path to CA certificate file.
-
#context_name ⇒ String
readonly
Name of the active context.
-
#default_node ⇒ String?
readonly
Default node for operations.
-
#max_retry_delay ⇒ Integer
readonly
Maximum delay cap for exponential backoff.
-
#password ⇒ String?
readonly
Password for password auth.
-
#retry_count ⇒ Integer
readonly
Maximum retry attempts.
-
#retry_delay ⇒ Integer
readonly
Base delay between retries in seconds.
-
#retry_writes ⇒ Boolean
readonly
Whether to retry write operations.
-
#server ⇒ String
readonly
Proxmox server URL.
-
#timeout ⇒ Integer
readonly
Request timeout in seconds.
-
#token_id ⇒ String?
readonly
API token ID.
-
#token_secret ⇒ String?
readonly
API token secret.
-
#username ⇒ String?
readonly
Username for password auth.
-
#verify_ssl ⇒ Boolean
readonly
Whether to verify SSL certificates.
Instance Method Summary collapse
-
#initialize(context_name:, server:, auth_type:, verify_ssl: true, certificate_authority: nil, token_id: nil, token_secret: nil, username: nil, password: nil, default_node: nil, timeout: nil, retry_count: nil, retry_delay: nil, max_retry_delay: nil, retry_writes: nil) ⇒ ResolvedConfig
constructor
Creates a new ResolvedConfig instance.
-
#password_auth? ⇒ Boolean
Checks if this config uses password authentication.
-
#to_connection_options ⇒ Hash
Converts the config to options hash for proxmox-api gem.
-
#token_auth? ⇒ Boolean
Checks if this config uses API token authentication.
Constructor Details
#initialize(context_name:, server:, auth_type:, verify_ssl: true, certificate_authority: nil, token_id: nil, token_secret: nil, username: nil, password: nil, default_node: nil, timeout: nil, retry_count: nil, retry_delay: nil, max_retry_delay: nil, retry_writes: nil) ⇒ ResolvedConfig
Creates a new ResolvedConfig instance.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/pvectl/config/models/resolved_config.rb', line 95 def initialize(context_name:, server:, auth_type:, verify_ssl: true, certificate_authority: nil, token_id: nil, token_secret: nil, username: nil, password: nil, default_node: nil, timeout: nil, retry_count: nil, retry_delay: nil, max_retry_delay: nil, retry_writes: nil) @context_name = context_name @server = server @verify_ssl = verify_ssl @certificate_authority = @auth_type = auth_type @token_id = token_id @token_secret = token_secret @username = username @password = password @default_node = default_node # Apply defaults for retry/timeout settings @timeout = timeout || DEFAULT_TIMEOUT @retry_count = retry_count || DEFAULT_RETRY_COUNT @retry_delay = retry_delay || DEFAULT_RETRY_DELAY @max_retry_delay = max_retry_delay || DEFAULT_MAX_RETRY_DELAY @retry_writes = retry_writes.nil? ? DEFAULT_RETRY_WRITES : retry_writes end |
Instance Attribute Details
#auth_type ⇒ Symbol (readonly)
Returns authentication type (:token or :password).
46 47 48 |
# File 'lib/pvectl/config/models/resolved_config.rb', line 46 def auth_type @auth_type end |
#certificate_authority ⇒ String? (readonly)
Returns path to CA certificate file.
43 44 45 |
# File 'lib/pvectl/config/models/resolved_config.rb', line 43 def @certificate_authority end |
#context_name ⇒ String (readonly)
Returns name of the active context.
34 35 36 |
# File 'lib/pvectl/config/models/resolved_config.rb', line 34 def context_name @context_name end |
#default_node ⇒ String? (readonly)
Returns default node for operations.
61 62 63 |
# File 'lib/pvectl/config/models/resolved_config.rb', line 61 def default_node @default_node end |
#max_retry_delay ⇒ Integer (readonly)
Returns maximum delay cap for exponential backoff.
73 74 75 |
# File 'lib/pvectl/config/models/resolved_config.rb', line 73 def max_retry_delay @max_retry_delay end |
#password ⇒ String? (readonly)
Returns password for password auth.
58 59 60 |
# File 'lib/pvectl/config/models/resolved_config.rb', line 58 def password @password end |
#retry_count ⇒ Integer (readonly)
Returns maximum retry attempts.
67 68 69 |
# File 'lib/pvectl/config/models/resolved_config.rb', line 67 def retry_count @retry_count end |
#retry_delay ⇒ Integer (readonly)
Returns base delay between retries in seconds.
70 71 72 |
# File 'lib/pvectl/config/models/resolved_config.rb', line 70 def retry_delay @retry_delay end |
#retry_writes ⇒ Boolean (readonly)
Returns whether to retry write operations.
76 77 78 |
# File 'lib/pvectl/config/models/resolved_config.rb', line 76 def retry_writes @retry_writes end |
#server ⇒ String (readonly)
Returns Proxmox server URL.
37 38 39 |
# File 'lib/pvectl/config/models/resolved_config.rb', line 37 def server @server end |
#timeout ⇒ Integer (readonly)
Returns request timeout in seconds.
64 65 66 |
# File 'lib/pvectl/config/models/resolved_config.rb', line 64 def timeout @timeout end |
#token_id ⇒ String? (readonly)
Returns API token ID.
49 50 51 |
# File 'lib/pvectl/config/models/resolved_config.rb', line 49 def token_id @token_id end |
#token_secret ⇒ String? (readonly)
Returns API token secret.
52 53 54 |
# File 'lib/pvectl/config/models/resolved_config.rb', line 52 def token_secret @token_secret end |
#username ⇒ String? (readonly)
Returns username for password auth.
55 56 57 |
# File 'lib/pvectl/config/models/resolved_config.rb', line 55 def username @username end |
#verify_ssl ⇒ Boolean (readonly)
Returns whether to verify SSL certificates.
40 41 42 |
# File 'lib/pvectl/config/models/resolved_config.rb', line 40 def verify_ssl @verify_ssl end |
Instance Method Details
#password_auth? ⇒ Boolean
Checks if this config uses password authentication.
129 130 131 |
# File 'lib/pvectl/config/models/resolved_config.rb', line 129 def password_auth? auth_type == :password end |
#to_connection_options ⇒ Hash
Converts the config to options hash for proxmox-api gem.
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/pvectl/config/models/resolved_config.rb', line 152 def = { server: server, verify_ssl: verify_ssl } if token_auth? [:token] = token_id [:secret] = token_secret else [:username] = username [:password] = password end end |
#token_auth? ⇒ Boolean
Checks if this config uses API token authentication.
122 123 124 |
# File 'lib/pvectl/config/models/resolved_config.rb', line 122 def token_auth? auth_type == :token end |