smplkit 1.0.24 → 1.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 716ac41c7f53fba00f896876246f36ca44e3db661aa3306d647675972edd64e9
4
- data.tar.gz: 96d4b2c60234daea039444a9e05ee9441adcf84bc99cd21b690fa504ab1b5ff8
3
+ metadata.gz: c5467982be79b924356216ec4b8a4158589ac70802cefbee82c819f5d390281d
4
+ data.tar.gz: 93f707d0f9951956db82350eb298d4a14f42ccb2effca770da64f9084e6908d4
5
5
  SHA512:
6
- metadata.gz: 04dc39a5fdc6e5d809686e9d0b5fc8468771722ff4b50fd8cf644e9baa9be89815213facb0dee695c7d832c7d45c04f1090837300eddd3bb7e95020fa62a4900
7
- data.tar.gz: faf0afd4dc392a14c44fcf91d34d631f8c819aa85561296839246346ef429015df0fa16d5d6427f931da1ea2960b0177c45f07ff070b4299aa11282d878b759c
6
+ metadata.gz: 50b0fd8883a16c7b2aff012f26c956a6b5c2f1e3501cb08a02b5641fa360eb1ca60cca85acb0290a141f416497be3a0f0c3a62ced5c6593a357667a149911dec
7
+ data.tar.gz: 36731f5638835a9939bd712574377f4f6ad7279883ad535f430c986173322c1d30044f95f2b47225c67b85c8eb2d5212ca9e736c4d6f5989b05b8c7260c43d68
@@ -10,13 +10,19 @@ module Smplkit
10
10
  class AuditClient
11
11
  attr_reader :events, :forwarders, :functions
12
12
 
13
- def initialize(api_key:, base_url:, timeout: 10.0)
13
+ SDK_OWNED_HEADERS = %w[authorization content-type user-agent].freeze
14
+
15
+ def initialize(api_key:, base_url:, timeout: 10.0, extra_headers: nil)
14
16
  cfg = SmplkitGeneratedClient::Audit::Configuration.new
15
17
  cfg.host = URI.parse(base_url).host
16
18
  cfg.scheme = URI.parse(base_url).scheme
17
19
  cfg.access_token = api_key
18
20
  cfg.timeout = timeout
19
21
  api_client = SmplkitGeneratedClient::Audit::ApiClient.new(cfg)
22
+ api_client.default_headers["User-Agent"] = "smplkit-ruby-sdk/#{Smplkit::VERSION}"
23
+ extra_headers&.each do |k, v|
24
+ api_client.default_headers[k] = v unless SDK_OWNED_HEADERS.include?(k.downcase)
25
+ end
20
26
  events_api = SmplkitGeneratedClient::Audit::EventsApi.new(api_client)
21
27
  forwarders_api = SmplkitGeneratedClient::Audit::ForwardersApi.new(api_client)
22
28
  @events = Events.new(events_api)
@@ -43,7 +43,8 @@ module Smplkit
43
43
  end
44
44
 
45
45
  def initialize(api_key: nil, environment: nil, service: nil, profile: nil, # rubocop:disable Metrics/AbcSize
46
- base_domain: nil, scheme: nil, debug: nil, telemetry: nil)
46
+ base_domain: nil, scheme: nil, debug: nil, telemetry: nil,
47
+ extra_headers: nil)
47
48
  cfg = ConfigResolution.resolve_config(
48
49
  profile: profile, api_key: api_key, base_domain: base_domain, scheme: scheme,
49
50
  environment: environment, service: service, debug: debug, telemetry: telemetry
@@ -67,7 +68,8 @@ module Smplkit
67
68
  mgmt_cfg = ConfigResolution::ResolvedManagementConfig.new(
68
69
  api_key: cfg.api_key, base_domain: cfg.base_domain, scheme: cfg.scheme, debug: cfg.debug
69
70
  )
70
- @manage = ManagementClient.from_resolved(mgmt_cfg)
71
+ @extra_headers = extra_headers
72
+ @manage = ManagementClient.from_resolved(mgmt_cfg, extra_headers: extra_headers)
71
73
 
72
74
  app_url = ConfigResolution.service_url(cfg.scheme, "app", cfg.base_domain)
73
75
  flags_url = ConfigResolution.service_url(cfg.scheme, "flags", cfg.base_domain)
@@ -87,7 +89,8 @@ module Smplkit
87
89
  flags_base_url: flags_url, app_base_url: app_url)
88
90
  @logging = Logging::LoggingClient.new(self, manage: @manage, metrics: @metrics,
89
91
  logging_base_url: logging_url, app_base_url: app_url)
90
- @audit = Audit::AuditClient.new(api_key: cfg.api_key, base_url: audit_url)
92
+ @audit = Audit::AuditClient.new(api_key: cfg.api_key, base_url: audit_url,
93
+ extra_headers: extra_headers)
91
94
 
92
95
  @closed = false
93
96
  schedule_periodic_flush
@@ -170,6 +173,7 @@ module Smplkit
170
173
  def _api_key = @api_key
171
174
  def _app_base_url = @app_base_url
172
175
  def _metrics = @metrics
176
+ def _extra_headers = @extra_headers
173
177
 
174
178
  def _ensure_ws
175
179
  @_ensure_ws ||= begin
@@ -30,12 +30,12 @@ module Smplkit
30
30
  attr_reader :contexts, :context_types, :environments, :account_settings,
31
31
  :config, :flags, :loggers, :log_groups
32
32
 
33
- def self.from_resolved(resolved)
34
- new(_resolved: resolved)
33
+ def self.from_resolved(resolved, extra_headers: nil)
34
+ new(_resolved: resolved, extra_headers: extra_headers)
35
35
  end
36
36
 
37
37
  def initialize(api_key: nil, base_domain: nil, scheme: nil, profile: nil,
38
- debug: nil, _resolved: nil)
38
+ debug: nil, _resolved: nil, extra_headers: nil)
39
39
  cfg = _resolved ||
40
40
  ConfigResolution.resolve_management_config(
41
41
  api_key: api_key, base_domain: base_domain, scheme: scheme,
@@ -45,6 +45,7 @@ module Smplkit
45
45
 
46
46
  @resolved = cfg
47
47
 
48
+ @extra_headers = extra_headers
48
49
  @app_api_client = build_api_client(SmplkitGeneratedClient::App, "app", cfg)
49
50
  @config_api_client = build_api_client(SmplkitGeneratedClient::Config, "config", cfg)
50
51
  @flags_api_client = build_api_client(SmplkitGeneratedClient::Flags, "flags", cfg)
@@ -71,6 +72,8 @@ module Smplkit
71
72
  def _flags_http = @flags_api_client
72
73
  def _logging_http = @logging_api_client
73
74
 
75
+ SDK_OWNED_HEADERS = %w[authorization content-type user-agent].freeze
76
+
74
77
  private
75
78
 
76
79
  def build_api_client(generated_module, subdomain, cfg)
@@ -82,6 +85,9 @@ module Smplkit
82
85
  configuration.debugging = cfg.debug
83
86
  generated_module::ApiClient.new(configuration).tap do |client|
84
87
  client.default_headers["User-Agent"] = "smplkit-ruby-sdk/#{Smplkit::VERSION}"
88
+ @extra_headers&.each do |k, v|
89
+ client.default_headers[k] = v unless SDK_OWNED_HEADERS.include?(k.downcase)
90
+ end
85
91
  end
86
92
  end
87
93
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smplkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.24
4
+ version: 1.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Smpl Solutions LLC