Class: SmplkitGeneratedClient::Audit::EventsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/events_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ EventsApi

Returns a new instance of EventsApi.



19
20
21
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/events_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/events_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#get_event(event_id, opts = {}) ⇒ EventResponse

Get Event Retrieve a single audit event by id.

Parameters:

  • event_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



27
28
29
30
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/events_api.rb', line 27

def get_event(event_id, opts = {})
  data, _status_code, _headers = get_event_with_http_info(event_id, opts)
  data
end

#get_event_with_http_info(event_id, opts = {}) ⇒ Array<(EventResponse, Integer, Hash)>

Get Event Retrieve a single audit event by id.

Parameters:

  • event_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(EventResponse, Integer, Hash)>)

    EventResponse data, response status code and response headers



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/events_api.rb', line 37

def get_event_with_http_info(event_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: EventsApi.get_event ...'
  end
  # verify the required parameter 'event_id' is set
  if @api_client.config.client_side_validation && event_id.nil?
    fail ArgumentError, "Missing the required parameter 'event_id' when calling EventsApi.get_event"
  end
  # resource path
  local_var_path = '/api/v1/events/{event_id}'.sub('{event_id}', CGI.escape(event_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'EventResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"EventsApi.get_event",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: EventsApi#get_event\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_events(opts = {}) ⇒ EventListResponse

List Events List audit events for this account. Default sort is ‘-occurred_at` (newest occurrence first). Sort by `occurred_at` or `created_at`, ascending or descending — keep the same `sort` value across paginated requests so the cursor stays consistent. Filters are exact-match except `filter`, which uses interval notation (e.g. `[2026-01-01T00:00:00Z,2026-01-31T00:00:00Z)`), and `filter`, which is a case-insensitive substring match against `resource_id` or `description`. Two filter-combination rules: - `filter` must be accompanied by `filter` (the index is keyed on the pair). - `filter` must be accompanied by either `filter` or `filter` + `filter` (substring matching has no index, so an unbounded substring scan is rejected). No other filter combinations are required — calling the endpoint with no query parameters returns the latest events for the account, paginated. `page` defaults to 1000 and must not exceed 1000. Pass `format=CSV` or `format=JSONL` to stream a download of the full filtered result set instead of a paginated JSON:API response. The download honors every supplied filter and ignores `page` and `page`.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :filter_occurred_at (String)
  • :filter_actor_type (String)
  • :filter_actor_id (String)
  • :filter_event_type (String)
  • :filter_resource_type (String)
  • :filter_resource_id (String)
  • :filter_severity (String)

    Exact match on the event&#39;s &#x60;severity&#x60; field. One of &#x60;TRACE&#x60;, &#x60;DEBUG&#x60;, &#x60;INFO&#x60;, &#x60;WARN&#x60;, &#x60;ERROR&#x60;, &#x60;FATAL&#x60;.

  • :filter_category (String)

    Exact match on the event&#39;s &#x60;category&#x60; field.

  • :filter_search (String)

    Case-insensitive substring match against &#x60;resource_id&#x60; or &#x60;description&#x60;. Use &#x60;filter&#x60; for an exact match on &#x60;resource_id&#x60;.

  • :filter_do_not_forward (Boolean)

    When set, restrict to events whose &#x60;do_not_forward&#x60; flag matches the given boolean. Forwarder previews typically pass &#x60;false&#x60; to match live-pipeline semantics (events flagged &#x60;do_not_forward&#x3D;true&#x60; are skipped by the forwarder pipeline).

  • :page_size (Integer)
  • :page_after (String)
  • :format (String)

    When set, stream a download of the full filtered result set in the chosen format instead of returning a paginated JSON:API response. &#x60;page&#x60; and &#x60;page&#x60; are ignored in this mode; every event matching the supplied filters is emitted. &#x60;CSV&#x60; writes one row per event with the event payload (&#x60;data&#x60;) serialized as a single JSON-encoded cell. &#x60;JSONL&#x60; writes one JSON object per line with the event payload nested as a JSON object. Omit this parameter to receive the paginated JSON:API response.

  • :sort (String)

    Field to sort by. Prefix with &#x60;-&#x60; for descending order. Default: &#x60;-occurred_at&#x60;. Allowed values: &#x60;created_at&#x60;, &#x60;-created_at&#x60;, &#x60;occurred_at&#x60;, &#x60;-occurred_at&#x60;. (default to ‘-occurred_at’)

Returns:



103
104
105
106
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/events_api.rb', line 103

def list_events(opts = {})
  data, _status_code, _headers = list_events_with_http_info(opts)
  data
end

#list_events_with_http_info(opts = {}) ⇒ Array<(EventListResponse, Integer, Hash)>

List Events List audit events for this account. Default sort is &#x60;-occurred_at&#x60; (newest occurrence first). Sort by &#x60;occurred_at&#x60; or &#x60;created_at&#x60;, ascending or descending — keep the same &#x60;sort&#x60; value across paginated requests so the cursor stays consistent. Filters are exact-match except &#x60;filter&#x60;, which uses interval notation (e.g. &#x60;[2026-01-01T00:00:00Z,2026-01-31T00:00:00Z)&#x60;), and &#x60;filter&#x60;, which is a case-insensitive substring match against &#x60;resource_id&#x60; or &#x60;description&#x60;. Two filter-combination rules: - &#x60;filter&#x60; must be accompanied by &#x60;filter&#x60; (the index is keyed on the pair). - &#x60;filter&#x60; must be accompanied by either &#x60;filter&#x60; or &#x60;filter&#x60; + &#x60;filter&#x60; (substring matching has no index, so an unbounded substring scan is rejected). No other filter combinations are required — calling the endpoint with no query parameters returns the latest events for the account, paginated. &#x60;page&#x60; defaults to 1000 and must not exceed 1000. Pass &#x60;format&#x3D;CSV&#x60; or &#x60;format&#x3D;JSONL&#x60; to stream a download of the full filtered result set instead of a paginated JSON:API response. The download honors every supplied filter and ignores &#x60;page&#x60; and &#x60;page&#x60;.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :filter_occurred_at (String)
  • :filter_actor_type (String)
  • :filter_actor_id (String)
  • :filter_event_type (String)
  • :filter_resource_type (String)
  • :filter_resource_id (String)
  • :filter_severity (String)

    Exact match on the event&#39;s &#x60;severity&#x60; field. One of &#x60;TRACE&#x60;, &#x60;DEBUG&#x60;, &#x60;INFO&#x60;, &#x60;WARN&#x60;, &#x60;ERROR&#x60;, &#x60;FATAL&#x60;.

  • :filter_category (String)

    Exact match on the event&#39;s &#x60;category&#x60; field.

  • :filter_search (String)

    Case-insensitive substring match against &#x60;resource_id&#x60; or &#x60;description&#x60;. Use &#x60;filter&#x60; for an exact match on &#x60;resource_id&#x60;.

  • :filter_do_not_forward (Boolean)

    When set, restrict to events whose &#x60;do_not_forward&#x60; flag matches the given boolean. Forwarder previews typically pass &#x60;false&#x60; to match live-pipeline semantics (events flagged &#x60;do_not_forward&#x3D;true&#x60; are skipped by the forwarder pipeline).

  • :page_size (Integer)
  • :page_after (String)
  • :format (String)

    When set, stream a download of the full filtered result set in the chosen format instead of returning a paginated JSON:API response. &#x60;page&#x60; and &#x60;page&#x60; are ignored in this mode; every event matching the supplied filters is emitted. &#x60;CSV&#x60; writes one row per event with the event payload (&#x60;data&#x60;) serialized as a single JSON-encoded cell. &#x60;JSONL&#x60; writes one JSON object per line with the event payload nested as a JSON object. Omit this parameter to receive the paginated JSON:API response.

  • :sort (String)

    Field to sort by. Prefix with &#x60;-&#x60; for descending order. Default: &#x60;-occurred_at&#x60;. Allowed values: &#x60;created_at&#x60;, &#x60;-created_at&#x60;, &#x60;occurred_at&#x60;, &#x60;-occurred_at&#x60;. (default to ‘-occurred_at’)

Returns:

  • (Array<(EventListResponse, Integer, Hash)>)

    EventListResponse data, response status code and response headers



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/events_api.rb', line 126

def list_events_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: EventsApi.list_events ...'
  end
  if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling EventsApi.list_events, must be greater than or equal to 1.'
  end

  allowable_values = ["CSV", "JSONL"]
  if @api_client.config.client_side_validation && opts[:'format'] && !allowable_values.include?(opts[:'format'])
    fail ArgumentError, "invalid value for \"format\", must be one of #{allowable_values}"
  end
  allowable_values = ["created_at", "-created_at", "occurred_at", "-occurred_at"]
  if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
    fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/v1/events'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'filter[occurred_at]'] = opts[:'filter_occurred_at'] if !opts[:'filter_occurred_at'].nil?
  query_params[:'filter[actor_type]'] = opts[:'filter_actor_type'] if !opts[:'filter_actor_type'].nil?
  query_params[:'filter[actor_id]'] = opts[:'filter_actor_id'] if !opts[:'filter_actor_id'].nil?
  query_params[:'filter[event_type]'] = opts[:'filter_event_type'] if !opts[:'filter_event_type'].nil?
  query_params[:'filter[resource_type]'] = opts[:'filter_resource_type'] if !opts[:'filter_resource_type'].nil?
  query_params[:'filter[resource_id]'] = opts[:'filter_resource_id'] if !opts[:'filter_resource_id'].nil?
  query_params[:'filter[severity]'] = opts[:'filter_severity'] if !opts[:'filter_severity'].nil?
  query_params[:'filter[category]'] = opts[:'filter_category'] if !opts[:'filter_category'].nil?
  query_params[:'filter[search]'] = opts[:'filter_search'] if !opts[:'filter_search'].nil?
  query_params[:'filter[do_not_forward]'] = opts[:'filter_do_not_forward'] if !opts[:'filter_do_not_forward'].nil?
  query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil?
  query_params[:'page[after]'] = opts[:'page_after'] if !opts[:'page_after'].nil?
  query_params[:'format'] = opts[:'format'] if !opts[:'format'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'EventListResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"EventsApi.list_events",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: EventsApi#list_events\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#record_event(event_request, opts = {}) ⇒ EventResponse

Record Event Record an audit event for this account. Returns ‘201 Created` on first write, `200 OK` if the request was a duplicate (matched by `Idempotency-Key` or a key derived from the event’s content). ‘resource_type` values beginning with `smpl.` are reserved for events that smplkit emits about its own resources and cannot be used here.

Parameters:

  • event_request (EventRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

Returns:



202
203
204
205
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/events_api.rb', line 202

def record_event(event_request, opts = {})
  data, _status_code, _headers = record_event_with_http_info(event_request, opts)
  data
end

#record_event_with_http_info(event_request, opts = {}) ⇒ Array<(EventResponse, Integer, Hash)>

Record Event Record an audit event for this account. Returns &#x60;201 Created&#x60; on first write, &#x60;200 OK&#x60; if the request was a duplicate (matched by &#x60;Idempotency-Key&#x60; or a key derived from the event&#39;s content). &#x60;resource_type&#x60; values beginning with &#x60;smpl.&#x60; are reserved for events that smplkit emits about its own resources and cannot be used here.

Parameters:

  • event_request (EventRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

Returns:

  • (Array<(EventResponse, Integer, Hash)>)

    EventResponse data, response status code and response headers



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/events_api.rb', line 213

def record_event_with_http_info(event_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: EventsApi.record_event ...'
  end
  # verify the required parameter 'event_request' is set
  if @api_client.config.client_side_validation && event_request.nil?
    fail ArgumentError, "Missing the required parameter 'event_request' when calling EventsApi.record_event"
  end
  # resource path
  local_var_path = '/api/v1/events'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(event_request)

  # return_type
  return_type = opts[:debug_return_type] || 'EventResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"EventsApi.record_event",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: EventsApi#record_event\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#search_events(event_search_request, opts = {}) ⇒ EventSearchResponse

Search Events Search audit events with column filters and an optional JSON Logic expression. Without a JSON Logic ‘filter`: behaves like `GET /api/v1/events` with the same column filters. With a JSON Logic `filter`: the search is silently capped to the last 30 days by `occurred_at` (intersected with any explicit `filter` the caller supplied), the column filters narrow the candidate set in SQL, and the JSON Logic expression runs in memory against each candidate row using the same `json-logic-qubit` evaluator the forwarder pipeline uses. Up to 50,000 rows are scanned per request; the response’s ‘meta.scan` block reports the scan stats so a selective filter doesn’t look like "0 matches" when the truth is "ceiling reached."

Parameters:

  • event_search_request (EventSearchRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



272
273
274
275
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/events_api.rb', line 272

def search_events(event_search_request, opts = {})
  data, _status_code, _headers = search_events_with_http_info(event_search_request, opts)
  data
end

#search_events_with_http_info(event_search_request, opts = {}) ⇒ Array<(EventSearchResponse, Integer, Hash)>

Search Events Search audit events with column filters and an optional JSON Logic expression. Without a JSON Logic &#x60;filter&#x60;: behaves like &#x60;GET /api/v1/events&#x60; with the same column filters. With a JSON Logic &#x60;filter&#x60;: the search is silently capped to the last 30 days by &#x60;occurred_at&#x60; (intersected with any explicit &#x60;filter&#x60; the caller supplied), the column filters narrow the candidate set in SQL, and the JSON Logic expression runs in memory against each candidate row using the same &#x60;json-logic-qubit&#x60; evaluator the forwarder pipeline uses. Up to 50,000 rows are scanned per request; the response&#39;s &#x60;meta.scan&#x60; block reports the scan stats so a selective filter doesn&#39;t look like &quot;0 matches&quot; when the truth is &quot;ceiling reached.&quot;

Parameters:

  • event_search_request (EventSearchRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(EventSearchResponse, Integer, Hash)>)

    EventSearchResponse data, response status code and response headers



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/events_api.rb', line 282

def search_events_with_http_info(event_search_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: EventsApi.search_events ...'
  end
  # verify the required parameter 'event_search_request' is set
  if @api_client.config.client_side_validation && event_search_request.nil?
    fail ArgumentError, "Missing the required parameter 'event_search_request' when calling EventsApi.search_events"
  end
  # resource path
  local_var_path = '/api/v1/events/search'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(event_search_request)

  # return_type
  return_type = opts[:debug_return_type] || 'EventSearchResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"EventsApi.search_events",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: EventsApi#search_events\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end