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/actions.rb,
lib/smplkit/audit/resource_types.rb

Defined Under Namespace

Modules: ForwarderType Classes: Action, ActionListPage, Actions, AuditClient, AuditEvent, EventBuffer, Events, Forwarder, ForwarderHttp, HttpHeader, ListEventsPage, ResourceType, ResourceTypeListPage, ResourceTypes

Class Method Summary collapse

Class Method Details

.call_apiObject

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



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/smplkit/audit/models.rb', line 15

def self.call_api
  yield
rescue SmplkitGeneratedClient::Audit::ApiError => e
  raise Smplkit::ConnectionError, e.message.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

.next_cursor(link) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/smplkit/audit/models.rb', line 27

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