ibm_watson 1.1.0 → 1.5.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.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (C) Copyright IBM Corp. 2019.
3
+ # (C) Copyright IBM Corp. 2018, 2020.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -33,6 +33,8 @@ module IBMWatson
33
33
  # The Assistant V2 service.
34
34
  class AssistantV2 < IBMCloudSdkCore::BaseService
35
35
  include Concurrent::Async
36
+ DEFAULT_SERVICE_NAME = "assistant"
37
+ DEFAULT_SERVICE_URL = "https://gateway.watsonplatform.net/assistant/api"
36
38
  ##
37
39
  # @!method initialize(args)
38
40
  # Construct a new client for the Assistant service.
@@ -51,19 +53,23 @@ module IBMWatson
51
53
  # @option args service_url [String] The base service URL to use when contacting the service.
52
54
  # The base service_url may differ between IBM Cloud regions.
53
55
  # @option args authenticator [Object] The Authenticator instance to be configured for this service.
56
+ # @option args service_name [String] The name of the service to configure. Will be used as the key to load
57
+ # any external configuration, if applicable.
54
58
  def initialize(args = {})
55
59
  @__async_initialized__ = false
56
60
  defaults = {}
57
61
  defaults[:version] = nil
58
- defaults[:service_url] = "https://gateway.watsonplatform.net/assistant/api"
62
+ defaults[:service_url] = DEFAULT_SERVICE_URL
63
+ defaults[:service_name] = DEFAULT_SERVICE_NAME
59
64
  defaults[:authenticator] = nil
65
+ user_service_url = args[:service_url] unless args[:service_url].nil?
60
66
  args = defaults.merge(args)
61
67
  @version = args[:version]
62
68
  raise ArgumentError.new("version must be provided") if @version.nil?
63
69
 
64
- args[:service_name] = "assistant"
65
70
  args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
66
71
  super
72
+ @service_url = user_service_url unless user_service_url.nil?
67
73
  end
68
74
 
69
75
  #########################
@@ -77,11 +83,11 @@ module IBMWatson
77
83
  # responses. It also maintains the state of the conversation. A session persists
78
84
  # until it is deleted, or until it times out because of inactivity. (For more
79
85
  # information, see the
80
- # [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-settings).
86
+ # [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-settings).
81
87
  # @param assistant_id [String] Unique identifier of the assistant. To find the assistant ID in the Watson
82
88
  # Assistant user interface, open the assistant settings and click **API Details**.
83
89
  # For information about creating assistants, see the
84
- # [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-add#assistant-add-task).
90
+ # [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-add#assistant-add-task).
85
91
  #
86
92
  # **Note:** Currently, the v2 API does not support creating assistants.
87
93
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
@@ -114,11 +120,11 @@ module IBMWatson
114
120
  # Delete session.
115
121
  # Deletes a session explicitly before it times out. (For more information about the
116
122
  # session inactivity timeout, see the
117
- # [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-settings)).
123
+ # [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-settings)).
118
124
  # @param assistant_id [String] Unique identifier of the assistant. To find the assistant ID in the Watson
119
125
  # Assistant user interface, open the assistant settings and click **API Details**.
120
126
  # For information about creating assistants, see the
121
- # [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-add#assistant-add-task).
127
+ # [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-add#assistant-add-task).
122
128
  #
123
129
  # **Note:** Currently, the v2 API does not support creating assistants.
124
130
  # @param session_id [String] Unique identifier of the session.
@@ -154,21 +160,26 @@ module IBMWatson
154
160
 
155
161
  ##
156
162
  # @!method message(assistant_id:, session_id:, input: nil, context: nil)
157
- # Send user input to assistant.
158
- # Send user input to an assistant and receive a response.
163
+ # Send user input to assistant (stateful).
164
+ # Send user input to an assistant and receive a response, with conversation state
165
+ # (including context data) stored by Watson Assistant for the duration of the
166
+ # session.
159
167
  #
160
168
  # There is no rate limit for this operation.
161
169
  # @param assistant_id [String] Unique identifier of the assistant. To find the assistant ID in the Watson
