Class: Smplkit::Audit::EventTypes

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

Overview

client.audit.event_types.list — distinct event_type slugs seen for the account.

Without filter_resource_type, returns one row per distinct event type — an event type recorded with multiple resource_types appears once. With the filter, returns the event types seen with that specific resource_type, which supports building a cascading resource-type-then- event-type filter.

Sorted alphabetically; offset paginated.

Instance Method Summary collapse

Constructor Details

#initialize(api) ⇒ EventTypes

Returns a new instance of EventTypes.



16
17
18
# File 'lib/smplkit/audit/event_types.rb', line 16

def initialize(api)
  @api = api
end

Instance Method Details

#list(filter_resource_type: nil, page_number: nil, page_size: nil, meta_total: nil, environments: nil) ⇒ Smplkit::Audit::EventTypeListPage

List the distinct event_type slugs seen in the account.

environments scopes the listing to a set of environments: pass an array of environment keys and/or the reserved “smplkit” control-plane bucket; the values are comma-joined into filter[environment]. Omitting it (or passing an empty array) leaves the filter off entirely.

Parameters:

  • filter_resource_type (String, nil) (defaults to: nil)

    Restrict the listing to event_types seen with this resource_type. Omit to list every distinct event_type.

  • page_number (Integer, nil) (defaults to: nil)

    1-based page index. Omit for the first page.

  • page_size (Integer, nil) (defaults to: nil)

    Maximum number of slugs to return in this page.

  • meta_total (Boolean, nil) (defaults to: nil)

    When true, populate total and total_pages in the returned page’s pagination block (costs an extra count server-side). Omit to skip it.

  • environments (Array<String>, nil) (defaults to: nil)

    Environment keys and/or the reserved “smplkit” control-plane bucket to scope the listing to. Omit to leave the filter off entirely.

Returns:



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/smplkit/audit/event_types.rb', line 42

def list(filter_resource_type: nil, page_number: nil, page_size: nil, meta_total: nil, environments: nil)
  opts = {}
  opts[:filter_resource_type] = filter_resource_type if filter_resource_type
  opts[:page_number] = page_number if page_number
  opts[:page_size] = page_size if page_size
  opts[:meta_total] = meta_total unless meta_total.nil?
  joined_environments = Smplkit::Audit.join_environments(environments)
  opts[:filter_environment] = joined_environments if joined_environments

  resp = Smplkit::Audit.call_api { @api.list_event_types(opts) }
  rows = (resp.data || []).map { |r| EventType.from_resource(r) }
  EventTypeListPage.new(rows, Smplkit::Audit.extract_pagination(resp.meta))
end