Class: SmplkitGeneratedClient::Audit::DefaultApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ DefaultApi

Returns a new instance of DefaultApi.



19
20
21
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/default_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/default_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_event(event_response, opts = {}) ⇒ EventResponse

Create Event 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.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

Returns:



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

def create_event(event_response, opts = {})
  data, _status_code, _headers = create_event_with_http_info(event_response, opts)
  data
end

#create_event_with_http_info(event_response, opts = {}) ⇒ Array<(EventResponse, Integer, Hash)>

Create Event Record an audit event for the authenticated account. Returns &#x60;&#x60;201 Created&#x60;&#x60; on first write, &#x60;&#x60;200 OK&#x60;&#x60; if the request was a duplicate (matched by &#x60;&#x60;Idempotency-Key&#x60;&#x60; or auto-derived key). Customers may not emit events whose &#x60;&#x60;resource_type&#x60;&#x60; starts with &#x60;&#x60;smpl.&#x60;&#x60; — that namespace is reserved for smplkit-emitted events about platform resources.

Parameters:

  • event_response (EventResponse)
  • 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



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
84
85
86
87
88
89
90
91
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/default_api.rb', line 39

def create_event_with_http_info(event_response, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.create_event ...'
  end
  # verify the required parameter 'event_response' is set
  if @api_client.config.client_side_validation && event_response.nil?
    fail ArgumentError, "Missing the required parameter 'event_response' when calling DefaultApi.create_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_response)

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

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

  new_options = opts.merge(
    :operation => :"DefaultApi.create_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: DefaultApi#create_event\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Get Event 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.

Parameters:

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

    the optional parameters

Returns:



98
99
100
101
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/default_api.rb', line 98

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. Returns 404 if no event with that id exists in the caller&#39;s account — RLS enforces tenant isolation; this endpoint never leaks the existence of another tenant&#39;s event.

Parameters:

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

    the optional parameters

Returns:

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

    EventResponse data, response status code and response headers



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/default_api.rb', line 108

def get_event_with_http_info(event_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.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 DefaultApi.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 => :"DefaultApi.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: DefaultApi#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 the authenticated account. Default sort is “-created_at“; cursor pagination via “page“ (the opaque cursor returned in “links.next“). Filters are exact-match except “filter“ which uses the platform’s range notation (“[2026-01-01T00:00:00Z,*)“).

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :filter_occurred_at (String)
  • :filter_actor_type (String)
  • :filter_actor_id (String)
  • :filter_action (String)
  • :filter_resource_type (String)
  • :filter_resource_id (String)
  • :page_size (Integer)
  • :page_after (String)

Returns:



168
169
170
171
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/default_api.rb', line 168

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 the authenticated account. Default sort is &#x60;&#x60;-created_at&#x60;&#x60;; cursor pagination via &#x60;&#x60;page&#x60;&#x60; (the opaque cursor returned in &#x60;&#x60;links.next&#x60;&#x60;). Filters are exact-match except &#x60;&#x60;filter&#x60;&#x60; which uses the platform&#39;s range notation (&#x60;&#x60;[2026-01-01T00:00:00Z,*)&#x60;&#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_action (String)
  • :filter_resource_type (String)
  • :filter_resource_id (String)
  • :page_size (Integer)
  • :page_after (String)

Returns:

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

    EventListResponse data, response status code and response headers



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
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
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/default_api.rb', line 185

def list_events_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.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 DefaultApi.list_events, must be greater than or equal to 1.'
  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[action]'] = opts[:'filter_action'] if !opts[:'filter_action'].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[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil?
  query_params[:'page[after]'] = opts[:'page_after'] if !opts[:'page_after'].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 => :"DefaultApi.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: DefaultApi#list_events\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_usage(filter_period, opts = {}) ⇒ UsageResponse

List Usage Current-period usage and quota for the audit product. Only “filter=current“ is supported; historical usage is a follow-up.

Parameters:

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

    the optional parameters

Returns:



246
247
248
249
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/default_api.rb', line 246

def list_usage(filter_period, opts = {})
  data, _status_code, _headers = list_usage_with_http_info(filter_period, opts)
  data
end

#list_usage_with_http_info(filter_period, opts = {}) ⇒ Array<(UsageResponse, Integer, Hash)>

List Usage Current-period usage and quota for the audit product. Only &#x60;&#x60;filter&#x3D;current&#x60;&#x60; is supported; historical usage is a follow-up.

Parameters:

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

    the optional parameters

Returns:

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

    UsageResponse data, response status code and response headers



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/default_api.rb', line 256

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

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'filter[period]'] = filter_period

  # 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] || 'UsageResponse'

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

  new_options = opts.merge(
    :operation => :"DefaultApi.list_usage",
    :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: DefaultApi#list_usage\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end