162
170
  # Assistant user interface, open the assistant settings and click **API Details**.
163
171
  # For information about creating assistants, see the
164
- # [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-add#assistant-add-task).
172
+ # [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-add#assistant-add-task).
165
173
  #
166
174
  # **Note:** Currently, the v2 API does not support creating assistants.
167
175
  # @param session_id [String] Unique identifier of the session.
168
176
  # @param input [MessageInput] An input object that includes the input text.
169
- # @param context [MessageContext] State information for the conversation. The context is stored by the assistant on
170
- # a per-session basis. You can use this property to set or modify context variables,
171
- # which can also be accessed by dialog nodes.
177
+ # @param context [MessageContext] Context data for the conversation. You can use this property to set or modify
178
+ # context variables, which can also be accessed by dialog nodes. The context is
179
+ # stored by the assistant on a per-session basis.
180
+ #
181
+ # **Note:** The total size of the context data stored for a stateful session cannot
182
+ # exceed 100KB.
172
183
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
173
184
  def message(assistant_id:, session_id:, input: nil, context: nil)
174
185
  raise ArgumentError.new("assistant_id must be provided") if assistant_id.nil?
@@ -201,5 +212,57 @@ module IBMWatson
201
212
  )
202
213
  response
203
214
  end
215
+
216
+ ##
217
+ # @!method message_stateless(assistant_id:, input: nil, context: nil)
218
+ # Send user input to assistant (stateless).
219
+ # Send user input to an assistant and receive a response, with conversation state
220
+ # (including context data) managed by your application.
221
+ #
222
+ # There is no rate limit for this operation.
223
+ # @param assistant_id [String] Unique identifier of the assistant. To find the assistant ID in the Watson
224
+ # Assistant user interface, open the assistant settings and click **API Details**.
225
+ # For information about creating assistants, see the
226
+ # [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-add#assistant-add-task).
227
+ #
228
+ # **Note:** Currently, the v2 API does not support creating assistants.
229
+ # @param input [MessageInputStateless] An input object that includes the input text.
230
+ # @param context [MessageContextStateless] Context data for the conversation. You can use this property to set or modify
231
+ # context variables, which can also be accessed by dialog nodes. The context is not
232
+ # stored by the assistant. To maintain session state, include the context from the
233
+ # previous response.
234
+ #
235
+ # **Note:** The total size of the context data for a stateless session cannot exceed
236
+ # 250KB.
237
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
238
+ def message_stateless(assistant_id:, input: nil, context: nil)
239
+ raise ArgumentError.new("assistant_id must be provided") if assistant_id.nil?
240
+
241
+ headers = {
242
+ }
243
+ sdk_headers = Common.new.get_sdk_headers("conversation", "V2", "message_stateless")
244
+ headers.merge!(sdk_headers)
245
+
246
+ params = {
247
+ "version" => @version
248
+ }
249
+
250
+ data = {
251
+ "input" => input,
252
+ "context" => context
253
+ }
254
+
255
+ method_url = "/v2/assistants/%s/message" % [ERB::Util.url_encode(assistant_id)]
256
+
257
+ response = request(
258
+ method: "POST",
259
+ url: method_url,
260
+ headers: headers,
261
+ params: params,
262
+ json: data,
263
+ accept_json: true
264
+ )
265
+ response
266
+ end
204
267
  end
205
268
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (C) Copyright IBM Corp. 2019.
3
+ # (C) Copyright IBM Corp. 2018, 2020.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -29,6 +29,8 @@ module IBMWatson
29
29
  # The Compare Comply V1 service.
30
30
  class CompareComplyV1 < IBMCloudSdkCore::BaseService
31
31
  include Concurrent::Async
32
+ DEFAULT_SERVICE_NAME = "compare_comply"
33
+ DEFAULT_SERVICE_URL = "https://gateway.watsonplatform.net/compare-comply/api"
32
34
  ##
33
35
  # @!method initialize(args)
34
36
  # Construct a new client for the Compare Comply service.
