Class: Smplkit::Audit::Categories

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

Overview

client.audit.categories.list — distinct category values seen for the account.

Response time is independent of how many years of events the account has accumulated. Sorted alphabetically; offset paginated.

Instance Method Summary collapse

Constructor Details

#initialize(api) ⇒ Categories

Returns a new instance of Categories.



11
12
13
# File 'lib/smplkit/audit/categories.rb', line 11

def initialize(api)
  @api = api
end

Instance Method Details

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

List the distinct category values 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:

  • 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 categories 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:



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/smplkit/audit/categories.rb', line 34

def list(page_number: nil, page_size: nil, meta_total: nil, environments: nil)
  opts = {}
  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_categories(opts) }
  rows = (resp.data || []).map { |r| Category.from_resource(r) }
  CategoryListPage.new(rows, Smplkit::Audit.extract_pagination(resp.meta))
end