sumologic-query 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5822fc268d1979e97d6993b7f233b720049f832c4d5d921a75c32ecccc16ce68
4
- data.tar.gz: f9e1cde6a138f45d70ec4ed2e06b22f87faf9500a6cb4fb7274fe8df787bcba1
3
+ metadata.gz: f62e0cd6d7ee0fbfd44b2720b0075e4f1776e086ef1ccbe39ad9e520f539f951
4
+ data.tar.gz: da262a85a0fa2d556c310876d011705edd4fc1b46db47c43d6f892adf71649ff
5
5
  SHA512:
6
- metadata.gz: 661862b1dfbc17a5729fbffc54c459e9b2e52a996346b0c028179002c606689096c0a191a26d7bb06d737c197f50324eb86e574289a093c4a392b9248a3e2647
7
- data.tar.gz: fda3e751c1dc953fa10d878288193ffe060dcd9366e9d18e8cad9d8eeaf8a194e0dcaa1f50ca245fdc5ab20a95c7f1b67809add3dbed2aa28341f68130188ffd
6
+ metadata.gz: 458d97b1853c3626d85f84770faaf918ebbd2842718ffed416ead1736a8a075bc4061eb040e003a24227e8af6b7f6f125baf2b2aec5627f0398abd6b054fe880
7
+ data.tar.gz: '078544851f936431eea88d6b0783f39c58789072bbfa8fe17f5147c2a9aff9df8bc0b3f5e71c48e7d6793f8ad94a69a134bfabe5ab3d46689ff35613a13446f5'
data/CHANGELOG.md CHANGED
@@ -6,6 +6,27 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
6
6
 
7
7
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8
8
  and release notes are automatically generated from commit messages.
9
+ ## [1.4.1](https://github.com/patrick204nqh/sumologic-query/compare/v1.4.0...v1.4.1) (2026-02-11)
10
+
11
+ ### 🎉 New Features
12
+
13
+ - add "Open in Sumo Logic" URL to search output
14
+ - add command recipe and CLI command specs
15
+
16
+ ### 🐛 Bug Fixes
17
+
18
+ - update source_code_uri metadata to use homepage
19
+
20
+ ### 🔧 Refactoring
21
+
22
+ - resolve ADR-006, fix README links, extract command helpers
23
+
24
+ ### 📚 Documentation
25
+
26
+ - consolidate query examples and document v1/v2 API split
27
+
28
+
29
+
9
30
  ## [1.4.0](https://github.com/patrick204nqh/sumologic-query/compare/v1.3.5...v1.4.0) (2026-02-11)
10
31
 
11
32
  ### 🎉 New Features
data/README.md CHANGED
@@ -152,9 +152,9 @@ client.list_all_sources
152
152
  ## Documentation
153
153
 
154
154
  - [Query Examples](examples/queries.md) - Query patterns and examples
155
- - [Quick Reference](docs/tldr.md) - Command cheat sheet
156
- - [Rate Limiting](docs/rate-limiting.md) - Performance tuning
157
- - [Architecture](docs/architecture/) - Design decisions
155
+ - [Quick Reference](docs/sdlc/7-maintain/tldr.md) - Command cheat sheet
156
+ - [Rate Limiting](docs/sdlc/4-develop/rate-limiting.md) - Performance tuning
157
+ - [Architecture](docs/sdlc/3-design/overview.md) - Design decisions
158
158
 
159
159
  ## Contributing
160
160
 
@@ -17,6 +17,18 @@ module Sumologic
17
17
 
18
18
  private
19
19
 
20
+ def list_resource(label:, key:)
21
+ warn "Fetching #{label}..."
22
+ items = yield
23
+ output_json(total: items.size, key => items)
24
+ end
25
+
26
+ def get_resource(label:, id:)
27
+ warn "Fetching #{label} #{id}..."
28
+ result = yield
29
+ output_json(result)
30
+ end
31
+
20
32
  def output_json(data)
21
33
  json_output = JSON.pretty_generate(data)
22
34
 
@@ -8,11 +8,9 @@ module Sumologic
8
8
  # Handles the export-content command execution
9
9
  class ExportContentCommand < BaseCommand
10
10
  def execute
11
- content_id = options[:content_id]
12
- warn "Exporting content #{content_id}..."
13
- result = client.export_content(content_id: content_id)
14
-
15
- output_json(result)
11
+ get_resource(label: 'content', id: options[:content_id]) do
12
+ client.export_content(content_id: options[:content_id])
13
+ end
16
14
  end
17
15
  end
18
16
  end
@@ -8,11 +8,9 @@ module Sumologic
8
8
  # Handles the get-content command execution
9
9
  class GetContentCommand < BaseCommand