@@ -47,19 +49,23 @@ module IBMWatson
47
49
  # @option args service_url [String] The base service URL to use when contacting the service.
48
50
  # The base service_url may differ between IBM Cloud regions.
49
51
  # @option args authenticator [Object] The Authenticator instance to be configured for this service.
52
+ # @option args service_name [String] The name of the service to configure. Will be used as the key to load
53
+ # any external configuration, if applicable.
50
54
  def initialize(args = {})
51
55
  @__async_initialized__ = false
52
56
  defaults = {}
53
57
  defaults[:version] = nil
54
- defaults[:service_url] = "https://gateway.watsonplatform.net/compare-comply/api"
58
+ defaults[:service_url] = DEFAULT_SERVICE_URL
59
+ defaults[:service_name] = DEFAULT_SERVICE_NAME
55
60
  defaults[:authenticator] = nil
61
+ user_service_url = args[:service_url] unless args[:service_url].nil?
56
62
  args = defaults.merge(args)
57
63
  @version = args[:version]
58
64
  raise ArgumentError.new("version must be provided") if @version.nil?
59
65
 
60
- args[:service_name] = "compare_comply"
61
66
  args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
62
67
  super
68
+ @service_url = user_service_url unless user_service_url.nil?
63
69
  end
64
70
 
65
71
  #########################
@@ -473,10 +479,10 @@ module IBMWatson
473
479
  # Run Compare and Comply methods over a collection of input documents.
474
480
  #
475
481
  # **Important:** Batch processing requires the use of the [IBM Cloud Object Storage
476
- # service](https://cloud.ibm.com/docs/services/cloud-object-storage?topic=cloud-object-storage-about#about-ibm-cloud-object-storage).
482
+ # service](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-about#about-ibm-cloud-object-storage).
477
483
  # The use of IBM Cloud Object Storage with Compare and Comply is discussed at [Using
478
484
  # batch
479
- # processing](https://cloud.ibm.com/docs/services/compare-comply?topic=compare-comply-batching#before-you-batch).
485
+ # processing](https://cloud.ibm.com/docs/compare-comply?topic=compare-comply-batching#before-you-batch).
480
486
  # @param function [String] The Compare and Comply method to run across the submitted input documents.
481
487
  # @param input_credentials_file [File] A JSON file containing the input Cloud Object Storage credentials. At a minimum,
482
488
  # the credentials must enable `READ` permissions on the bucket defined by the
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (C) Copyright IBM Corp. 2019.
3
+ # (C) Copyright IBM Corp. 2018, 2020.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -32,6 +32,8 @@ module IBMWatson
32
32
  # The Discovery V1 service.
33
33
  class DiscoveryV1 < IBMCloudSdkCore::BaseService
34
34
  include Concurrent::Async
35
+ DEFAULT_SERVICE_NAME = "discovery"
36
+ DEFAULT_SERVICE_URL = "https://gateway.watsonplatform.net/discovery/api"
35
37
  ##
36
38
  # @!method initialize(args)
37
39
  # Construct a new client for the Discovery service.
@@ -50,19 +52,23 @@ module IBMWatson
50
52
  # @option args service_url [String] The base service URL to use when contacting the service.
51
53
  # The base service_url may differ between IBM Cloud regions.
52
54
  # @option args authenticator [Object] The Authenticator instance to be configured for this service.
55
+ # @option args service_name [String] The name of the service to configure. Will be used as the key to load
56
+ # any external configuration, if applicable.
53
57
  def initialize(args = {})
54
58
  @__async_initialized__ = false
55
59
  defaults = {}
56
60
  defaults[:version] = nil
57
- defaults[:service_url] = "https://gateway.watsonplatform.net/discovery/api"
61
+ defaults[:service_url] = DEFAULT_SERVICE_URL
62
+ defaults[:service_name] = DEFAULT_SERVICE_NAME
58
63
  defaults[:authenticator] = nil
64
+ user_service_url = args[:service_url] unless args[:service_url].nil?
59
65
  args = defaults.merge(args)
