smplkit 3.0.95 → 3.0.97
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 +4 -4
- data/lib/smplkit/account/client.rb +128 -0
- data/lib/smplkit/account/models.rb +71 -0
- data/lib/smplkit/api_support.rb +91 -0
- data/lib/smplkit/audit/buffer.rb +3 -1
- data/lib/smplkit/audit/categories.rb +21 -10
- data/lib/smplkit/audit/client.rb +18 -9
- data/lib/smplkit/audit/event_types.rb +26 -10
- data/lib/smplkit/audit/events.rb +93 -17
- data/lib/smplkit/{management/audit.rb → audit/forwarders.rb} +93 -85
- data/lib/smplkit/audit/models.rb +86 -32
- data/lib/smplkit/audit/resource_types.rb +21 -9
- data/lib/smplkit/buffers.rb +250 -0
- data/lib/smplkit/client.rb +161 -70
- data/lib/smplkit/config/client.rb +874 -186
- data/lib/smplkit/config/helpers.rb +44 -6
- data/lib/smplkit/config/models.rb +114 -7
- data/lib/smplkit/config_resolution.rb +17 -9
- data/lib/smplkit/errors.rb +14 -3
- data/lib/smplkit/flags/client.rb +602 -116
- data/lib/smplkit/flags/models.rb +110 -8
- data/lib/smplkit/flags/types.rb +8 -9
- data/lib/smplkit/jobs/client.rb +306 -0
- data/lib/smplkit/jobs/models.rb +47 -18
- data/lib/smplkit/logging/client.rb +755 -191
- data/lib/smplkit/logging/helpers.rb +5 -1
- data/lib/smplkit/logging/levels.rb +3 -1
- data/lib/smplkit/logging/models.rb +163 -6
- data/lib/smplkit/logging/normalize.rb +3 -1
- data/lib/smplkit/logging/resolution.rb +4 -4
- data/lib/smplkit/logging/sources.rb +1 -1
- data/lib/smplkit/platform/client.rb +597 -0
- data/lib/smplkit/platform/models.rb +282 -0
- data/lib/smplkit/{management → platform}/types.rb +21 -4
- data/lib/smplkit/transport.rb +103 -0
- data/lib/smplkit/ws.rb +1 -1
- data/lib/smplkit.rb +18 -6
- metadata +11 -7
- data/lib/smplkit/management/buffer.rb +0 -198
- data/lib/smplkit/management/client.rb +0 -1074
- data/lib/smplkit/management/jobs.rb +0 -226
- data/lib/smplkit/management/models.rb +0 -178
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smplkit
|
|
4
|
+
module Platform
|
|
5
|
+
# Accept Color, hex string, or nil; reject anything else.
|
|
6
|
+
#
|
|
7
|
+
# @api private
|
|
8
|
+
def self.coerce_color(value)
|
|
9
|
+
return value if value.nil? || value.is_a?(Color)
|
|
10
|
+
return Color.new(value) if value.is_a?(String)
|
|
11
|
+
|
|
12
|
+
raise TypeError, "color must be a Color, hex string, or nil; got #{value.class}: #{value.inspect}"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Environment resource (sync). Mutate fields, then call +save+.
|
|
16
|
+
class Environment
|
|
17
|
+
attr_accessor :id, :name, :classification, :created_at, :updated_at
|
|
18
|
+
attr_reader :color
|
|
19
|
+
|
|
20
|
+
# Create an environment instance.
|
|
21
|
+
#
|
|
22
|
+
# Prefer +client.platform.environments.new(...)+ to build an unsaved
|
|
23
|
+
# environment; this constructor is also used internally to wrap server
|
|
24
|
+
# responses.
|
|
25
|
+
#
|
|
26
|
+
# @param client [EnvironmentsClient, nil] Client used to persist and
|
|
27
|
+
# delete this environment. +nil+ produces a detached instance that
|
|
28
|
+
# cannot +save+.
|
|
29
|
+
# @param name [String] Display name shown in the Console.
|
|
30
|
+
# @param id [String, nil] Stable, human-readable identifier for the
|
|
31
|
+
# environment.
|
|
32
|
+
# @param color [Color, String, nil] Accent color, as a +Color+ or a CSS
|
|
33
|
+
# hex string. Defaults to no color.
|
|
34
|
+
# @param classification [String] Whether the environment participates in
|
|
35
|
+
# the standard environment ordering. Defaults to
|
|
36
|
+
# +EnvironmentClassification::STANDARD+.
|
|
37
|
+
# @param created_at [String, nil] When the environment was created. Set
|
|
38
|
+
# on instances returned by the server; leave +nil+ for unsaved ones.
|
|
39
|
+
# @param updated_at [String, nil] When the environment was last updated.
|
|
40
|
+
# Set on instances returned by the server; leave +nil+ for unsaved ones.
|
|
41
|
+
def initialize(client = nil, name:, id: nil, color: nil,
|
|
42
|
+
classification: EnvironmentClassification::STANDARD,
|
|
43
|
+
created_at: nil, updated_at: nil)
|
|
44
|
+
@client = client
|
|
45
|
+
@id = id
|
|
46
|
+
@name = name
|
|
47
|
+
@color = Platform.coerce_color(color)
|
|
48
|
+
@classification = classification
|
|
49
|
+
@created_at = created_at
|
|
50
|
+
@updated_at = updated_at
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Set the accent color, coercing the value to a +Color+.
|
|
54
|
+
#
|
|
55
|
+
# @param value [Color, String, nil] A +Color+, a CSS hex string, or +nil+
|
|
56
|
+
# to clear the color.
|
|
57
|
+
# @return [void]
|
|
58
|
+
def color=(value)
|
|
59
|
+
@color = Platform.coerce_color(value)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Create or update this environment on the server.
|
|
63
|
+
#
|
|
64
|
+
# @return [Environment] +self+, updated with the server response.
|
|
65
|
+
# @raise [RuntimeError] If this environment was constructed without a
|
|
66
|
+
# client.
|
|
67
|
+
def save
|
|
68
|
+
raise "Environment was constructed without a client; cannot save" if @client.nil?
|
|
69
|
+
|
|
70
|
+
other = @created_at.nil? ? @client._create(self) : @client._update(self)
|
|
71
|
+
_apply(other)
|
|
72
|
+
self
|
|
73
|
+
end
|
|
74
|
+
alias save! save
|
|
75
|
+
|
|
76
|
+
# Delete this environment from the server.
|
|
77
|
+
#
|
|
78
|
+
# @return [void]
|
|
79
|
+
# @raise [RuntimeError] If this environment was constructed without a
|
|
80
|
+
# client or id.
|
|
81
|
+
def delete
|
|
82
|
+
raise "Environment was constructed without a client or id; cannot delete" if @client.nil? || @id.nil?
|
|
83
|
+
|
|
84
|
+
@client.delete(@id)
|
|
85
|
+
end
|
|
86
|
+
alias delete! delete
|
|
87
|
+
|
|
88
|
+
def to_s
|
|
89
|
+
"Environment(id=#{@id.inspect}, name=#{@name.inspect}, classification=#{@classification.inspect})"
|
|
90
|
+
end
|
|
91
|
+
alias inspect to_s
|
|
92
|
+
|
|
93
|
+
# @api private
|
|
94
|
+
def _apply(other)
|
|
95
|
+
@id = other.id
|
|
96
|
+
@name = other.name
|
|
97
|
+
@color = other.color
|
|
98
|
+
@classification = other.classification
|
|
99
|
+
@created_at = other.created_at
|
|
100
|
+
@updated_at = other.updated_at
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Service resource (sync). Mutate fields, then call +save+.
|
|
105
|
+
class Service
|
|
106
|
+
attr_accessor :id, :name, :created_at, :updated_at
|
|
107
|
+
|
|
108
|
+
# Create a service instance.
|
|
109
|
+
#
|
|
110
|
+
# Prefer +client.platform.services.new(...)+ to build an unsaved service;
|
|
111
|
+
# this constructor is also used internally to wrap server responses.
|
|
112
|
+
#
|
|
113
|
+
# @param client [ServicesClient, nil] Client used to persist and delete
|
|
114
|
+
# this service. +nil+ produces a detached instance that cannot +save+.
|
|
115
|
+
# @param name [String] Display name shown in the Console.
|
|
116
|
+
# @param id [String, nil] Stable, human-readable identifier for the
|
|
117
|
+
# service.
|
|
118
|
+
# @param created_at [String, nil] When the service was created. Set on
|
|
119
|
+
# instances returned by the server; leave +nil+ for unsaved ones.
|
|
120
|
+
# @param updated_at [String, nil] When the service was last updated. Set
|
|
121
|
+
# on instances returned by the server; leave +nil+ for unsaved ones.
|
|
122
|
+
def initialize(client = nil, name:, id: nil, created_at: nil, updated_at: nil)
|
|
123
|
+
@client = client
|
|
124
|
+
@id = id
|
|
125
|
+
@name = name
|
|
126
|
+
@created_at = created_at
|
|
127
|
+
@updated_at = updated_at
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Create or update this service on the server.
|
|
131
|
+
#
|
|
132
|
+
# @return [Service] +self+, updated with the server response.
|
|
133
|
+
# @raise [RuntimeError] If this service was constructed without a client.
|
|
134
|
+
def save
|
|
135
|
+
raise "Service was constructed without a client; cannot save" if @client.nil?
|
|
136
|
+
|
|
137
|
+
other = @created_at.nil? ? @client._create(self) : @client._update(self)
|
|
138
|
+
_apply(other)
|
|
139
|
+
self
|
|
140
|
+
end
|
|
141
|
+
alias save! save
|
|
142
|
+
|
|
143
|
+
# Delete this service from the server.
|
|
144
|
+
#
|
|
145
|
+
# @return [void]
|
|
146
|
+
# @raise [RuntimeError] If this service was constructed without a client
|
|
147
|
+
# or id.
|
|
148
|
+
def delete
|
|
149
|
+
raise "Service was constructed without a client or id; cannot delete" if @client.nil? || @id.nil?
|
|
150
|
+
|
|
151
|
+
@client.delete(@id)
|
|
152
|
+
end
|
|
153
|
+
alias delete! delete
|
|
154
|
+
|
|
155
|
+
def to_s
|
|
156
|
+
"Service(id=#{@id.inspect}, name=#{@name.inspect})"
|
|
157
|
+
end
|
|
158
|
+
alias inspect to_s
|
|
159
|
+
|
|
160
|
+
# @api private
|
|
161
|
+
def _apply(other)
|
|
162
|
+
@id = other.id
|
|
163
|
+
@name = other.name
|
|
164
|
+
@created_at = other.created_at
|
|
165
|
+
@updated_at = other.updated_at
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# A context type resource (e.g. "user", "account").
|
|
170
|
+
class ContextType
|
|
171
|
+
attr_accessor :id, :name, :attributes, :created_at, :updated_at
|
|
172
|
+
|
|
173
|
+
# Create a context-type instance.
|
|
174
|
+
#
|
|
175
|
+
# Prefer +client.platform.context_types.new(...)+ to build an unsaved
|
|
176
|
+
# context type; this constructor is also used internally to wrap server
|
|
177
|
+
# responses.
|
|
178
|
+
#
|
|
179
|
+
# @param client [ContextTypesClient, nil] Client used to persist and
|
|
180
|
+
# delete this context type. +nil+ produces a detached instance that
|
|
181
|
+
# cannot +save+.
|
|
182
|
+
# @param name [String] Display name shown in the Console.
|
|
183
|
+
# @param id [String, nil] Stable, human-readable identifier for the
|
|
184
|
+
# context type.
|
|
185
|
+
# @param attributes [Hash, nil] Known-attribute slots, keyed by attribute
|
|
186
|
+
# name, with a metadata dict per slot. Defaults to no declared
|
|
187
|
+
# attributes.
|
|
188
|
+
# @param created_at [String, nil] When the context type was created. Set
|
|
189
|
+
# on instances returned by the server; leave +nil+ for unsaved ones.
|
|
190
|
+
# @param updated_at [String, nil] When the context type was last updated.
|
|
191
|
+
# Set on instances returned by the server; leave +nil+ for unsaved ones.
|
|
192
|
+
def initialize(client = nil, name:, id: nil, attributes: nil, created_at: nil, updated_at: nil)
|
|
193
|
+
@client = client
|
|
194
|
+
@id = id
|
|
195
|
+
@name = name
|
|
196
|
+
@attributes = attributes ? deep_dup_attrs(attributes) : {}
|
|
197
|
+
@created_at = created_at
|
|
198
|
+
@updated_at = updated_at
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# Add a known-attribute slot. Local-only; call +save+ to persist.
|
|
202
|
+
#
|
|
203
|
+
# @param name [String] Attribute name to declare on this context type.
|
|
204
|
+
# @param metadata [Hash] Arbitrary metadata stored for the attribute slot.
|
|
205
|
+
# @return [void]
|
|
206
|
+
def add_attribute(name, **metadata)
|
|
207
|
+
@attributes[name] = stringify_meta(metadata)
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# Remove a known-attribute slot. Local-only; call +save+ to persist.
|
|
211
|
+
#
|
|
212
|
+
# @param name [String] Attribute name to remove. A no-op if the attribute
|
|
213
|
+
# is not declared on this context type.
|
|
214
|
+
# @return [void]
|
|
215
|
+
def remove_attribute(name)
|
|
216
|
+
@attributes.delete(name)
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# Replace a known-attribute slot's metadata. Local-only; call +save+.
|
|
220
|
+
#
|
|
221
|
+
# @param name [String] Attribute name whose metadata to replace.
|
|
222
|
+
# @param metadata [Hash] New metadata for the attribute slot, replacing
|
|
223
|
+
# any existing metadata.
|
|
224
|
+
# @return [void]
|
|
225
|
+
def update_attribute(name, **metadata)
|
|
226
|
+
@attributes[name] = stringify_meta(metadata)
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
# Create or update this context type on the server.
|
|
230
|
+
#
|
|
231
|
+
# @return [ContextType] +self+, updated with the server response.
|
|
232
|
+
# @raise [RuntimeError] If this context type was constructed without a
|
|
233
|
+
# client.
|
|
234
|
+
def save
|
|
235
|
+
raise "ContextType was constructed without a client; cannot save" if @client.nil?
|
|
236
|
+
|
|
237
|
+
other = @created_at.nil? ? @client._create(self) : @client._update(self)
|
|
238
|
+
_apply(other)
|
|
239
|
+
self
|
|
240
|
+
end
|
|
241
|
+
alias save! save
|
|
242
|
+
|
|
243
|
+
# Delete this context type from the server.
|
|
244
|
+
#
|
|
245
|
+
# @return [void]
|
|
246
|
+
# @raise [RuntimeError] If this context type was constructed without a
|
|
247
|
+
# client or id.
|
|
248
|
+
def delete
|
|
249
|
+
raise "ContextType was constructed without a client or id; cannot delete" if @client.nil? || @id.nil?
|
|
250
|
+
|
|
251
|
+
@client.delete(@id)
|
|
252
|
+
end
|
|
253
|
+
alias delete! delete
|
|
254
|
+
|
|
255
|
+
def to_s
|
|
256
|
+
"ContextType(id=#{@id.inspect}, name=#{@name.inspect})"
|
|
257
|
+
end
|
|
258
|
+
alias inspect to_s
|
|
259
|
+
|
|
260
|
+
# @api private
|
|
261
|
+
def _apply(other)
|
|
262
|
+
@id = other.id
|
|
263
|
+
@name = other.name
|
|
264
|
+
@attributes = deep_dup_attrs(other.attributes)
|
|
265
|
+
@created_at = other.created_at
|
|
266
|
+
@updated_at = other.updated_at
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
private
|
|
270
|
+
|
|
271
|
+
def stringify_meta(metadata)
|
|
272
|
+
metadata.each_with_object({}) { |(k, v), out| out[k.to_s] = v }
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
def deep_dup_attrs(attrs)
|
|
276
|
+
attrs.each_with_object({}) do |(k, v), out|
|
|
277
|
+
out[k.to_s] = v.is_a?(Hash) ? stringify_meta(v) : v
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
end
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Smplkit
|
|
4
|
-
module
|
|
4
|
+
module Platform
|
|
5
5
|
# Whether an environment participates in the canonical ordering.
|
|
6
6
|
#
|
|
7
7
|
# +STANDARD+ environments are the customer's deploy targets — production,
|
|
8
|
-
# staging, development, etc.
|
|
8
|
+
# staging, development, etc. They participate in
|
|
9
|
+
# +account.settings.environment_order+ and appear in the standard Console
|
|
10
|
+
# environment columns.
|
|
11
|
+
#
|
|
9
12
|
# +AD_HOC+ environments are transient targets (preview branches, individual
|
|
10
13
|
# developer sandboxes) that should not appear in the standard ordering.
|
|
11
14
|
module EnvironmentClassification
|
|
@@ -28,6 +31,12 @@ module Smplkit
|
|
|
28
31
|
class Color
|
|
29
32
|
attr_reader :hex
|
|
30
33
|
|
|
34
|
+
# Build a +Color+ from a CSS hex string.
|
|
35
|
+
#
|
|
36
|
+
# @param hex [String] A CSS hex string like +"#RGB"+, +"#RRGGBB"+, or
|
|
37
|
+
# +"#RRGGBBAA"+. Normalized to lowercase.
|
|
38
|
+
# @raise [TypeError] If +hex+ is not a String.
|
|
39
|
+
# @raise [ArgumentError] If +hex+ is not a valid CSS hex string.
|
|
31
40
|
def initialize(hex)
|
|
32
41
|
raise TypeError, "Color hex must be a String, got #{hex.class}: #{hex.inspect}" unless hex.is_a?(String)
|
|
33
42
|
unless HEX_RE.match?(hex)
|
|
@@ -39,6 +48,14 @@ module Smplkit
|
|
|
39
48
|
freeze
|
|
40
49
|
end
|
|
41
50
|
|
|
51
|
+
# Construct a +Color+ from 0-255 RGB components.
|
|
52
|
+
#
|
|
53
|
+
# @param red [Integer] Red component, an integer in the range 0-255.
|
|
54
|
+
# @param green [Integer] Green component, an integer in the range 0-255.
|
|
55
|
+
# @param blue [Integer] Blue component, an integer in the range 0-255.
|
|
56
|
+
# @return [Color] A color with the equivalent hex value.
|
|
57
|
+
# @raise [TypeError] If any component is not an integer.
|
|
58
|
+
# @raise [ArgumentError] If any component is outside the range 0-255.
|
|
42
59
|
def self.rgb(red, green, blue)
|
|
43
60
|
[%w[red green blue], [red, green, blue]].transpose.each do |name, val|
|
|
44
61
|
unless val.is_a?(Integer) && !val.is_a?(TrueClass) && !val.is_a?(FalseClass)
|
|
@@ -60,6 +77,6 @@ module Smplkit
|
|
|
60
77
|
end
|
|
61
78
|
end
|
|
62
79
|
|
|
63
|
-
Color =
|
|
64
|
-
EnvironmentClassification =
|
|
80
|
+
Color = Platform::Color
|
|
81
|
+
EnvironmentClassification = Platform::EnvironmentClassification
|
|
65
82
|
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "uri"
|
|
4
|
+
|
|
5
|
+
module Smplkit
|
|
6
|
+
# Internal per-service HTTP transport construction.
|
|
7
|
+
#
|
|
8
|
+
# The top-level +Smplkit::Client+ needs one authenticated transport per
|
|
9
|
+
# backend service (app, config, flags, logging, jobs) plus a
|
|
10
|
+
# context-registration buffer that +client.platform+ owns. This module builds
|
|
11
|
+
# them in one place so the construction is side-effect-free (transports
|
|
12
|
+
# connect lazily on first call) and shared by the top-level client.
|
|
13
|
+
#
|
|
14
|
+
# There is no audit transport here — +client.audit+ owns its own.
|
|
15
|
+
#
|
|
16
|
+
# @api private
|
|
17
|
+
module Transport
|
|
18
|
+
SDK_OWNED_HEADERS = %w[authorization content-type user-agent].freeze
|
|
19
|
+
|
|
20
|
+
module_function
|
|
21
|
+
|
|
22
|
+
# Project the runtime +ResolvedConfig+ down to the transport subset.
|
|
23
|
+
#
|
|
24
|
+
# The top-level client's resolved config is a superset of what the
|
|
25
|
+
# transports need; this drops the runtime-only fields (environment,
|
|
26
|
+
# service, telemetry).
|
|
27
|
+
def to_transport_config(cfg, extra_headers = nil)
|
|
28
|
+
ConfigResolution::ResolvedClientConfig.new(
|
|
29
|
+
api_key: cfg.api_key,
|
|
30
|
+
base_domain: cfg.base_domain,
|
|
31
|
+
scheme: cfg.scheme,
|
|
32
|
+
debug: cfg.debug,
|
|
33
|
+
extra_headers: extra_headers
|
|
34
|
+
)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# The per-service authenticated transports built for a top-level client.
|
|
38
|
+
#
|
|
39
|
+
# Construction is side-effect-free: each transport connects lazily on its
|
|
40
|
+
# first call. +app_url+ is carried alongside so the account settings client
|
|
41
|
+
# and the WebSocket can reach the app service. +close+ tears down the
|
|
42
|
+
# underlying Faraday connection pools.
|
|
43
|
+
#
|
|
44
|
+
# @api private
|
|
45
|
+
ServiceTransports = Struct.new(
|
|
46
|
+
:app_url, :api_key, :app_http, :config_http, :flags_http, :logging_http, :jobs_http,
|
|
47
|
+
keyword_init: true
|
|
48
|
+
) do
|
|
49
|
+
def close
|
|
50
|
+
# The generated ApiClient owns Faraday connections that release on GC.
|
|
51
|
+
# No explicit shutdown is exposed; this stub keeps the API stable.
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Build the five per-service transports from a resolved transport config.
|
|
56
|
+
#
|
|
57
|
+
# Side-effect-free — the underlying Faraday clients are created lazily on
|
|
58
|
+
# the first request. Smpl Jobs is JSON:API, so its transport carries the
|
|
59
|
+
# +application/vnd.api+json+ Accept header.
|
|
60
|
+
def build_service_transports(cfg)
|
|
61
|
+
app_url = ConfigResolution.service_url(cfg.scheme, "app", cfg.base_domain)
|
|
62
|
+
ServiceTransports.new(
|
|
63
|
+
app_url: app_url,
|
|
64
|
+
api_key: cfg.api_key,
|
|
65
|
+
app_http: build_api_client(SmplkitGeneratedClient::App, "app", cfg),
|
|
66
|
+
config_http: build_api_client(SmplkitGeneratedClient::Config, "config", cfg),
|
|
67
|
+
flags_http: build_api_client(SmplkitGeneratedClient::Flags, "flags", cfg),
|
|
68
|
+
logging_http: build_api_client(SmplkitGeneratedClient::Logging, "logging", cfg),
|
|
69
|
+
jobs_http: build_api_client(SmplkitGeneratedClient::Jobs, "jobs", cfg,
|
|
70
|
+
accept: "application/vnd.api+json")
|
|
71
|
+
)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Build a generated +ApiClient+ for one service from a resolved config.
|
|
75
|
+
#
|
|
76
|
+
# +base_url+, when supplied, overrides the +scheme+/+host+ derived from
|
|
77
|
+
# +subdomain+/+base_domain+ (the path a standalone product client takes
|
|
78
|
+
# when handed a fully-resolved app URL).
|
|
79
|
+
def build_api_client(generated_module, subdomain, cfg, accept: nil, base_url: nil)
|
|
80
|
+
configuration = generated_module::Configuration.new
|
|
81
|
+
if base_url.nil?
|
|
82
|
+
configuration.scheme = cfg.scheme
|
|
83
|
+
configuration.host = "#{subdomain}.#{cfg.base_domain}"
|
|
84
|
+
else
|
|
85
|
+
uri = URI.parse(base_url)
|
|
86
|
+
configuration.scheme = uri.scheme
|
|
87
|
+
port_suffix = uri.port && ![80, 443].include?(uri.port) ? ":#{uri.port}" : ""
|
|
88
|
+
configuration.host = "#{uri.host}#{port_suffix}"
|
|
89
|
+
end
|
|
90
|
+
configuration.base_path = ""
|
|
91
|
+
configuration.access_token = cfg.api_key
|
|
92
|
+
configuration.debugging = cfg.debug
|
|
93
|
+
HttpPool.configure(configuration)
|
|
94
|
+
generated_module::ApiClient.new(configuration).tap do |client|
|
|
95
|
+
client.default_headers["User-Agent"] = "smplkit-ruby-sdk/#{Smplkit::VERSION}"
|
|
96
|
+
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
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
data/lib/smplkit/ws.rb
CHANGED
|
@@ -19,7 +19,7 @@ module Smplkit
|
|
|
19
19
|
# +Async+ reactor and the underlying +async-websocket+ I/O. Public
|
|
20
20
|
# methods are thread-safe and non-blocking.
|
|
21
21
|
#
|
|
22
|
-
# Gateway protocol
|
|
22
|
+
# Gateway protocol:
|
|
23
23
|
#
|
|
24
24
|
# - Connect to +wss://app.<base_domain>/api/ws/v1/events?api_key={key}+
|
|
25
25
|
# - Receive +{"type": "connected"}+ on success
|
data/lib/smplkit.rb
CHANGED
|
@@ -44,9 +44,25 @@ require_relative "smplkit/context"
|
|
|
44
44
|
require_relative "smplkit/config_resolution"
|
|
45
45
|
require_relative "smplkit/metrics"
|
|
46
46
|
require_relative "smplkit/ws"
|
|
47
|
+
|
|
48
|
+
# Internal foundation shared by every product client.
|
|
49
|
+
require_relative "smplkit/buffers"
|
|
50
|
+
require_relative "smplkit/api_support"
|
|
51
|
+
require_relative "smplkit/transport"
|
|
52
|
+
|
|
53
|
+
# Flags types (incl. Context) load before platform, which references Context.
|
|
47
54
|
require_relative "smplkit/flags/types"
|
|
48
55
|
require_relative "smplkit/flags/models"
|
|
49
56
|
require_relative "smplkit/flags/helpers"
|
|
57
|
+
|
|
58
|
+
# Platform + account (the cross-cutting surfaces) before the product clients
|
|
59
|
+
# that borrow them.
|
|
60
|
+
require_relative "smplkit/platform/types"
|
|
61
|
+
require_relative "smplkit/platform/models"
|
|
62
|
+
require_relative "smplkit/platform/client"
|
|
63
|
+
require_relative "smplkit/account/models"
|
|
64
|
+
require_relative "smplkit/account/client"
|
|
65
|
+
|
|
50
66
|
require_relative "smplkit/flags/client"
|
|
51
67
|
require_relative "smplkit/config/models"
|
|
52
68
|
require_relative "smplkit/config/helpers"
|
|
@@ -66,14 +82,10 @@ require_relative "smplkit/audit/events"
|
|
|
66
82
|
require_relative "smplkit/audit/resource_types"
|
|
67
83
|
require_relative "smplkit/audit/event_types"
|
|
68
84
|
require_relative "smplkit/audit/categories"
|
|
85
|
+
require_relative "smplkit/audit/forwarders"
|
|
69
86
|
require_relative "smplkit/audit/client"
|
|
70
87
|
require_relative "smplkit/jobs/models"
|
|
71
|
-
require_relative "smplkit/
|
|
72
|
-
require_relative "smplkit/management/models"
|
|
73
|
-
require_relative "smplkit/management/buffer"
|
|
74
|
-
require_relative "smplkit/management/audit"
|
|
75
|
-
require_relative "smplkit/management/jobs"
|
|
76
|
-
require_relative "smplkit/management/client"
|
|
88
|
+
require_relative "smplkit/jobs/client"
|
|
77
89
|
require_relative "smplkit/client"
|
|
78
90
|
|
|
79
91
|
require_relative "smplkit/railtie" if defined?(Rails::Railtie)
|
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.
|
|
4
|
+
version: 3.0.97
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Smpl Solutions LLC
|
|
@@ -879,13 +879,18 @@ files:
|
|
|
879
879
|
- lib/smplkit/_generated/logging/spec/models/usage_list_response_spec.rb
|
|
880
880
|
- lib/smplkit/_generated/logging/spec/models/usage_resource_spec.rb
|
|
881
881
|
- lib/smplkit/_generated/logging/spec/spec_helper.rb
|
|
882
|
+
- lib/smplkit/account/client.rb
|
|
883
|
+
- lib/smplkit/account/models.rb
|
|
884
|
+
- lib/smplkit/api_support.rb
|
|
882
885
|
- lib/smplkit/audit/buffer.rb
|
|
883
886
|
- lib/smplkit/audit/categories.rb
|
|
884
887
|
- lib/smplkit/audit/client.rb
|
|
885
888
|
- lib/smplkit/audit/event_types.rb
|
|
886
889
|
- lib/smplkit/audit/events.rb
|
|
890
|
+
- lib/smplkit/audit/forwarders.rb
|
|
887
891
|
- lib/smplkit/audit/models.rb
|
|
888
892
|
- lib/smplkit/audit/resource_types.rb
|
|
893
|
+
- lib/smplkit/buffers.rb
|
|
889
894
|
- lib/smplkit/client.rb
|
|
890
895
|
- lib/smplkit/config/client.rb
|
|
891
896
|
- lib/smplkit/config/helpers.rb
|
|
@@ -901,6 +906,7 @@ files:
|
|
|
901
906
|
- lib/smplkit/generators/install_generator.rb
|
|
902
907
|
- lib/smplkit/helpers.rb
|
|
903
908
|
- lib/smplkit/http_pool.rb
|
|
909
|
+
- lib/smplkit/jobs/client.rb
|
|
904
910
|
- lib/smplkit/jobs/models.rb
|
|
905
911
|
- lib/smplkit/log_level.rb
|
|
906
912
|
- lib/smplkit/logging/adapters/base.rb
|
|
@@ -913,14 +919,12 @@ files:
|
|
|
913
919
|
- lib/smplkit/logging/normalize.rb
|
|
914
920
|
- lib/smplkit/logging/resolution.rb
|
|
915
921
|
- lib/smplkit/logging/sources.rb
|
|
916
|
-
- lib/smplkit/management/audit.rb
|
|
917
|
-
- lib/smplkit/management/buffer.rb
|
|
918
|
-
- lib/smplkit/management/client.rb
|
|
919
|
-
- lib/smplkit/management/jobs.rb
|
|
920
|
-
- lib/smplkit/management/models.rb
|
|
921
|
-
- lib/smplkit/management/types.rb
|
|
922
922
|
- lib/smplkit/metrics.rb
|
|
923
|
+
- lib/smplkit/platform/client.rb
|
|
924
|
+
- lib/smplkit/platform/models.rb
|
|
925
|
+
- lib/smplkit/platform/types.rb
|
|
923
926
|
- lib/smplkit/railtie.rb
|
|
927
|
+
- lib/smplkit/transport.rb
|
|
924
928
|
- lib/smplkit/version.rb
|
|
925
929
|
- lib/smplkit/ws.rb
|
|
926
930
|
- sig/smplkit.rbs
|