ibm_watson 2.0.2 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,10 +14,18 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
  #
17
- # IBM OpenAPI SDK Code Generator Version: 3.19.0-be3b4618-20201113-200858
17
+ # IBM OpenAPI SDK Code Generator Version: 3.31.0-902c9336-20210504-161156
18
18
  #
19
- # IBM Watson™ Compare and Comply analyzes governing documents to provide details
20
- # about critical aspects of the documents.
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.
21
29
 
22
30
  require "concurrent"
23
31
  require "erb"
@@ -25,7 +33,6 @@ require "json"
25
33
  require "ibm_cloud_sdk_core"
26
34
  require_relative "./common.rb"
27
35
 
28
- # Module for the Watson APIs
29
36
  module IBMWatson
30
37
  ##
31
38
  # The Compare Comply V1 service.
@@ -14,7 +14,7 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
  #
17
- # IBM OpenAPI SDK Code Generator Version: 3.19.0-be3b4618-20201113-200858
17
+ # IBM OpenAPI SDK Code Generator Version: 3.31.0-902c9336-20210504-161156
18
18
  #
19
19
  # IBM Watson™ Discovery is a cognitive search and content analytics engine that
20
20
  # you can add to applications to identify patterns, trends and actionable insights to
@@ -28,7 +28,6 @@ require "json"
28
28
  require "ibm_cloud_sdk_core"
29
29
  require_relative "./common.rb"
30
30
 
31
- # Module for the Watson APIs
32
31
  module IBMWatson
33
32
  ##
34
33
  # The Discovery V1 service.
@@ -1430,7 +1429,7 @@ module IBMWatson
1430
1429
  # parameter.
1431
1430
  # @param spelling_suggestions [Boolean] When `true` and the **natural_language_query** parameter is used, the
1432
1431
  # **natural_languge_query** parameter is spell checked. The most likely correction
1433
- # is retunred in the **suggested_query** field of the response (if one exists).
1432
+ # is returned in the **suggested_query** field of the response (if one exists).
1434
1433
  #
1435
1434
  # **Important:** this parameter is only valid when using the Cloud Pak version of
1436
1435
  # Discovery.
@@ -14,7 +14,7 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
  #
17
- # IBM OpenAPI SDK Code Generator Version: 3.19.0-be3b4618-20201113-200858
17
+ # IBM OpenAPI SDK Code Generator Version: 3.31.0-902c9336-20210504-161156
18
18
  #
19
19
  # IBM Watson™ Discovery is a cognitive search and content analytics engine that
20
20
  # you can add to applications to identify patterns, trends and actionable insights to
@@ -28,7 +28,6 @@ require "json"
28
28
  require "ibm_cloud_sdk_core"
29
29
  require_relative "./common.rb"
30
30
 
31
- # Module for the Watson APIs
32
31
  module IBMWatson
33
32
  ##
34
33
  # The Discovery V2 service.
@@ -408,12 +407,66 @@ module IBMWatson
408
407
  response
409
408
  end
410
409
 
410
+ ##
411
+ # @!method query_collection_notices(project_id:, collection_id:, filter: nil, query: nil, natural_language_query: nil, count: nil, offset: nil)
412
+ # Query collection notices.
413
+ # Finds collection-level notices (errors and warnings) that are generated when
414
+ # documents are ingested.
415
+ # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
416
+ # Discovery administrative tooling.
417
+ # @param collection_id [String] The ID of the collection.
418
+ # @param filter [String] A cacheable query that excludes documents that don't mention the query content.
419
+ # Filter searches are better for metadata-type searches and for assessing the
420
+ # concepts in the data set.
421
+ # @param query [String] A query search returns all documents in your data set with full enrichments and
422
+ # full text, but with the most relevant documents listed first.
423
+ # @param natural_language_query [String] A natural language query that returns relevant documents by utilizing training
424
+ # data and natural language understanding.
425
+ # @param count [Fixnum] Number of results to return. The maximum for the **count** and **offset** values
426
+ # together in any one query is **10000**.
427
+ # @param offset [Fixnum] The number of query results to skip at the beginning. For example, if the total
428
+ # number of results that are returned is 10 and the offset is 8, it returns the last
429
+ # two results. The maximum for the **count** and **offset** values together in any
430
+ # one query is **10000**.
431
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
432
+ def query_collection_notices(project_id:, collection_id:, filter: nil, query: nil, natural_language_query: nil, count: nil, offset: nil)
433
+ raise ArgumentError.new("version must be provided") if version.nil?
434
+
435
+ raise ArgumentError.new("project_id must be provided") if project_id.nil?
436
+
437
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
438
+
439
+ headers = {
440
+ }
441
+ sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "query_collection_notices")
442
+ headers.merge!(sdk_headers)
443
+
444
+ params = {
445
+ "version" => @version,
446
+ "filter" => filter,
447
+ "query" => query,
448
+ "natural_language_query" => natural_language_query,
449
+ "count" => count,
450
+ "offset" => offset
451
+ }
452
+
453
+ method_url = "/v2/projects/%s/collections/%s/notices" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(collection_id)]
454
+
455
+ response = request(
456
+ method: "GET",
457
+ url: method_url,
458
+ headers: headers,
459
+ params: params,
460
+ accept_json: true
461
+ )
462
+ response
463
+ end
464
+
411
465
  ##