60
66
  @version = args[:version]
61
67
  raise ArgumentError.new("version must be provided") if @version.nil?
62
68
 
63
- args[:service_name] = "discovery"
64
69
  args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
65
70
  super
71
+ @service_url = user_service_url unless user_service_url.nil?
66
72
  end
67
73
 
68
74
  #########################
@@ -631,6 +637,8 @@ module IBMWatson
631
637
 
632
638
  raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
633
639
 
640
+ raise ArgumentError.new("name must be provided") if name.nil?
641
+
634
642
  headers = {
635
643
  }
636
644
  sdk_headers = Common.new.get_sdk_headers("discovery", "V1", "update_collection")
@@ -1310,7 +1318,7 @@ module IBMWatson
1310
1318
  # Query a collection.
1311
1319
  # By using this method, you can construct long queries. For details, see the
1312
1320
  # [Discovery
1313
- # documentation](https://cloud.ibm.com/docs/services/discovery?topic=discovery-query-concepts#query-concepts).
1321
+ # documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-concepts#query-concepts).
1314
1322
  # @param environment_id [String] The ID of the environment.
1315
1323
  # @param collection_id [String] The ID of the collection.
1316
1324
  # @param filter [String] A cacheable query that excludes documents that don't mention the query content.
@@ -1430,7 +1438,7 @@ module IBMWatson
1430
1438
  # Queries for notices (errors or warnings) that might have been generated by the
1431
1439
  # system. Notices are generated when ingesting documents and performing relevance
1432
1440
  # training. See the [Discovery
1433
- # documentation](https://cloud.ibm.com/docs/services/discovery?topic=discovery-query-concepts#query-concepts)
1441
+ # documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-concepts#query-concepts)
1434
1442
  # for more details on the query language.
1435
1443
  # @param environment_id [String] The ID of the environment.
1436
1444
  # @param collection_id [String] The ID of the collection.
@@ -1530,7 +1538,7 @@ module IBMWatson
1530
1538
  # Query multiple collections.
1531
1539
  # By using this method, you can construct long queries that search multiple
1532
1540
  # collection. For details, see the [Discovery
1533
- # documentation](https://cloud.ibm.com/docs/services/discovery?topic=discovery-query-concepts#query-concepts).
1541
+ # documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-concepts#query-concepts).
1534
1542
  # @param environment_id [String] The ID of the environment.
1535
1543
  # @param collection_ids [String] A comma-separated list of collection IDs to be queried against.
1536
1544
  # @param filter [String] A cacheable query that excludes documents that don't mention the query content.
@@ -1590,6 +1598,8 @@ module IBMWatson
1590
1598
  def federated_query(environment_id:, collection_ids:, filter: nil, query: nil, natural_language_query: nil, passages: nil, aggregation: nil, count: nil, _return: nil, offset: nil, sort: nil, highlight: nil, passages_fields: nil, passages_count: nil, passages_characters: nil, deduplicate: nil, deduplicate_field: nil, similar: nil, similar_document_ids: nil, similar_fields: nil, bias: nil, x_watson_logging_opt_out: nil)
1591
1599
  raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1592
1600
 
1601
+ raise ArgumentError.new("collection_ids must be provided") if collection_ids.nil?
1602
+
1593
1603
  headers = {
1594
1604
  "X-Watson-Logging-Opt-Out" => x_watson_logging_opt_out
1595
1605
  }
@@ -1642,7 +1652,7 @@ module IBMWatson
1642
1652
  # Queries for notices (errors or warnings) that might have been generated by the
1643
1653
  # system. Notices are generated when ingesting documents and performing relevance
1644
1654
  # training. See the [Discovery
1645
- # documentation](https://cloud.ibm.com/docs/services/discovery?topic=discovery-query-concepts#query-concepts)
1655
+ # documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-concepts#query-concepts)
1646
1656
  # for more details on the query language.
1647
1657
  # @param environment_id [String] The ID of the environment.
1648
1658
  # @param collection_ids [Array[String]] A comma-separated list of collection IDs to be queried against.
