smplkit 1.0.19 → 1.0.20
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/_generated/audit/lib/smplkit_audit_client/api/{default_api.rb → events_api.rb} +38 -102
- data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/usage_api.rb +86 -0
- data/lib/smplkit/_generated/audit/lib/smplkit_audit_client.rb +2 -1
- data/lib/smplkit/_generated/audit/spec/api/{default_api_spec.rb → events_api_spec.rb} +13 -25
- data/lib/smplkit/_generated/audit/spec/api/usage_api_spec.rb +47 -0
- data/lib/smplkit/audit/buffer.rb +15 -6
- data/lib/smplkit/audit/client.rb +1 -1
- data/lib/smplkit/audit/events.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d69e237a8de7cca75190f3b21d08309a0cf54cab21131f9d8d576a56700155f0
|
|
4
|
+
data.tar.gz: fc2b7cf8d52d92adcccca9454d402cb5d7622cead3007a82d941e1c9d3d2b8eb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a4e173231e776348149477ea584001905fcfa826bcdcbf2f5f220103af5afc9a80f6a1dc4398a1bac761771daf613145c977865e3f6442f39c91e393e5503c63
|
|
7
|
+
data.tar.gz: e3d413229b945a4c4feaf6eadb7c6a13735fe3fd7e9a96e939d422ce6c7fa96ec34491eaa4554e3fdefcb6feb3f781607bbf3577628cfb19c58425c094e815e3
|
data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/{default_api.rb → events_api.rb}
RENAMED
|
@@ -13,83 +13,12 @@ Generator version: 7.22.0
|
|
|
13
13
|
require 'cgi'
|
|
14
14
|
|
|
15
15
|
module SmplkitGeneratedClient::Audit
|
|
16
|
-
class
|
|
16
|
+
class EventsApi
|
|
17
17
|
attr_accessor :api_client
|
|
18
18
|
|
|
19
19
|
def initialize(api_client = ApiClient.default)
|
|
20
20
|
@api_client = api_client
|
|
21
21
|
end
|
|
22
|
-
# Create Event
|
|
23
|
-
# Record an audit event for the authenticated account. Returns ``201 Created`` on first write, ``200 OK`` if the request was a duplicate (matched by ``Idempotency-Key`` or auto-derived key). Customers may not emit events whose ``resource_type`` starts with ``smpl.`` — that namespace is reserved for smplkit-emitted events about platform resources.
|
|
24
|
-
# @param event_response [EventResponse]
|
|
25
|
-
# @param [Hash] opts the optional parameters
|
|
26
|
-
# @option opts [String] :idempotency_key
|
|
27
|
-
# @return [EventResponse]
|
|
28
|
-
def create_event(event_response, opts = {})
|
|
29
|
-
data, _status_code, _headers = create_event_with_http_info(event_response, opts)
|
|
30
|
-
data
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# Create Event
|
|
34
|
-
# Record an audit event for the authenticated account. Returns ``201 Created`` on first write, ``200 OK`` if the request was a duplicate (matched by ``Idempotency-Key`` or auto-derived key). Customers may not emit events whose ``resource_type`` starts with ``smpl.`` — that namespace is reserved for smplkit-emitted events about platform resources.
|
|
35
|
-
# @param event_response [EventResponse]
|
|
36
|
-
# @param [Hash] opts the optional parameters
|
|
37
|
-
# @option opts [String] :idempotency_key
|
|
38
|
-
# @return [Array<(EventResponse, Integer, Hash)>] EventResponse data, response status code and response headers
|
|
39
|
-
def create_event_with_http_info(event_response, opts = {})
|
|
40
|
-
if @api_client.config.debugging
|
|
41
|
-
@api_client.config.logger.debug 'Calling API: DefaultApi.create_event ...'
|
|
42
|
-
end
|
|
43
|
-
# verify the required parameter 'event_response' is set
|
|
44
|
-
if @api_client.config.client_side_validation && event_response.nil?
|
|
45
|
-
fail ArgumentError, "Missing the required parameter 'event_response' when calling DefaultApi.create_event"
|
|
46
|
-
end
|
|
47
|
-
# resource path
|
|
48
|
-
local_var_path = '/api/v1/events'
|
|
49
|
-
|
|
50
|
-
# query parameters
|
|
51
|
-
query_params = opts[:query_params] || {}
|
|
52
|
-
|
|
53
|
-
# header parameters
|
|
54
|
-
header_params = opts[:header_params] || {}
|
|
55
|
-
# HTTP header 'Accept' (if needed)
|
|
56
|
-
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) unless header_params['Accept']
|
|
57
|
-
# HTTP header 'Content-Type'
|
|
58
|
-
content_type = @api_client.select_header_content_type(['application/vnd.api+json'])
|
|
59
|
-
if !content_type.nil?
|
|
60
|
-
header_params['Content-Type'] = content_type
|
|
61
|
-
end
|
|
62
|
-
header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?
|
|
63
|
-
|
|
64
|
-
# form parameters
|
|
65
|
-
form_params = opts[:form_params] || {}
|
|
66
|
-
|
|
67
|
-
# http body (model)
|
|
68
|
-
post_body = opts[:debug_body] || @api_client.object_to_http_body(event_response)
|
|
69
|
-
|
|
70
|
-
# return_type
|
|
71
|
-
return_type = opts[:debug_return_type] || 'EventResponse'
|
|
72
|
-
|
|
73
|
-
# auth_names
|
|
74
|
-
auth_names = opts[:debug_auth_names] || ['HTTPBearer']
|
|
75
|
-
|
|
76
|
-
new_options = opts.merge(
|
|
77
|
-
:operation => :"DefaultApi.create_event",
|
|
78
|
-
:header_params => header_params,
|
|
79
|
-
:query_params => query_params,
|
|
80
|
-
:form_params => form_params,
|
|
81
|
-
:body => post_body,
|
|
82
|
-
:auth_names => auth_names,
|
|
83
|
-
:return_type => return_type
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
|
87
|
-
if @api_client.config.debugging
|
|
88
|
-
@api_client.config.logger.debug "API called: DefaultApi#create_event\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
89
|
-
end
|
|
90
|
-
return data, status_code, headers
|
|
91
|
-
end
|
|
92
|
-
|
|
93
22
|
# Get Event
|
|
94
23
|
# Retrieve a single audit event by id. Returns 404 if no event with that id exists in the caller's account — RLS enforces tenant isolation; this endpoint never leaks the existence of another tenant's event.
|
|
95
24
|
# @param event_id [String]
|
|
@@ -107,11 +36,11 @@ module SmplkitGeneratedClient::Audit
|
|
|
107
36
|
# @return [Array<(EventResponse, Integer, Hash)>] EventResponse data, response status code and response headers
|
|
108
37
|
def get_event_with_http_info(event_id, opts = {})
|
|
109
38
|
if @api_client.config.debugging
|
|
110
|
-
@api_client.config.logger.debug 'Calling API:
|
|
39
|
+
@api_client.config.logger.debug 'Calling API: EventsApi.get_event ...'
|
|
111
40
|
end
|
|
112
41
|
# verify the required parameter 'event_id' is set
|
|
113
42
|
if @api_client.config.client_side_validation && event_id.nil?
|
|
114
|
-
fail ArgumentError, "Missing the required parameter 'event_id' when calling
|
|
43
|
+
fail ArgumentError, "Missing the required parameter 'event_id' when calling EventsApi.get_event"
|
|
115
44
|
end
|
|
116
45
|
# resource path
|
|
117
46
|
local_var_path = '/api/v1/events/{event_id}'.sub('{event_id}', CGI.escape(event_id.to_s))
|
|
@@ -137,7 +66,7 @@ module SmplkitGeneratedClient::Audit
|
|
|
137
66
|
auth_names = opts[:debug_auth_names] || ['HTTPBearer']
|
|
138
67
|
|
|
139
68
|
new_options = opts.merge(
|
|
140
|
-
:operation => :"
|
|
69
|
+
:operation => :"EventsApi.get_event",
|
|
141
70
|
:header_params => header_params,
|
|
142
71
|
:query_params => query_params,
|
|
143
72
|
:form_params => form_params,
|
|
@@ -148,7 +77,7 @@ module SmplkitGeneratedClient::Audit
|
|
|
148
77
|
|
|
149
78
|
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
|
150
79
|
if @api_client.config.debugging
|
|
151
|
-
@api_client.config.logger.debug "API called:
|
|
80
|
+
@api_client.config.logger.debug "API called: EventsApi#get_event\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
152
81
|
end
|
|
153
82
|
return data, status_code, headers
|
|
154
83
|
end
|
|
@@ -184,10 +113,10 @@ module SmplkitGeneratedClient::Audit
|
|
|
184
113
|
# @return [Array<(EventListResponse, Integer, Hash)>] EventListResponse data, response status code and response headers
|
|
185
114
|
def list_events_with_http_info(opts = {})
|
|
186
115
|
if @api_client.config.debugging
|
|
187
|
-
@api_client.config.logger.debug 'Calling API:
|
|
116
|
+
@api_client.config.logger.debug 'Calling API: EventsApi.list_events ...'
|
|
188
117
|
end
|
|
189
118
|
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
|
|
190
|
-
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling
|
|
119
|
+
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling EventsApi.list_events, must be greater than or equal to 1.'
|
|
191
120
|
end
|
|
192
121
|
|
|
193
122
|
# resource path
|
|
@@ -222,7 +151,7 @@ module SmplkitGeneratedClient::Audit
|
|
|
222
151
|
auth_names = opts[:debug_auth_names] || ['HTTPBearer']
|
|
223
152
|
|
|
224
153
|
new_options = opts.merge(
|
|
225
|
-
:operation => :"
|
|
154
|
+
:operation => :"EventsApi.list_events",
|
|
226
155
|
:header_params => header_params,
|
|
227
156
|
:query_params => query_params,
|
|
228
157
|
:form_params => form_params,
|
|
@@ -233,60 +162,67 @@ module SmplkitGeneratedClient::Audit
|
|
|
233
162
|
|
|
234
163
|
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
|
235
164
|
if @api_client.config.debugging
|
|
236
|
-
@api_client.config.logger.debug "API called:
|
|
165
|
+
@api_client.config.logger.debug "API called: EventsApi#list_events\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
237
166
|
end
|
|
238
167
|
return data, status_code, headers
|
|
239
168
|
end
|
|
240
169
|
|
|
241
|
-
#
|
|
242
|
-
#
|
|
243
|
-
# @param
|
|
170
|
+
# Record Event
|
|
171
|
+
# Record an audit event for the authenticated account. Returns ``201 Created`` on first write, ``200 OK`` if the request was a duplicate (matched by ``Idempotency-Key`` or auto-derived key). Customers may not emit events whose ``resource_type`` starts with ``smpl.`` — that namespace is reserved for smplkit-emitted events about platform resources.
|
|
172
|
+
# @param event_response [EventResponse]
|
|
244
173
|
# @param [Hash] opts the optional parameters
|
|
245
|
-
# @
|
|
246
|
-
|
|
247
|
-
|
|
174
|
+
# @option opts [String] :idempotency_key
|
|
175
|
+
# @return [EventResponse]
|
|
176
|
+
def record_event(event_response, opts = {})
|
|
177
|
+
data, _status_code, _headers = record_event_with_http_info(event_response, opts)
|
|
248
178
|
data
|
|
249
179
|
end
|
|
250
180
|
|
|
251
|
-
#
|
|
252
|
-
#
|
|
253
|
-
# @param
|
|
181
|
+
# Record Event
|
|
182
|
+
# Record an audit event for the authenticated account. Returns ``201 Created`` on first write, ``200 OK`` if the request was a duplicate (matched by ``Idempotency-Key`` or auto-derived key). Customers may not emit events whose ``resource_type`` starts with ``smpl.`` — that namespace is reserved for smplkit-emitted events about platform resources.
|
|
183
|
+
# @param event_response [EventResponse]
|
|
254
184
|
# @param [Hash] opts the optional parameters
|
|
255
|
-
# @
|
|
256
|
-
|
|
185
|
+
# @option opts [String] :idempotency_key
|
|
186
|
+
# @return [Array<(EventResponse, Integer, Hash)>] EventResponse data, response status code and response headers
|
|
187
|
+
def record_event_with_http_info(event_response, opts = {})
|
|
257
188
|
if @api_client.config.debugging
|
|
258
|
-
@api_client.config.logger.debug 'Calling API:
|
|
189
|
+
@api_client.config.logger.debug 'Calling API: EventsApi.record_event ...'
|
|
259
190
|
end
|
|
260
|
-
# verify the required parameter '
|
|
261
|
-
if @api_client.config.client_side_validation &&
|
|
262
|
-
fail ArgumentError, "Missing the required parameter '
|
|
191
|
+
# verify the required parameter 'event_response' is set
|
|
192
|
+
if @api_client.config.client_side_validation && event_response.nil?
|
|
193
|
+
fail ArgumentError, "Missing the required parameter 'event_response' when calling EventsApi.record_event"
|
|
263
194
|
end
|
|
264
195
|
# resource path
|
|
265
|
-
local_var_path = '/api/v1/
|
|
196
|
+
local_var_path = '/api/v1/events'
|
|
266
197
|
|
|
267
198
|
# query parameters
|
|
268
199
|
query_params = opts[:query_params] || {}
|
|
269
|
-
query_params[:'filter[period]'] = filter_period
|
|
270
200
|
|
|
271
201
|
# header parameters
|
|
272
202
|
header_params = opts[:header_params] || {}
|
|
273
203
|
# HTTP header 'Accept' (if needed)
|
|
274
204
|
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) unless header_params['Accept']
|
|
205
|
+
# HTTP header 'Content-Type'
|
|
206
|
+
content_type = @api_client.select_header_content_type(['application/vnd.api+json'])
|
|
207
|
+
if !content_type.nil?
|
|
208
|
+
header_params['Content-Type'] = content_type
|
|
209
|
+
end
|
|
210
|
+
header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?
|
|
275
211
|
|
|
276
212
|
# form parameters
|
|
277
213
|
form_params = opts[:form_params] || {}
|
|
278
214
|
|
|
279
215
|
# http body (model)
|
|
280
|
-
post_body = opts[:debug_body]
|
|
216
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(event_response)
|
|
281
217
|
|
|
282
218
|
# return_type
|
|
283
|
-
return_type = opts[:debug_return_type] || '
|
|
219
|
+
return_type = opts[:debug_return_type] || 'EventResponse'
|
|
284
220
|
|
|
285
221
|
# auth_names
|
|
286
222
|
auth_names = opts[:debug_auth_names] || ['HTTPBearer']
|
|
287
223
|
|
|
288
224
|
new_options = opts.merge(
|
|
289
|
-
:operation => :"
|
|
225
|
+
:operation => :"EventsApi.record_event",
|
|
290
226
|
:header_params => header_params,
|
|
291
227
|
:query_params => query_params,
|
|
292
228
|
:form_params => form_params,
|
|
@@ -295,9 +231,9 @@ module SmplkitGeneratedClient::Audit
|
|
|
295
231
|
:return_type => return_type
|
|
296
232
|
)
|
|
297
233
|
|
|
298
|
-
data, status_code, headers = @api_client.call_api(:
|
|
234
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
|
299
235
|
if @api_client.config.debugging
|
|
300
|
-
@api_client.config.logger.debug "API called:
|
|
236
|
+
@api_client.config.logger.debug "API called: EventsApi#record_event\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
301
237
|
end
|
|
302
238
|
return data, status_code, headers
|
|
303
239
|
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#smplkit Audit API
|
|
3
|
+
|
|
4
|
+
#Append-only change-history substrate for smpl.* resources and customer-application events. ADR-047.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 0.1.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.22.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'cgi'
|
|
14
|
+
|
|
15
|
+
module SmplkitGeneratedClient::Audit
|
|
16
|
+
class UsageApi
|
|
17
|
+
attr_accessor :api_client
|
|
18
|
+
|
|
19
|
+
def initialize(api_client = ApiClient.default)
|
|
20
|
+
@api_client = api_client
|
|
21
|
+
end
|
|
22
|
+
# List Usage
|
|
23
|
+
# Current-period usage and quota for the audit product. Only ``filter[period]=current`` is supported; historical usage is a follow-up.
|
|
24
|
+
# @param filter_period [String]
|
|
25
|
+
# @param [Hash] opts the optional parameters
|
|
26
|
+
# @return [UsageResponse]
|
|
27
|
+
def list_usage(filter_period, opts = {})
|
|
28
|
+
data, _status_code, _headers = list_usage_with_http_info(filter_period, opts)
|
|
29
|
+
data
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# List Usage
|
|
33
|
+
# Current-period usage and quota for the audit product. Only ``filter[period]=current`` is supported; historical usage is a follow-up.
|
|
34
|
+
# @param filter_period [String]
|
|
35
|
+
# @param [Hash] opts the optional parameters
|
|
36
|
+
# @return [Array<(UsageResponse, Integer, Hash)>] UsageResponse data, response status code and response headers
|
|
37
|
+
def list_usage_with_http_info(filter_period, opts = {})
|
|
38
|
+
if @api_client.config.debugging
|
|
39
|
+
@api_client.config.logger.debug 'Calling API: UsageApi.list_usage ...'
|
|
40
|
+
end
|
|
41
|
+
# verify the required parameter 'filter_period' is set
|
|
42
|
+
if @api_client.config.client_side_validation && filter_period.nil?
|
|
43
|
+
fail ArgumentError, "Missing the required parameter 'filter_period' when calling UsageApi.list_usage"
|
|
44
|
+
end
|
|
45
|
+
# resource path
|
|
46
|
+
local_var_path = '/api/v1/usage'
|
|
47
|
+
|
|
48
|
+
# query parameters
|
|
49
|
+
query_params = opts[:query_params] || {}
|
|
50
|
+
query_params[:'filter[period]'] = filter_period
|
|
51
|
+
|
|
52
|
+
# header parameters
|
|
53
|
+
header_params = opts[:header_params] || {}
|
|
54
|
+
# HTTP header 'Accept' (if needed)
|
|
55
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) unless header_params['Accept']
|
|
56
|
+
|
|
57
|
+
# form parameters
|
|
58
|
+
form_params = opts[:form_params] || {}
|
|
59
|
+
|
|
60
|
+
# http body (model)
|
|
61
|
+
post_body = opts[:debug_body]
|
|
62
|
+
|
|
63
|
+
# return_type
|
|
64
|
+
return_type = opts[:debug_return_type] || 'UsageResponse'
|
|
65
|
+
|
|
66
|
+
# auth_names
|
|
67
|
+
auth_names = opts[:debug_auth_names] || ['HTTPBearer']
|
|
68
|
+
|
|
69
|
+
new_options = opts.merge(
|
|
70
|
+
:operation => :"UsageApi.list_usage",
|
|
71
|
+
:header_params => header_params,
|
|
72
|
+
:query_params => query_params,
|
|
73
|
+
:form_params => form_params,
|
|
74
|
+
:body => post_body,
|
|
75
|
+
:auth_names => auth_names,
|
|
76
|
+
:return_type => return_type
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
|
80
|
+
if @api_client.config.debugging
|
|
81
|
+
@api_client.config.logger.debug "API called: UsageApi#list_usage\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
82
|
+
end
|
|
83
|
+
return data, status_code, headers
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -28,7 +28,8 @@ require 'smplkit_audit_client/models/usage_resource'
|
|
|
28
28
|
require 'smplkit_audit_client/models/usage_response'
|
|
29
29
|
|
|
30
30
|
# APIs
|
|
31
|
-
require 'smplkit_audit_client/api/
|
|
31
|
+
require 'smplkit_audit_client/api/events_api'
|
|
32
|
+
require 'smplkit_audit_client/api/usage_api'
|
|
32
33
|
|
|
33
34
|
module SmplkitGeneratedClient::Audit
|
|
34
35
|
class << self
|
|
@@ -13,35 +13,22 @@ Generator version: 7.22.0
|
|
|
13
13
|
require 'spec_helper'
|
|
14
14
|
require 'json'
|
|
15
15
|
|
|
16
|
-
# Unit tests for SmplkitGeneratedClient::Audit::
|
|
16
|
+
# Unit tests for SmplkitGeneratedClient::Audit::EventsApi
|
|
17
17
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
|
18
18
|
# Please update as you see appropriate
|
|
19
|
-
describe '
|
|
19
|
+
describe 'EventsApi' do
|
|
20
20
|
before do
|
|
21
21
|
# run before each test
|
|
22
|
-
@api_instance = SmplkitGeneratedClient::Audit::
|
|
22
|
+
@api_instance = SmplkitGeneratedClient::Audit::EventsApi.new
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
after do
|
|
26
26
|
# run after each test
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
describe 'test an instance of
|
|
30
|
-
it 'should create an instance of
|
|
31
|
-
expect(@api_instance).to be_instance_of(SmplkitGeneratedClient::Audit::
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# unit tests for create_event
|
|
36
|
-
# Create Event
|
|
37
|
-
# Record an audit event for the authenticated account. Returns ``201 Created`` on first write, ``200 OK`` if the request was a duplicate (matched by ``Idempotency-Key`` or auto-derived key). Customers may not emit events whose ``resource_type`` starts with ``smpl.`` — that namespace is reserved for smplkit-emitted events about platform resources.
|
|
38
|
-
# @param event_response
|
|
39
|
-
# @param [Hash] opts the optional parameters
|
|
40
|
-
# @option opts [String] :idempotency_key
|
|
41
|
-
# @return [EventResponse]
|
|
42
|
-
describe 'create_event test' do
|
|
43
|
-
it 'should work' do
|
|
44
|
-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
|
|
29
|
+
describe 'test an instance of EventsApi' do
|
|
30
|
+
it 'should create an instance of EventsApi' do
|
|
31
|
+
expect(@api_instance).to be_instance_of(SmplkitGeneratedClient::Audit::EventsApi)
|
|
45
32
|
end
|
|
46
33
|
end
|
|
47
34
|
|
|
@@ -76,13 +63,14 @@ describe 'DefaultApi' do
|
|
|
76
63
|
end
|
|
77
64
|
end
|
|
78
65
|
|
|
79
|
-
# unit tests for
|
|
80
|
-
#
|
|
81
|
-
#
|
|
82
|
-
# @param
|
|
66
|
+
# unit tests for record_event
|
|
67
|
+
# Record Event
|
|
68
|
+
# Record an audit event for the authenticated account. Returns ``201 Created`` on first write, ``200 OK`` if the request was a duplicate (matched by ``Idempotency-Key`` or auto-derived key). Customers may not emit events whose ``resource_type`` starts with ``smpl.`` — that namespace is reserved for smplkit-emitted events about platform resources.
|
|
69
|
+
# @param event_response
|
|
83
70
|
# @param [Hash] opts the optional parameters
|
|
84
|
-
# @
|
|
85
|
-
|
|
71
|
+
# @option opts [String] :idempotency_key
|
|
72
|
+
# @return [EventResponse]
|
|
73
|
+
describe 'record_event test' do
|
|
86
74
|
it 'should work' do
|
|
87
75
|
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
|
|
88
76
|
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#smplkit Audit API
|
|
3
|
+
|
|
4
|
+
#Append-only change-history substrate for smpl.* resources and customer-application events. ADR-047.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 0.1.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.22.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'spec_helper'
|
|
14
|
+
require 'json'
|
|
15
|
+
|
|
16
|
+
# Unit tests for SmplkitGeneratedClient::Audit::UsageApi
|
|
17
|
+
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
|
18
|
+
# Please update as you see appropriate
|
|
19
|
+
describe 'UsageApi' do
|
|
20
|
+
before do
|
|
21
|
+
# run before each test
|
|
22
|
+
@api_instance = SmplkitGeneratedClient::Audit::UsageApi.new
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
after do
|
|
26
|
+
# run after each test
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe 'test an instance of UsageApi' do
|
|
30
|
+
it 'should create an instance of UsageApi' do
|
|
31
|
+
expect(@api_instance).to be_instance_of(SmplkitGeneratedClient::Audit::UsageApi)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# unit tests for list_usage
|
|
36
|
+
# List Usage
|
|
37
|
+
# Current-period usage and quota for the audit product. Only ``filter[period]=current`` is supported; historical usage is a follow-up.
|
|
38
|
+
# @param filter_period
|
|
39
|
+
# @param [Hash] opts the optional parameters
|
|
40
|
+
# @return [UsageResponse]
|
|
41
|
+
describe 'list_usage test' do
|
|
42
|
+
it 'should work' do
|
|
43
|
+
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
data/lib/smplkit/audit/buffer.rb
CHANGED
|
@@ -25,6 +25,13 @@ module Smplkit
|
|
|
25
25
|
@cond = ConditionVariable.new
|
|
26
26
|
@closed = false
|
|
27
27
|
@dropped_count = 0
|
|
28
|
+
# +@in_flight+ is the number of items the worker has shifted off
|
|
29
|
+
# the queue but not yet finished POSTing. +#flush+ must wait on
|
|
30
|
+
# both queue empty AND in_flight == 0 — otherwise it can return
|
|
31
|
+
# while a just-shifted item is still in the middle of its HTTP
|
|
32
|
+
# round-trip, and an immediately following +list+ call would
|
|
33
|
+
# miss the event.
|
|
34
|
+
@in_flight = 0
|
|
28
35
|
@worker = Thread.new { run }
|
|
29
36
|
@worker.report_on_exception = false
|
|
30
37
|
end
|
|
@@ -49,8 +56,8 @@ module Smplkit
|
|
|
49
56
|
def flush(timeout: 5.0)
|
|
50
57
|
deadline = monotonic_now + timeout
|
|
51
58
|
loop do
|
|
52
|
-
|
|
53
|
-
return if
|
|
59
|
+
idle = @mutex.synchronize { @queue.empty? && @in_flight.zero? }
|
|
60
|
+
return if idle
|
|
54
61
|
|
|
55
62
|
if monotonic_now >= deadline
|
|
56
63
|
warn "[smplkit.audit] flush timed out (timeout=#{timeout}s)"
|
|
@@ -102,12 +109,13 @@ module Smplkit
|
|
|
102
109
|
return if head.next_retry_at && head.next_retry_at > monotonic_now
|
|
103
110
|
|
|
104
111
|
item = @queue.shift
|
|
112
|
+
@in_flight += 1
|
|
105
113
|
end
|
|
106
114
|
|
|
107
115
|
status = 0
|
|
108
116
|
begin
|
|
109
117
|
opts = item.idempotency_key ? { idempotency_key: item.idempotency_key } : {}
|
|
110
|
-
@api.
|
|
118
|
+
@api.record_event(item.body, opts)
|
|
111
119
|
status = 201
|
|
112
120
|
rescue SmplkitGeneratedClient::Audit::ApiError => e
|
|
113
121
|
status = e.code || 0
|
|
@@ -116,10 +124,11 @@ module Smplkit
|
|
|
116
124
|
end
|
|
117
125
|
|
|
118
126
|
requeue = handle_outcome(item, status)
|
|
119
|
-
|
|
120
|
-
@
|
|
121
|
-
|
|
127
|
+
@mutex.synchronize do
|
|
128
|
+
@in_flight -= 1
|
|
129
|
+
@queue.unshift(requeue) if requeue
|
|
122
130
|
end
|
|
131
|
+
return if requeue
|
|
123
132
|
end
|
|
124
133
|
end
|
|
125
134
|
|
data/lib/smplkit/audit/client.rb
CHANGED
|
@@ -17,7 +17,7 @@ module Smplkit
|
|
|
17
17
|
cfg.access_token = api_key
|
|
18
18
|
cfg.timeout = timeout
|
|
19
19
|
api_client = SmplkitGeneratedClient::Audit::ApiClient.new(cfg)
|
|
20
|
-
api = SmplkitGeneratedClient::Audit::
|
|
20
|
+
api = SmplkitGeneratedClient::Audit::EventsApi.new(api_client)
|
|
21
21
|
@events = Events.new(api)
|
|
22
22
|
end
|
|
23
23
|
|
data/lib/smplkit/audit/events.rb
CHANGED
|
@@ -18,7 +18,7 @@ module Smplkit
|
|
|
18
18
|
# Customer attempts to record events with +resource_type+ starting
|
|
19
19
|
# with +smpl.+ are rejected by the server with a 403 (the buffer
|
|
20
20
|
# logs and drops permanent failures).
|
|
21
|
-
def
|
|
21
|
+
def record(action:, resource_type:, resource_id:,
|
|
22
22
|
occurred_at: nil, snapshot: nil, data: nil, idempotency_key: nil)
|
|
23
23
|
raise ArgumentError, "action is required" if action.nil? || action.to_s.empty?
|
|
24
24
|
raise ArgumentError, "resource_type is required" if resource_type.nil? || resource_type.to_s.empty?
|
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.
|
|
4
|
+
version: 1.0.20
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Smpl Solutions LLC
|
|
@@ -389,7 +389,8 @@ files:
|
|
|
389
389
|
- lib/smplkit/_generated/app/spec/models/verify_email_request_spec.rb
|
|
390
390
|
- lib/smplkit/_generated/app/spec/spec_helper.rb
|
|
391
391
|
- lib/smplkit/_generated/audit/lib/smplkit_audit_client.rb
|
|
392
|
-
- lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/
|
|
392
|
+
- lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/events_api.rb
|
|
393
|
+
- lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/usage_api.rb
|
|
393
394
|
- lib/smplkit/_generated/audit/lib/smplkit_audit_client/api_client.rb
|
|
394
395
|
- lib/smplkit/_generated/audit/lib/smplkit_audit_client/api_error.rb
|
|
395
396
|
- lib/smplkit/_generated/audit/lib/smplkit_audit_client/api_model_base.rb
|
|
@@ -403,7 +404,8 @@ files:
|
|
|
403
404
|
- lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/usage_resource.rb
|
|
404
405
|
- lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/usage_response.rb
|
|
405
406
|
- lib/smplkit/_generated/audit/lib/smplkit_audit_client/version.rb
|
|
406
|
-
- lib/smplkit/_generated/audit/spec/api/
|
|
407
|
+
- lib/smplkit/_generated/audit/spec/api/events_api_spec.rb
|
|
408
|
+
- lib/smplkit/_generated/audit/spec/api/usage_api_spec.rb
|
|
407
409
|
- lib/smplkit/_generated/audit/spec/models/event_list_links_spec.rb
|
|
408
410
|
- lib/smplkit/_generated/audit/spec/models/event_list_meta_spec.rb
|
|
409
411
|
- lib/smplkit/_generated/audit/spec/models/event_list_response_spec.rb
|