smplkit 3.0.131 → 3.0.133

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: 80d71501763192031a0fb659bbe16d4aa0b021c1995dbcef803cb3cc11298355
4
- data.tar.gz: e8f81502fe54983ca18c2d83bda4089e36f21b6bd5e6b58aea74ebd4b6a5edec
3
+ metadata.gz: cb735320cad6cc35e02d16ba48a6a95b307b5befd743f0971511a719c92cc376
4
+ data.tar.gz: d49318a508cb0f2ebd7387bc1ee3c201c491df7bf18a2177d7dd69cdf03d631b
5
5
  SHA512:
6
- metadata.gz: cd8267d396fcb466ff2f4b2ac8addfbbd667b33bc122a599628d0a49134be4c93810fae6b779ae12f633d52062fc032ad3da0948d36c5fd472857ac0d604dfae
7
- data.tar.gz: 36368e8ea040abb9905ff4d84650cd147cadf3bcef6038165970c1804df311d42e3e84fdd51e522042ee7c5a98324961a3733efc86f207243079db4a0872997d
6
+ metadata.gz: 3ae89d87c1e2c1df13c09adead2ead58f590e2f8d0a58324772aa56c655962686aa492e592f8c614eae5840cbe77af389703970ebcf802b1c0822de43f362861
7
+ data.tar.gz: 60844a59a76a58e7917690e145d4432cc7082231ffd409161c6880a38676dd8fa0e58527244f08387d5a5ce46482f465c4b82cdfa3b2bd934472039e23f047a9
@@ -20,7 +20,7 @@ module SmplkitGeneratedClient::App
20
20
  @api_client = api_client
21
21
  end
22
22
  # Create Group
23
- # Create an Environment Access Group. The caller provides the group id (a snake-case key, unique within the account) in the request body. The id is immutable thereafter. Returns `409` if a group with that id already exists, or `422` if `managed_environments` is not exactly `['*']` or a subset of the account's standard environment keys.
23
+ # Create an Environment Access Group. The caller provides the group id (a kebab-case key, unique within the account) in the request body. The id is immutable thereafter. Returns `409` if a group with that id already exists, or `422` if `managed_environments` is not exactly `['*']` or a subset of the account's standard environment keys.
24
24
  # @param group_create_request [GroupCreateRequest]
25
25
  # @param [Hash] opts the optional parameters
26
26
  # @return [GroupResponse]
@@ -30,7 +30,7 @@ module SmplkitGeneratedClient::App
30
30
  end
31
31
 
32
32
  # Create Group
33
- # Create an Environment Access Group. The caller provides the group id (a snake-case key, unique within the account) in the request body. The id is immutable thereafter. Returns `409` if a group with that id already exists, or `422` if `managed_environments` is not exactly `['*']` or a subset of the account's standard environment keys.
33
+ # Create an Environment Access Group. The caller provides the group id (a kebab-case key, unique within the account) in the request body. The id is immutable thereafter. Returns `409` if a group with that id already exists, or `422` if `managed_environments` is not exactly `['*']` or a subset of the account's standard environment keys.
34
34
  # @param group_create_request [GroupCreateRequest]
35
35
  # @param [Hash] opts the optional parameters
36
36
  # @return [Array<(GroupResponse, Integer, Hash)>] GroupResponse data, response status code and response headers
@@ -34,7 +34,7 @@ describe 'GroupsApi' do
34
34
 
35
35
  # unit tests for create_group
36
36
  # Create Group
37
- # Create an Environment Access Group. The caller provides the group id (a snake-case key, unique within the account) in the request body. The id is immutable thereafter. Returns &#x60;409&#x60; if a group with that id already exists, or &#x60;422&#x60; if &#x60;managed_environments&#x60; is not exactly &#x60;[&#39;*&#39;]&#x60; or a subset of the account&#39;s standard environment keys.
37
+ # Create an Environment Access Group. The caller provides the group id (a kebab-case key, unique within the account) in the request body. The id is immutable thereafter. Returns &#x60;409&#x60; if a group with that id already exists, or &#x60;422&#x60; if &#x60;managed_environments&#x60; is not exactly &#x60;[&#39;*&#39;]&#x60; or a subset of the account&#39;s standard environment keys.
38
38
  # @param group_create_request
39
39
  # @param [Hash] opts the optional parameters
40
40
  # @return [GroupResponse]
