Module: Smplkit::Audit
- Defined in:
- lib/smplkit/audit/buffer.rb,
lib/smplkit/audit/client.rb,
lib/smplkit/audit/events.rb,
lib/smplkit/audit/models.rb,
lib/smplkit/audit/categories.rb,
lib/smplkit/audit/forwarders.rb,
lib/smplkit/audit/event_types.rb,
lib/smplkit/audit/resource_types.rb
Defined Under Namespace
Modules: ForwarderType, HttpMethod, TransformType Classes: AuditClient, AuditEvent, Categories, Category, CategoryListPage, EventBuffer, EventType, EventTypeListPage, EventTypes, Events, Forwarder, ForwarderEnvironment, ForwarderListPage, ForwardersClient, HttpConfiguration, HttpHeader, ListEventsPage, ResourceType, ResourceTypeListPage, ResourceTypes
Class Method Summary collapse
-
.call_api ⇒ Object
private
Wrap a generated-audit-API call and translate
ApiErrorinto theSmplkit::Errorhierarchy. -
.extract_pagination(meta) ⇒ Object
private
Pull the offset-pagination block out of a JSON:API
metaenvelope. -
.join_environments(environments) ⇒ Object
private
Coerce a caller-supplied
environmentsvalue into the comma-separated string the audit read endpoints expect forfilter[environment], ornilwhen no filter should be sent. -
.next_cursor(link) ⇒ Object
private
Parse the
page[after]cursor out of a JSON:APIlinks.nextURL.
Class Method Details
.call_api ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Wrap a generated-audit-API call and translate ApiError into the Smplkit::Error hierarchy. Connection-level failures (no response code) become ConnectionError; status-coded failures route through Errors.raise_for_status, which emits PaymentRequiredError / NotFoundError / ConflictError / ValidationError / Error depending on the JSON:API body.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/smplkit/audit/models.rb', line 13 def self.call_api yield rescue SmplkitGeneratedClient::Audit::ApiError => e raise Smplkit::ConnectionError, e..to_s if e.code.nil? || e.code.zero? Smplkit::Errors.raise_for_status(e.code, e.response_body.to_s) # raise_for_status only returns on 2xx; if we get here the # generated layer raised on a 2xx (shouldn't happen) — re-raise # the original so the caller can inspect. raise end |
.extract_pagination(meta) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Pull the offset-pagination block out of a JSON:API meta envelope. Returns a hash with :page/:size (and :total/:total_pages when the request opted into meta=true). Always returns a hash so callers don’t have to nil-check before reading individual keys.
48 49 50 51 52 53 54 55 56 |
# File 'lib/smplkit/audit/models.rb', line 48 def self.extract_pagination() pagination = &.pagination return {} if pagination.nil? out = { page: pagination.page, size: pagination.size } out[:total] = pagination.total unless pagination.total.nil? out[:total_pages] = pagination.total_pages unless pagination.total_pages.nil? out end |
.join_environments(environments) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Coerce a caller-supplied environments value into the comma-separated string the audit read endpoints expect for filter[environment], or nil when no filter should be sent.
The audit read endpoints (events list, the resource_type / event_type / category discovery lists) accept an optional comma-separated filter[environment] of real environment keys and/or the reserved “smplkit” control-plane bucket. The wrapper takes an array of keys for an ergonomic surface and joins it here.
nil or an empty array (or one whose entries are all blank) returns nil so the caller omits the query param entirely and behaves exactly as before — existing callers are byte-for-byte unchanged on the wire. “smplkit” is passed through like any other key; it carries no special handling in the SDK.
75 76 77 78 79 80 |
# File 'lib/smplkit/audit/models.rb', line 75 def self.join_environments(environments) return nil if environments.nil? values = Array(environments).map { |e| e.to_s.strip }.reject(&:empty?) values.empty? ? nil : values.join(",") end |
.next_cursor(link) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Parse the page[after] cursor out of a JSON:API links.next URL. Returns nil for non-string input or when the link carries no cursor parameter; trims trailing query params at the next ampersand so they don’t leak into the token.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/smplkit/audit/models.rb', line 31 def self.next_cursor(link) return nil unless link.is_a?(String) idx = link.index("page[after]=") return nil if idx.nil? token = link[(idx + "page[after]=".length)..] amp = token.index("&") amp ? token[0...amp] : token end |