Module: Smplkit::Config
- Defined in:
- lib/smplkit/config/client.rb,
lib/smplkit/config/models.rb,
lib/smplkit/config/helpers.rb
Defined Under Namespace
Modules: Discovery, Helpers, ItemType Classes: Config, ConfigChangeEvent, ConfigClient, ConfigEnvironment, ConfigItem, LiveConfigProxy
Class Method Summary collapse
-
.config_transport(api_key:, base_url:, profile:, base_domain:, scheme:, debug:, extra_headers:) ⇒ Object
Build a standalone config transport and resolve the app base URL.
-
.resolve_parent_id(parent) ⇒ Object
Normalize a
parentargument to a config id string.
Class Method Details
.config_transport(api_key:, base_url:, profile:, base_domain:, scheme:, debug:, extra_headers:) ⇒ Object
Build a standalone config transport and resolve the app base URL.
base_url/api_key are used directly when supplied (the path a top-level client takes after it has already resolved them); otherwise the management config resolver fills in whatever is missing (+~/.smplkit+ / env vars / defaults). The app base URL is returned alongside so a standalone client can open its own WebSocket against the event gateway.
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/smplkit/config/client.rb', line 252 def self.config_transport(api_key:, base_url:, profile:, base_domain:, scheme:, debug:, extra_headers:) cfg = ConfigResolution.resolve_management_config( profile: profile, api_key: api_key, base_domain: base_domain, scheme: scheme, debug: debug ) resolved_key = api_key.nil? ? cfg.api_key : api_key merged = {} merged.merge!(cfg.extra_headers || {}) merged.merge!(extra_headers || {}) tcfg = ConfigResolution::ResolvedManagementConfig.new( api_key: resolved_key, base_domain: cfg.base_domain, scheme: cfg.scheme, debug: cfg.debug, extra_headers: merged ) app_url = ConfigResolution.service_url(cfg.scheme, "app", cfg.base_domain) transport = Transport.build_api_client(SmplkitGeneratedClient::Config, "config", tcfg, base_url: base_url) [transport, app_url, resolved_key] end |
.resolve_parent_id(parent) ⇒ Object
Normalize a parent argument to a config id string.
236 237 238 239 240 241 242 243 |
# File 'lib/smplkit/config/client.rb', line 236 def self.resolve_parent_id(parent) return parent if parent.nil? || parent.is_a?(String) if parent.id.nil? || parent.id == "" raise ArgumentError, "parent config must be saved (have an id) before being used as a parent" end parent.id end |