@@ -36,7 +36,12 @@ module Smplkit
36
36
  @headers = {
37
37
  "Authorization" => "Bearer #{api_key}",
38
38
  "Content-Type" => "application/json"
39
- }.merge(extra_headers || {})
39
+ }
40
+ # Default SDK User-Agent unless the caller supplied one (any casing) —
41
+ # without it this raw Faraday connection would fall through to
42
+ # Faraday's own "Faraday vX.Y.Z" default.
43
+ @headers["User-Agent"] = Smplkit.user_agent unless Transport.user_agent_supplied?(extra_headers)
44
+ @headers.merge!(extra_headers || {})
40
45
  end
41
46
 
42
47
  # Fetch the authenticated account's current settings.
@@ -36,8 +36,9 @@ module Smplkit
36
36
  # @param debug [Boolean, nil] Enable SDK debug logging.
37
37
  # @param timeout [Float] Per-request timeout, in seconds. Defaults to +10.0+.
38
38
  # @param extra_headers [Hash{String => String}, nil] Extra headers attached
39
- # to every request. SDK-owned headers (authorization, content-type,
40
- # user-agent) cannot be overridden.
39
+ # to every request. SDK-owned headers (authorization, content-type)
40
+ # cannot be overridden. A caller-supplied User-Agent (any casing)
41
+ # replaces the SDK default +smplkit-sdk-ruby/<version>+.
41
42
  # @param buffered [Boolean] Buffer event recording (default +true+):
42
43
  # +events.record+ enqueues onto an in-memory buffer that a background
43
44
  # worker drains with retry, and returns immediately. Set +false+ for the
@@ -48,8 +49,6 @@ module Smplkit
48
49
  class AuditClient
49
50
  attr_reader :events, :resource_types, :event_types, :categories, :forwarders
50
51
 
51
- SDK_OWNED_HEADERS = %w[authorization content-type user-agent].freeze
52
-
53
52
  def initialize(api_key: nil, base_url: nil, environment: nil, profile: nil,
54
53
  base_domain: nil, scheme: nil, debug: nil, timeout: 10.0,
55
54
  extra_headers: nil, buffered: true)
@@ -77,17 +76,15 @@ module Smplkit
77
76
  cfg.debugging = debug unless debug.nil?
78
77
  HttpPool.configure(cfg)
79
78
  api_client = SmplkitGeneratedClient::Audit::ApiClient.new(cfg)
80
- api_client.default_headers["User-Agent"] = "smplkit-ruby-sdk/#{Smplkit::VERSION}"
81
79
  # Runtime audit ops are environment-scoped, but the scoping is
82
80
  # body-driven (ADR-055): +events.record+ stamps the configured
83
81
  # environment onto the event request body, and the read surfaces
84
82
  # (events list plus the resource_type / event_type / category discovery
85
83
  # lists) default +filter[environment]+ to it. The transport therefore