10
10
  def execute
11
- path = options[:path]
12
- warn "Looking up content at path: #{path}..."
13
- content = client.get_content(path: path)
14
-
15
- output_json(content)
11
+ get_resource(label: 'content at path:', id: options[:path]) do
12
+ client.get_content(path: options[:path])
13
+ end
16
14
  end
17
15
  end
18
16
  end
@@ -8,11 +8,9 @@ module Sumologic
8
8
  # Handles the get-dashboard command execution
9
9
  class GetDashboardCommand < BaseCommand
10
10
  def execute
11
- dashboard_id = options[:dashboard_id]
12
- warn "Fetching dashboard #{dashboard_id}..."
13
- dashboard = client.get_dashboard(dashboard_id: dashboard_id)
14
-
15
- output_json(dashboard)
11
+ get_resource(label: 'dashboard', id: options[:dashboard_id]) do
12
+ client.get_dashboard(dashboard_id: options[:dashboard_id])
13
+ end
16
14
  end
17
15
  end
18
16
  end
@@ -8,11 +8,9 @@ module Sumologic
8
8
  # Handles the get-lookup command execution
9
9
  class GetLookupCommand < BaseCommand
10
10
  def execute
11
- lookup_id = options[:lookup_id]
12
- warn "Fetching lookup table #{lookup_id}..."
13
- lookup = client.get_lookup(lookup_id: lookup_id)
14
-
15
- output_json(lookup)
11
+ get_resource(label: 'lookup table', id: options[:lookup_id]) do
12
+ client.get_lookup(lookup_id: options[:lookup_id])
13
+ end
16
14
  end
17
15
  end
18
16
  end
@@ -8,11 +8,9 @@ module Sumologic
8
8
  # Handles the get-monitor command execution
9
9
  class GetMonitorCommand < BaseCommand
10
10
  def execute
11
- monitor_id = options[:monitor_id]
12
- warn "Fetching monitor #{monitor_id}..."
13
- monitor = client.get_monitor(monitor_id: monitor_id)
14
-
15
- output_json(monitor)
11
+ get_resource(label: 'monitor', id: options[:monitor_id]) do
12
+ client.get_monitor(monitor_id: options[:monitor_id])
13
+ end
16
14
  end
17
15
  end
18
16
  end
@@ -8,13 +8,7 @@ module Sumologic
8
8
  # Handles the list-apps command execution
9
9
  class ListAppsCommand < BaseCommand
10
10
  def execute
11
- warn 'Fetching app catalog...'
12
- apps = client.list_apps
13
-
14
- output_json(
15
- total: apps.size,
16
- apps: apps
17
- )
11
+ list_resource(label: 'app catalog', key: :apps) { client.list_apps }
18
12
  end
19
13
  end
20
14
  end
@@ -8,13 +8,7 @@ module Sumologic
8
8
  # Handles the list-collectors command execution
9
9
  class ListCollectorsCommand < BaseCommand
10
10
  def execute
11
- warn 'Fetching collectors...'
12
- collectors = client.list_collectors
13
-
14
- output_json(
15
- total: collectors.size,
16
- collectors: collectors
17
- )
11
+ list_resource(label: 'collectors', key: :collectors) { client.list_collectors }
18
12
  end
19
13
  end
20
14
  end
@@ -8,13 +8,9 @@ module Sumologic
8
8
  # Handles the list-dashboards command execution
9
9
  class ListDashboardsCommand < BaseCommand
10
10
  def execute
11
- warn 'Fetching dashboards...'
12
- dashboards = client.list_dashboards(limit: options[:limit] || 100)
13
-
14
- output_json(
15
- total: dashboards.size,
16
- dashboards: dashboards
17
- )
11
+ list_resource(label: 'dashboards', key: :dashboards) do
12
+ client.list_dashboards(limit: options[:limit] || 100)
13
+ end
18
14
  end
19
15
  end
20
16
  end
@@ -8,13 +8,9 @@ module Sumologic
8
8
  # Handles the list-health-events command execution
9
9
  class ListHealthEventsCommand < BaseCommand
10
10
  def execute
11
- warn 'Fetching health events...'
12
- events = client.list_health_events(limit: options[:limit] || 100)
13
-
14
- output_json(
15
- total: events.size,
16
- healthEvents: events
17
- )
11
+ list_resource(label: 'health events', key: :healthEvents) do
12
+ client.list_health_events(limit: options[:limit] || 100)
13
+ end
18
14
  end
19
15
  end
20
16
  end
@@ -9,17 +9,13 @@ module Sumologic
9
9
  # Uses the monitors search API for flat, filterable results
10
10
  class ListMonitorsCommand < BaseCommand