@@ -2180,7 +2190,7 @@ module IBMWatson
2180
2190
  # You associate a customer ID with data by passing the **X-Watson-Metadata** header
2181
2191
  # with a request that passes data. For more information about personal data and
2182
2192
  # customer IDs, see [Information
2183
- # security](https://cloud.ibm.com/docs/services/discovery?topic=discovery-information-security#information-security).
2193
+ # security](https://cloud.ibm.com/docs/discovery?topic=discovery-information-security#information-security).
2184
2194
  # @param customer_id [String] The customer ID for which all data is to be deleted.
2185
2195
  # @return [nil]
2186
2196
  def delete_user_data(customer_id:)
@@ -2216,7 +2226,7 @@ module IBMWatson
2216
2226
  # Create event.
2217
2227
  # The **Events** API can be used to create log entries that are associated with
2218
2228
  # specific queries. For example, you can record which documents in the results set
2219
- # were "clicked" by a user and when that click occured.
2229
+ # were "clicked" by a user and when that click occurred.
2220
2230
  # @param type [String] The event type to be created.
2221
2231
  # @param data [EventData] Query event data object.
2222
2232
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (C) Copyright IBM Corp. 2019.
3
+ # (C) Copyright IBM Corp. 2019, 2020.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -32,6 +32,8 @@ module IBMWatson
32
32
  # The Discovery V2 service.
33
33
  class DiscoveryV2 < IBMCloudSdkCore::BaseService
34
34
  include Concurrent::Async
35
+ DEFAULT_SERVICE_NAME = "discovery"
36
+ DEFAULT_SERVICE_URL = nil
35
37
  ##
36
38
  # @!method initialize(args)
37
39
  # Construct a new client for the Discovery service.
@@ -50,19 +52,23 @@ module IBMWatson
50
52
  # @option args service_url [String] The base service URL to use when contacting the service.
51
53
  # The base service_url may differ between IBM Cloud regions.
52
54
  # @option args authenticator [Object] The Authenticator instance to be configured for this service.
55
+ # @option args service_name [String] The name of the service to configure. Will be used as the key to load
56
+ # any external configuration, if applicable.
53
57
  def initialize(args = {})
54
58
  @__async_initialized__ = false
55
59
  defaults = {}
56
60
  defaults[:version] = nil
57
- defaults[:service_url] = nil
61
+ defaults[:service_url] = DEFAULT_SERVICE_URL
62
+ defaults[:service_name] = DEFAULT_SERVICE_NAME
58
63
  defaults[:authenticator] = nil
64
+ user_service_url = args[:service_url] unless args[:service_url].nil?
59
65
  args = defaults.merge(args)
60
66
  @version = args[:version]
61
67
  raise ArgumentError.new("version must be provided") if @version.nil?
62
68
 
63
- args[:service_name] = "discovery"
64
69
  args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
65
70
  super
71
+ @service_url = user_service_url unless user_service_url.nil?
66
72
  end
67
73
 
68
74
  #########################
@@ -107,7 +113,7 @@ module IBMWatson
107
113
  # @!method query(project_id:, collection_ids: nil, filter: nil, query: nil, natural_language_query: nil, aggregation: nil, count: nil, _return: nil, offset: nil, sort: nil, highlight: nil, spelling_suggestions: nil, table_results: nil, suggested_refinements: nil, passages: nil)
108
114
  # Query a project.
109
115
  # By using this method, you can construct queries. For details, see the [Discovery
110
- # documentation](https://cloud.ibm.com/docs/services/discovery-data?topic=discovery-data-query-concepts).
116
+ # documentation](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-query-concepts).
111
117
  # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
112
118
  # Discovery administrative tooling.
113
119
  # @param collection_ids [Array[String]] A comma-separated list of collection IDs to be queried against.
@@ -387,14 +393,14 @@ module IBMWatson
387
393
  # **_/v2/projects/{project_id}/collections/{collection_id}/documents** method.
388
394
  #
389
395
  # **Note:** This operation only works on collections created to accept direct file
