Class: Smplkit::Audit::AuditClient

Inherits:
Object
  • Object
show all
Defined in:
lib/smplkit/audit/client.rb

Overview

The Smpl Audit client — accessed via client.audit.

One client exposes the full surface — event recording and reads, distinct-value discovery, and SIEM forwarder CRUD. Owns fire-and-forget #events.record, plus the audit-log list / get and the distinct-value listings (resource_types, event_types, categories), plus SIEM forwarder CRUD on #forwarders.

Constant Summary collapse

SDK_OWNED_HEADERS =
%w[authorization content-type user-agent].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, base_url:, environment: nil, timeout: 10.0, extra_headers: nil) ⇒ AuditClient

Returns a new instance of AuditClient.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/smplkit/audit/client.rb', line 28

def initialize(api_key:, base_url:, environment: nil, timeout: 10.0, extra_headers: nil)
  cfg = SmplkitGeneratedClient::Audit::Configuration.new
  cfg.host = URI.parse(base_url).host
  cfg.scheme = URI.parse(base_url).scheme
  cfg.access_token = api_key
  cfg.timeout = timeout
  HttpPool.configure(cfg)
  api_client = SmplkitGeneratedClient::Audit::ApiClient.new(cfg)
  api_client.default_headers["User-Agent"] = "smplkit-ruby-sdk/#{Smplkit::VERSION}"
  # Runtime audit ops are environment-scoped: record / list / get /
  # discovery all resolve their environment from the
  # +X-Smplkit-Environment+ request header (ADR-055). We stamp it once
  # at the client level from the SDK's configured runtime environment so
  # every generated call carries it. It is stamped before +extra_headers+
  # is applied so a caller-supplied entry of the same name wins (explicit
  # override).
  api_client.default_headers["X-Smplkit-Environment"] = environment unless environment.nil?
  extra_headers&.each do |k, v|
    api_client.default_headers[k] = v unless SDK_OWNED_HEADERS.include?(k.downcase)
  end
  @events = Events.new(SmplkitGeneratedClient::Audit::EventsApi.new(api_client))
  @resource_types = ResourceTypes.new(SmplkitGeneratedClient::Audit::ResourceTypesApi.new(api_client))
  @event_types = EventTypes.new(SmplkitGeneratedClient::Audit::EventTypesApi.new(api_client))
  @categories = Categories.new(SmplkitGeneratedClient::Audit::CategoriesApi.new(api_client))
  @forwarders = ForwardersClient.new(SmplkitGeneratedClient::Audit::ForwardersApi.new(api_client))
end

Instance Attribute Details

#categoriesObject (readonly)

Returns the value of attribute categories.



24
25
26
# File 'lib/smplkit/audit/client.rb', line 24

def categories
  @categories
end

#event_typesObject (readonly)

Returns the value of attribute event_types.



24
25
26
# File 'lib/smplkit/audit/client.rb', line 24

def event_types
  @event_types
end

#eventsObject (readonly)

Returns the value of attribute events.



24
25
26
# File 'lib/smplkit/audit/client.rb', line 24

def events
  @events
end

#forwardersObject (readonly)

Returns the value of attribute forwarders.



24
25
26
# File 'lib/smplkit/audit/client.rb', line 24

def forwarders
  @forwarders
end

#resource_typesObject (readonly)

Returns the value of attribute resource_types.



24
25
26
# File 'lib/smplkit/audit/client.rb', line 24

def resource_types
  @resource_types
end

Instance Method Details

#_closeObject



55
56
57
# File 'lib/smplkit/audit/client.rb', line 55

def _close
  @events._close
end