11
11
  def execute
12
- warn 'Fetching monitors...'
13
- monitors = client.list_monitors(
14
- query: options[:query],
15
- status: options[:status],
16
- limit: options[:limit] || 100
17
- )
18
-
19
- output_json(
20
- total: monitors.size,
21
- monitors: monitors
22
- )
12
+ list_resource(label: 'monitors', key: :monitors) do
13
+ client.list_monitors(
14
+ query: options[:query],
15
+ status: options[:status],
16
+ limit: options[:limit] || 100
17
+ )
18
+ end
23
19
  end
24
20
  end
25
21
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'erb'
3
4
  require_relative 'base_command'
4
5
  require_relative '../../utils/time_parser'
5
6
 
@@ -46,6 +47,7 @@ module Sumologic
46
47
  end
47
48
  warn "Query: #{options[:query]}"
48
49
  warn "Limit: #{options[:limit] || 'unlimited'}"
50
+ warn "Open in Sumo: #{build_search_url}"
49
51
  warn '-' * 60
50
52
  warn 'Creating search job...'
51
53
  $stderr.puts
@@ -96,6 +98,7 @@ module Sumologic
96
98
  from_original: @original_from,
97
99
  to_original: @original_to,
98
100
  time_zone: @parsed_timezone,
101
+ search_url: build_search_url,
99
102
  record_count: results.size,
100
103
  records: results
101
104
  )
@@ -107,6 +110,7 @@ module Sumologic
107
110
  from_original: @original_from,
108
111
  to_original: @original_to,
109
112
  time_zone: @parsed_timezone,
113
+ search_url: build_search_url,
110
114
  message_count: results.size,
111
115
  messages: results
112
116
  )
@@ -135,10 +139,20 @@ module Sumologic
135
139
  'from' => @parsed_from,
136
140
  'to' => @parsed_to,
137
141
  'time_zone' => @parsed_timezone,
142
+ 'search_url' => build_search_url,
138
143
  'message_count' => results.size,
139
144
  'messages' => results
140
145
  }
141
146
  end
147
+
148
+ def build_search_url
149
+ from_ms = (Time.parse("#{@parsed_from}Z").to_f * 1000).to_i
150
+ to_ms = (Time.parse("#{@parsed_to}Z").to_f * 1000).to_i
151
+ encoded_query = ERB::Util.url_encode(options[:query])
152
+ base = client.config.web_ui_base_url
153
+
154
+ "#{base}/ui/#/search/create?query=#{encoded_query}&startTime=#{from_ms}&endTime=#{to_ms}"
155
+ end
142
156
  end
143
157
  end
144
158
  end
@@ -45,6 +45,10 @@ module Sumologic
45
45
  @base_url_v2 ||= build_base_url('v2')
46
46
  end
47
47
 
48
+ def web_ui_base_url
49
+ @web_ui_base_url ||= build_web_ui_base_url
50
+ end
51
+
48
52
  def validate!
49
53
  raise AuthenticationError, 'SUMO_ACCESS_ID not set' unless @access_id
50
54
  raise AuthenticationError, 'SUMO_ACCESS_KEY not set' unless @access_key
@@ -52,6 +56,23 @@ module Sumologic
52
56
 
53
57
  private
54
58
 
59
+ def build_web_ui_base_url
60
+ case @deployment
61
+ when /^http/
62
+ @deployment.sub('api.', 'service.').sub(%r{/api/v\d+.*}, '')
63
+ when 'us1'
64
+ 'https://service.sumologic.com'
65
+ when 'us2'
66
+ 'https://service.us2.sumologic.com'
67
+ when 'eu'
68
+ 'https://service.eu.sumologic.com'
69
+ when 'au'
70
+ 'https://service.au.sumologic.com'
71
+ else
72
+ "https://service.#{@deployment}.sumologic.com"
73
+ end
74
+ end
75
+
55
76
  def build_base_url(version = API_VERSION)
56
77
  case @deployment
57
78
  when /^http/
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sumologic
4
- VERSION = '1.4.0'
4
+ VERSION = '1.4.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sumologic-query
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - patrick204nqh
@@ -154,7 +154,6 @@ homepage: https://github.com/patrick204nqh/sumologic-query
154
154
  licenses:
155
155
  - MIT
156
156
  metadata:
157
- homepage_uri: https://github.com/patrick204nqh/sumologic-query
158
157
  source_code_uri: https://github.com/patrick204nqh/sumologic-query
159
158
  bug_tracker_uri: https://github.com/patrick204nqh/sumologic-query/issues
160
159
  changelog_uri: https://github.com/patrick204nqh/sumologic-query/blob/main/CHANGELOG.md