Class: Sumologic::Metadata::Collector

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/sumologic/metadata/collector.rb

Overview

Handles collector metadata operations

Instance Method Summary collapse

Constructor Details

#initialize(http_client:) ⇒ Collector

Returns a new instance of Collector.



12
13
14
# File 'lib/sumologic/metadata/collector.rb', line 12

def initialize(http_client:)
  @http = http_client
end

Instance Method Details

#list(query: nil, limit: nil) ⇒ Array<Hash>

List collectors with optional client-side filtering

Parameters:

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

    Filter by name or category (case-insensitive substring match)

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

    Maximum number of collectors to return

Returns:

  • (Array<Hash>)

    Array of collector objects



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/sumologic/metadata/collector.rb', line 21

def list(query: nil, limit: nil)
  data = @http.request(
    method: :get,
    path: '/collectors'
  )

  collectors = data['collectors'] || []
  log_info "Found #{collectors.size} collectors"

  collectors = filter_by_query(collectors, query) if query
  collectors = collectors.take(limit) if limit

  collectors
rescue StandardError => e
  raise Error, "Failed to list collectors: #{e.message}"
end