412
466
  # @!method query_notices(project_id:, filter: nil, query: nil, natural_language_query: nil, count: nil, offset: nil)
413
- # Query system notices.
414
- # Queries for notices (errors or warnings) that might have been generated by the
415
- # system. Notices are generated when ingesting documents and performing relevance
416
- # training.
467
+ # Query project notices.
468
+ # Finds project-level notices (errors and warnings). Currently, project-level
469
+ # notices are generated by relevancy training.
417
470
  # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
418
471
  # Discovery administrative tooling.
419
472
  # @param filter [String] A cacheable query that excludes documents that don't mention the query content.
@@ -975,6 +1028,43 @@ module IBMWatson
975
1028
  )
976
1029
  response
977
1030
  end
1031
+
1032
+ ##
1033
+ # @!method delete_training_query(project_id:, query_id:)
1034
+ # Delete a training data query.
1035
+ # Removes details from a training data query, including the query string and all
1036
+ # examples.
1037
+ # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
1038
+ # Discovery administrative tooling.
1039
+ # @param query_id [String] The ID of the query used for training.
1040
+ # @return [nil]
1041
+ def delete_training_query(project_id:, query_id:)
1042
+ raise ArgumentError.new("version must be provided") if version.nil?
1043
+
1044
+ raise ArgumentError.new("project_id must be provided") if project_id.nil?
1045
+
1046
+ raise ArgumentError.new("query_id must be provided") if query_id.nil?
1047
+
1048
+ headers = {
1049
+ }
1050
+ sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "delete_training_query")
1051
+ headers.merge!(sdk_headers)
1052
+
1053
+ params = {
1054
+ "version" => @version
1055
+ }
1056
+
1057
+ method_url = "/v2/projects/%s/training_data/queries/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(query_id)]
1058
+
1059
+ request(
1060
+ method: "DELETE",
1061
+ url: method_url,
1062
+ headers: headers,
1063
+ params: params,
1064
+ accept_json: false
1065
+ )
1066
+ nil
1067
+ end
978
1068
  #########################
979
1069
  # analyze
980
1070
  #########################
@@ -1091,7 +1181,7 @@ module IBMWatson
1091
1181
  # Create an enrichment for use with the specified project/.
1092
1182
  # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
1093
1183
  # Discovery administrative tooling.
1094
- # @param enrichment [CreateEnrichment]
1184
+ # @param enrichment [CreateEnrichment] Information about a specific enrichment.
1095
1185
  # @param file [File] The enrichment file to upload.
1096
1186
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
1097
1187
  def create_enrichment(project_id:, enrichment:, file: nil)
@@ -14,7 +14,7 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
  #
17
- # IBM OpenAPI SDK Code Generator Version: 3.19.0-be3b4618-20201113-200858
17
+ # IBM OpenAPI SDK Code Generator Version: 3.31.0-902c9336-20210504-161156
18
18
  #
19
19
  # IBM Watson™ Language Translator translates text from one language to another.
20
20
  # The service offers multiple IBM-provided translation models that you can customize based
@@ -28,7 +28,6 @@ require "json"
28
28
  require "ibm_cloud_sdk_core"
29
29
  require_relative "./common.rb"
30
30
 
31
- # Module for the Watson APIs
32
31
  module IBMWatson
33
32
  ##
34
33
  # The Language Translator V3 service.
@@ -14,7 +14,7 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
  #
17
- # IBM OpenAPI SDK Code Generator Version: 3.19.0-be3b4618-20201113-200858
17
+ # IBM OpenAPI SDK Code Generator Version: 3.31.0-902c9336-20210504-161156
18
18
  #
19
19
  # IBM Watson™ Natural Language Classifier uses machine learning algorithms to
20
20
  # return the top matching predefined classes for short text input. You create and train a
@@ -27,7 +27,6 @@ require "json"
27
27
  require "ibm_cloud_sdk_core"
28
28
  require_relative "./common.rb"
29
29
 
30
- # Module for the Watson APIs
31
30
  module IBMWatson
32
31
  ##
33
32
  # The Natural Language Classifier V1 service.
@@ -14,7 +14,7 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
  #
17
- # IBM OpenAPI SDK Code Generator Version: 3.19.0-be3b4618-20201113-200858
17
+ # IBM OpenAPI SDK Code Generator Version: 3.31.0-902c9336-20210504-161156
18
18
  #
19
19
  # Analyze various features of text content at scale. Provide text, raw HTML, or a public
20
20
  # URL and IBM Watson Natural Language Understanding will give you results for the features
