Class: Smplkit::Logging::LogGroupsClient
- Inherits:
-
Object
- Object
- Smplkit::Logging::LogGroupsClient
- Defined in:
- lib/smplkit/logging/client.rb
Overview
Surface for client.logging.log_groups.* (sync).
Instance Method Summary collapse
- #_create_log_group(group) ⇒ Object private
- #_update_log_group(group) ⇒ Object private
-
#delete(id) ⇒ void
Delete a log group by id.
-
#get(id) ⇒ SmplLogGroup
Fetch a single log group by id.
-
#get_group_entry(key) ⇒ Object
private
Fetch one log group as a resolution-cache entry.
-
#initialize(http_client) ⇒ LogGroupsClient
constructor
A new instance of LogGroupsClient.
-
#list(page_number: nil, page_size: nil) ⇒ Array<SmplLogGroup>
List log groups for the authenticated account.
-
#list_group_entries ⇒ Object
private
Runtime entry — walks every page and returns an id-keyed Hash of resolution-cache entries (
level,group,environments). -
#new(id, name: nil, group: nil) ⇒ SmplLogGroup
Build a new unsaved log group.
Constructor Details
#initialize(http_client) ⇒ LogGroupsClient
Returns a new instance of LogGroupsClient.
291 292 293 |
# File 'lib/smplkit/logging/client.rb', line 291 def initialize(http_client) @api = SmplkitGeneratedClient::Logging::LogGroupsApi.new(http_client) end |
Instance Method Details
#_create_log_group(group) ⇒ 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.
348 349 350 351 |
# File 'lib/smplkit/logging/client.rb', line 348 def _create_log_group(group) response = ApiSupport::ErrorMapping.call { @api.create_log_group(log_group_body(group)) } Helpers.log_group_resource_to_model(self, ApiSupport::ResourceShim.from_model(response.data)) end |
#_update_log_group(group) ⇒ 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.
354 355 356 357 |
# File 'lib/smplkit/logging/client.rb', line 354 def _update_log_group(group) response = ApiSupport::ErrorMapping.call { @api.update_log_group(group.key, log_group_body(group)) } Helpers.log_group_resource_to_model(self, ApiSupport::ResourceShim.from_model(response.data)) end |
#delete(id) ⇒ void
This method returns an undefined value.
Delete a log group by id.
342 343 344 345 |
# File 'lib/smplkit/logging/client.rb', line 342 def delete(id) ApiSupport::ErrorMapping.call { @api.delete_log_group(id) } nil end |
#get(id) ⇒ SmplLogGroup
Fetch a single log group by id.
332 333 334 335 |
# File 'lib/smplkit/logging/client.rb', line 332 def get(id) response = ApiSupport::ErrorMapping.call { @api.get_log_group(id) } Helpers.log_group_resource_to_model(self, ApiSupport::ResourceShim.from_model(response.data)) end |
#get_group_entry(key) ⇒ 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.
Fetch one log group as a resolution-cache entry. Used by the group_changed WS handler.
374 375 376 377 |
# File 'lib/smplkit/logging/client.rb', line 374 def get_group_entry(key) response = ApiSupport::ErrorMapping.call { @api.get_log_group(key) } group_entry_from_resource(ApiSupport::ResourceShim.from_model(response.data)) end |
#list(page_number: nil, page_size: nil) ⇒ Array<SmplLogGroup>
List log groups for the authenticated account.
317 318 319 320 321 322 323 324 325 |
# File 'lib/smplkit/logging/client.rb', line 317 def list(page_number: nil, page_size: nil) opts = {} opts[:page_number] = page_number unless page_number.nil? opts[:page_size] = page_size unless page_size.nil? response = ApiSupport::ErrorMapping.call { @api.list_log_groups(opts) } (response.data || []).map do |r| Helpers.log_group_resource_to_model(self, ApiSupport::ResourceShim.from_model(r)) end end |
#list_group_entries ⇒ 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.
Runtime entry — walks every page and returns an id-keyed Hash of resolution-cache entries (level, group, environments). The group key carries the *parent group id* so the resolution algorithm can walk the chain with the same key shape it uses for loggers.
365 366 367 368 |
# File 'lib/smplkit/logging/client.rb', line 365 def list_group_entries rows = ApiSupport::PaginatedFetch.collect { |opts| @api.list_log_groups(opts) } rows.to_h { |r| group_entry_from_resource(ApiSupport::ResourceShim.from_model(r)) } end |
#new(id, name: nil, group: nil) ⇒ SmplLogGroup
Build a new unsaved log group. The returned SmplLogGroup is local only; call its SmplLogGroup#save to persist it.
304 305 306 307 308 |
# File 'lib/smplkit/logging/client.rb', line 304 def new(id, name: nil, group: nil) SmplLogGroup.new( self, key: id, name: name.nil? ? Smplkit::Helpers.key_to_display_name(id) : name, group: group ) end |