390
- # uploads. It cannot be used to modify a collection that conects to an external
396
+ # uploads. It cannot be used to modify a collection that connects to an external
391
397
  # source such as Microsoft SharePoint.
392
398
  # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
393
399
  # Discovery administrative tooling.
394
400
  # @param collection_id [String] The ID of the collection.
395
401
  # @param file [File] The content of the document to ingest. The maximum supported file size when adding
396
402
  # a file to a collection is 50 megabytes, the maximum supported file size when
397
- # testing a confiruration is 1 megabyte. Files larger than the supported size are
403
+ # testing a configuration is 1 megabyte. Files larger than the supported size are
398
404
  # rejected.
399
405
  # @param filename [String] The filename for file.
400
406
  # @param file_content_type [String] The content type of file.
@@ -459,15 +465,18 @@ module IBMWatson
459
465
  # any document stored with the same **document_id** if it exists.
460
466
  #
461
467
  # **Note:** This operation only works on collections created to accept direct file
462
- # uploads. It cannot be used to modify a collection that conects to an external
468
+ # uploads. It cannot be used to modify a collection that connects to an external
463
469
  # source such as Microsoft SharePoint.
470
+ #
471
+ # **Note:** If an uploaded document is segmented, all segments will be overwritten,
472
+ # even if the updated version of the document has fewer segments.
464
473
  # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
465
474
  # Discovery administrative tooling.
466
475
  # @param collection_id [String] The ID of the collection.
467
476
  # @param document_id [String] The ID of the document.
468
477
  # @param file [File] The content of the document to ingest. The maximum supported file size when adding
469
478
  # a file to a collection is 50 megabytes, the maximum supported file size when
470
- # testing a confiruration is 1 megabyte. Files larger than the supported size are
479
+ # testing a configuration is 1 megabyte. Files larger than the supported size are
471
480
  # rejected.
472
481
  # @param filename [String] The filename for file.
473
482
  # @param file_content_type [String] The content type of file.
@@ -529,8 +538,11 @@ module IBMWatson
529
538
  # 'deleted'.
530
539
  #
531
540
  # **Note:** This operation only works on collections created to accept direct file
532
- # uploads. It cannot be used to modify a collection that conects to an external
541
+ # uploads. It cannot be used to modify a collection that connects to an external
533
542
  # source such as Microsoft SharePoint.
543
+ #
544
+ # **Note:** Segments of an uploaded document cannot be deleted individually. Delete
545
+ # all segments by deleting using the `parent_document_id` of a segment result.
534
546
  # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
535
547
  # Discovery administrative tooling.
536
548
  # @param collection_id [String] The ID of the collection.
@@ -647,6 +659,10 @@ module IBMWatson
647
659
  def create_training_query(project_id:, natural_language_query:, examples:, filter: nil)
648
660
  raise ArgumentError.new("project_id must be provided") if project_id.nil?
649
661
 
662
+ raise ArgumentError.new("natural_language_query must be provided") if natural_language_query.nil?
663
+
664
+ raise ArgumentError.new("examples must be provided") if examples.nil?
665
+
650
666
  headers = {
651
667
  }
652
668
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "create_training_query")
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (C) Copyright IBM Corp. 2019.
3
+ # (C) Copyright IBM Corp. 2018, 2020.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -32,6 +32,8 @@ module IBMWatson
32
32
  # The Language Translator V3 service.
33
33
  class LanguageTranslatorV3 < IBMCloudSdkCore::BaseService
34
34
  include Concurrent::Async
35
+ DEFAULT_SERVICE_NAME = "language_translator"
36
+ DEFAULT_SERVICE_URL = "https://gateway.watsonplatform.net/language-translator/api"
35
37
  ##
36
38
  # @!method initialize(args)
37
39
  # Construct a new client for the Language Translator service.
@@ -50,19 +52,23 @@ module IBMWatson
50
52
  # @option args service_url [String] The base service URL to use when contacting the service.
51
53
  # The base service_url may differ between IBM Cloud regions.
