exa-ai 0.13.0 → 0.14.0
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 +4 -4
- data/README.md +119 -73
- data/exe/exa-ai +41 -136
- data/exe/exa-ai-agent-run-create +55 -20
- data/exe/exa-ai-agent-run-delete +1 -8
- data/exe/exa-ai-agent-run-events +21 -1
- data/exe/exa-ai-agent-run-list +1 -1
- data/exe/exa-ai-agent-run-stop +93 -0
- data/exe/exa-ai-answer +25 -0
- data/exe/exa-ai-context +6 -2
- data/exe/exa-ai-find-similar +26 -68
- data/exe/exa-ai-get-contents +138 -42
- data/exe/exa-ai-search +27 -104
- data/exe/exa-ai-search-monitor-batch +93 -0
- data/exe/exa-ai-search-monitor-create +104 -0
- data/exe/exa-ai-search-monitor-delete +69 -0
- data/exe/exa-ai-search-monitor-get +69 -0
- data/exe/exa-ai-search-monitor-list +73 -0
- data/exe/exa-ai-search-monitor-runs-get +68 -0
- data/exe/exa-ai-search-monitor-runs-list +75 -0
- data/exe/exa-ai-search-monitor-trigger +69 -0
- data/exe/exa-ai-search-monitor-update +102 -0
- data/lib/exa/cli/base.rb +57 -0
- data/lib/exa/cli/contents_flags.rb +199 -0
- data/lib/exa/cli/formatters/agent_run_formatter.rb +79 -3
- data/lib/exa/cli/formatters/search_formatter.rb +18 -2
- data/lib/exa/cli/formatters/search_monitor_formatter.rb +98 -0
- data/lib/exa/cli/search_parser.rb +46 -87
- data/lib/exa/client.rb +186 -310
- data/lib/exa/resources/agent_run.rb +5 -3
- data/lib/exa/resources/agent_run_deletion.rb +17 -0
- data/lib/exa/resources/answer.rb +3 -3
- data/lib/exa/resources/contents_result.rb +5 -1
- data/lib/exa/resources/find_similar_result.rb +5 -1
- data/lib/exa/resources/search_monitor.rb +42 -0
- data/lib/exa/resources/search_monitor_batch_result.rb +11 -0
- data/lib/exa/resources/search_monitor_list.rb +19 -0
- data/lib/exa/resources/search_monitor_run.rb +46 -0
- data/lib/exa/resources/search_monitor_trigger_result.rb +11 -0
- data/lib/exa/resources/search_result.rb +11 -1
- data/lib/exa/services/agent_run_cancel.rb +1 -12
- data/lib/exa/services/agent_run_create.rb +1 -12
- data/lib/exa/services/agent_run_delete.rb +6 -14
- data/lib/exa/services/agent_run_events.rb +33 -4
- data/lib/exa/services/agent_run_get.rb +1 -12
- data/lib/exa/services/agent_run_list.rb +1 -12
- data/lib/exa/services/agent_run_stop.rb +21 -0
- data/lib/exa/services/agent_run_stream.rb +53 -51
- data/lib/exa/services/answer.rb +5 -2
- data/lib/exa/services/answer_stream.rb +54 -45
- data/lib/exa/services/context.rb +3 -1
- data/lib/exa/services/find_similar.rb +9 -2
- data/lib/exa/services/get_contents.rb +14 -15
- data/lib/exa/services/parameter_converter.rb +128 -111
- data/lib/exa/services/search.rb +58 -19
- data/lib/exa/services/search_monitors/batch.rb +36 -0
- data/lib/exa/services/search_monitors/create.rb +37 -0
- data/lib/exa/services/search_monitors/delete.rb +22 -0
- data/lib/exa/services/search_monitors/get.rb +22 -0
- data/lib/exa/services/search_monitors/list.rb +29 -0
- data/lib/exa/services/search_monitors/runs_get.rb +23 -0
- data/lib/exa/services/search_monitors/runs_list.rb +29 -0
- data/lib/exa/services/search_monitors/trigger.rb +22 -0
- data/lib/exa/services/search_monitors/update.rb +42 -0
- data/lib/exa/services/search_stream.rb +38 -0
- data/lib/exa/version.rb +1 -1
- data/lib/exa.rb +18 -50
- metadata +30 -84
- data/exe/exa-ai-enrichment-cancel +0 -108
- data/exe/exa-ai-enrichment-create +0 -226
- data/exe/exa-ai-enrichment-delete +0 -122
- data/exe/exa-ai-enrichment-get +0 -104
- data/exe/exa-ai-enrichment-list +0 -99
- data/exe/exa-ai-enrichment-update +0 -171
- data/exe/exa-ai-import-create +0 -253
- data/exe/exa-ai-import-delete +0 -92
- data/exe/exa-ai-import-get +0 -92
- data/exe/exa-ai-import-list +0 -72
- data/exe/exa-ai-import-update +0 -164
- data/exe/exa-ai-monitor-create +0 -223
- data/exe/exa-ai-monitor-delete +0 -101
- data/exe/exa-ai-monitor-get +0 -92
- data/exe/exa-ai-monitor-list +0 -90
- data/exe/exa-ai-monitor-runs-get +0 -103
- data/exe/exa-ai-monitor-runs-list +0 -110
- data/exe/exa-ai-monitor-update +0 -207
- data/exe/exa-ai-webset-cancel +0 -97
- data/exe/exa-ai-webset-create +0 -254
- data/exe/exa-ai-webset-delete +0 -111
- data/exe/exa-ai-webset-get +0 -93
- data/exe/exa-ai-webset-item-delete +0 -111
- data/exe/exa-ai-webset-item-get +0 -105
- data/exe/exa-ai-webset-item-list +0 -108
- data/exe/exa-ai-webset-list +0 -91
- data/exe/exa-ai-webset-search-cancel +0 -104
- data/exe/exa-ai-webset-search-create +0 -247
- data/exe/exa-ai-webset-search-get +0 -105
- data/exe/exa-ai-webset-update +0 -143
- data/lib/exa/cli/formatters/enrichment_formatter.rb +0 -125
- data/lib/exa/cli/formatters/import_formatter.rb +0 -153
- data/lib/exa/cli/formatters/monitor_formatter.rb +0 -144
- data/lib/exa/cli/formatters/monitor_run_formatter.rb +0 -126
- data/lib/exa/cli/formatters/webset_formatter.rb +0 -134
- data/lib/exa/cli/formatters/webset_item_formatter.rb +0 -131
- data/lib/exa/cli/formatters/webset_search_formatter.rb +0 -57
- data/lib/exa/constants/websets.rb +0 -19
- data/lib/exa/resources/import.rb +0 -86
- data/lib/exa/resources/import_collection.rb +0 -33
- data/lib/exa/resources/monitor.rb +0 -48
- data/lib/exa/resources/monitor_collection.rb +0 -30
- data/lib/exa/resources/monitor_run.rb +0 -52
- data/lib/exa/resources/monitor_run_collection.rb +0 -30
- data/lib/exa/resources/webset.rb +0 -74
- data/lib/exa/resources/webset_collection.rb +0 -33
- data/lib/exa/resources/webset_enrichment.rb +0 -71
- data/lib/exa/resources/webset_enrichment_collection.rb +0 -28
- data/lib/exa/resources/webset_item_collection.rb +0 -33
- data/lib/exa/resources/webset_search.rb +0 -112
- data/lib/exa/services/websets/cancel.rb +0 -36
- data/lib/exa/services/websets/cancel_enrichment.rb +0 -35
- data/lib/exa/services/websets/cancel_search.rb +0 -44
- data/lib/exa/services/websets/create.rb +0 -45
- data/lib/exa/services/websets/create_enrichment.rb +0 -35
- data/lib/exa/services/websets/create_search.rb +0 -48
- data/lib/exa/services/websets/create_search_validator.rb +0 -128
- data/lib/exa/services/websets/create_validator.rb +0 -213
- data/lib/exa/services/websets/delete.rb +0 -36
- data/lib/exa/services/websets/delete_enrichment.rb +0 -35
- data/lib/exa/services/websets/delete_item.rb +0 -20
- data/lib/exa/services/websets/get_item.rb +0 -20
- data/lib/exa/services/websets/get_search.rb +0 -43
- data/lib/exa/services/websets/import_create.rb +0 -40
- data/lib/exa/services/websets/import_delete.rb +0 -37
- data/lib/exa/services/websets/import_get.rb +0 -37
- data/lib/exa/services/websets/import_list.rb +0 -25
- data/lib/exa/services/websets/import_update.rb +0 -38
- data/lib/exa/services/websets/import_upload.rb +0 -59
- data/lib/exa/services/websets/list.rb +0 -25
- data/lib/exa/services/websets/list_items.rb +0 -26
- data/lib/exa/services/websets/monitors/create.rb +0 -42
- data/lib/exa/services/websets/monitors/delete.rb +0 -32
- data/lib/exa/services/websets/monitors/get.rb +0 -33
- data/lib/exa/services/websets/monitors/list.rb +0 -27
- data/lib/exa/services/websets/monitors/runs/get.rb +0 -37
- data/lib/exa/services/websets/monitors/runs/list.rb +0 -30
- data/lib/exa/services/websets/monitors/update.rb +0 -33
- data/lib/exa/services/websets/retrieve.rb +0 -47
- data/lib/exa/services/websets/retrieve_enrichment.rb +0 -35
- data/lib/exa/services/websets/update.rb +0 -37
- data/lib/exa/services/websets/update_enrichment.rb +0 -36
- data/lib/exa/services/websets_parameter_converter.rb +0 -45
data/exe/exa-ai-webset-update
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require "exa-ai"
|
|
5
|
-
require "json"
|
|
6
|
-
|
|
7
|
-
# Parse arguments
|
|
8
|
-
webset_id = nil
|
|
9
|
-
title = nil
|
|
10
|
-
metadata = nil
|
|
11
|
-
api_key = nil
|
|
12
|
-
output_format = "json"
|
|
13
|
-
|
|
14
|
-
# Recursively convert hash keys from strings to symbols
|
|
15
|
-
def deep_symbolize_keys(obj)
|
|
16
|
-
case obj
|
|
17
|
-
when Hash
|
|
18
|
-
obj.each_with_object({}) do |(key, value), result|
|
|
19
|
-
result[key.to_sym] = deep_symbolize_keys(value)
|
|
20
|
-
end
|
|
21
|
-
when Array
|
|
22
|
-
obj.map { |item| deep_symbolize_keys(item) }
|
|
23
|
-
else
|
|
24
|
-
obj
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# Helper to parse JSON string or load from file
|
|
29
|
-
def parse_json_or_file(value)
|
|
30
|
-
json_data = if value.start_with?("@")
|
|
31
|
-
file_path = value[1..]
|
|
32
|
-
JSON.parse(File.read(file_path))
|
|
33
|
-
else
|
|
34
|
-
JSON.parse(value)
|
|
35
|
-
end
|
|
36
|
-
deep_symbolize_keys(json_data)
|
|
37
|
-
rescue JSON::ParserError => e
|
|
38
|
-
$stderr.puts "Error: Invalid JSON: #{e.message}"
|
|
39
|
-
exit 1
|
|
40
|
-
rescue Errno::ENOENT => e
|
|
41
|
-
$stderr.puts "Error: File not found: #{e.message}"
|
|
42
|
-
exit 1
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
args = ARGV.dup
|
|
46
|
-
while args.any?
|
|
47
|
-
arg = args.shift
|
|
48
|
-
case arg
|
|
49
|
-
when "--title"
|
|
50
|
-
title = args.shift
|
|
51
|
-
when "--metadata"
|
|
52
|
-
metadata = parse_json_or_file(args.shift)
|
|
53
|
-
when "--api-key"
|
|
54
|
-
api_key = args.shift
|
|
55
|
-
when "--output-format"
|
|
56
|
-
output_format = args.shift
|
|
57
|
-
when "--help", "-h"
|
|
58
|
-
puts <<~HELP
|
|
59
|
-
Usage: exa-ai webset-update <webset_id> [OPTIONS]
|
|
60
|
-
|
|
61
|
-
Update a webset's title and/or metadata
|
|
62
|
-
|
|
63
|
-
Arguments:
|
|
64
|
-
webset_id ID of the webset to update (required)
|
|
65
|
-
|
|
66
|
-
Options:
|
|
67
|
-
--title TITLE Title for the webset
|
|
68
|
-
--metadata JSON Custom metadata to update (supports @file.json)
|
|
69
|
-
--api-key KEY Exa API key (or set EXA_API_KEY env var)
|
|
70
|
-
--output-format FMT Output format: json, pretty, or text (default: json)
|
|
71
|
-
--help, -h Show this help message
|
|
72
|
-
|
|
73
|
-
Examples:
|
|
74
|
-
exa-ai webset-update ws_abc123 --metadata '{"project":"Q1-2025"}'
|
|
75
|
-
exa-ai webset-update ws_abc123 --title "Q1 Research"
|
|
76
|
-
exa-ai webset-update ws_abc123 --title "Q1 Research" --metadata '{"project":"Q1-2025"}'
|
|
77
|
-
exa-ai webset-update ws_abc123 --metadata @metadata.json
|
|
78
|
-
exa-ai webset-update ws_abc123 --metadata '{"tags":["important"]}' --output-format pretty
|
|
79
|
-
HELP
|
|
80
|
-
exit 0
|
|
81
|
-
else
|
|
82
|
-
# First positional argument is webset_id
|
|
83
|
-
if webset_id.nil?
|
|
84
|
-
webset_id = arg
|
|
85
|
-
else
|
|
86
|
-
$stderr.puts "Unknown option: #{arg}"
|
|
87
|
-
exit 1
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# Validate required arguments
|
|
93
|
-
if webset_id.nil?
|
|
94
|
-
$stderr.puts "Error: webset_id argument is required"
|
|
95
|
-
$stderr.puts "Usage: exa-ai webset-update <webset_id> [OPTIONS]"
|
|
96
|
-
$stderr.puts "Try 'exa-ai webset-update --help' for more information"
|
|
97
|
-
exit 1
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
begin
|
|
101
|
-
# Resolve API key and format
|
|
102
|
-
api_key = Exa::CLI::Base.resolve_api_key(api_key)
|
|
103
|
-
output_format = Exa::CLI::Base.resolve_output_format(output_format)
|
|
104
|
-
|
|
105
|
-
# Build client
|
|
106
|
-
client = Exa::CLI::Base.build_client(api_key)
|
|
107
|
-
|
|
108
|
-
# Update webset
|
|
109
|
-
update_params = {}
|
|
110
|
-
update_params[:title] = title if title
|
|
111
|
-
update_params[:metadata] = metadata if metadata
|
|
112
|
-
webset = client.update_webset(webset_id, **update_params)
|
|
113
|
-
|
|
114
|
-
# Format and output
|
|
115
|
-
output = Exa::CLI::Formatters::WebsetFormatter.format(webset, output_format)
|
|
116
|
-
puts output
|
|
117
|
-
$stdout.flush
|
|
118
|
-
|
|
119
|
-
rescue Exa::NotFound => e
|
|
120
|
-
$stderr.puts "Webset not found: #{e.message}"
|
|
121
|
-
exit 1
|
|
122
|
-
rescue Exa::ConfigurationError => e
|
|
123
|
-
$stderr.puts "Configuration error: #{e.message}"
|
|
124
|
-
exit 1
|
|
125
|
-
rescue Exa::Unauthorized => e
|
|
126
|
-
$stderr.puts "Authentication error: #{e.message}"
|
|
127
|
-
$stderr.puts "Check your API key (set EXA_API_KEY or use --api-key)"
|
|
128
|
-
exit 1
|
|
129
|
-
rescue Exa::ClientError => e
|
|
130
|
-
$stderr.puts "Client error: #{e.message}"
|
|
131
|
-
exit 1
|
|
132
|
-
rescue Exa::ServerError => e
|
|
133
|
-
$stderr.puts "Server error: #{e.message}"
|
|
134
|
-
$stderr.puts "The Exa API may be experiencing issues. Please try again later."
|
|
135
|
-
exit 1
|
|
136
|
-
rescue Exa::Error => e
|
|
137
|
-
$stderr.puts "Error: #{e.message}"
|
|
138
|
-
exit 1
|
|
139
|
-
rescue StandardError => e
|
|
140
|
-
$stderr.puts "Unexpected error: #{e.message}"
|
|
141
|
-
$stderr.puts e.backtrace.first(5) if ENV["DEBUG"]
|
|
142
|
-
exit 1
|
|
143
|
-
end
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module CLI
|
|
5
|
-
module Formatters
|
|
6
|
-
class EnrichmentFormatter
|
|
7
|
-
def self.format(enrichment, output_format)
|
|
8
|
-
case output_format
|
|
9
|
-
when "json"
|
|
10
|
-
JSON.generate(enrichment.to_h)
|
|
11
|
-
when "pretty"
|
|
12
|
-
format_as_pretty(enrichment)
|
|
13
|
-
when "text"
|
|
14
|
-
format_as_text(enrichment)
|
|
15
|
-
when "toon"
|
|
16
|
-
Exa::CLI::Base.encode_as_toon(enrichment.to_h)
|
|
17
|
-
else
|
|
18
|
-
raise ArgumentError, "Unknown output format: #{output_format}"
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def self.format_collection(collection, output_format)
|
|
23
|
-
case output_format
|
|
24
|
-
when "json"
|
|
25
|
-
JSON.generate(collection.to_h)
|
|
26
|
-
when "pretty"
|
|
27
|
-
format_collection_as_pretty(collection)
|
|
28
|
-
when "text"
|
|
29
|
-
format_collection_as_text(collection)
|
|
30
|
-
when "toon"
|
|
31
|
-
Exa::CLI::Base.encode_as_toon(collection.to_h)
|
|
32
|
-
else
|
|
33
|
-
raise ArgumentError, "Unknown output format: #{output_format}"
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def self.format_as_pretty(enrichment)
|
|
38
|
-
lines = []
|
|
39
|
-
lines << "Enrichment ID: #{enrichment.id}"
|
|
40
|
-
lines << "Webset ID: #{enrichment.webset_id}" if enrichment.webset_id
|
|
41
|
-
lines << "Status: #{enrichment.status}"
|
|
42
|
-
lines << "Title: #{enrichment.title}" if enrichment.title
|
|
43
|
-
lines << "Description: #{enrichment.description}" if enrichment.description
|
|
44
|
-
lines << "Format: #{enrichment.format}" if enrichment.format
|
|
45
|
-
|
|
46
|
-
if enrichment.options && !enrichment.options.empty?
|
|
47
|
-
lines << ""
|
|
48
|
-
lines << "Options (#{enrichment.options.length}):"
|
|
49
|
-
enrichment.options.each do |option|
|
|
50
|
-
lines << " • #{option['label']}" if option['label']
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
lines << ""
|
|
55
|
-
lines << "Created: #{enrichment.created_at}" if enrichment.created_at
|
|
56
|
-
lines << "Updated: #{enrichment.updated_at}" if enrichment.updated_at
|
|
57
|
-
|
|
58
|
-
lines.join("\n")
|
|
59
|
-
end
|
|
60
|
-
private_class_method :format_as_pretty
|
|
61
|
-
|
|
62
|
-
def self.format_as_text(enrichment)
|
|
63
|
-
lines = []
|
|
64
|
-
lines << "Enrichment: #{enrichment.id}"
|
|
65
|
-
lines << "Webset: #{enrichment.webset_id}" if enrichment.webset_id
|
|
66
|
-
lines << "Status: #{enrichment.status}"
|
|
67
|
-
lines << "Title: #{enrichment.title}" if enrichment.title
|
|
68
|
-
lines << "Description: #{enrichment.description}" if enrichment.description
|
|
69
|
-
lines << "Format: #{enrichment.format}" if enrichment.format
|
|
70
|
-
|
|
71
|
-
if enrichment.options && !enrichment.options.empty?
|
|
72
|
-
lines << "\nOptions:"
|
|
73
|
-
enrichment.options.each do |option|
|
|
74
|
-
lines << " - #{option['label']}" if option['label']
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
lines << "Created: #{enrichment.created_at}" if enrichment.created_at
|
|
79
|
-
lines << "Updated: #{enrichment.updated_at}" if enrichment.updated_at
|
|
80
|
-
|
|
81
|
-
lines.join("\n")
|
|
82
|
-
end
|
|
83
|
-
private_class_method :format_as_text
|
|
84
|
-
|
|
85
|
-
def self.format_collection_as_pretty(collection)
|
|
86
|
-
lines = []
|
|
87
|
-
lines << "Enrichments (#{collection.data.length} items)"
|
|
88
|
-
lines << ""
|
|
89
|
-
|
|
90
|
-
collection.data.each_with_index do |enr, idx|
|
|
91
|
-
lines << "" if idx > 0 # Blank line between enrichments
|
|
92
|
-
|
|
93
|
-
lines << "Enrichment ID: #{enr['id']}"
|
|
94
|
-
lines << "Webset ID: #{enr['websetId']}" if enr['websetId']
|
|
95
|
-
lines << "Status: #{enr['status']}"
|
|
96
|
-
lines << "Title: #{enr['title']}" if enr['title']
|
|
97
|
-
lines << "Description: #{enr['description']}" if enr['description']
|
|
98
|
-
lines << "Format: #{enr['format']}" if enr['format']
|
|
99
|
-
lines << "Created: #{enr['createdAt']}" if enr['createdAt']
|
|
100
|
-
lines << "Updated: #{enr['updatedAt']}" if enr['updatedAt']
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
if collection.has_more
|
|
104
|
-
lines << ""
|
|
105
|
-
lines << "Next Cursor: #{collection.next_cursor}"
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
lines.join("\n")
|
|
109
|
-
end
|
|
110
|
-
private_class_method :format_collection_as_pretty
|
|
111
|
-
|
|
112
|
-
def self.format_collection_as_text(collection)
|
|
113
|
-
lines = ["Enrichments (#{collection.data.length} items):"]
|
|
114
|
-
collection.data.each do |enr|
|
|
115
|
-
lines << "\n #{enr['id']}"
|
|
116
|
-
lines << " Status: #{enr['status']}"
|
|
117
|
-
lines << " Title: #{enr['title']}" if enr['title']
|
|
118
|
-
end
|
|
119
|
-
lines.join("\n")
|
|
120
|
-
end
|
|
121
|
-
private_class_method :format_collection_as_text
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
end
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module CLI
|
|
5
|
-
module Formatters
|
|
6
|
-
class ImportFormatter
|
|
7
|
-
def self.format(import, output_format)
|
|
8
|
-
case output_format
|
|
9
|
-
when "json"
|
|
10
|
-
JSON.generate(import.to_h)
|
|
11
|
-
when "pretty"
|
|
12
|
-
format_as_pretty(import)
|
|
13
|
-
when "text"
|
|
14
|
-
format_as_text(import)
|
|
15
|
-
when "toon"
|
|
16
|
-
Exa::CLI::Base.encode_as_toon(import.to_h)
|
|
17
|
-
else
|
|
18
|
-
raise ArgumentError, "Unknown output format: #{output_format}"
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def self.format_collection(collection, output_format)
|
|
23
|
-
case output_format
|
|
24
|
-
when "json"
|
|
25
|
-
JSON.generate(collection.to_h)
|
|
26
|
-
when "pretty"
|
|
27
|
-
format_collection_as_pretty(collection)
|
|
28
|
-
when "text"
|
|
29
|
-
format_collection_as_text(collection)
|
|
30
|
-
when "toon"
|
|
31
|
-
Exa::CLI::Base.encode_as_toon(collection.to_h)
|
|
32
|
-
else
|
|
33
|
-
raise ArgumentError, "Unknown output format: #{output_format}"
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def self.format_as_pretty(import)
|
|
38
|
-
lines = []
|
|
39
|
-
lines << "Import ID: #{import.id}"
|
|
40
|
-
lines << "Status: #{import.status}"
|
|
41
|
-
lines << "Title: #{import.title}" if import.title
|
|
42
|
-
lines << "Format: #{import.format}" if import.format
|
|
43
|
-
|
|
44
|
-
if import.entity
|
|
45
|
-
entity_type = import.entity['type'] || import.entity[:type]
|
|
46
|
-
lines << "Entity Type: #{entity_type}" if entity_type
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
lines << "Count: #{import.count}" if import.count
|
|
50
|
-
|
|
51
|
-
if import.failed?
|
|
52
|
-
lines << ""
|
|
53
|
-
lines << "Failure:"
|
|
54
|
-
lines << " Reason: #{import.failed_reason}" if import.failed_reason
|
|
55
|
-
lines << " Message: #{import.failed_message}" if import.failed_message
|
|
56
|
-
lines << " Failed At: #{import.failed_at}" if import.failed_at
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
if import.upload_url
|
|
60
|
-
lines << ""
|
|
61
|
-
lines << "Upload:"
|
|
62
|
-
lines << " URL: #{import.upload_url}"
|
|
63
|
-
lines << " Valid Until: #{import.upload_valid_until}" if import.upload_valid_until
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
lines << ""
|
|
67
|
-
lines << "Created: #{import.created_at}" if import.created_at
|
|
68
|
-
lines << "Updated: #{import.updated_at}" if import.updated_at
|
|
69
|
-
|
|
70
|
-
lines.join("\n")
|
|
71
|
-
end
|
|
72
|
-
private_class_method :format_as_pretty
|
|
73
|
-
|
|
74
|
-
def self.format_as_text(import)
|
|
75
|
-
lines = []
|
|
76
|
-
lines << "Import: #{import.id}"
|
|
77
|
-
lines << "Status: #{import.status}"
|
|
78
|
-
lines << "Title: #{import.title}" if import.title
|
|
79
|
-
lines << "Format: #{import.format}" if import.format
|
|
80
|
-
|
|
81
|
-
if import.entity
|
|
82
|
-
entity_type = import.entity['type'] || import.entity[:type]
|
|
83
|
-
lines << "Entity Type: #{entity_type}" if entity_type
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
lines << "Count: #{import.count}" if import.count
|
|
87
|
-
|
|
88
|
-
if import.failed?
|
|
89
|
-
lines << "\nFailure Details:"
|
|
90
|
-
lines << " Reason: #{import.failed_reason}" if import.failed_reason
|
|
91
|
-
lines << " Message: #{import.failed_message}" if import.failed_message
|
|
92
|
-
lines << " Failed At: #{import.failed_at}" if import.failed_at
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
if import.upload_url
|
|
96
|
-
lines << "\nUpload:"
|
|
97
|
-
lines << " URL: #{import.upload_url}"
|
|
98
|
-
lines << " Valid Until: #{import.upload_valid_until}" if import.upload_valid_until
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
lines << "\nCreated: #{import.created_at}" if import.created_at
|
|
102
|
-
lines << "Updated: #{import.updated_at}" if import.updated_at
|
|
103
|
-
|
|
104
|
-
lines.join("\n")
|
|
105
|
-
end
|
|
106
|
-
private_class_method :format_as_text
|
|
107
|
-
|
|
108
|
-
def self.format_collection_as_pretty(collection)
|
|
109
|
-
lines = []
|
|
110
|
-
lines << "Imports (#{collection.data.length} items)"
|
|
111
|
-
lines << ""
|
|
112
|
-
|
|
113
|
-
collection.data.each_with_index do |imp, idx|
|
|
114
|
-
lines << "" if idx > 0 # Blank line between imports
|
|
115
|
-
|
|
116
|
-
lines << "Import ID: #{imp.id}"
|
|
117
|
-
lines << "Status: #{imp.status}"
|
|
118
|
-
lines << "Title: #{imp.title}" if imp.title
|
|
119
|
-
lines << "Format: #{imp.format}" if imp.format
|
|
120
|
-
lines << "Entity Type: #{imp.entity['type']}" if imp.entity && imp.entity['type']
|
|
121
|
-
lines << "Count: #{imp.count}" if imp.count
|
|
122
|
-
lines << "Created: #{imp.created_at}" if imp.created_at
|
|
123
|
-
lines << "Updated: #{imp.updated_at}" if imp.updated_at
|
|
124
|
-
|
|
125
|
-
if imp.status == 'failed'
|
|
126
|
-
lines << "Failed Reason: #{imp.failed_reason}" if imp.failed_reason
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
if collection.has_more
|
|
131
|
-
lines << ""
|
|
132
|
-
lines << "Next Cursor: #{collection.next_cursor}"
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
lines.join("\n")
|
|
136
|
-
end
|
|
137
|
-
private_class_method :format_collection_as_pretty
|
|
138
|
-
|
|
139
|
-
def self.format_collection_as_text(collection)
|
|
140
|
-
lines = ["Imports (#{collection.data.length} items):"]
|
|
141
|
-
collection.data.each do |imp|
|
|
142
|
-
lines << "\n #{imp.id}"
|
|
143
|
-
lines << " Status: #{imp.status}"
|
|
144
|
-
lines << " Title: #{imp.title}" if imp.title
|
|
145
|
-
lines << " Count: #{imp.count}" if imp.count
|
|
146
|
-
end
|
|
147
|
-
lines.join("\n")
|
|
148
|
-
end
|
|
149
|
-
private_class_method :format_collection_as_text
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
end
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module CLI
|
|
5
|
-
module Formatters
|
|
6
|
-
class MonitorFormatter
|
|
7
|
-
def self.format(monitor, output_format)
|
|
8
|
-
case output_format
|
|
9
|
-
when "json"
|
|
10
|
-
JSON.generate(monitor.to_h)
|
|
11
|
-
when "pretty"
|
|
12
|
-
format_as_pretty(monitor)
|
|
13
|
-
when "text"
|
|
14
|
-
format_as_text(monitor)
|
|
15
|
-
when "toon"
|
|
16
|
-
Exa::CLI::Base.encode_as_toon(monitor.to_h)
|
|
17
|
-
else
|
|
18
|
-
raise ArgumentError, "Unknown output format: #{output_format}"
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def self.format_collection(collection, output_format)
|
|
23
|
-
case output_format
|
|
24
|
-
when "json"
|
|
25
|
-
JSON.generate(collection.to_h)
|
|
26
|
-
when "pretty"
|
|
27
|
-
format_collection_as_pretty(collection)
|
|
28
|
-
when "text"
|
|
29
|
-
format_collection_as_text(collection)
|
|
30
|
-
when "toon"
|
|
31
|
-
Exa::CLI::Base.encode_as_toon(collection.to_h)
|
|
32
|
-
else
|
|
33
|
-
raise ArgumentError, "Unknown output format: #{output_format}"
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def self.format_as_pretty(monitor)
|
|
38
|
-
lines = []
|
|
39
|
-
lines << "Monitor ID: #{monitor.id}"
|
|
40
|
-
lines << "Webset ID: #{monitor.webset_id}" if monitor.webset_id
|
|
41
|
-
lines << "Status: #{monitor.status}"
|
|
42
|
-
|
|
43
|
-
if monitor.cadence
|
|
44
|
-
lines << ""
|
|
45
|
-
lines << "Cadence:"
|
|
46
|
-
lines << " Cron: #{monitor.cadence['cron']}" if monitor.cadence['cron']
|
|
47
|
-
lines << " Timezone: #{monitor.cadence['timezone']}" if monitor.cadence['timezone']
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
if monitor.behavior
|
|
51
|
-
lines << ""
|
|
52
|
-
lines << "Behavior:"
|
|
53
|
-
lines << " Type: #{monitor.behavior['type']}" if monitor.behavior['type']
|
|
54
|
-
lines << " Query: #{monitor.behavior['query']}" if monitor.behavior['query']
|
|
55
|
-
lines << " Count: #{monitor.behavior['count']}" if monitor.behavior['count']
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
lines << ""
|
|
59
|
-
lines << "Created: #{monitor.created_at}" if monitor.created_at
|
|
60
|
-
lines << "Updated: #{monitor.updated_at}" if monitor.updated_at
|
|
61
|
-
|
|
62
|
-
lines.join("\n")
|
|
63
|
-
end
|
|
64
|
-
private_class_method :format_as_pretty
|
|
65
|
-
|
|
66
|
-
def self.format_as_text(monitor)
|
|
67
|
-
lines = []
|
|
68
|
-
lines << "Monitor: #{monitor.id}"
|
|
69
|
-
lines << "Webset: #{monitor.webset_id}" if monitor.webset_id
|
|
70
|
-
lines << "Status: #{monitor.status}"
|
|
71
|
-
|
|
72
|
-
if monitor.cadence
|
|
73
|
-
lines << "\nCadence:"
|
|
74
|
-
lines << " Cron: #{monitor.cadence['cron']}" if monitor.cadence['cron']
|
|
75
|
-
lines << " Timezone: #{monitor.cadence['timezone']}" if monitor.cadence['timezone']
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
if monitor.behavior
|
|
79
|
-
lines << "\nBehavior:"
|
|
80
|
-
lines << " Type: #{monitor.behavior['type']}" if monitor.behavior['type']
|
|
81
|
-
lines << " Query: #{monitor.behavior['query']}" if monitor.behavior['query']
|
|
82
|
-
lines << " Count: #{monitor.behavior['count']}" if monitor.behavior['count']
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
lines << "\nCreated: #{monitor.created_at}" if monitor.created_at
|
|
86
|
-
lines << "Updated: #{monitor.updated_at}" if monitor.updated_at
|
|
87
|
-
|
|
88
|
-
lines.join("\n")
|
|
89
|
-
end
|
|
90
|
-
private_class_method :format_as_text
|
|
91
|
-
|
|
92
|
-
def self.format_collection_as_pretty(collection)
|
|
93
|
-
lines = []
|
|
94
|
-
lines << "Monitors (#{collection.data.length} items)"
|
|
95
|
-
lines << ""
|
|
96
|
-
|
|
97
|
-
collection.data.each_with_index do |mon, idx|
|
|
98
|
-
lines << "" if idx > 0 # Blank line between monitors
|
|
99
|
-
|
|
100
|
-
lines << "Monitor ID: #{mon['id']}"
|
|
101
|
-
lines << "Webset ID: #{mon['websetId']}" if mon['websetId']
|
|
102
|
-
lines << "Status: #{mon['status']}"
|
|
103
|
-
|
|
104
|
-
if mon['cadence']
|
|
105
|
-
lines << "Cron: #{mon['cadence']['cron']}" if mon['cadence']['cron']
|
|
106
|
-
lines << "Timezone: #{mon['cadence']['timezone']}" if mon['cadence']['timezone']
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
if mon['behavior']
|
|
110
|
-
lines << "Query: #{mon['behavior']['query']}" if mon['behavior']['query']
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
lines << "Created: #{mon['createdAt']}" if mon['createdAt']
|
|
114
|
-
lines << "Updated: #{mon['updatedAt']}" if mon['updatedAt']
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
if collection.has_more
|
|
118
|
-
lines << ""
|
|
119
|
-
lines << "Next Cursor: #{collection.next_cursor}"
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
lines.join("\n")
|
|
123
|
-
end
|
|
124
|
-
private_class_method :format_collection_as_pretty
|
|
125
|
-
|
|
126
|
-
def self.format_collection_as_text(collection)
|
|
127
|
-
lines = ["Monitors (#{collection.data.length} items):"]
|
|
128
|
-
collection.data.each do |mon|
|
|
129
|
-
lines << "\n #{mon['id']}"
|
|
130
|
-
lines << " Status: #{mon['status']}"
|
|
131
|
-
lines << " Webset: #{mon['websetId']}" if mon['websetId']
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
if collection.has_more
|
|
135
|
-
lines << "\nMore available (cursor: #{collection.next_cursor})"
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
lines.join("\n")
|
|
139
|
-
end
|
|
140
|
-
private_class_method :format_collection_as_text
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
end
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module CLI
|
|
5
|
-
module Formatters
|
|
6
|
-
class MonitorRunFormatter
|
|
7
|
-
def self.format(monitor_run, output_format)
|
|
8
|
-
case output_format
|
|
9
|
-
when "json"
|
|
10
|
-
JSON.generate(monitor_run.to_h)
|
|
11
|
-
when "pretty"
|
|
12
|
-
format_as_pretty(monitor_run)
|
|
13
|
-
when "text"
|
|
14
|
-
format_as_text(monitor_run)
|
|
15
|
-
when "toon"
|
|
16
|
-
Exa::CLI::Base.encode_as_toon(monitor_run.to_h)
|
|
17
|
-
else
|
|
18
|
-
raise ArgumentError, "Unknown output format: #{output_format}"
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def self.format_collection(collection, output_format)
|
|
23
|
-
case output_format
|
|
24
|
-
when "json"
|
|
25
|
-
JSON.generate(collection.to_h)
|
|
26
|
-
when "pretty"
|
|
27
|
-
format_collection_as_pretty(collection)
|
|
28
|
-
when "text"
|
|
29
|
-
format_collection_as_text(collection)
|
|
30
|
-
when "toon"
|
|
31
|
-
Exa::CLI::Base.encode_as_toon(collection.to_h)
|
|
32
|
-
else
|
|
33
|
-
raise ArgumentError, "Unknown output format: #{output_format}"
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def self.format_as_pretty(monitor_run)
|
|
38
|
-
lines = []
|
|
39
|
-
lines << "Monitor Run ID: #{monitor_run.id}"
|
|
40
|
-
lines << "Monitor ID: #{monitor_run.monitor_id}" if monitor_run.monitor_id
|
|
41
|
-
lines << "Status: #{monitor_run.status}"
|
|
42
|
-
|
|
43
|
-
lines << ""
|
|
44
|
-
lines << "Created: #{monitor_run.created_at}" if monitor_run.created_at
|
|
45
|
-
lines << "Updated: #{monitor_run.updated_at}" if monitor_run.updated_at
|
|
46
|
-
lines << "Completed: #{monitor_run.completed_at}" if monitor_run.completed_at
|
|
47
|
-
|
|
48
|
-
if monitor_run.failed?
|
|
49
|
-
lines << ""
|
|
50
|
-
lines << "Failed: #{monitor_run.failed_at}" if monitor_run.failed_at
|
|
51
|
-
lines << "Reason: #{monitor_run.failed_reason}" if monitor_run.failed_reason
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
lines.join("\n")
|
|
55
|
-
end
|
|
56
|
-
private_class_method :format_as_pretty
|
|
57
|
-
|
|
58
|
-
def self.format_as_text(monitor_run)
|
|
59
|
-
lines = []
|
|
60
|
-
lines << "Monitor Run: #{monitor_run.id}"
|
|
61
|
-
lines << "Monitor: #{monitor_run.monitor_id}" if monitor_run.monitor_id
|
|
62
|
-
lines << "Status: #{monitor_run.status}"
|
|
63
|
-
|
|
64
|
-
lines << "\nCreated: #{monitor_run.created_at}" if monitor_run.created_at
|
|
65
|
-
lines << "Updated: #{monitor_run.updated_at}" if monitor_run.updated_at
|
|
66
|
-
lines << "Completed: #{monitor_run.completed_at}" if monitor_run.completed_at
|
|
67
|
-
|
|
68
|
-
if monitor_run.failed?
|
|
69
|
-
lines << "Failed: #{monitor_run.failed_at}" if monitor_run.failed_at
|
|
70
|
-
lines << "Reason: #{monitor_run.failed_reason}" if monitor_run.failed_reason
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
lines.join("\n")
|
|
74
|
-
end
|
|
75
|
-
private_class_method :format_as_text
|
|
76
|
-
|
|
77
|
-
def self.format_collection_as_pretty(collection)
|
|
78
|
-
lines = []
|
|
79
|
-
lines << "Monitor Runs (#{collection.data.length} items)"
|
|
80
|
-
lines << ""
|
|
81
|
-
|
|
82
|
-
collection.data.each_with_index do |run, idx|
|
|
83
|
-
lines << "" if idx > 0 # Blank line between runs
|
|
84
|
-
|
|
85
|
-
lines << "Monitor Run ID: #{run['id']}"
|
|
86
|
-
lines << "Monitor ID: #{run['monitorId']}" if run['monitorId']
|
|
87
|
-
lines << "Status: #{run['status']}"
|
|
88
|
-
lines << "Created: #{run['createdAt']}" if run['createdAt']
|
|
89
|
-
lines << "Updated: #{run['updatedAt']}" if run['updatedAt']
|
|
90
|
-
lines << "Completed: #{run['completedAt']}" if run['completedAt']
|
|
91
|
-
|
|
92
|
-
if run['status'] == 'failed'
|
|
93
|
-
lines << "Failed: #{run['failedAt']}" if run['failedAt']
|
|
94
|
-
lines << "Reason: #{run['failedReason']}" if run['failedReason']
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
if collection.has_more
|
|
99
|
-
lines << ""
|
|
100
|
-
lines << "Next Cursor: #{collection.next_cursor}"
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
lines.join("\n")
|
|
104
|
-
end
|
|
105
|
-
private_class_method :format_collection_as_pretty
|
|
106
|
-
|
|
107
|
-
def self.format_collection_as_text(collection)
|
|
108
|
-
lines = ["Monitor Runs (#{collection.data.length} items):"]
|
|
109
|
-
collection.data.each do |run|
|
|
110
|
-
lines << "\n #{run['id']}"
|
|
111
|
-
lines << " Status: #{run['status']}"
|
|
112
|
-
lines << " Completed: #{run['completedAt']}" if run['completedAt']
|
|
113
|
-
lines << " Failed: #{run['failedReason']}" if run['failedReason']
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
if collection.has_more
|
|
117
|
-
lines << "\nMore available (cursor: #{collection.next_cursor})"
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
lines.join("\n")
|
|
121
|
-
end
|
|
122
|
-
private_class_method :format_collection_as_text
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
end
|