Class: Sumologic::Metadata::Dashboard
- Inherits:
-
Object
- Object
- Sumologic::Metadata::Dashboard
- Includes:
- Loggable
- Defined in:
- lib/sumologic/metadata/dashboard.rb
Overview
Handles dashboard operations via v2 API Uses GET /v2/dashboards endpoints
Instance Method Summary collapse
-
#get(dashboard_id) ⇒ Hash
Get a specific dashboard by ID Returns full dashboard details including panels.
-
#initialize(http_client:) ⇒ Dashboard
constructor
A new instance of Dashboard.
-
#list(limit: 100) ⇒ Array<Hash>
List all dashboards Returns array of dashboard objects.
-
#list_by_folder(folder_id:, limit: 100) ⇒ Array<Hash>
List dashboards in a specific folder.
-
#search(query:, limit: 100) ⇒ Array<Hash>
Search dashboards by title or description Returns matching dashboards.
Constructor Details
#initialize(http_client:) ⇒ Dashboard
Returns a new instance of Dashboard.
13 14 15 |
# File 'lib/sumologic/metadata/dashboard.rb', line 13 def initialize(http_client:) @http = http_client end |
Instance Method Details
#get(dashboard_id) ⇒ Hash
Get a specific dashboard by ID Returns full dashboard details including panels
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/sumologic/metadata/dashboard.rb', line 56 def get(dashboard_id) data = @http.request( method: :get, path: "/dashboards/#{dashboard_id}" ) log_info "Retrieved dashboard: #{data['title']} (#{dashboard_id})" data rescue StandardError => e raise Error, "Failed to get dashboard #{dashboard_id}: #{e.}" end |
#list(limit: 100) ⇒ Array<Hash>
List all dashboards Returns array of dashboard objects
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/sumologic/metadata/dashboard.rb', line 22 def list(limit: 100) dashboards = [] token = nil loop do query_params = { limit: [limit - dashboards.size, 100].min } query_params[:token] = token if token data = @http.request( method: :get, path: '/dashboards', query_params: query_params ) batch = data['dashboards'] || [] dashboards.concat(batch) log_info "Fetched #{batch.size} dashboards (total: #{dashboards.size})" # Check for pagination token = data['next'] break if token.nil? || dashboards.size >= limit end dashboards.take(limit) rescue StandardError => e raise Error, "Failed to list dashboards: #{e.}" end |
#list_by_folder(folder_id:, limit: 100) ⇒ Array<Hash>
List dashboards in a specific folder
93 94 95 96 97 98 99 100 101 |
# File 'lib/sumologic/metadata/dashboard.rb', line 93 def list_by_folder(folder_id:, limit: 100) dashboards = list(limit: limit * 2) filtered = dashboards.select do |d| d['folderId'] == folder_id end filtered.take(limit) end |
#search(query:, limit: 100) ⇒ Array<Hash>
Search dashboards by title or description Returns matching dashboards
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/sumologic/metadata/dashboard.rb', line 74 def search(query:, limit: 100) # Use list and filter client-side dashboards = list(limit: limit * 2) query_lower = query.downcase filtered = dashboards.select do |d| title_match = d['title']&.downcase&.include?(query_lower) desc_match = d['description']&.downcase&.include?(query_lower) title_match || desc_match end filtered.take(limit) end |