52
54
  # @option args authenticator [Object] The Authenticator instance to be configured for this service.
55
+ # @option args service_name [String] The name of the service to configure. Will be used as the key to load
56
+ # any external configuration, if applicable.
53
57
  def initialize(args = {})
54
58
  @__async_initialized__ = false
55
59
  defaults = {}
56
60
  defaults[:version] = nil
57
- defaults[:service_url] = "https://gateway.watsonplatform.net/language-translator/api"
61
+ defaults[:service_url] = DEFAULT_SERVICE_URL
62
+ defaults[:service_name] = DEFAULT_SERVICE_NAME
58
63
  defaults[:authenticator] = nil
64
+ user_service_url = args[:service_url] unless args[:service_url].nil?
59
65
  args = defaults.merge(args)
60
66
  @version = args[:version]
61
67
  raise ArgumentError.new("version must be provided") if @version.nil?
62
68
 
63
- args[:service_name] = "language_translator"
64
69
  args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
65
70
  super
71
+ @service_url = user_service_url unless user_service_url.nil?
66
72
  end
67
73
 
68
74
  #########################
@@ -72,13 +78,18 @@ module IBMWatson
72
78
  ##
73
79
  # @!method translate(text:, model_id: nil, source: nil, target: nil)
74
80
  # Translate.
75
- # Translates the input text from the source language to the target language.
81
+ # Translates the input text from the source language to the target language. A
82
+ # target language or translation model ID is required. The service attempts to
83
+ # detect the language of the source text if it is not specified.
76
84
  # @param text [Array[String]] Input text in UTF-8 encoding. Multiple entries will result in multiple
77
85
  # translations in the response.
78
- # @param model_id [String] A globally unique string that identifies the underlying model that is used for
79
- # translation.
80
- # @param source [String] Translation source language code.
81
- # @param target [String] Translation target language code.
86
+ # @param model_id [String] The model to use for translation. For example, `en-de` selects the IBM provided
87
+ # base model for English to German translation. A model ID overrides the source and
88
+ # target parameters and is required if you use a custom model. If no model ID is
89
+ # specified, you must specify a target language.
90
+ # @param source [String] Language code that specifies the language of the source document.
91
+ # @param target [String] Language code that specifies the target language for translation. Required if
92
+ # model ID is not specified.
82
93
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
83
94
  def translate(text:, model_id: nil, source: nil, target: nil)
84
95
  raise ArgumentError.new("text must be provided") if text.nil?
@@ -391,18 +402,21 @@ module IBMWatson
391
402
  # Submit a document for translation. You can submit the document contents in the
392
403
  # `file` parameter, or you can reference a previously submitted document by document
393
404
  # ID.
394
- # @param file [File] The source file to translate.
405
+ # @param file [File] The contents of the source file to translate.
395
406
  #
396
407
  # [Supported file
397
- # types](https://cloud.ibm.com/docs/services/language-translator?topic=language-translator-document-translator-tutorial#supported-file-formats)
408
+ # types](https://cloud.ibm.com/docs/language-translator?topic=language-translator-document-translator-tutorial#supported-file-formats)
398
409
  #
399
410
  # Maximum file size: **20 MB**.
400
411
  # @param filename [String] The filename for file.
401
412
  # @param file_content_type [String] The content type of file.
402
- # @param model_id [String] The model to use for translation. `model_id` or both `source` and `target` are
403
- # required.
413
+ # @param model_id [String] The model to use for translation. For example, `en-de` selects the IBM provided
414
+ # base model for English to German translation. A model ID overrides the source and
415
+ # target parameters and is required if you use a custom model. If no model ID is
416
+ # specified, you must specify a target language.
404
417
  # @param source [String] Language code that specifies the language of the source document.
405
- # @param target [String] Language code that specifies the target language for translation.
418
+ # @param target [String] Language code that specifies the target language for translation. Required if
419
+ # model ID is not specified.
406
420
  # @param document_id [String] To use a previously submitted document as the source for a new translation, enter
407
421
  # the `document_id` of the document.
408
422
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.