@@ -32,7 +32,6 @@ require "json"
32
32
  require "ibm_cloud_sdk_core"
33
33
  require_relative "./common.rb"
34
34
 
35
- # Module for the Watson APIs
36
35
  module IBMWatson
37
36
  ##
38
37
  # The Natural Language Understanding V1 service.
@@ -47,7 +46,7 @@ module IBMWatson
47
46
  #
48
47
  # @param args [Hash] The args to initialize with
49
48
  # @option args version [String] Release date of the API version you want to use. Specify dates in YYYY-MM-DD
50
- # format. The current version is `2020-08-01`.
49
+ # format. The current version is `2021-03-25`.
51
50
  # @option args service_url [String] The base service URL to use when contacting the service.
52
51
  # The base service_url may differ between IBM Cloud regions.
53
52
  # @option args authenticator [Object] The Authenticator instance to be configured for this service.
@@ -79,6 +78,7 @@ module IBMWatson
79
78
  # Analyze text.
80
79
  # Analyzes text, HTML, or a public webpage for the following features:
81
80
  # - Categories
81
+ # - Classifications
82
82
  # - Concepts
83
83
  # - Emotion
84
84
  # - Entities
@@ -212,6 +212,695 @@ module IBMWatson
212
212
 
213
213
  method_url = "/v1/models/%s" % [ERB::Util.url_encode(model_id)]
214
214
 
