ibm_watson 2.1.3 → 2.2.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 +13 -13
- data/lib/ibm_watson/assistant_v1.rb +2 -2
- data/lib/ibm_watson/assistant_v2.rb +2 -2
- data/lib/ibm_watson/discovery_v1.rb +3 -4
- data/lib/ibm_watson/language_translator_v3.rb +1 -1
- data/lib/ibm_watson/natural_language_understanding_v1.rb +1 -1
- data/lib/ibm_watson/speech_to_text_v1.rb +257 -176
- data/lib/ibm_watson/text_to_speech_v1.rb +38 -119
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson.rb +0 -6
- metadata +2 -20
- data/lib/ibm_watson/compare_comply_v1.rb +0 -683
- data/lib/ibm_watson/natural_language_classifier_v1.rb +0 -267
- data/lib/ibm_watson/personality_insights_v3.rb +0 -223
- data/lib/ibm_watson/tone_analyzer_v3.rb +0 -230
- data/lib/ibm_watson/visual_recognition_v3.rb +0 -517
- data/lib/ibm_watson/visual_recognition_v4.rb +0 -930
- data/test/integration/test_compare_comply_v1.rb +0 -105
- data/test/integration/test_natural_language_classifier_v1.rb +0 -80
- data/test/integration/test_personality_insights_v3.rb +0 -81
- data/test/integration/test_tone_analyzer_v3.rb +0 -66
- data/test/integration/test_visual_recognition_v3.rb +0 -68
- data/test/integration/test_visual_recognition_v4.rb +0 -87
- data/test/unit/test_compare_comply_v1.rb +0 -232
- data/test/unit/test_natural_language_classifier_v1.rb +0 -191
- data/test/unit/test_personality_insights_v3.rb +0 -192
- data/test/unit/test_tone_analyzer_v3.rb +0 -217
- data/test/unit/test_visual_recognition_v3.rb +0 -300
- data/test/unit/test_visual_recognition_v4.rb +0 -422
@@ -1,683 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# (C) Copyright IBM Corp. 2018, 2020.
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
#
|
17
|
-
# IBM OpenAPI SDK Code Generator Version: 3.38.0-07189efd-20210827-205025
|
18
|
-
#
|
19
|
-
# IBM Watson™ Compare and Comply is discontinued. Existing instances are supported
|
20
|
-
# until 30 November 2021, but as of 1 December 2020, you can't create instances. Any
|
21
|
-
# instance that exists on 30 November 2021 will be deleted. Consider migrating to Watson
|
22
|
-
# Discovery Premium on IBM Cloud for your Compare and Comply use cases. To start the
|
23
|
-
# migration process, visit
|
24
|
-
# [https://ibm.biz/contact-wdc-premium](https://ibm.biz/contact-wdc-premium).
|
25
|
-
# {: deprecated}
|
26
|
-
#
|
27
|
-
# Compare and Comply analyzes governing documents to provide details about critical
|
28
|
-
# aspects of the documents.
|
29
|
-
|
30
|
-
require "concurrent"
|
31
|
-
require "erb"
|
32
|
-
require "json"
|
33
|
-
require "ibm_cloud_sdk_core"
|
34
|
-
require_relative "./common.rb"
|
35
|
-
|
36
|
-
module IBMWatson
|
37
|
-
##
|
38
|
-
# The Compare Comply V1 service.
|
39
|
-
class CompareComplyV1 < IBMCloudSdkCore::BaseService
|
40
|
-
include Concurrent::Async
|
41
|
-
DEFAULT_SERVICE_NAME = "compare_comply"
|
42
|
-
DEFAULT_SERVICE_URL = "https://api.us-south.compare-comply.watson.cloud.ibm.com"
|
43
|
-
attr_accessor :version
|
44
|
-
##
|
45
|
-
# @!method initialize(args)
|
46
|
-
# Construct a new client for the Compare Comply service.
|
47
|
-
#
|
48
|
-
# @param args [Hash] The args to initialize with
|
49
|
-
# @option args version [String] Release date of the version of the API you want to use. Specify dates in
|
50
|
-
# YYYY-MM-DD format. The current version is `2018-10-15`.
|
51
|
-
# @option args service_url [String] The base service URL to use when contacting the service.
|
52
|
-
# The base service_url may differ between IBM Cloud regions.
|
53
|
-
# @option args authenticator [Object] The Authenticator instance to be configured for this service.
|
54
|
-
# @option args service_name [String] The name of the service to configure. Will be used as the key to load
|
55
|
-
# any external configuration, if applicable.
|
56
|
-
def initialize(args = {})
|
57
|
-
warn "On 30 November 2021, Compare and Comply will no longer be available. For more information, see https://github.com/watson-developer-cloud/ruby-sdk#compare-and-comply-deprecation."
|
58
|
-
@__async_initialized__ = false
|
59
|
-
defaults = {}
|
60
|
-
defaults[:service_url] = DEFAULT_SERVICE_URL
|
61
|
-
defaults[:service_name] = DEFAULT_SERVICE_NAME
|
62
|
-
defaults[:authenticator] = nil
|
63
|
-
defaults[:version] = nil
|
64
|
-
user_service_url = args[:service_url] unless args[:service_url].nil?
|
65
|
-
args = defaults.merge(args)
|
66
|
-
@version = args[:version]
|
67
|
-
raise ArgumentError.new("version must be provided") if @version.nil?
|
68
|
-
|
69
|
-
args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
|
70
|
-
super
|
71
|
-
@service_url = user_service_url unless user_service_url.nil?
|
72
|
-
end
|
73
|
-
|
74
|
-
#########################
|
75
|
-
# HTML conversion
|
76
|
-
#########################
|
77
|
-
|
78
|
-
##
|
79
|
-
# @!method convert_to_html(file:, file_content_type: nil, model: nil)
|
80
|
-
# Convert document to HTML.
|
81
|
-
# Converts a document to HTML.
|
82
|
-
# @param file [File] The document to convert.
|
83
|
-
# @param file_content_type [String] The content type of file.
|
84
|
-
# @param model [String] The analysis model to be used by the service. For the **Element classification**
|
85
|
-
# and **Compare two documents** methods, the default is `contracts`. For the
|
86
|
-
# **Extract tables** method, the default is `tables`. These defaults apply to the
|
87
|
-
# standalone methods as well as to the methods' use in batch-processing requests.
|
88
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
89
|
-
def convert_to_html(file:, file_content_type: nil, model: nil)
|
90
|
-
raise ArgumentError.new("version must be provided") if version.nil?
|
91
|
-
|
92
|
-
raise ArgumentError.new("file must be provided") if file.nil?
|
93
|
-
|
94
|
-
headers = {
|
95
|
-
}
|
96
|
-
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "convert_to_html")
|
97
|
-
headers.merge!(sdk_headers)
|
98
|
-
|
99
|
-
params = {
|
100
|
-
"version" => @version,
|
101
|
-
"model" => model
|
102
|
-
}
|
103
|
-
|
104
|
-
form_data = {}
|
105
|
-
|
106
|
-
unless file.instance_of?(StringIO) || file.instance_of?(File)
|
107
|
-
file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
|
108
|
-
end
|
109
|
-
form_data[:file] = HTTP::FormData::File.new(file, content_type: file_content_type.nil? ? "application/octet-stream" : file_content_type, filename: file.respond_to?(:path) ? file.path : nil)
|
110
|
-
|
111
|
-
method_url = "/v1/html_conversion"
|
112
|
-
|
113
|
-
response = request(
|
114
|
-
method: "POST",
|
115
|
-
url: method_url,
|
116
|
-
headers: headers,
|
117
|
-
params: params,
|
118
|
-
form: form_data,
|
119
|
-
accept_json: true
|
120
|
-
)
|
121
|
-
response
|
122
|
-
end
|
123
|
-
#########################
|
124
|
-
# Element classification
|
125
|
-
#########################
|
126
|
-
|
127
|
-
##
|
128
|
-
# @!method classify_elements(file:, file_content_type: nil, model: nil)
|
129
|
-
# Classify the elements of a document.
|
130
|
-
# Analyzes the structural and semantic elements of a document.
|
131
|
-
# @param file [File] The document to classify.
|
132
|
-
# @param file_content_type [String] The content type of file.
|
133
|
-
# @param model [String] The analysis model to be used by the service. For the **Element classification**
|
134
|
-
# and **Compare two documents** methods, the default is `contracts`. For the
|
135
|
-
# **Extract tables** method, the default is `tables`. These defaults apply to the
|
136
|
-
# standalone methods as well as to the methods' use in batch-processing requests.
|
137
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
138
|
-
def classify_elements(file:, file_content_type: nil, model: nil)
|
139
|
-
raise ArgumentError.new("version must be provided") if version.nil?
|
140
|
-
|
141
|
-
raise ArgumentError.new("file must be provided") if file.nil?
|
142
|
-
|
143
|
-
headers = {
|
144
|
-
}
|
145
|
-
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "classify_elements")
|
146
|
-
headers.merge!(sdk_headers)
|
147
|
-
|
148
|
-
params = {
|
149
|
-
"version" => @version,
|
150
|
-
"model" => model
|
151
|
-
}
|
152
|
-
|
153
|
-
form_data = {}
|
154
|
-
|
155
|
-
unless file.instance_of?(StringIO) || file.instance_of?(File)
|
156
|
-
file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
|
157
|
-
end
|
158
|
-
form_data[:file] = HTTP::FormData::File.new(file, content_type: file_content_type.nil? ? "application/octet-stream" : file_content_type, filename: file.respond_to?(:path) ? file.path : nil)
|
159
|
-
|
160
|
-
method_url = "/v1/element_classification"
|
161
|
-
|
162
|
-
response = request(
|
163
|
-
method: "POST",
|
164
|
-
url: method_url,
|
165
|
-
headers: headers,
|
166
|
-
params: params,
|
167
|
-
form: form_data,
|
168
|
-
accept_json: true
|
169
|
-
)
|
170
|
-
response
|
171
|
-
end
|
172
|
-
#########################
|
173
|
-
# Tables
|
174
|
-
#########################
|
175
|
-
|
176
|
-
##
|
177
|
-
# @!method extract_tables(file:, file_content_type: nil, model: nil)
|
178
|
-
# Extract a document's tables.
|
179
|
-
# Analyzes the tables in a document.
|
180
|
-
# @param file [File] The document on which to run table extraction.
|
181
|
-
# @param file_content_type [String] The content type of file.
|
182
|
-
# @param model [String] The analysis model to be used by the service. For the **Element classification**
|
183
|
-
# and **Compare two documents** methods, the default is `contracts`. For the
|
184
|
-
# **Extract tables** method, the default is `tables`. These defaults apply to the
|
185
|
-
# standalone methods as well as to the methods' use in batch-processing requests.
|
186
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
187
|
-
def extract_tables(file:, file_content_type: nil, model: nil)
|
188
|
-
raise ArgumentError.new("version must be provided") if version.nil?
|
189
|
-
|
190
|
-
raise ArgumentError.new("file must be provided") if file.nil?
|
191
|
-
|
192
|
-
headers = {
|
193
|
-
}
|
194
|
-
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "extract_tables")
|
195
|
-
headers.merge!(sdk_headers)
|
196
|
-
|
197
|
-
params = {
|
198
|
-
"version" => @version,
|
199
|
-
"model" => model
|
200
|
-
}
|
201
|
-
|
202
|
-
form_data = {}
|
203
|
-
|
204
|
-
unless file.instance_of?(StringIO) || file.instance_of?(File)
|
205
|
-
file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
|
206
|
-
end
|
207
|
-
form_data[:file] = HTTP::FormData::File.new(file, content_type: file_content_type.nil? ? "application/octet-stream" : file_content_type, filename: file.respond_to?(:path) ? file.path : nil)
|
208
|
-
|
209
|
-
method_url = "/v1/tables"
|
210
|
-
|
211
|
-
response = request(
|
212
|
-
method: "POST",
|
213
|
-
url: method_url,
|
214
|
-
headers: headers,
|
215
|
-
params: params,
|
216
|
-
form: form_data,
|
217
|
-
accept_json: true
|
218
|
-
)
|
219
|
-
response
|
220
|
-
end
|
221
|
-
#########################
|
222
|
-
# Comparison
|
223
|
-
#########################
|
224
|
-
|
225
|
-
##
|
226
|
-
# @!method compare_documents(file_1:, file_2:, file_1_content_type: nil, file_2_content_type: nil, file_1_label: nil, file_2_label: nil, model: nil)
|
227
|
-
# Compare two documents.
|
228
|
-
# Compares two input documents. Documents must be in the same format.
|
229
|
-
# @param file_1 [File] The first document to compare.
|
230
|
-
# @param file_2 [File] The second document to compare.
|
231
|
-
# @param file_1_content_type [String] The content type of file_1.
|
232
|
-
# @param file_2_content_type [String] The content type of file_2.
|
233
|
-
# @param file_1_label [String] A text label for the first document.
|
234
|
-
# @param file_2_label [String] A text label for the second document.
|
235
|
-
# @param model [String] The analysis model to be used by the service. For the **Element classification**
|
236
|
-
# and **Compare two documents** methods, the default is `contracts`. For the
|
237
|
-
# **Extract tables** method, the default is `tables`. These defaults apply to the
|
238
|
-
# standalone methods as well as to the methods' use in batch-processing requests.
|
239
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
240
|
-
def compare_documents(file_1:, file_2:, file_1_content_type: nil, file_2_content_type: nil, file_1_label: nil, file_2_label: nil, model: nil)
|
241
|
-
raise ArgumentError.new("version must be provided") if version.nil?
|
242
|
-
|
243
|
-
raise ArgumentError.new("file_1 must be provided") if file_1.nil?
|
244
|
-
|
245
|
-
raise ArgumentError.new("file_2 must be provided") if file_2.nil?
|
246
|
-
|
247
|
-
headers = {
|
248
|
-
}
|
249
|
-
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "compare_documents")
|
250
|
-
headers.merge!(sdk_headers)
|
251
|
-
|
252
|
-
params = {
|
253
|
-
"version" => @version,
|
254
|
-
"file_1_label" => file_1_label,
|
255
|
-
"file_2_label" => file_2_label,
|
256
|
-
"model" => model
|
257
|
-
}
|
258
|
-
|
259
|
-
form_data = {}
|
260
|
-
|
261
|
-
unless file_1.instance_of?(StringIO) || file_1.instance_of?(File)
|
262
|
-
file_1 = file_1.respond_to?(:to_json) ? StringIO.new(file_1.to_json) : StringIO.new(file_1)
|
263
|
-
end
|
264
|
-
form_data[:file_1] = HTTP::FormData::File.new(file_1, content_type: file_1_content_type.nil? ? "application/octet-stream" : file_1_content_type, filename: file_1.respond_to?(:path) ? file_1.path : nil)
|
265
|
-
|
266
|
-
unless file_2.instance_of?(StringIO) || file_2.instance_of?(File)
|
267
|
-
file_2 = file_2.respond_to?(:to_json) ? StringIO.new(file_2.to_json) : StringIO.new(file_2)
|
268
|
-
end
|
269
|
-
form_data[:file_2] = HTTP::FormData::File.new(file_2, content_type: file_2_content_type.nil? ? "application/octet-stream" : file_2_content_type, filename: file_2.respond_to?(:path) ? file_2.path : nil)
|
270
|
-
|
271
|
-
method_url = "/v1/comparison"
|
272
|
-
|
273
|
-
response = request(
|
274
|
-
method: "POST",
|
275
|
-
url: method_url,
|
276
|
-
headers: headers,
|
277
|
-
params: params,
|
278
|
-
form: form_data,
|
279
|
-
accept_json: true
|
280
|
-
)
|
281
|
-
response
|
282
|
-
end
|
283
|
-
#########################
|
284
|
-
# Feedback
|
285
|
-
#########################
|
286
|
-
|
287
|
-
##
|
288
|
-
# @!method add_feedback(feedback_data:, user_id: nil, comment: nil)
|
289
|
-
# Add feedback.
|
290
|
-
# Adds feedback in the form of _labels_ from a subject-matter expert (SME) to a
|
291
|
-
# governing document.
|
292
|
-
# **Important:** Feedback is not immediately incorporated into the training model,
|
293
|
-
# nor is it guaranteed to be incorporated at a later date. Instead, submitted
|
294
|
-
# feedback is used to suggest future updates to the training model.
|
295
|
-
# @param feedback_data [FeedbackDataInput] Feedback data for submission.
|
296
|
-
# @param user_id [String] An optional string identifying the user.
|
297
|
-
# @param comment [String] An optional comment on or description of the feedback.
|
298
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
299
|
-
def add_feedback(feedback_data:, user_id: nil, comment: nil)
|
300
|
-
raise ArgumentError.new("version must be provided") if version.nil?
|
301
|
-
|
302
|
-
raise ArgumentError.new("feedback_data must be provided") if feedback_data.nil?
|
303
|
-
|
304
|
-
headers = {
|
305
|
-
}
|
306
|
-
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "add_feedback")
|
307
|
-
headers.merge!(sdk_headers)
|
308
|
-
|
309
|
-
params = {
|
310
|
-
"version" => @version
|
311
|
-
}
|
312
|
-
|
313
|
-
data = {
|
314
|
-
"feedback_data" => feedback_data,
|
315
|
-
"user_id" => user_id,
|
316
|
-
"comment" => comment
|
317
|
-
}
|
318
|
-
|
319
|
-
method_url = "/v1/feedback"
|
320
|
-
|
321
|
-
response = request(
|
322
|
-
method: "POST",
|
323
|
-
url: method_url,
|
324
|
-
headers: headers,
|
325
|
-
params: params,
|
326
|
-
json: data,
|
327
|
-
accept_json: true
|
328
|
-
)
|
329
|
-
response
|
330
|
-
end
|
331
|
-
|
332
|
-
##
|
333
|
-
# @!method list_feedback(feedback_type: nil, document_title: nil, model_id: nil, model_version: nil, category_removed: nil, category_added: nil, category_not_changed: nil, type_removed: nil, type_added: nil, type_not_changed: nil, page_limit: nil, cursor: nil, sort: nil, include_total: nil)
|
334
|
-
# List the feedback in a document.
|
335
|
-
# Lists the feedback in a document.
|
336
|
-
# @param feedback_type [String] An optional string that filters the output to include only feedback with the
|
337
|
-
# specified feedback type. The only permitted value is `element_classification`.
|
338
|
-
# @param document_title [String] An optional string that filters the output to include only feedback from the
|
339
|
-
# document with the specified `document_title`.
|
340
|
-
# @param model_id [String] An optional string that filters the output to include only feedback with the
|
341
|
-
# specified `model_id`. The only permitted value is `contracts`.
|
342
|
-
# @param model_version [String] An optional string that filters the output to include only feedback with the
|
343
|
-
# specified `model_version`.
|
344
|
-
# @param category_removed [String] An optional string in the form of a comma-separated list of categories. If it is
|
345
|
-
# specified, the service filters the output to include only feedback that has at
|
346
|
-
# least one category from the list removed.
|
347
|
-
# @param category_added [String] An optional string in the form of a comma-separated list of categories. If this is
|
348
|
-
# specified, the service filters the output to include only feedback that has at
|
349
|
-
# least one category from the list added.
|
350
|
-
# @param category_not_changed [String] An optional string in the form of a comma-separated list of categories. If this is
|
351
|
-
# specified, the service filters the output to include only feedback that has at
|
352
|
-
# least one category from the list unchanged.
|
353
|
-
# @param type_removed [String] An optional string of comma-separated `nature`:`party` pairs. If this is
|
354
|
-
# specified, the service filters the output to include only feedback that has at
|
355
|
-
# least one `nature`:`party` pair from the list removed.
|
356
|
-
# @param type_added [String] An optional string of comma-separated `nature`:`party` pairs. If this is
|
357
|
-
# specified, the service filters the output to include only feedback that has at
|
358
|
-
# least one `nature`:`party` pair from the list removed.
|
359
|
-
# @param type_not_changed [String] An optional string of comma-separated `nature`:`party` pairs. If this is
|
360
|
-
# specified, the service filters the output to include only feedback that has at
|
361
|
-
# least one `nature`:`party` pair from the list unchanged.
|
362
|
-
# @param page_limit [Fixnum] An optional integer specifying the number of documents that you want the service
|
363
|
-
# to return.
|
364
|
-
# @param cursor [String] An optional string that returns the set of documents after the previous set. Use
|
365
|
-
# this parameter with the `page_limit` parameter.
|
366
|
-
# @param sort [String] An optional comma-separated list of fields in the document to sort on. You can
|
367
|
-
# optionally specify the sort direction by prefixing the value of the field with `-`
|
368
|
-
# for descending order or `+` for ascending order (the default). Currently permitted
|
369
|
-
# sorting fields are `created`, `user_id`, and `document_title`.
|
370
|
-
# @param include_total [Boolean] An optional boolean value. If specified as `true`, the `pagination` object in the
|
371
|
-
# output includes a value called `total` that gives the total count of feedback
|
372
|
-
# created.
|
373
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
374
|
-
def list_feedback(feedback_type: nil, document_title: nil, model_id: nil, model_version: nil, category_removed: nil, category_added: nil, category_not_changed: nil, type_removed: nil, type_added: nil, type_not_changed: nil, page_limit: nil, cursor: nil, sort: nil, include_total: nil)
|
375
|
-
raise ArgumentError.new("version must be provided") if version.nil?
|
376
|
-
|
377
|
-
headers = {
|
378
|
-
}
|
379
|
-
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "list_feedback")
|
380
|
-
headers.merge!(sdk_headers)
|
381
|
-
|
382
|
-
params = {
|
383
|
-
"version" => @version,
|
384
|
-
"feedback_type" => feedback_type,
|
385
|
-
"document_title" => document_title,
|
386
|
-
"model_id" => model_id,
|
387
|
-
"model_version" => model_version,
|
388
|
-
"category_removed" => category_removed,
|
389
|
-
"category_added" => category_added,
|
390
|
-
"category_not_changed" => category_not_changed,
|
391
|
-
"type_removed" => type_removed,
|
392
|
-
"type_added" => type_added,
|
393
|
-
"type_not_changed" => type_not_changed,
|
394
|
-
"page_limit" => page_limit,
|
395
|
-
"cursor" => cursor,
|
396
|
-
"sort" => sort,
|
397
|
-
"include_total" => include_total
|
398
|
-
}
|
399
|
-
|
400
|
-
method_url = "/v1/feedback"
|
401
|
-
|
402
|
-
response = request(
|
403
|
-
method: "GET",
|
404
|
-
url: method_url,
|
405
|
-
headers: headers,
|
406
|
-
params: params,
|
407
|
-
accept_json: true
|
408
|
-
)
|
409
|
-
response
|
410
|
-
end
|
411
|
-
|
412
|
-
##
|
413
|
-
# @!method get_feedback(feedback_id:, model: nil)
|
414
|
-
# Get a specified feedback entry.
|
415
|
-
# Gets a feedback entry with a specified `feedback_id`.
|
416
|
-
# @param feedback_id [String] A string that specifies the feedback entry to be included in the output.
|
417
|
-
# @param model [String] The analysis model to be used by the service. For the **Element classification**
|
418
|
-
# and **Compare two documents** methods, the default is `contracts`. For the
|
419
|
-
# **Extract tables** method, the default is `tables`. These defaults apply to the
|
420
|
-
# standalone methods as well as to the methods' use in batch-processing requests.
|
421
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
422
|
-
def get_feedback(feedback_id:, model: nil)
|
423
|
-
raise ArgumentError.new("version must be provided") if version.nil?
|
424
|
-
|
425
|
-
raise ArgumentError.new("feedback_id must be provided") if feedback_id.nil?
|
426
|
-
|
427
|
-
headers = {
|
428
|
-
}
|
429
|
-
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "get_feedback")
|
430
|
-
headers.merge!(sdk_headers)
|
431
|
-
|
432
|
-
params = {
|
433
|
-
"version" => @version,
|
434
|
-
"model" => model
|
435
|
-
}
|
436
|
-
|
437
|
-
method_url = "/v1/feedback/%s" % [ERB::Util.url_encode(feedback_id)]
|
438
|
-
|
439
|
-
response = request(
|
440
|
-
method: "GET",
|
441
|
-
url: method_url,
|
442
|
-
headers: headers,
|
443
|
-
params: params,
|
444
|
-
accept_json: true
|
445
|
-
)
|
446
|
-
response
|
447
|
-
end
|
448
|
-
|
449
|
-
##
|
450
|
-
# @!method delete_feedback(feedback_id:, model: nil)
|
451
|
-
# Delete a specified feedback entry.
|
452
|
-
# Deletes a feedback entry with a specified `feedback_id`.
|
453
|
-
# @param feedback_id [String] A string that specifies the feedback entry to be deleted from the document.
|
454
|
-
# @param model [String] The analysis model to be used by the service. For the **Element classification**
|
455
|
-
# and **Compare two documents** methods, the default is `contracts`. For the
|
456
|
-
# **Extract tables** method, the default is `tables`. These defaults apply to the
|
457
|
-
# standalone methods as well as to the methods' use in batch-processing requests.
|
458
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
459
|
-
def delete_feedback(feedback_id:, model: nil)
|
460
|
-
raise ArgumentError.new("version must be provided") if version.nil?
|
461
|
-
|
462
|
-
raise ArgumentError.new("feedback_id must be provided") if feedback_id.nil?
|
463
|
-
|
464
|
-
headers = {
|
465
|
-
}
|
466
|
-
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "delete_feedback")
|
467
|
-
headers.merge!(sdk_headers)
|
468
|
-
|
469
|
-
params = {
|
470
|
-
"version" => @version,
|
471
|
-
"model" => model
|
472
|
-
}
|
473
|
-
|
474
|
-
method_url = "/v1/feedback/%s" % [ERB::Util.url_encode(feedback_id)]
|
475
|
-
|
476
|
-
response = request(
|
477
|
-
method: "DELETE",
|
478
|
-
url: method_url,
|
479
|
-
headers: headers,
|
480
|
-
params: params,
|
481
|
-
accept_json: true
|
482
|
-
)
|
483
|
-
response
|
484
|
-
end
|
485
|
-
#########################
|
486
|
-
# Batches
|
487
|
-
#########################
|
488
|
-
|
489
|
-
##
|
490
|
-
# @!method create_batch(function:, input_credentials_file:, input_bucket_location:, input_bucket_name:, output_credentials_file:, output_bucket_location:, output_bucket_name:, model: nil)
|
491
|
-
# Submit a batch-processing request.
|
492
|
-
# Run Compare and Comply methods over a collection of input documents.
|
493
|
-
#
|
494
|
-
# **Important:** Batch processing requires the use of the [IBM Cloud Object Storage
|
495
|
-
# service](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-about#about-ibm-cloud-object-storage).
|
496
|
-
# The use of IBM Cloud Object Storage with Compare and Comply is discussed at [Using
|
497
|
-
# batch
|
498
|
-
# processing](https://cloud.ibm.com/docs/compare-comply?topic=compare-comply-batching#before-you-batch).
|
499
|
-
# @param function [String] The Compare and Comply method to run across the submitted input documents.
|
500
|
-
# @param input_credentials_file [File] A JSON file containing the input Cloud Object Storage credentials. At a minimum,
|
501
|
-
# the credentials must enable `READ` permissions on the bucket defined by the
|
502
|
-
# `input_bucket_name` parameter.
|
503
|
-
# @param input_bucket_location [String] The geographical location of the Cloud Object Storage input bucket as listed on
|
504
|
-
# the **Endpoint** tab of your Cloud Object Storage instance; for example, `us-geo`,
|
505
|
-
# `eu-geo`, or `ap-geo`.
|
506
|
-
# @param input_bucket_name [String] The name of the Cloud Object Storage input bucket.
|
507
|
-
# @param output_credentials_file [File] A JSON file that lists the Cloud Object Storage output credentials. At a minimum,
|
508
|
-
# the credentials must enable `READ` and `WRITE` permissions on the bucket defined
|
509
|
-
# by the `output_bucket_name` parameter.
|
510
|
-
# @param output_bucket_location [String] The geographical location of the Cloud Object Storage output bucket as listed on
|
511
|
-
# the **Endpoint** tab of your Cloud Object Storage instance; for example, `us-geo`,
|
512
|
-
# `eu-geo`, or `ap-geo`.
|
513
|
-
# @param output_bucket_name [String] The name of the Cloud Object Storage output bucket.
|
514
|
-
# @param model [String] The analysis model to be used by the service. For the **Element classification**
|
515
|
-
# and **Compare two documents** methods, the default is `contracts`. For the
|
516
|
-
# **Extract tables** method, the default is `tables`. These defaults apply to the
|
517
|
-
# standalone methods as well as to the methods' use in batch-processing requests.
|
518
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
519
|
-
def create_batch(function:, input_credentials_file:, input_bucket_location:, input_bucket_name:, output_credentials_file:, output_bucket_location:, output_bucket_name:, model: nil)
|
520
|
-
raise ArgumentError.new("version must be provided") if version.nil?
|
521
|
-
|
522
|
-
raise ArgumentError.new("function must be provided") if function.nil?
|
523
|
-
|
524
|
-
raise ArgumentError.new("input_credentials_file must be provided") if input_credentials_file.nil?
|
525
|
-
|
526
|
-
raise ArgumentError.new("input_bucket_location must be provided") if input_bucket_location.nil?
|
527
|
-
|
528
|
-
raise ArgumentError.new("input_bucket_name must be provided") if input_bucket_name.nil?
|
529
|
-
|
530
|
-
raise ArgumentError.new("output_credentials_file must be provided") if output_credentials_file.nil?
|
531
|
-
|
532
|
-
raise ArgumentError.new("output_bucket_location must be provided") if output_bucket_location.nil?
|
533
|
-
|
534
|
-
raise ArgumentError.new("output_bucket_name must be provided") if output_bucket_name.nil?
|
535
|
-
|
536
|
-
headers = {
|
537
|
-
}
|
538
|
-
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "create_batch")
|
539
|
-
headers.merge!(sdk_headers)
|
540
|
-
|
541
|
-
params = {
|
542
|
-
"version" => @version,
|
543
|
-
"function" => function,
|
544
|
-
"model" => model
|
545
|
-
}
|
546
|
-
|
547
|
-
form_data = {}
|
548
|
-
|
549
|
-
unless input_credentials_file.instance_of?(StringIO) || input_credentials_file.instance_of?(File)
|
550
|
-
input_credentials_file = input_credentials_file.respond_to?(:to_json) ? StringIO.new(input_credentials_file.to_json) : StringIO.new(input_credentials_file)
|
551
|
-
end
|
552
|
-
form_data[:input_credentials_file] = HTTP::FormData::File.new(input_credentials_file, content_type: "application/json", filename: input_credentials_file.respond_to?(:path) ? input_credentials_file.path : nil)
|
553
|
-
|
554
|
-
form_data[:input_bucket_location] = HTTP::FormData::Part.new(input_bucket_location.to_s, content_type: "text/plain")
|
555
|
-
|
556
|
-
form_data[:input_bucket_name] = HTTP::FormData::Part.new(input_bucket_name.to_s, content_type: "text/plain")
|
557
|
-
|
558
|
-
unless output_credentials_file.instance_of?(StringIO) || output_credentials_file.instance_of?(File)
|
559
|
-
output_credentials_file = output_credentials_file.respond_to?(:to_json) ? StringIO.new(output_credentials_file.to_json) : StringIO.new(output_credentials_file)
|
560
|
-
end
|
561
|
-
form_data[:output_credentials_file] = HTTP::FormData::File.new(output_credentials_file, content_type: "application/json", filename: output_credentials_file.respond_to?(:path) ? output_credentials_file.path : nil)
|
562
|
-
|
563
|
-
form_data[:output_bucket_location] = HTTP::FormData::Part.new(output_bucket_location.to_s, content_type: "text/plain")
|
564
|
-
|
565
|
-
form_data[:output_bucket_name] = HTTP::FormData::Part.new(output_bucket_name.to_s, content_type: "text/plain")
|
566
|
-
|
567
|
-
method_url = "/v1/batches"
|
568
|
-
|
569
|
-
response = request(
|
570
|
-
method: "POST",
|
571
|
-
url: method_url,
|
572
|
-
headers: headers,
|
573
|
-
params: params,
|
574
|
-
form: form_data,
|
575
|
-
accept_json: true
|
576
|
-
)
|
577
|
-
response
|
578
|
-
end
|
579
|
-
|
580
|
-
##
|
581
|
-
# @!method list_batches
|
582
|
-
# List submitted batch-processing jobs.
|
583
|
-
# Lists batch-processing jobs submitted by users.
|
584
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
585
|
-
def list_batches
|
586
|
-
raise ArgumentError.new("version must be provided") if version.nil?
|
587
|
-
|
588
|
-
headers = {
|
589
|
-
}
|
590
|
-
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "list_batches")
|
591
|
-
headers.merge!(sdk_headers)
|
592
|
-
|
593
|
-
params = {
|
594
|
-
"version" => @version
|
595
|
-
}
|
596
|
-
|
597
|
-
method_url = "/v1/batches"
|
598
|
-
|
599
|
-
response = request(
|
600
|
-
method: "GET",
|
601
|
-
url: method_url,
|
602
|
-
headers: headers,
|
603
|
-
params: params,
|
604
|
-
accept_json: true
|
605
|
-
)
|
606
|
-
response
|
607
|
-
end
|
608
|
-
|
609
|
-
##
|
610
|
-
# @!method get_batch(batch_id:)
|
611
|
-
# Get information about a specific batch-processing job.
|
612
|
-
# Gets information about a batch-processing job with a specified ID.
|
613
|
-
# @param batch_id [String] The ID of the batch-processing job whose information you want to retrieve.
|
614
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
615
|
-
def get_batch(batch_id:)
|
616
|
-
raise ArgumentError.new("version must be provided") if version.nil?
|
617
|
-
|
618
|
-
raise ArgumentError.new("batch_id must be provided") if batch_id.nil?
|
619
|
-
|
620
|
-
headers = {
|
621
|
-
}
|
622
|
-
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "get_batch")
|
623
|
-
headers.merge!(sdk_headers)
|
624
|
-
|
625
|
-
params = {
|
626
|
-
"version" => @version
|
627
|
-
}
|
628
|
-
|
629
|
-
method_url = "/v1/batches/%s" % [ERB::Util.url_encode(batch_id)]
|
630
|
-
|
631
|
-
response = request(
|
632
|
-
method: "GET",
|
633
|
-
url: method_url,
|
634
|
-
headers: headers,
|
635
|
-
params: params,
|
636
|
-
accept_json: true
|
637
|
-
)
|
638
|
-
response
|
639
|
-
end
|
640
|
-
|
641
|
-
##
|
642
|
-
# @!method update_batch(batch_id:, action:, model: nil)
|
643
|
-
# Update a pending or active batch-processing job.
|
644
|
-
# Updates a pending or active batch-processing job. You can rescan the input bucket
|
645
|
-
# to check for new documents or cancel a job.
|
646
|
-
# @param batch_id [String] The ID of the batch-processing job you want to update.
|
647
|
-
# @param action [String] The action you want to perform on the specified batch-processing job.
|
648
|
-
# @param model [String] The analysis model to be used by the service. For the **Element classification**
|
649
|
-
# and **Compare two documents** methods, the default is `contracts`. For the
|
650
|
-
# **Extract tables** method, the default is `tables`. These defaults apply to the
|
651
|
-
# standalone methods as well as to the methods' use in batch-processing requests.
|
652
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
653
|
-
def update_batch(batch_id:, action:, model: nil)
|
654
|
-
raise ArgumentError.new("version must be provided") if version.nil?
|
655
|
-
|
656
|
-
raise ArgumentError.new("batch_id must be provided") if batch_id.nil?
|
657
|
-
|
658
|
-
raise ArgumentError.new("action must be provided") if action.nil?
|
659
|
-
|
660
|
-
headers = {
|
661
|
-
}
|
662
|
-
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "update_batch")
|
663
|
-
headers.merge!(sdk_headers)
|
664
|
-
|
665
|
-
params = {
|
666
|
-
"version" => @version,
|
667
|
-
"action" => action,
|
668
|
-
"model" => model
|
669
|
-
}
|
670
|
-
|
671
|
-
method_url = "/v1/batches/%s" % [ERB::Util.url_encode(batch_id)]
|
672
|
-
|
673
|
-
response = request(
|
674
|
-
method: "PUT",
|
675
|
-
url: method_url,
|
676
|
-
headers: headers,
|
677
|
-
params: params,
|
678
|
-
accept_json: true
|
679
|
-
)
|
680
|
-
response
|
681
|
-
end
|
682
|
-
end
|
683
|
-
end
|