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
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "../../constants/websets"
|
|
4
|
-
|
|
5
|
-
module Exa
|
|
6
|
-
module Services
|
|
7
|
-
module Websets
|
|
8
|
-
# Validates parameters for webset creation
|
|
9
|
-
class CreateValidator
|
|
10
|
-
VALID_ENTITY_TYPES = Constants::Websets::ENTITY_TYPES
|
|
11
|
-
VALID_ENRICHMENT_FORMATS = Constants::Websets::ENRICHMENT_FORMATS
|
|
12
|
-
VALID_SOURCE_TYPES = Constants::Websets::SOURCE_TYPES
|
|
13
|
-
|
|
14
|
-
class << self
|
|
15
|
-
def validate!(params)
|
|
16
|
-
validate_has_search_or_import!(params)
|
|
17
|
-
validate_search!(params[:search]) if params[:search]
|
|
18
|
-
validate_import!(params[:import]) if params[:import]
|
|
19
|
-
validate_enrichments!(params[:enrichments]) if params[:enrichments]
|
|
20
|
-
validate_exclude!(params[:exclude]) if params[:exclude]
|
|
21
|
-
validate_external_id!(params[:externalId]) if params[:externalId]
|
|
22
|
-
validate_title!(params[:title]) if params[:title]
|
|
23
|
-
validate_metadata!(params[:metadata]) if params[:metadata]
|
|
24
|
-
validate_no_duplicate_ids_in_import_and_scope!(params)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
private
|
|
28
|
-
|
|
29
|
-
def validate_has_search_or_import!(params)
|
|
30
|
-
return if params[:search] || params[:import]
|
|
31
|
-
|
|
32
|
-
raise ArgumentError, "At least one of :search or :import is required"
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def validate_search!(search)
|
|
36
|
-
raise ArgumentError, "search must be a Hash" unless search.is_a?(Hash)
|
|
37
|
-
raise ArgumentError, "search[:query] is required" unless search[:query]
|
|
38
|
-
raise ArgumentError, "search[:query] must be a String" unless search[:query].is_a?(String)
|
|
39
|
-
raise ArgumentError, "search[:query] cannot be empty" if search[:query].strip.empty?
|
|
40
|
-
raise ArgumentError, "search[:query] cannot exceed 5000 characters" if search[:query].length > 5000
|
|
41
|
-
|
|
42
|
-
validate_count!(search[:count]) if search[:count]
|
|
43
|
-
validate_entity!(search[:entity]) if search[:entity]
|
|
44
|
-
validate_criteria!(search[:criteria]) if search[:criteria]
|
|
45
|
-
validate_scope!(search[:scope]) if search[:scope]
|
|
46
|
-
validate_exclude_list!(search[:exclude]) if search[:exclude]
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def validate_count!(count)
|
|
50
|
-
raise ArgumentError, "count must be a positive Integer" unless count.is_a?(Integer) && count > 0
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def validate_entity!(entity)
|
|
54
|
-
raise ArgumentError, "entity must be a Hash" unless entity.is_a?(Hash)
|
|
55
|
-
raise ArgumentError, "entity[:type] is required" unless entity[:type]
|
|
56
|
-
|
|
57
|
-
type = entity[:type]
|
|
58
|
-
unless VALID_ENTITY_TYPES.include?(type)
|
|
59
|
-
raise ArgumentError, "entity[:type] must be one of: #{VALID_ENTITY_TYPES.join(', ')}"
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
if type == "custom"
|
|
63
|
-
raise ArgumentError, "entity[:description] is required for custom entity type" unless entity[:description]
|
|
64
|
-
validate_string_length!(entity[:description], "entity[:description]", min: 2, max: 200)
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def validate_criteria!(criteria)
|
|
69
|
-
raise ArgumentError, "criteria must be an Array" unless criteria.is_a?(Array)
|
|
70
|
-
raise ArgumentError, "criteria must have at least 1 item" if criteria.empty?
|
|
71
|
-
raise ArgumentError, "criteria cannot have more than 5 items" if criteria.length > 5
|
|
72
|
-
|
|
73
|
-
criteria.each_with_index do |criterion, index|
|
|
74
|
-
raise ArgumentError, "criteria[#{index}] must be a Hash" unless criterion.is_a?(Hash)
|
|
75
|
-
raise ArgumentError, "criteria[#{index}][:description] is required" unless criterion[:description]
|
|
76
|
-
validate_string_length!(criterion[:description], "criteria[#{index}][:description]", min: 1, max: 1000)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def validate_scope!(scope)
|
|
81
|
-
raise ArgumentError, "scope must be an Array" unless scope.is_a?(Array)
|
|
82
|
-
|
|
83
|
-
scope.each_with_index do |item, index|
|
|
84
|
-
validate_source_reference!(item, "scope[#{index}]")
|
|
85
|
-
|
|
86
|
-
next unless item[:relationship]
|
|
87
|
-
|
|
88
|
-
rel = item[:relationship]
|
|
89
|
-
raise ArgumentError, "scope[#{index}][:relationship] must be a Hash" unless rel.is_a?(Hash)
|
|
90
|
-
raise ArgumentError, "scope[#{index}][:relationship][:definition] is required" unless rel[:definition]
|
|
91
|
-
raise ArgumentError, "scope[#{index}][:relationship][:limit] is required" unless rel[:limit]
|
|
92
|
-
|
|
93
|
-
limit = rel[:limit]
|
|
94
|
-
unless limit.is_a?(Integer) && limit >= 1 && limit <= 10
|
|
95
|
-
raise ArgumentError, "scope[#{index}][:relationship][:limit] must be an Integer between 1 and 10"
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def validate_exclude_list!(exclude)
|
|
101
|
-
raise ArgumentError, "exclude must be an Array" unless exclude.is_a?(Array)
|
|
102
|
-
|
|
103
|
-
exclude.each_with_index do |item, index|
|
|
104
|
-
validate_source_reference!(item, "exclude[#{index}]")
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def validate_import!(import)
|
|
109
|
-
raise ArgumentError, "import must be an Array" unless import.is_a?(Array)
|
|
110
|
-
|
|
111
|
-
import.each_with_index do |item, index|
|
|
112
|
-
validate_source_reference!(item, "import[#{index}]")
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
def validate_enrichments!(enrichments)
|
|
117
|
-
raise ArgumentError, "enrichments must be an Array" unless enrichments.is_a?(Array)
|
|
118
|
-
|
|
119
|
-
enrichments.each_with_index do |enrichment, index|
|
|
120
|
-
raise ArgumentError, "enrichments[#{index}] must be a Hash" unless enrichment.is_a?(Hash)
|
|
121
|
-
raise ArgumentError, "enrichments[#{index}][:description] is required" unless enrichment[:description]
|
|
122
|
-
validate_string_length!(enrichment[:description], "enrichments[#{index}][:description]", min: 1, max: 5000)
|
|
123
|
-
|
|
124
|
-
if enrichment[:format]
|
|
125
|
-
format = enrichment[:format]
|
|
126
|
-
unless VALID_ENRICHMENT_FORMATS.include?(format)
|
|
127
|
-
raise ArgumentError, "enrichments[#{index}][:format] must be one of: #{VALID_ENRICHMENT_FORMATS.join(', ')}"
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
if format == "options"
|
|
131
|
-
validate_enrichment_options!(enrichment[:options], index)
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
def validate_enrichment_options!(options, enrichment_index)
|
|
138
|
-
unless options.is_a?(Array)
|
|
139
|
-
raise ArgumentError, "enrichments[#{enrichment_index}][:options] is required when format is 'options'"
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
if options.empty? || options.length > 150
|
|
143
|
-
raise ArgumentError, "enrichments[#{enrichment_index}][:options] must have between 1 and 150 items"
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
options.each_with_index do |option, option_index|
|
|
147
|
-
unless option.is_a?(Hash) && option[:label]
|
|
148
|
-
raise ArgumentError, "enrichments[#{enrichment_index}][:options][#{option_index}][:label] is required"
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
def validate_exclude!(exclude)
|
|
154
|
-
validate_exclude_list!(exclude)
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
def validate_external_id!(external_id)
|
|
158
|
-
raise ArgumentError, "externalId must be a String" unless external_id.is_a?(String)
|
|
159
|
-
raise ArgumentError, "externalId cannot exceed 300 characters" if external_id.length > 300
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
def validate_title!(title)
|
|
163
|
-
raise ArgumentError, "title must be a String" unless title.is_a?(String)
|
|
164
|
-
raise ArgumentError, "title cannot be empty" if title.strip.empty?
|
|
165
|
-
raise ArgumentError, "title cannot exceed 1000 characters" if title.length > 1000
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
def validate_metadata!(metadata)
|
|
169
|
-
raise ArgumentError, "metadata must be a Hash" unless metadata.is_a?(Hash)
|
|
170
|
-
|
|
171
|
-
metadata.each do |key, value|
|
|
172
|
-
raise ArgumentError, "metadata values must be Strings" unless value.is_a?(String)
|
|
173
|
-
raise ArgumentError, "metadata value for '#{key}' cannot exceed 1000 characters" if value.length > 1000
|
|
174
|
-
end
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
def validate_source_reference!(item, context)
|
|
178
|
-
raise ArgumentError, "#{context} must be a Hash" unless item.is_a?(Hash)
|
|
179
|
-
raise ArgumentError, "#{context}[:source] is required" unless item[:source]
|
|
180
|
-
raise ArgumentError, "#{context}[:id] is required" unless item[:id]
|
|
181
|
-
|
|
182
|
-
source = item[:source]
|
|
183
|
-
unless VALID_SOURCE_TYPES.include?(source)
|
|
184
|
-
raise ArgumentError, "#{context}[:source] must be one of: #{VALID_SOURCE_TYPES.join(', ')}"
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
raise ArgumentError, "#{context}[:id] must be a non-empty String" unless item[:id].is_a?(String) && !item[:id].empty?
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
def validate_string_length!(value, name, min: nil, max: nil)
|
|
191
|
-
raise ArgumentError, "#{name} must be a String" unless value.is_a?(String)
|
|
192
|
-
raise ArgumentError, "#{name} must be at least #{min} characters" if min && value.length < min
|
|
193
|
-
raise ArgumentError, "#{name} cannot exceed #{max} characters" if max && value.length > max
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
def validate_no_duplicate_ids_in_import_and_scope!(params)
|
|
197
|
-
return unless params[:import] && params[:search] && params[:search][:scope]
|
|
198
|
-
|
|
199
|
-
import_ids = params[:import].map { |item| item[:id] }
|
|
200
|
-
scope_ids = params[:search][:scope].map { |item| item[:id] }
|
|
201
|
-
|
|
202
|
-
duplicates = import_ids & scope_ids
|
|
203
|
-
|
|
204
|
-
return if duplicates.empty?
|
|
205
|
-
|
|
206
|
-
raise ArgumentError,
|
|
207
|
-
"Cannot use the same import/webset ID in both :import and search[:scope]: #{duplicates.join(', ')}"
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
end
|
|
211
|
-
end
|
|
212
|
-
end
|
|
213
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
class Delete
|
|
7
|
-
def initialize(connection, id:)
|
|
8
|
-
@connection = connection
|
|
9
|
-
@id = id
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def call
|
|
13
|
-
response = @connection.delete("/websets/v0/websets/#{@id}")
|
|
14
|
-
body = response.body
|
|
15
|
-
|
|
16
|
-
Resources::Webset.new(
|
|
17
|
-
id: body["id"],
|
|
18
|
-
object: body["object"],
|
|
19
|
-
status: body["status"],
|
|
20
|
-
external_id: body["externalId"],
|
|
21
|
-
title: body["title"],
|
|
22
|
-
searches: body["searches"],
|
|
23
|
-
imports: body["imports"],
|
|
24
|
-
enrichments: body["enrichments"],
|
|
25
|
-
monitors: body["monitors"],
|
|
26
|
-
excludes: body["excludes"],
|
|
27
|
-
metadata: body["metadata"],
|
|
28
|
-
created_at: body["createdAt"],
|
|
29
|
-
updated_at: body["updatedAt"],
|
|
30
|
-
items: body["items"]
|
|
31
|
-
)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
class DeleteEnrichment
|
|
7
|
-
def initialize(connection, webset_id:, id:)
|
|
8
|
-
@connection = connection
|
|
9
|
-
@webset_id = webset_id
|
|
10
|
-
@id = id
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def call
|
|
14
|
-
response = @connection.delete("/websets/v0/websets/#{@webset_id}/enrichments/#{@id}")
|
|
15
|
-
body = response.body
|
|
16
|
-
|
|
17
|
-
Resources::WebsetEnrichment.new(
|
|
18
|
-
id: body["id"],
|
|
19
|
-
object: body["object"],
|
|
20
|
-
status: body["status"],
|
|
21
|
-
webset_id: body["websetId"],
|
|
22
|
-
title: body["title"],
|
|
23
|
-
description: body["description"],
|
|
24
|
-
format: body["format"],
|
|
25
|
-
options: body["options"],
|
|
26
|
-
instructions: body["instructions"],
|
|
27
|
-
metadata: body["metadata"],
|
|
28
|
-
created_at: body["createdAt"],
|
|
29
|
-
updated_at: body["updatedAt"]
|
|
30
|
-
)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
class DeleteItem
|
|
7
|
-
def initialize(connection, webset_id:, id:)
|
|
8
|
-
@connection = connection
|
|
9
|
-
@webset_id = webset_id
|
|
10
|
-
@id = id
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def call
|
|
14
|
-
@connection.delete("/websets/v0/websets/#{@webset_id}/items/#{@id}")
|
|
15
|
-
true
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
class GetItem
|
|
7
|
-
def initialize(connection, webset_id:, id:)
|
|
8
|
-
@connection = connection
|
|
9
|
-
@webset_id = webset_id
|
|
10
|
-
@id = id
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def call
|
|
14
|
-
response = @connection.get("/websets/v0/websets/#{@webset_id}/items/#{@id}")
|
|
15
|
-
response.body
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
class GetSearch
|
|
7
|
-
def initialize(connection, webset_id:, id:)
|
|
8
|
-
@connection = connection
|
|
9
|
-
@webset_id = webset_id
|
|
10
|
-
@id = id
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def call
|
|
14
|
-
response = @connection.get(
|
|
15
|
-
"/websets/v0/websets/#{@webset_id}/searches/#{@id}"
|
|
16
|
-
)
|
|
17
|
-
body = response.body
|
|
18
|
-
|
|
19
|
-
Resources::WebsetSearch.new(
|
|
20
|
-
id: body["id"],
|
|
21
|
-
object: body["object"],
|
|
22
|
-
status: body["status"],
|
|
23
|
-
webset_id: body["websetId"],
|
|
24
|
-
query: body["query"],
|
|
25
|
-
entity: body["entity"],
|
|
26
|
-
criteria: body["criteria"],
|
|
27
|
-
count: body["count"],
|
|
28
|
-
behavior: body["behavior"],
|
|
29
|
-
exclude: body["exclude"],
|
|
30
|
-
scope: body["scope"],
|
|
31
|
-
progress: body["progress"],
|
|
32
|
-
recall: body["recall"],
|
|
33
|
-
metadata: body["metadata"],
|
|
34
|
-
canceled_at: body["canceledAt"],
|
|
35
|
-
canceled_reason: body["canceledReason"],
|
|
36
|
-
created_at: body["createdAt"],
|
|
37
|
-
updated_at: body["updatedAt"]
|
|
38
|
-
)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
class CreateImport
|
|
7
|
-
def initialize(connection, **params)
|
|
8
|
-
@connection = connection
|
|
9
|
-
@params = params
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def call
|
|
13
|
-
response = @connection.post(
|
|
14
|
-
"/websets/v0/imports",
|
|
15
|
-
@params
|
|
16
|
-
)
|
|
17
|
-
body = response.body
|
|
18
|
-
|
|
19
|
-
Resources::Import.new(
|
|
20
|
-
id: body["id"],
|
|
21
|
-
object: body["object"],
|
|
22
|
-
status: body["status"],
|
|
23
|
-
format: body["format"],
|
|
24
|
-
entity: body["entity"],
|
|
25
|
-
title: body["title"],
|
|
26
|
-
count: body["count"],
|
|
27
|
-
metadata: body["metadata"],
|
|
28
|
-
failed_reason: body["failedReason"],
|
|
29
|
-
failed_at: body["failedAt"],
|
|
30
|
-
failed_message: body["failedMessage"],
|
|
31
|
-
created_at: body["createdAt"],
|
|
32
|
-
updated_at: body["updatedAt"],
|
|
33
|
-
upload_url: body["uploadUrl"],
|
|
34
|
-
upload_valid_until: body["uploadValidUntil"]
|
|
35
|
-
)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
class DeleteImport
|
|
7
|
-
def initialize(connection, id:)
|
|
8
|
-
@connection = connection
|
|
9
|
-
@id = id
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def call
|
|
13
|
-
response = @connection.delete("/websets/v0/imports/#{@id}")
|
|
14
|
-
body = response.body
|
|
15
|
-
|
|
16
|
-
Resources::Import.new(
|
|
17
|
-
id: body["id"],
|
|
18
|
-
object: body["object"],
|
|
19
|
-
status: body["status"],
|
|
20
|
-
format: body["format"],
|
|
21
|
-
entity: body["entity"],
|
|
22
|
-
title: body["title"],
|
|
23
|
-
count: body["count"],
|
|
24
|
-
metadata: body["metadata"],
|
|
25
|
-
failed_reason: body["failedReason"],
|
|
26
|
-
failed_at: body["failedAt"],
|
|
27
|
-
failed_message: body["failedMessage"],
|
|
28
|
-
created_at: body["createdAt"],
|
|
29
|
-
updated_at: body["updatedAt"],
|
|
30
|
-
upload_url: body["uploadUrl"],
|
|
31
|
-
upload_valid_until: body["uploadValidUntil"]
|
|
32
|
-
)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
class GetImport
|
|
7
|
-
def initialize(connection, id:)
|
|
8
|
-
@connection = connection
|
|
9
|
-
@id = id
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def call
|
|
13
|
-
response = @connection.get("/websets/v0/imports/#{@id}")
|
|
14
|
-
body = response.body
|
|
15
|
-
|
|
16
|
-
Resources::Import.new(
|
|
17
|
-
id: body["id"],
|
|
18
|
-
object: body["object"],
|
|
19
|
-
status: body["status"],
|
|
20
|
-
format: body["format"],
|
|
21
|
-
entity: body["entity"],
|
|
22
|
-
title: body["title"],
|
|
23
|
-
count: body["count"],
|
|
24
|
-
metadata: body["metadata"],
|
|
25
|
-
failed_reason: body["failedReason"],
|
|
26
|
-
failed_at: body["failedAt"],
|
|
27
|
-
failed_message: body["failedMessage"],
|
|
28
|
-
created_at: body["createdAt"],
|
|
29
|
-
updated_at: body["updatedAt"],
|
|
30
|
-
upload_url: body["uploadUrl"],
|
|
31
|
-
upload_valid_until: body["uploadValidUntil"]
|
|
32
|
-
)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
class ListImports
|
|
7
|
-
def initialize(connection, **params)
|
|
8
|
-
@connection = connection
|
|
9
|
-
@params = params
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def call
|
|
13
|
-
response = @connection.get("/websets/v0/imports", @params)
|
|
14
|
-
body = response.body
|
|
15
|
-
|
|
16
|
-
Resources::ImportCollection.new(
|
|
17
|
-
data: body["data"],
|
|
18
|
-
has_more: body["hasMore"],
|
|
19
|
-
next_cursor: body["nextCursor"]
|
|
20
|
-
)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
class UpdateImport
|
|
7
|
-
def initialize(connection, id:, **params)
|
|
8
|
-
@connection = connection
|
|
9
|
-
@id = id
|
|
10
|
-
@params = params
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def call
|
|
14
|
-
response = @connection.patch("/websets/v0/imports/#{@id}", @params)
|
|
15
|
-
body = response.body
|
|
16
|
-
|
|
17
|
-
Resources::Import.new(
|
|
18
|
-
id: body["id"],
|
|
19
|
-
object: body["object"],
|
|
20
|
-
status: body["status"],
|
|
21
|
-
format: body["format"],
|
|
22
|
-
entity: body["entity"],
|
|
23
|
-
title: body["title"],
|
|
24
|
-
count: body["count"],
|
|
25
|
-
metadata: body["metadata"],
|
|
26
|
-
failed_reason: body["failedReason"],
|
|
27
|
-
failed_at: body["failedAt"],
|
|
28
|
-
failed_message: body["failedMessage"],
|
|
29
|
-
created_at: body["createdAt"],
|
|
30
|
-
updated_at: body["updatedAt"],
|
|
31
|
-
upload_url: body["uploadUrl"],
|
|
32
|
-
upload_valid_until: body["uploadValidUntil"]
|
|
33
|
-
)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "faraday"
|
|
4
|
-
|
|
5
|
-
module Exa
|
|
6
|
-
module Services
|
|
7
|
-
module Websets
|
|
8
|
-
class UploadImport
|
|
9
|
-
def initialize(connection, file_path:, **params)
|
|
10
|
-
@connection = connection
|
|
11
|
-
@file_path = file_path
|
|
12
|
-
@params = params
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def call
|
|
16
|
-
validate_file!
|
|
17
|
-
|
|
18
|
-
# Infer file size
|
|
19
|
-
file_size = File.size(@file_path)
|
|
20
|
-
|
|
21
|
-
# Create import with inferred size
|
|
22
|
-
import = CreateImport.new(@connection, size: file_size, **@params).call
|
|
23
|
-
|
|
24
|
-
# Upload file to the upload URL
|
|
25
|
-
upload_file(import.upload_url)
|
|
26
|
-
|
|
27
|
-
# Return the import resource
|
|
28
|
-
import
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
private
|
|
32
|
-
|
|
33
|
-
def validate_file!
|
|
34
|
-
unless File.exist?(@file_path)
|
|
35
|
-
raise Error, "File not found: #{@file_path}"
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
unless File.readable?(@file_path)
|
|
39
|
-
raise Error, "Permission denied: file is not readable: #{@file_path}"
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def upload_file(upload_url)
|
|
44
|
-
file_content = File.read(@file_path)
|
|
45
|
-
|
|
46
|
-
upload_connection = Faraday.new do |f|
|
|
47
|
-
f.response :raise_error
|
|
48
|
-
f.adapter Faraday.default_adapter
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
upload_connection.put(upload_url) do |req|
|
|
52
|
-
req.headers["Content-Type"] = "text/csv"
|
|
53
|
-
req.body = file_content
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
class List
|
|
7
|
-
def initialize(connection, **params)
|
|
8
|
-
@connection = connection
|
|
9
|
-
@params = params
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def call
|
|
13
|
-
response = @connection.get("/websets/v0/websets", @params)
|
|
14
|
-
body = response.body
|
|
15
|
-
|
|
16
|
-
Resources::WebsetCollection.new(
|
|
17
|
-
data: body["data"],
|
|
18
|
-
has_more: body["hasMore"],
|
|
19
|
-
next_cursor: body["nextCursor"]
|
|
20
|
-
)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
class ListItems
|
|
7
|
-
def initialize(connection, webset_id:, **params)
|
|
8
|
-
@connection = connection
|
|
9
|
-
@webset_id = webset_id
|
|
10
|
-
@params = params
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def call
|
|
14
|
-
response = @connection.get("/websets/v0/websets/#{@webset_id}/items", @params)
|
|
15
|
-
body = response.body
|
|
16
|
-
|
|
17
|
-
Resources::WebsetItemCollection.new(
|
|
18
|
-
data: body["data"] || [],
|
|
19
|
-
has_more: body["hasMore"] || false,
|
|
20
|
-
next_cursor: body["nextCursor"]
|
|
21
|
-
)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|