86
- # carries only auth plus any caller-supplied +extra_headers+ — no
87
- # environment header. Forwarder CRUD is environment-agnostic.
88
- extra_headers&.each do |k, v|
89
- api_client.default_headers[k] = v unless SDK_OWNED_HEADERS.include?(k.downcase)
90
- end
84
+ # carries only auth, the default User-Agent, and any caller-supplied
85
+ # +extra_headers+ — no environment header. Forwarder CRUD is
86
+ # environment-agnostic.
87
+ Transport.apply_headers(api_client, extra_headers)
91
88
  @events = Events.new(
92
89
  SmplkitGeneratedClient::Audit::EventsApi.new(api_client),
93
90
  environment: environment, buffered: buffered
@@ -15,10 +15,37 @@ module Smplkit
15
15
  #
16
16
  # @api private
17
17
  module Transport
18
- SDK_OWNED_HEADERS = %w[authorization content-type user-agent].freeze
18
+ # Headers the SDK always owns — +extra_headers+ cannot override these
19
+ # (authorization carries the credential; content-type is set per request
20
+ # by the generated client). User-Agent is deliberately NOT in this list:
21
+ # a caller-supplied User-Agent wins over the SDK default.
22
+ SDK_OWNED_HEADERS = %w[authorization content-type].freeze
19
23
 
20
24
  module_function
21
25
 
26
+ # Whether an extra-headers hash carries a caller-supplied User-Agent,
27
+ # under any representation the surface accepts — string keys in any
28
+ # casing ("User-Agent", "user-agent", …) and symbol keys (:"user-agent").
29
+ def user_agent_supplied?(extra_headers)
30
+ (extra_headers || {}).keys.any? { |k| k.to_s.casecmp("user-agent").zero? }
31
+ end
32
+
33
+ # Stamp the default headers onto a generated +ApiClient+.
34
+ #
35
+ # User-Agent precedence: caller-supplied via +extra_headers+ (any casing
36
+ # or symbol representation) > the SDK default (+Smplkit.user_agent+,
37
+ # +smplkit-sdk-ruby/<version>+) > the generated stack's own default
38
+ # (+OpenAPI-Generator/x.y.z/ruby+, removed here so exactly one
39
+ # User-Agent representation remains). Other +extra_headers+ entries are
40
+ # applied as-is unless SDK-owned.
41
+ def apply_headers(client, extra_headers)
42
+ client.default_headers.delete("User-Agent")
43
+ client.default_headers["User-Agent"] = Smplkit.user_agent unless user_agent_supplied?(extra_headers)
44
+ (extra_headers || {}).each do |k, v|
45
+ client.default_headers[k] = v unless SDK_OWNED_HEADERS.include?(k.to_s.downcase)
46
+ end
47
+ end
48
+
22
49
  # Project the runtime +ResolvedConfig+ down to the transport subset.
23
50
  #
24
51
  # The top-level client's resolved config is a superset of what the
@@ -92,11 +119,8 @@ module Smplkit
92
119
  configuration.debugging = cfg.debug
93
120
  HttpPool.configure(configuration)
94
121
  generated_module::ApiClient.new(configuration).tap do |client|
95
- client.default_headers["User-Agent"] = "smplkit-ruby-sdk/#{Smplkit::VERSION}"
96
122
  client.default_headers["Accept"] = accept if accept
97
- (cfg.extra_headers || {}).each do |k, v|
98
- client.default_headers[k] = v unless SDK_OWNED_HEADERS.include?(k.downcase)
99
- end
123
+ apply_headers(client, cfg.extra_headers)
100
124
  end
101
125
  end
102
126
  end
@@ -1,5 +1,41 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Smplkit
4
+ # Local-development fallback only. The canonical version of a published gem
5
+ # is stamped into the gem's build-time metadata from the release tag by the
6
+ # gemspec (see +smplkit.gemspec+); +Smplkit.gem_version+ reads that metadata
7
+ # at runtime. This constant is used when the SDK runs from a source
8
+ # checkout that has no installed gem to consult.
4
9
  VERSION = "0.0.0"
10
+
11
+ # The version of the smplkit gem actually loaded, read from RubyGems
12
+ # package metadata.
13
+ #
14
+ # The release workflow never rewrites +VERSION+ above — the published
15
+ # version exists only in the git tag and, via the gemspec's build-time
16
+ # derivation, in the built gem's serialized specification. An installed gem
17
+ # therefore reports the real release version through +Gem.loaded_specs+,
18
+ # while a plain source checkout falls back to +VERSION+. The +smplkit-sdk+
19
+ # name is the ADR-046 §2.1 fallback gem name.
20
+ #
21
+ # @api private
22
+ # @return [String] the loaded gem's version, or +VERSION+ when the SDK is
23
+ # not running from an installed gem.
24
+ def self.gem_version
25
+ spec = Gem.loaded_specs["smplkit"] || Gem.loaded_specs["smplkit-sdk"]
26
+ spec ? spec.version.to_s : VERSION
27
+ end
28
+
29
+ # The default User-Agent stamped on every outbound request (HTTP and the
30
+ # WebSocket handshake) when the caller has not supplied their own.
31
+ #
32
+ # The platform sits behind a WAF that rejects requests carrying no
33
+ # User-Agent, and an SDK-identifying value keeps support/telemetry able to
34
+ # attribute traffic to an SDK and version in access logs.
35
+ #
36
+ # @api private
37
+ # @return [String] +smplkit-sdk-ruby/<version>+
38
+ def self.user_agent
39
+ "smplkit-sdk-ruby/#{gem_version}"
40
+ end
5
41
  end
data/lib/smplkit/ws.rb CHANGED
@@ -34,7 +34,10 @@ module Smplkit
34
34
  class SharedWebSocket
35
35
  BACKOFF_SCHEDULE = [1, 2, 4, 8, 16, 32, 60].freeze
36
36
 
37
- USER_AGENT = "smplkit-ruby-sdk/#{Smplkit::VERSION}".freeze
37
+ # Sent on the WebSocket upgrade request — the platform WAF rejects
38
+ # handshakes that carry no User-Agent. There is no caller-supplied
39
+ # header surface on the WebSocket, so the SDK default always applies.
40
+ USER_AGENT = Smplkit.user_agent.freeze
38
41
 
39
42
  def initialize(app_base_url:, api_key:, metrics: nil)
40
43
  @app_base_url = app_base_url
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: 3.0.131
4
+ version: 3.0.133
5
5
  platform: ruby
6
6
  authors:
7
7
  - Smpl Solutions LLC