215
+ response = request(
216
+ method: "DELETE",
217
+ url: method_url,
218
+ headers: headers,
219
+ params: params,
220
+ accept_json: true
221
+ )
222
+ response
223
+ end
224
+ #########################
225
+ # Manage sentiment models
226
+ #########################
227
+
228
+ ##
229
+ # @!method create_sentiment_model(language:, training_data:, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
230
+ # Create sentiment model.
231
+ # (Beta) Creates a custom sentiment model by uploading training data and associated
232
+ # metadata. The model begins the training and deploying process and is ready to use
233
+ # when the `status` is `available`.
234
+ # @param language [String] The 2-letter language code of this model.
235
+ # @param training_data [File] Training data in CSV format. For more information, see [Sentiment training data
236
+ # requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-custom-sentiment#sentiment-training-data-requirements).
237
+ # @param name [String] An optional name for the model.
238
+ # @param description [String] An optional description of the model.
239
+ # @param model_version [String] An optional version string.
240
+ # @param workspace_id [String] ID of the Watson Knowledge Studio workspace that deployed this model to Natural
241
+ # Language Understanding.
242
+ # @param version_description [String] The description of the version.
243
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
244
+ def create_sentiment_model(language:, training_data:, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
245
+ raise ArgumentError.new("version must be provided") if version.nil?
246
+
247
+ raise ArgumentError.new("language must be provided") if language.nil?
248
+
249
+ raise ArgumentError.new("training_data must be provided") if training_data.nil?
250
+
251
+ headers = {
252
+ }
253
+ sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "create_sentiment_model")
254
+ headers.merge!(sdk_headers)
255
+
256
+ params = {
257
+ "version" => @version
258
+ }
259
+
260
+ form_data = {}
261
+
262
+ form_data[:language] = HTTP::FormData::Part.new(language.to_s, content_type: "text/plain")
263
+
264
+ unless training_data.instance_of?(StringIO) || training_data.instance_of?(File)
265
+ training_data = training_data.respond_to?(:to_json) ? StringIO.new(training_data.to_json) : StringIO.new(training_data)
266
+ end
267
+ form_data[:training_data] = HTTP::FormData::File.new(training_data, content_type: "text/csv", filename: training_data.respond_to?(:path) ? training_data.path : nil)
268
+
269
+ form_data[:name] = HTTP::FormData::Part.new(name.to_s, content_type: "text/plain") unless name.nil?
270
+
271
+ form_data[:description] = HTTP::FormData::Part.new(description.to_s, content_type: "text/plain") unless description.nil?
272
+
273
+ form_data[:model_version] = HTTP::FormData::Part.new(model_version.to_s, content_type: "text/plain") unless model_version.nil?
274
+
275
+ form_data[:workspace_id] = HTTP::FormData::Part.new(workspace_id.to_s, content_type: "text/plain") unless workspace_id.nil?
276
+
277
+ form_data[:version_description] = HTTP::FormData::Part.new(version_description.to_s, content_type: "text/plain") unless version_description.nil?
278
+
279
+ method_url = "/v1/models/sentiment"
280
+
281
+ response = request(
282
+ method: "POST",
283
+ url: method_url,
284
+ headers: headers,
285
+ params: params,
286
+ form: form_data,
287
+ accept_json: true
288
+ )
289
+ response
290
+ end
291
+
292
+ ##
293
+ # @!method list_sentiment_models
294
+ # List sentiment models.
295
+ # (Beta) Returns all custom sentiment models associated with this service instance.
296
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
297
+ def list_sentiment_models
298
+ raise ArgumentError.new("version must be provided") if version.nil?
299
+
300
+ headers = {
301
+ }
302
+ sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "list_sentiment_models")
303
+ headers.merge!(sdk_headers)
304
+
305
+ params = {
306
+ "version" => @version
307
+ }
308
+
309
+ method_url = "/v1/models/sentiment"
310
+
311
+ response = request(
312
+ method: "GET",
313
+ url: method_url,
314
+ headers: headers,
315
+ params: params,
316
+ accept_json: true
317
+ )
318
+ response
319
+ end
320
+
321
+ ##
322
+ # @!method get_sentiment_model(model_id:)
323
+ # Get sentiment model details.
324
+ # (Beta) Returns the status of the sentiment model with the given model ID.
325
+ # @param model_id [String] ID of the model.
326
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
327
+ def get_sentiment_model(model_id:)
328
+ raise ArgumentError.new("version must be provided") if version.nil?
329
+
330
+ raise ArgumentError.new("model_id must be provided") if model_id.nil?
331
+
332
+ headers = {
333
+ }
334
+ sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "get_sentiment_model")
335
+ headers.merge!(sdk_headers)
336
+
337
+ params = {
338
+ "version" => @version
339
+ }
340
+
341
+ method_url = "/v1/models/sentiment/%s" % [ERB::Util.url_encode(model_id)]
342
+
343
+ response = request(
344
+ method: "GET",
345
+ url: method_url,
346
+ headers: headers,
347
+ params: params,
348
+ accept_json: true
349
+ )
350
+ response
351
+ end
352
+
353
+ ##
354
+ # @!method update_sentiment_model(model_id:, language:, training_data:, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
355
+ # Update sentiment model.
356
+ # (Beta) Overwrites the training data associated with this custom sentiment model
357
+ # and retrains the model. The new model replaces the current deployment.
358
+ # @param model_id [String] ID of the model.
359
+ # @param language [String] The 2-letter language code of this model.
360
+ # @param training_data [File] Training data in CSV format. For more information, see [Sentiment training data
361
+ # requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-custom-sentiment#sentiment-training-data-requirements).
362
+ # @param name [String] An optional name for the model.
363
+ # @param description [String] An optional description of the model.
364
+ # @param model_version [String] An optional version string.
365
+ # @param workspace_id [String] ID of the Watson Knowledge Studio workspace that deployed this model to Natural
366
+ # Language Understanding.
367
+ # @param version_description [String] The description of the version.
368
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
369
+ def update_sentiment_model(model_id:, language:, training_data:, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
370
+ raise ArgumentError.new("version must be provided") if version.nil?
371
+
372
+ raise ArgumentError.new("model_id must be provided") if model_id.nil?
373
+
374
+ raise ArgumentError.new("language must be provided") if language.nil?
375
+
376
+ raise ArgumentError.new("training_data must be provided") if training_data.nil?
377
+
378
+ headers = {
379
+ }
380
+ sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "update_sentiment_model")
381
+ headers.merge!(sdk_headers)
382
+
383
+ params = {
384
+ "version" => @version
385
+ }
386
+
387
+ form_data = {}
388
+
389
+ form_data[:language] = HTTP::FormData::Part.new(language.to_s, content_type: "text/plain")
390
+
391
+ unless training_data.instance_of?(StringIO) || training_data.instance_of?(File)
392
+ training_data = training_data.respond_to?(:to_json) ? StringIO.new(training_data.to_json) : StringIO.new(training_data)
393
+ end
394
+ form_data[:training_data] = HTTP::FormData::File.new(training_data, content_type: "text/csv", filename: training_data.respond_to?(:path) ? training_data.path : nil)
395
+
396
+ form_data[:name] = HTTP::FormData::Part.new(name.to_s, content_type: "text/plain") unless name.nil?
397
+
398
+ form_data[:description] = HTTP::FormData::Part.new(description.to_s, content_type: "text/plain") unless description.nil?
399
+
400
+ form_data[:model_version] = HTTP::FormData::Part.new(model_version.to_s, content_type: "text/plain") unless model_version.nil?
401
+
402
+ form_data[:workspace_id] = HTTP::FormData::Part.new(workspace_id.to_s, content_type: "text/plain") unless workspace_id.nil?
403
+
404
+ form_data[:version_description] = HTTP::FormData::Part.new(version_description.to_s, content_type: "text/plain") unless version_description.nil?
405
+
406
+ method_url = "/v1/models/sentiment/%s" % [ERB::Util.url_encode(model_id)]
407
+
408
+ response = request(
409
+ method: "PUT",
410
+ url: method_url,
411
+ headers: headers,
412
+ params: params,
413
+ form: form_data,
414
+ accept_json: true
415
+ )
416
+ response
417
+ end
418
+
419
+ ##
420
+ # @!method delete_sentiment_model(model_id:)
421
+ # Delete sentiment model.
422
+ # (Beta) Un-deploys the custom sentiment model with the given model ID and deletes
423
+ # all associated customer data, including any training data or binary artifacts.
424
+ # @param model_id [String] ID of the model.
425
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
426
+ def delete_sentiment_model(model_id:)
427
+ raise ArgumentError.new("version must be provided") if version.nil?
428
+
429
+ raise ArgumentError.new("model_id must be provided") if model_id.nil?
430
+
431
+ headers = {
432
+ }
433
+ sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "delete_sentiment_model")
434
+ headers.merge!(sdk_headers)
435
+
436
+ params = {
437
+ "version" => @version
438
+ }
439
+
440
+ method_url = "/v1/models/sentiment/%s" % [ERB::Util.url_encode(model_id)]
441
+
442
+ response = request(
443
+ method: "DELETE",
444
+ url: method_url,
445
+ headers: headers,
446
+ params: params,
447
+ accept_json: true
448
+ )
449
+ response
450
+ end
451
+ #########################
452
+ # Manage categories models
453
+ #########################
454
+
455
+ ##
456
+ # @!method create_categories_model(language:, training_data:, training_data_content_type: nil, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
457
+ # Create categories model.
458
+ # (Beta) Creates a custom categories model by uploading training data and associated
459
+ # metadata. The model begins the training and deploying process and is ready to use
460
+ # when the `status` is `available`.
461
+ # @param language [String] The 2-letter language code of this model.
462
+ # @param training_data [File] Training data in JSON format. For more information, see [Categories training data
463
+ # requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-categories##categories-training-data-requirements).
464
+ # @param training_data_content_type [String] The content type of training_data.
465
+ # @param name [String] An optional name for the model.
466
+ # @param description [String] An optional description of the model.
467
+ # @param model_version [String] An optional version string.
468
+ # @param workspace_id [String] ID of the Watson Knowledge Studio workspace that deployed this model to Natural
469
+ # Language Understanding.
470
+ # @param version_description [String] The description of the version.
471
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
472
+ def create_categories_model(language:, training_data:, training_data_content_type: nil, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
473
+ raise ArgumentError.new("version must be provided") if version.nil?
474
+
475
+ raise ArgumentError.new("language must be provided") if language.nil?
476
+
477
+ raise ArgumentError.new("training_data must be provided") if training_data.nil?
478
+
479
+ headers = {
480
+ }
481
+ sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "create_categories_model")
482
+ headers.merge!(sdk_headers)
483
+
484
+ params = {
485
+ "version" => @version
486
+ }
487
+
488
+ form_data = {}
489
+
490
+ form_data[:language] = HTTP::FormData::Part.new(language.to_s, content_type: "text/plain")
491
+
492
+ unless training_data.instance_of?(StringIO) || training_data.instance_of?(File)
493
+ training_data = training_data.respond_to?(:to_json) ? StringIO.new(training_data.to_json) : StringIO.new(training_data)
494
+ end
495
+ form_data[:training_data] = HTTP::FormData::File.new(training_data, content_type: training_data_content_type.nil? ? "application/octet-stream" : training_data_content_type, filename: training_data.respond_to?(:path) ? training_data.path : nil)
496
+
497
+ form_data[:name] = HTTP::FormData::Part.new(name.to_s, content_type: "text/plain") unless name.nil?
498
+
499
+ form_data[:description] = HTTP::FormData::Part.new(description.to_s, content_type: "text/plain") unless description.nil?
500
+
501
+ form_data[:model_version] = HTTP::FormData::Part.new(model_version.to_s, content_type: "text/plain") unless model_version.nil?
502
+
503
+ form_data[:workspace_id] = HTTP::FormData::Part.new(workspace_id.to_s, content_type: "text/plain") unless workspace_id.nil?
504
+
505
+ form_data[:version_description] = HTTP::FormData::Part.new(version_description.to_s, content_type: "text/plain") unless version_description.nil?
506
+
507
+ method_url = "/v1/models/categories"
508
+
509
+ response = request(
510
+ method: "POST",
511
+ url: method_url,
512
+ headers: headers,
513
+ params: params,
514
+ form: form_data,
515
+ accept_json: true
516
+ )
517
+ response
518
+ end
519
+
520
+ ##
521
+ # @!method list_categories_models
522
+ # List categories models.
523
+ # (Beta) Returns all custom categories models associated with this service instance.
524
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
525
+ def list_categories_models
526
+ raise ArgumentError.new("version must be provided") if version.nil?
527
+
528
+ headers = {
529
+ }
530
+ sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "list_categories_models")
531
+ headers.merge!(sdk_headers)
532
+
533
+ params = {
534
+ "version" => @version
535
+ }
536
+
537
+ method_url = "/v1/models/categories"
538
+
539
+ response = request(
540
+ method: "GET",
541
+ url: method_url,
542
+ headers: headers,
543
+ params: params,
544
+ accept_json: true
545
+ )
546
+ response
547
+ end
548
+
549
+ ##
550
+ # @!method get_categories_model(model_id:)
551
+ # Get categories model details.
552
+ # (Beta) Returns the status of the categories model with the given model ID.
553
+ # @param model_id [String] ID of the model.
554
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
555
+ def get_categories_model(model_id:)
556
+ raise ArgumentError.new("version must be provided") if version.nil?
557
+
558
+ raise ArgumentError.new("model_id must be provided") if model_id.nil?
559
+
560
+ headers = {
561
+ }
562
+ sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "get_categories_model")
563
+ headers.merge!(sdk_headers)
564
+
565
+ params = {
566
+ "version" => @version
567
+ }
568
+
569
+ method_url = "/v1/models/categories/%s" % [ERB::Util.url_encode(model_id)]
570
+
571
+ response = request(
572
+ method: "GET",
573
+ url: method_url,
574
+ headers: headers,
575
+ params: params,
576
+ accept_json: true
577
+ )
578
+ response
579
+ end
580
+
581
+ ##
582
+ # @!method update_categories_model(model_id:, language:, training_data:, training_data_content_type: nil, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
583
+ # Update categories model.
584
+ # (Beta) Overwrites the training data associated with this custom categories model
585
+ # and retrains the model. The new model replaces the current deployment.
586
+ # @param model_id [String] ID of the model.
587
+ # @param language [String] The 2-letter language code of this model.
588
+ # @param training_data [File] Training data in JSON format. For more information, see [Categories training data
589
+ # requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-categories##categories-training-data-requirements).
590
+ # @param training_data_content_type [String] The content type of training_data.
591
+ # @param name [String] An optional name for the model.
592
+ # @param description [String] An optional description of the model.
593
+ # @param model_version [String] An optional version string.
594
+ # @param workspace_id [String] ID of the Watson Knowledge Studio workspace that deployed this model to Natural
595
+ # Language Understanding.
596
+ # @param version_description [String] The description of the version.
597
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
598
+ def update_categories_model(model_id:, language:, training_data:, training_data_content_type: nil, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
599
+ raise ArgumentError.new("version must be provided") if version.nil?
600
+
601
+ raise ArgumentError.new("model_id must be provided") if model_id.nil?
602
+
603
+ raise ArgumentError.new("language must be provided") if language.nil?
604
+
605
+ raise ArgumentError.new("training_data must be provided") if training_data.nil?
606
+
607
+ headers = {
608
+ }
609
+ sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "update_categories_model")
610
+ headers.merge!(sdk_headers)
611
+
612
+ params = {
613
+ "version" => @version
614
+ }
615
+
616
+ form_data = {}
617
+
618
+ form_data[:language] = HTTP::FormData::Part.new(language.to_s, content_type: "text/plain")
619
+
620
+ unless training_data.instance_of?(StringIO) || training_data.instance_of?(File)
621
+ training_data = training_data.respond_to?(:to_json) ? StringIO.new(training_data.to_json) : StringIO.new(training_data)
622
+ end
623
+ form_data[:training_data] = HTTP::FormData::File.new(training_data, content_type: training_data_content_type.nil? ? "application/octet-stream" : training_data_content_type, filename: training_data.respond_to?(:path) ? training_data.path : nil)
624
+
625
+ form_data[:name] = HTTP::FormData::Part.new(name.to_s, content_type: "text/plain") unless name.nil?
626
+
627
+ form_data[:description] = HTTP::FormData::Part.new(description.to_s, content_type: "text/plain") unless description.nil?
628
+
629
+ form_data[:model_version] = HTTP::FormData::Part.new(model_version.to_s, content_type: "text/plain") unless model_version.nil?
630
+
631
+ form_data[:workspace_id] = HTTP::FormData::Part.new(workspace_id.to_s, content_type: "text/plain") unless workspace_id.nil?
632
+
633
+ form_data[:version_description] = HTTP::FormData::Part.new(version_description.to_s, content_type: "text/plain") unless version_description.nil?
634
+
635
+ method_url = "/v1/models/categories/%s" % [ERB::Util.url_encode(model_id)]
636
+
637
+ response = request(
638
+ method: "PUT",
639
+ url: method_url,
640
+ headers: headers,
641
+ params: params,
642
+ form: form_data,
643
+ accept_json: true
644
+ )
645
+ response
646
+ end
647
+
648
+ ##
649
+ # @!method delete_categories_model(model_id:)
650
+ # Delete categories model.
651
+ # (Beta) Un-deploys the custom categories model with the given model ID and deletes
652
+ # all associated customer data, including any training data or binary artifacts.
653
+ # @param model_id [String] ID of the model.
654
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
655
+ def delete_categories_model(model_id:)
656
+ raise ArgumentError.new("version must be provided") if version.nil?
657
+
658
+ raise ArgumentError.new("model_id must be provided") if model_id.nil?
659
+
660
+ headers = {
661
+ }
662
+ sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "delete_categories_model")
663
+ headers.merge!(sdk_headers)
664
+
665
+ params = {
666
+ "version" => @version
667
+ }
668
+
669
+ method_url = "/v1/models/categories/%s" % [ERB::Util.url_encode(model_id)]
670
+
671
+ response = request(
672
+ method: "DELETE",
673
+ url: method_url,
674
+ headers: headers,
675
+ params: params,
676
+ accept_json: true
677
+ )
678
+ response
679
+ end
680
+ #########################
681
+ # Manage classifications models
682
+ #########################
683
+
684
+ ##
685
+ # @!method create_classifications_model(language:, training_data:, training_data_content_type: nil, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
686
+ # Create classifications model.
687
+ # (Beta) Creates a custom classifications model by uploading training data and
688
+ # associated metadata. The model begins the training and deploying process and is
689
+ # ready to use when the `status` is `available`.
690
+ # @param language [String] The 2-letter language code of this model.
691
+ # @param training_data [File] Training data in JSON format. For more information, see [Classifications training
692
+ # data
693
+ # requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-classifications#classification-training-data-requirements).
694
+ # @param training_data_content_type [String] The content type of training_data.
695
+ # @param name [String] An optional name for the model.
696
+ # @param description [String] An optional description of the model.
697
+ # @param model_version [String] An optional version string.
698
+ # @param workspace_id [String] ID of the Watson Knowledge Studio workspace that deployed this model to Natural
699
+ # Language Understanding.
700
+ # @param version_description [String] The description of the version.
701
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
702
+ def create_classifications_model(language:, training_data:, training_data_content_type: nil, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
703
+ raise ArgumentError.new("version must be provided") if version.nil?
704
+
705
+ raise ArgumentError.new("language must be provided") if language.nil?
706
+
707
+ raise ArgumentError.new("training_data must be provided") if training_data.nil?
708
+
709
+ headers = {
710
+ }
711
+ sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "create_classifications_model")
712
+ headers.merge!(sdk_headers)
713
+
714
+ params = {
715
+ "version" => @version
716
+ }
717
+
718
+ form_data = {}
719
+
720
+ form_data[:language] = HTTP::FormData::Part.new(language.to_s, content_type: "text/plain")
721
+
722
+ unless training_data.instance_of?(StringIO) || training_data.instance_of?(File)
723
+ training_data = training_data.respond_to?(:to_json) ? StringIO.new(training_data.to_json) : StringIO.new(training_data)
724
+ end
725
+ form_data[:training_data] = HTTP::FormData::File.new(training_data, content_type: training_data_content_type.nil? ? "application/octet-stream" : training_data_content_type, filename: training_data.respond_to?(:path) ? training_data.path : nil)
726
+
727
+ form_data[:name] = HTTP::FormData::Part.new(name.to_s, content_type: "text/plain") unless name.nil?
728
+
729
+ form_data[:description] = HTTP::FormData::Part.new(description.to_s, content_type: "text/plain") unless description.nil?
730
+
731
+ form_data[:model_version] = HTTP::FormData::Part.new(model_version.to_s, content_type: "text/plain") unless model_version.nil?
732
+
733
+ form_data[:workspace_id] = HTTP::FormData::Part.new(workspace_id.to_s, content_type: "text/plain") unless workspace_id.nil?
734
+
735
+ form_data[:version_description] = HTTP::FormData::Part.new(version_description.to_s, content_type: "text/plain") unless version_description.nil?
736
+
737
+ method_url = "/v1/models/classifications"
738
+
739
+ response = request(
740
+ method: "POST",
741
+ url: method_url,
742
+ headers: headers,
743
+ params: params,
744
+ form: form_data,
745
+ accept_json: true
746
+ )
747
+ response
748
+ end
749
+
750
+ ##
751
+ # @!method list_classifications_models
752
+ # List classifications models.
753
+ # (Beta) Returns all custom classifications models associated with this service
754
+ # instance.
755
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
756
+ def list_classifications_models
757
+ raise ArgumentError.new("version must be provided") if version.nil?
758
+
759
+ headers = {
760
+ }
761
+ sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "list_classifications_models")
762
+ headers.merge!(sdk_headers)
763
+
764
+ params = {
765
+ "version" => @version
766
+ }
767
+
768
+ method_url = "/v1/models/classifications"
769
+
770
+ response = request(
771
+ method: "GET",
772
+ url: method_url,
773
+ headers: headers,
774
+ params: params,
775
+ accept_json: true
776
+ )
777
+ response
778
+ end
779
+
780
+ ##
781
+ # @!method get_classifications_model(model_id:)
782
+ # Get classifications model details.
783
+ # (Beta) Returns the status of the classifications model with the given model ID.
784
+ # @param model_id [String] ID of the model.
785
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
786
+ def get_classifications_model(model_id:)
787
+ raise ArgumentError.new("version must be provided") if version.nil?
788
+
789
+ raise ArgumentError.new("model_id must be provided") if model_id.nil?
790
+
791
+ headers = {
792
+ }
793
+ sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "get_classifications_model")
794
+ headers.merge!(sdk_headers)
795
+
796
+ params = {
797
+ "version" => @version
798
+ }
799
+
800
+ method_url = "/v1/models/classifications/%s" % [ERB::Util.url_encode(model_id)]
801
+
802
+ response = request(
803
+ method: "GET",
804
+ url: method_url,
805
+ headers: headers,
806
+ params: params,
807
+ accept_json: true
808
+ )
809
+ response
810
+ end
811
+
812
+ ##
813
+ # @!method update_classifications_model(model_id:, language:, training_data:, training_data_content_type: nil, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
814
+ # Update classifications model.
815
+ # (Beta) Overwrites the training data associated with this custom classifications
816
+ # model and retrains the model. The new model replaces the current deployment.
817
+ # @param model_id [String] ID of the model.
818
+ # @param language [String] The 2-letter language code of this model.
819
+ # @param training_data [File] Training data in JSON format. For more information, see [Classifications training
820
+ # data
821
+ # requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-classifications#classification-training-data-requirements).
822
+ # @param training_data_content_type [String] The content type of training_data.
823
+ # @param name [String] An optional name for the model.
824
+ # @param description [String] An optional description of the model.
825
+ # @param model_version [String] An optional version string.
826
+ # @param workspace_id [String] ID of the Watson Knowledge Studio workspace that deployed this model to Natural
827
+ # Language Understanding.
828
+ # @param version_description [String] The description of the version.
829
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
830
+ def update_classifications_model(model_id:, language:, training_data:, training_data_content_type: nil, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
831
+ raise ArgumentError.new("version must be provided") if version.nil?
832
+
833
+ raise ArgumentError.new("model_id must be provided") if model_id.nil?
834
+
835
+ raise ArgumentError.new("language must be provided") if language.nil?
836
+
837
+ raise ArgumentError.new("training_data must be provided") if training_data.nil?
838
+
839
+ headers = {
840
+ }
841
+ sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "update_classifications_model")
842
+ headers.merge!(sdk_headers)
843
+
844
+ params = {
845
+ "version" => @version
846
+ }
847
+
848
+ form_data = {}
849
+
850
+ form_data[:language] = HTTP::FormData::Part.new(language.to_s, content_type: "text/plain")
851
+
852
+ unless training_data.instance_of?(StringIO) || training_data.instance_of?(File)
853
+ training_data = training_data.respond_to?(:to_json) ? StringIO.new(training_data.to_json) : StringIO.new(training_data)
854
+ end
855
+ form_data[:training_data] = HTTP::FormData::File.new(training_data, content_type: training_data_content_type.nil? ? "application/octet-stream" : training_data_content_type, filename: training_data.respond_to?(:path) ? training_data.path : nil)
856
+
857
+ form_data[:name] = HTTP::FormData::Part.new(name.to_s, content_type: "text/plain") unless name.nil?
858
+
859
+ form_data[:description] = HTTP::FormData::Part.new(description.to_s, content_type: "text/plain") unless description.nil?
860
+
861
+ form_data[:model_version] = HTTP::FormData::Part.new(model_version.to_s, content_type: "text/plain") unless model_version.nil?
862
+
863
+ form_data[:workspace_id] = HTTP::FormData::Part.new(workspace_id.to_s, content_type: "text/plain") unless workspace_id.nil?
864
+
865
+ form_data[:version_description] = HTTP::FormData::Part.new(version_description.to_s, content_type: "text/plain") unless version_description.nil?
866
+
867
+ method_url = "/v1/models/classifications/%s" % [ERB::Util.url_encode(model_id)]
868
+
869
+ response = request(
870
+ method: "PUT",
871
+ url: method_url,
872
+ headers: headers,
873
+ params: params,
874
+ form: form_data,
875
+ accept_json: true
876
+ )
877
+ response
878
+ end
879
+
880
+ ##
881
+ # @!method delete_classifications_model(model_id:)
882
+ # Delete classifications model.
883
+ # (Beta) Un-deploys the custom classifications model with the given model ID and
884
+ # deletes all associated customer data, including any training data or binary
885
+ # artifacts.
886
+ # @param model_id [String] ID of the model.
887
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
888
+ def delete_classifications_model(model_id:)
889
+ raise ArgumentError.new("version must be provided") if version.nil?
890
+
891
+ raise ArgumentError.new("model_id must be provided") if model_id.nil?
892
+
893
+ headers = {
894
+ }
895
+ sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "delete_classifications_model")
896
+ headers.merge!(sdk_headers)
897
+
898
+ params = {
899
+ "version" => @version
900
+ }
901
+
902
+ method_url = "/v1/models/classifications/%s" % [ERB::Util.url_encode(model_id)]
903
+
215
904
  response = request(
216
905
  method: "DELETE",
217
906
  url: method_url,