ibm_watson 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39e10926734524673eccb99a00cdcb9356d3570514b6ee6e320054b6a11f310e
4
- data.tar.gz: 50a19a96c0bfb3843eba4540bc36a417ed0aed27ca1eb02e491c73a2897c2912
3
+ metadata.gz: ae8370e694afb3c9bc5904e6cf9156e329c46569e531953bd5de499d8e06d069
4
+ data.tar.gz: 07a2a51577402b7a908996e3e536d7085bfd4e3fbb1e854bff24902d71d085c9
5
5
  SHA512:
6
- metadata.gz: 313e51742037b568acc09e6caff75508e6a3f900cea657a499fc4f7f0b15052c224071577ccd4beb6774a3fc0c60eda8f22fe2393c2eaf84f594d6a5cc38b32b
7
- data.tar.gz: d35a075c19323141bac2c5c15bf61b873d616ac5c4bb9578969713294056b81207d3d200560fba3947ca019acc00a6bb30bdebc8638e95c8ffca50df810e03ed
6
+ metadata.gz: 12746df4ba137cda554cfb8fcd7f313bfc7a355f2f258a86a39d3d6824f06e9e7e30947c22b846bc811d3bafadb8e7e1cdb4e916209fe76b44c74358fa1f6c75
7
+ data.tar.gz: 9942822349a390ebe594b4905f1148b0a21aa6eac12de531c6505aee9e43d00a5cdb16a3a18ad71b87bc75625987ff35ee2c1d92f06a11123da797b5d3a6f254
data/README.md CHANGED
@@ -16,6 +16,7 @@ Ruby gem to quickly get started with the various [IBM Watson][wdc] services.
16
16
  * [Before you begin](#before-you-begin)
17
17
  * [Installation](#installation)
18
18
  * [Examples](#examples)
19
+ * [Discovery v2 only on CP4D](#discovery-v2-only-on-cp4d)
19
20
  * [Running in IBM Cloud](#running-in-ibm-cloud)
20
21
  * [Authentication](#authentication)
21
22
  * [Getting credentials](#getting-credentials)
@@ -61,6 +62,10 @@ require "ibm_watson"
61
62
 
62
63
  The [examples][examples] folder has basic and advanced examples. The examples within each service assume that you already have [service credentials](#getting-credentials).
63
64
 
65
+ ## Discovery v2 only on CP4D
66
+
67
+ Discovery v2 is only available on Cloud Pak for Data.
68
+
64
69
  ## Running in IBM Cloud
65
70
 
66
71
  If you run your app in IBM Cloud, the SDK gets credentials from the [`VCAP_SERVICES`][vcap_services] environment variable.
@@ -350,7 +355,7 @@ The SDK will manage the token for the user
350
355
 
351
356
  ```ruby
352
357
 
353
- authenticator = IBMWatson::Authenticators::CLoudPakForDataAuthenticator.new(
358
+ authenticator = IBMWatson::Authenticators::CloudPakForDataAuthenticator.new(
354
359
  username: "<username>",
355
360
  password: "<password>",
356
361
  url: "<authentication url>",
@@ -360,7 +365,7 @@ assistant = IBMWatson::AssistantV1.new(
360
365
  version: "<version>",
361
366
  authenticator: authenticator
362
367
  )
363
- assistant.configure_http_client(disable_ssl_verification: true) # MAKE SURE SSL VERIFICATION IS DISABLED
368
+
364
369
  ```
365
370
 
366
371
  ## Ruby version
@@ -13,6 +13,7 @@ module IBMWatson
13
13
  require_relative("./ibm_watson/assistant_v2.rb")
14
14
  require_relative("./ibm_watson/text_to_speech_v1.rb")
15
15
  require_relative("./ibm_watson/discovery_v1.rb")
16
+ require_relative("./ibm_watson/discovery_v2.rb")
16
17
  require_relative("./ibm_watson/natural_language_understanding_v1.rb")
17
18
  require_relative("./ibm_watson/speech_to_text_v1.rb")
18
19
  require_relative("./ibm_watson/visual_recognition_v3.rb")
@@ -177,7 +177,7 @@ module IBMWatson
177
177
  end
178
178
 
179
179
  ##
180
- # @!method create_workspace(name: nil, description: nil, language: nil, metadata: nil, learning_opt_out: nil, system_settings: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil)
180
+ # @!method create_workspace(name: nil, description: nil, language: nil, metadata: nil, learning_opt_out: nil, system_settings: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, webhooks: nil)
181
181
  # Create workspace.
182
182
  # Create a workspace based on component objects. You must provide workspace
183
183
  # components defining the content of the new workspace.
@@ -199,8 +199,9 @@ module IBMWatson
199
199
  # @param dialog_nodes [Array[DialogNode]] An array of objects describing the dialog nodes in the workspace.
200
200
  # @param counterexamples [Array[Counterexample]] An array of objects defining input examples that have been marked as irrelevant
201
201
  # input.
202
+ # @param webhooks [Array[Webhook]]
202
203
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
203
- def create_workspace(name: nil, description: nil, language: nil, metadata: nil, learning_opt_out: nil, system_settings: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil)
204
+ def create_workspace(name: nil, description: nil, language: nil, metadata: nil, learning_opt_out: nil, system_settings: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, webhooks: nil)
204
205
  headers = {
205
206
  }
206
207
  sdk_headers = Common.new.get_sdk_headers("conversation", "V1", "create_workspace")
@@ -220,7 +221,8 @@ module IBMWatson
220
221
  "intents" => intents,
221
222
  "entities" => entities,
222
223
  "dialog_nodes" => dialog_nodes,
223
- "counterexamples" => counterexamples
224
+ "counterexamples" => counterexamples,
225
+ "webhooks" => webhooks
224
226
  }
225
227
 
226
228
  method_url = "/v1/workspaces"
@@ -282,7 +284,7 @@ module IBMWatson
282
284
  end
283
285
 
284
286
  ##
285
- # @!method update_workspace(workspace_id:, name: nil, description: nil, language: nil, metadata: nil, learning_opt_out: nil, system_settings: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, append: nil)
287
+ # @!method update_workspace(workspace_id:, name: nil, description: nil, language: nil, metadata: nil, learning_opt_out: nil, system_settings: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, webhooks: nil, append: nil)
286
288
  # Update workspace.
287
289
  # Update an existing workspace with new or modified data. You must provide component
288
290
  # objects defining the content of the updated workspace.
@@ -305,6 +307,7 @@ module IBMWatson
305
307
  # @param dialog_nodes [Array[DialogNode]] An array of objects describing the dialog nodes in the workspace.
306
308
  # @param counterexamples [Array[Counterexample]] An array of objects defining input examples that have been marked as irrelevant
307
309
  # input.
310
+ # @param webhooks [Array[Webhook]]
308
311
  # @param append [Boolean] Whether the new data is to be appended to the existing data in the workspace. If
309
312
  # **append**=`false`, elements included in the new data completely replace the
310
313
  # corresponding existing elements, including all subelements. For example, if the
@@ -315,7 +318,7 @@ module IBMWatson
315
318
  # added. If any elements in the new data collide with existing elements, the update
316
319
  # request fails.
317
320
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
318
- def update_workspace(workspace_id:, name: nil, description: nil, language: nil, metadata: nil, learning_opt_out: nil, system_settings: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, append: nil)
321
+ def update_workspace(workspace_id:, name: nil, description: nil, language: nil, metadata: nil, learning_opt_out: nil, system_settings: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, webhooks: nil, append: nil)
319
322
  raise ArgumentError.new("workspace_id must be provided") if workspace_id.nil?
320
323
 
321
324
  headers = {
@@ -338,7 +341,8 @@ module IBMWatson
338
341
  "intents" => intents,
339
342
  "entities" => entities,
340
343
  "dialog_nodes" => dialog_nodes,
341
- "counterexamples" => counterexamples
344
+ "counterexamples" => counterexamples,
345
+ "webhooks" => webhooks
342
346
  }
343
347
 
344
348
  method_url = "/v1/workspaces/%s" % [ERB::Util.url_encode(workspace_id)]
@@ -1936,7 +1940,7 @@ module IBMWatson
1936
1940
  end
1937
1941
 
1938
1942
  ##
1939
- # @!method create_dialog_node(workspace_id:, dialog_node:, description: nil, conditions: nil, parent: nil, previous_sibling: nil, output: nil, context: nil, metadata: nil, next_step: nil, title: nil, type: nil, event_name: nil, variable: nil, actions: nil, digress_in: nil, digress_out: nil, digress_out_slots: nil, user_label: nil)
1943
+ # @!method create_dialog_node(workspace_id:, dialog_node:, description: nil, conditions: nil, parent: nil, previous_sibling: nil, output: nil, context: nil, metadata: nil, next_step: nil, title: nil, type: nil, event_name: nil, variable: nil, actions: nil, digress_in: nil, digress_out: nil, digress_out_slots: nil, user_label: nil, disambiguation_opt_out: nil)
1940
1944
  # Create dialog node.
1941
1945
  # Create a new dialog node.
1942
1946
  #
@@ -1976,8 +1980,9 @@ module IBMWatson
1976
1980
  # @param digress_out_slots [String] Whether the user can digress to top-level nodes while filling out slots.
1977
1981
  # @param user_label [String] A label that can be displayed externally to describe the purpose of the node to
1978
1982
  # users.
1983
+ # @param disambiguation_opt_out [Boolean] Whether the dialog node should be excluded from disambiguation suggestions.
1979
1984
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
1980
- def create_dialog_node(workspace_id:, dialog_node:, description: nil, conditions: nil, parent: nil, previous_sibling: nil, output: nil, context: nil, metadata: nil, next_step: nil, title: nil, type: nil, event_name: nil, variable: nil, actions: nil, digress_in: nil, digress_out: nil, digress_out_slots: nil, user_label: nil)
1985
+ def create_dialog_node(workspace_id:, dialog_node:, description: nil, conditions: nil, parent: nil, previous_sibling: nil, output: nil, context: nil, metadata: nil, next_step: nil, title: nil, type: nil, event_name: nil, variable: nil, actions: nil, digress_in: nil, digress_out: nil, digress_out_slots: nil, user_label: nil, disambiguation_opt_out: nil)
1981
1986
  raise ArgumentError.new("workspace_id must be provided") if workspace_id.nil?
1982
1987
 
1983
1988
  raise ArgumentError.new("dialog_node must be provided") if dialog_node.nil?
@@ -2009,7 +2014,8 @@ module IBMWatson
2009
2014
  "digress_in" => digress_in,
2010
2015
  "digress_out" => digress_out,
2011
2016
  "digress_out_slots" => digress_out_slots,
2012
- "user_label" => user_label
2017
+ "user_label" => user_label,
2018
+ "disambiguation_opt_out" => disambiguation_opt_out
2013
2019
  }
2014
2020
 
2015
2021
  method_url = "/v1/workspaces/%s/dialog_nodes" % [ERB::Util.url_encode(workspace_id)]
@@ -2065,7 +2071,7 @@ module IBMWatson
2065
2071
  end
2066
2072
 
2067
2073
  ##
2068
- # @!method update_dialog_node(workspace_id:, dialog_node:, new_dialog_node: nil, new_description: nil, new_conditions: nil, new_parent: nil, new_previous_sibling: nil, new_output: nil, new_context: nil, new_metadata: nil, new_next_step: nil, new_title: nil, new_type: nil, new_event_name: nil, new_variable: nil, new_actions: nil, new_digress_in: nil, new_digress_out: nil, new_digress_out_slots: nil, new_user_label: nil)
2074
+ # @!method update_dialog_node(workspace_id:, dialog_node:, new_dialog_node: nil, new_description: nil, new_conditions: nil, new_parent: nil, new_previous_sibling: nil, new_output: nil, new_context: nil, new_metadata: nil, new_next_step: nil, new_title: nil, new_type: nil, new_event_name: nil, new_variable: nil, new_actions: nil, new_digress_in: nil, new_digress_out: nil, new_digress_out_slots: nil, new_user_label: nil, new_disambiguation_opt_out: nil)
2069
2075
  # Update dialog node.
2070
2076
  # Update an existing dialog node with new or modified data.
2071
2077
  #
@@ -2106,8 +2112,9 @@ module IBMWatson
2106
2112
  # @param new_digress_out_slots [String] Whether the user can digress to top-level nodes while filling out slots.
2107
2113
  # @param new_user_label [String] A label that can be displayed externally to describe the purpose of the node to
2108
2114
  # users.
2115
+ # @param new_disambiguation_opt_out [Boolean] Whether the dialog node should be excluded from disambiguation suggestions.
2109
2116
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
2110
- def update_dialog_node(workspace_id:, dialog_node:, new_dialog_node: nil, new_description: nil, new_conditions: nil, new_parent: nil, new_previous_sibling: nil, new_output: nil, new_context: nil, new_metadata: nil, new_next_step: nil, new_title: nil, new_type: nil, new_event_name: nil, new_variable: nil, new_actions: nil, new_digress_in: nil, new_digress_out: nil, new_digress_out_slots: nil, new_user_label: nil)
2117
+ def update_dialog_node(workspace_id:, dialog_node:, new_dialog_node: nil, new_description: nil, new_conditions: nil, new_parent: nil, new_previous_sibling: nil, new_output: nil, new_context: nil, new_metadata: nil, new_next_step: nil, new_title: nil, new_type: nil, new_event_name: nil, new_variable: nil, new_actions: nil, new_digress_in: nil, new_digress_out: nil, new_digress_out_slots: nil, new_user_label: nil, new_disambiguation_opt_out: nil)
2111
2118
  raise ArgumentError.new("workspace_id must be provided") if workspace_id.nil?
2112
2119
 
2113
2120
  raise ArgumentError.new("dialog_node must be provided") if dialog_node.nil?
@@ -2139,7 +2146,8 @@ module IBMWatson
2139
2146
  "digress_in" => new_digress_in,
2140
2147
  "digress_out" => new_digress_out,
2141
2148
  "digress_out_slots" => new_digress_out_slots,
2142
- "user_label" => new_user_label
2149
+ "user_label" => new_user_label,
2150
+ "disambiguation_opt_out" => new_disambiguation_opt_out
2143
2151
  }
2144
2152
 
2145
2153
  method_url = "/v1/workspaces/%s/dialog_nodes/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(dialog_node)]
@@ -2249,8 +2257,8 @@ module IBMWatson
2249
2257
  # more information, see **Rate limiting**.
2250
2258
  # @param filter [String] A cacheable parameter that limits the results to those matching the specified
2251
2259
  # filter. You must specify a filter query that includes a value for `language`, as
2252
- # well as a value for `workspace_id` or `request.context.metadata.deployment`. For
2253
- # more information, see the
2260
+ # well as a value for `request.context.system.assistant_id`, `workspace_id`, or
2261
+ # `request.context.metadata.deployment`. For more information, see the
2254
2262
  # [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-filter-reference#filter-reference).
2255
2263
  # @param sort [String] How to sort the returned log events. You can sort by **request_timestamp**. To
2256
2264
  # reverse the sort order, prefix the parameter value with a minus sign (`-`).
@@ -74,7 +74,10 @@ module IBMWatson
74
74
  # @!method create_session(assistant_id:)
75
75
  # Create a session.
76
76
  # Create a new session. A session is used to send user input to a skill and receive
77
- # responses. It also maintains the state of the conversation.
77
+ # responses. It also maintains the state of the conversation. A session persists
78
+ # until it is deleted, or until it times out because of inactivity. (For more
79
+ # information, see the
80
+ # [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-settings).
78
81
  # @param assistant_id [String] Unique identifier of the assistant. To find the assistant ID in the Watson
79
82
  # Assistant user interface, open the assistant settings and click **API Details**.
80
83
  # For information about creating assistants, see the
@@ -109,7 +112,9 @@ module IBMWatson
109
112
  ##
110
113
  # @!method delete_session(assistant_id:, session_id:)
111
114
  # Delete session.
112
- # Deletes a session explicitly before it times out.
115
+ # Deletes a session explicitly before it times out. (For more information about the
116
+ # session inactivity timeout, see the
117
+ # [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-settings)).
113
118
  # @param assistant_id [String] Unique identifier of the assistant. To find the assistant ID in the Watson
114
119
  # Assistant user interface, open the assistant settings and click **API Details**.
115
120
  # For information about creating assistants, see the
@@ -1112,7 +1112,7 @@ module IBMWatson
1112
1112
  # @param collection_id [String] The ID of the collection.
1113
1113
  # @param file [File] The content of the document to ingest. The maximum supported file size when adding
1114
1114
  # a file to a collection is 50 megabytes, the maximum supported file size when
1115
- # testing a confiruration is 1 megabyte. Files larger than the supported size are
1115
+ # testing a configuration is 1 megabyte. Files larger than the supported size are
1116
1116
  # rejected.
1117
1117
  # @param filename [String] The filename for file.
1118
1118
  # @param file_content_type [String] The content type of file.
@@ -1213,7 +1213,7 @@ module IBMWatson
1213
1213
  # @param document_id [String] The ID of the document.
1214
1214
  # @param file [File] The content of the document to ingest. The maximum supported file size when adding
1215
1215
  # a file to a collection is 50 megabytes, the maximum supported file size when
1216
- # testing a confiruration is 1 megabyte. Files larger than the supported size are
1216
+ # testing a configuration is 1 megabyte. Files larger than the supported size are
1217
1217
  # rejected.
1218
1218
  # @param filename [String] The filename for file.
1219
1219
  # @param file_content_type [String] The content type of file.
@@ -0,0 +1,762 @@
1
+ # frozen_string_literal: true
2
+
3
+ # (C) Copyright IBM Corp. 2019.
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 Watson&trade; Discovery for IBM Cloud Pak for Data is a cognitive search and
18
+ # content analytics engine that you can add to applications to identify patterns, trends
19
+ # and actionable insights to drive better decision-making. Securely unify structured and
20
+ # unstructured data with pre-enriched content, and use a simplified query language to
21
+ # eliminate the need for manual filtering of results.
22
+
23
+ require "concurrent"
24
+ require "erb"
25
+ require "json"
26
+ require "ibm_cloud_sdk_core"
27
+ require_relative "./common.rb"
28
+
29
+ # Module for the Watson APIs
30
+ module IBMWatson
31
+ ##
32
+ # The Discovery V2 service.
33
+ class DiscoveryV2 < IBMCloudSdkCore::BaseService
34
+ include Concurrent::Async
35
+ ##
36
+ # @!method initialize(args)
37
+ # Construct a new client for the Discovery service.
38
+ #
39
+ # @param args [Hash] The args to initialize with
40
+ # @option args version [String] The API version date to use with the service, in
41
+ # "YYYY-MM-DD" format. Whenever the API is changed in a backwards
42
+ # incompatible way, a new minor version of the API is released.
43
+ # The service uses the API version for the date you specify, or
44
+ # the most recent version before that date. Note that you should
45
+ # not programmatically specify the current date at runtime, in
46
+ # case the API has been updated since your application's release.
47
+ # Instead, specify a version date that is compatible with your
48
+ # application, and don't change it until your application is
49
+ # ready for a later version.
50
+ # @option args service_url [String] The base service URL to use when contacting the service.
51
+ # The base service_url may differ between IBM Cloud regions.
52
+ # @option args authenticator [Object] The Authenticator instance to be configured for this service.
53
+ def initialize(args = {})
54
+ @__async_initialized__ = false
55
+ defaults = {}
56
+ defaults[:version] = nil
57
+ defaults[:service_url] = nil
58
+ defaults[:authenticator] = nil
59
+ args = defaults.merge(args)
60
+ @version = args[:version]
61
+ raise ArgumentError.new("version must be provided") if @version.nil?
62
+
63
+ args[:service_name] = "discovery"
64
+ args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
65
+ super
66
+ end
67
+
68
+ #########################
69
+ # Collections
70
+ #########################
71
+
72
+ ##
73
+ # @!method list_collections(project_id:)
74
+ # List collections.
75
+ # Lists existing collections for the specified project.
76
+ # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
77
+ # Discovery administrative tooling.
78
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
79
+ def list_collections(project_id:)
80
+ raise ArgumentError.new("project_id must be provided") if project_id.nil?
81
+
82
+ headers = {
83
+ }
84
+ sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "list_collections")
85
+ headers.merge!(sdk_headers)
86
+
87
+ params = {
88
+ "version" => @version
89
+ }
90
+
91
+ method_url = "/v2/projects/%s/collections" % [ERB::Util.url_encode(project_id)]
92
+
93
+ response = request(
94
+ method: "GET",
95
+ url: method_url,
96
+ headers: headers,
97
+ params: params,
98
+ accept_json: true
99
+ )
100
+ response
101
+ end
102
+ #########################
103
+ # Queries
104
+ #########################
105
+
106
+ ##
107
+ # @!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
+ # Query a project.
109
+ # 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).
111
+ # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
112
+ # Discovery administrative tooling.
113
+ # @param collection_ids [Array[String]] A comma-separated list of collection IDs to be queried against.
114
+ # @param filter [String] A cacheable query that excludes documents that don't mention the query content.
115
+ # Filter searches are better for metadata-type searches and for assessing the
116
+ # concepts in the data set.
117
+ # @param query [String] A query search returns all documents in your data set with full enrichments and
118
+ # full text, but with the most relevant documents listed first. Use a query search
119
+ # when you want to find the most relevant search results.
120
+ # @param natural_language_query [String] A natural language query that returns relevant documents by utilizing training
121
+ # data and natural language understanding.
122
+ # @param aggregation [String] An aggregation search that returns an exact answer by combining query search with
123
+ # filters. Useful for applications to build lists, tables, and time series. For a
124
+ # full list of possible aggregations, see the Query reference.
125
+ # @param count [Fixnum] Number of results to return.
126
+ # @param _return [Array[String]] A list of the fields in the document hierarchy to return. If this parameter not
127
+ # specified, then all top-level fields are returned.
128
+ # @param offset [Fixnum] The number of query results to skip at the beginning. For example, if the total
129
+ # number of results that are returned is 10 and the offset is 8, it returns the last
130
+ # two results.
131
+ # @param sort [String] A comma-separated list of fields in the document to sort on. You can optionally
132
+ # specify a sort direction by prefixing the field with `-` for descending or `+` for
133
+ # ascending. Ascending is the default sort direction if no prefix is specified. This
134
+ # parameter cannot be used in the same query as the **bias** parameter.
135
+ # @param highlight [Boolean] When `true`, a highlight field is returned for each result which contains the
136
+ # fields which match the query with `<em></em>` tags around the matching query
137
+ # terms.
138
+ # @param spelling_suggestions [Boolean] When `true` and the **natural_language_query** parameter is used, the
139
+ # **natural_language_query** parameter is spell checked. The most likely correction
140
+ # is returned in the **suggested_query** field of the response (if one exists).
141
+ # @param table_results [QueryLargeTableResults] Configuration for table retrieval.
142
+ # @param suggested_refinements [QueryLargeSuggestedRefinements] Configuration for suggested refinements.
143
+ # @param passages [QueryLargePassages] Configuration for passage retrieval.
144
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
145
+ def 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)
146
+ raise ArgumentError.new("project_id must be provided") if project_id.nil?
147
+
148
+ headers = {
149
+ }
150
+ sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "query")
151
+ headers.merge!(sdk_headers)
152
+
153
+ params = {
154
+ "version" => @version
155
+ }
156
+
157
+ data = {
158
+ "collection_ids" => collection_ids,
159
+ "filter" => filter,
160
+ "query" => query,
161
+ "natural_language_query" => natural_language_query,
162
+ "aggregation" => aggregation,
163
+ "count" => count,
164
+ "return" => _return,
165
+ "offset" => offset,
166
+ "sort" => sort,
167
+ "highlight" => highlight,
168
+ "spelling_suggestions" => spelling_suggestions,
169
+ "table_results" => table_results,
170
+ "suggested_refinements" => suggested_refinements,
171
+ "passages" => passages
172
+ }
173
+
174
+ method_url = "/v2/projects/%s/query" % [ERB::Util.url_encode(project_id)]
175
+
176
+ response = request(
177
+ method: "POST",
178
+ url: method_url,
179
+ headers: headers,
180
+ params: params,
181
+ json: data,
182
+ accept_json: true
183
+ )
184
+ response
185
+ end
186
+
187
+ ##
188
+ # @!method get_autocompletion(project_id:, prefix:, collection_ids: nil, field: nil, count: nil)
189
+ # Get Autocomplete Suggestions.
190
+ # Returns completion query suggestions for the specified prefix.
191
+ # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
192
+ # Discovery administrative tooling.
193
+ # @param prefix [String] The prefix to use for autocompletion. For example, the prefix `Ho` could
194
+ # autocomplete to `Hot`, `Housing`, or `How do I upgrade`. Possible completions are.
195
+ # @param collection_ids [Array[String]] Comma separated list of the collection IDs. If this parameter is not specified,
196
+ # all collections in the project are used.
197
+ # @param field [String] The field in the result documents that autocompletion suggestions are identified
198
+ # from.
199
+ # @param count [Fixnum] The number of autocompletion suggestions to return.
200
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
201
+ def get_autocompletion(project_id:, prefix:, collection_ids: nil, field: nil, count: nil)
202
+ raise ArgumentError.new("project_id must be provided") if project_id.nil?
203
+
204
+ raise ArgumentError.new("prefix must be provided") if prefix.nil?
205
+
206
+ headers = {
207
+ }
208
+ sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "get_autocompletion")
209
+ headers.merge!(sdk_headers)
210
+ collection_ids *= "," unless collection_ids.nil?
211
+
212
+ params = {
213
+ "version" => @version,
214
+ "prefix" => prefix,
215
+ "collection_ids" => collection_ids,
216
+ "field" => field,
217
+ "count" => count
218
+ }
219
+
220
+ method_url = "/v2/projects/%s/autocompletion" % [ERB::Util.url_encode(project_id)]
221
+
222
+ response = request(
223
+ method: "GET",
224
+ url: method_url,
225
+ headers: headers,
226
+ params: params,
227
+ accept_json: true
228
+ )
229
+ response
230
+ end
231
+
232
+ ##
233
+ # @!method query_notices(project_id:, filter: nil, query: nil, natural_language_query: nil, count: nil, offset: nil)
234
+ # Query system notices.
235
+ # Queries for notices (errors or warnings) that might have been generated by the
236
+ # system. Notices are generated when ingesting documents and performing relevance
237
+ # training.
238
+ # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
239
+ # Discovery administrative tooling.
240
+ # @param filter [String] A cacheable query that excludes documents that don't mention the query content.
241
+ # Filter searches are better for metadata-type searches and for assessing the
242
+ # concepts in the data set.
243
+ # @param query [String] A query search returns all documents in your data set with full enrichments and
244
+ # full text, but with the most relevant documents listed first.
245
+ # @param natural_language_query [String] A natural language query that returns relevant documents by utilizing training
246
+ # data and natural language understanding.
247
+ # @param count [Fixnum] Number of results to return. The maximum for the **count** and **offset** values
248
+ # together in any one query is **10000**.
249
+ # @param offset [Fixnum] The number of query results to skip at the beginning. For example, if the total
250
+ # number of results that are returned is 10 and the offset is 8, it returns the last
251
+ # two results. The maximum for the **count** and **offset** values together in any
252
+ # one query is **10000**.
253
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
254
+ def query_notices(project_id:, filter: nil, query: nil, natural_language_query: nil, count: nil, offset: nil)
255
+ raise ArgumentError.new("project_id must be provided") if project_id.nil?
256
+
257
+ headers = {
258
+ }
259
+ sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "query_notices")
260
+ headers.merge!(sdk_headers)
261
+
262
+ params = {
263
+ "version" => @version,
264
+ "filter" => filter,
265
+ "query" => query,
266
+ "natural_language_query" => natural_language_query,
267
+ "count" => count,
268
+ "offset" => offset
269
+ }
270
+
271
+ method_url = "/v2/projects/%s/notices" % [ERB::Util.url_encode(project_id)]
272
+
273
+ response = request(
274
+ method: "GET",
275
+ url: method_url,
276
+ headers: headers,
277
+ params: params,
278
+ accept_json: true
279
+ )
280
+ response
281
+ end
282
+
283
+ ##
284
+ # @!method list_fields(project_id:, collection_ids: nil)
285
+ # List fields.
286
+ # Gets a list of the unique fields (and their types) stored in the the specified
287
+ # collections.
288
+ # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
289
+ # Discovery administrative tooling.
290
+ # @param collection_ids [Array[String]] Comma separated list of the collection IDs. If this parameter is not specified,
291
+ # all collections in the project are used.
292
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
293
+ def list_fields(project_id:, collection_ids: nil)
294
+ raise ArgumentError.new("project_id must be provided") if project_id.nil?
295
+
296
+ headers = {
297
+ }
298
+ sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "list_fields")
299
+ headers.merge!(sdk_headers)
300
+ collection_ids *= "," unless collection_ids.nil?
301
+
302
+ params = {
303
+ "version" => @version,
304
+ "collection_ids" => collection_ids
305
+ }
306
+
307
+ method_url = "/v2/projects/%s/fields" % [ERB::Util.url_encode(project_id)]
308
+
309
+ response = request(
310
+ method: "GET",
311
+ url: method_url,
312
+ headers: headers,
313
+ params: params,
314
+ accept_json: true
315
+ )
316
+ response
317
+ end
318
+ #########################
319
+ # Component settings
320
+ #########################
321
+
322
+ ##
323
+ # @!method get_component_settings(project_id:)
324
+ # Configuration settings for components.
325
+ # Returns default configuration settings for components.
326
+ # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
327
+ # Discovery administrative tooling.
328
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
329
+ def get_component_settings(project_id:)
330
+ raise ArgumentError.new("project_id must be provided") if project_id.nil?
331
+
332
+ headers = {
333
+ }
334
+ sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "get_component_settings")
335
+ headers.merge!(sdk_headers)
336
+
337
+ params = {
338
+ "version" => @version
339
+ }
340
+
341
+ method_url = "/v2/projects/%s/component_settings" % [ERB::Util.url_encode(project_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
+ # Documents
354
+ #########################
355
+
356
+ ##
357
+ # @!method add_document(project_id:, collection_id:, file: nil, filename: nil, file_content_type: nil, metadata: nil, x_watson_discovery_force: nil)
358
+ # Add a document.
359
+ # Add a document to a collection with optional metadata.
360
+ #
361
+ # Returns immediately after the system has accepted the document for processing.
362
+ #
363
+ # * The user must provide document content, metadata, or both. If the request is
364
+ # missing both document content and metadata, it is rejected.
365
+ #
366
+ # * The user can set the **Content-Type** parameter on the **file** part to
367
+ # indicate the media type of the document. If the **Content-Type** parameter is
368
+ # missing or is one of the generic media types (for example,
369
+ # `application/octet-stream`), then the service attempts to automatically detect the
370
+ # document's media type.
371
+ #
372
+ # * The following field names are reserved and will be filtered out if present
373
+ # after normalization: `id`, `score`, `highlight`, and any field with the prefix of:
374
+ # `_`, `+`, or `-`
375
+ #
376
+ # * Fields with empty name values after normalization are filtered out before
377
+ # indexing.
378
+ #
379
+ # * Fields containing the following characters after normalization are filtered
380
+ # out before indexing: `#` and `,`
381
+ #
382
+ # If the document is uploaded to a collection that has it's data shared with
383
+ # another collection, the **X-Watson-Discovery-Force** header must be set to `true`.
384
+ #
385
+ #
386
+ # **Note:** Documents can be added with a specific **document_id** by using the
387
+ # **_/v2/projects/{project_id}/collections/{collection_id}/documents** method.
388
+ #
389
+ # **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
391
+ # source such as Microsoft SharePoint.
392
+ # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
393
+ # Discovery administrative tooling.
394
+ # @param collection_id [String] The ID of the collection.
395
+ # @param file [File] The content of the document to ingest. The maximum supported file size when adding
396
+ # 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
398
+ # rejected.
399
+ # @param filename [String] The filename for file.
400
+ # @param file_content_type [String] The content type of file.
401
+ # @param metadata [String] The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB
402
+ # are rejected. Example: ``` {
403
+ # "Creator": "Johnny Appleseed",
404
+ # "Subject": "Apples"
405
+ # } ```.
406
+ # @param x_watson_discovery_force [Boolean] When `true`, the uploaded document is added to the collection even if the data for
407
+ # that collection is shared with other collections.
408
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
409
+ def add_document(project_id:, collection_id:, file: nil, filename: nil, file_content_type: nil, metadata: nil, x_watson_discovery_force: nil)
410
+ raise ArgumentError.new("project_id must be provided") if project_id.nil?
411
+
412
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
413
+
414
+ headers = {
415
+ "X-Watson-Discovery-Force" => x_watson_discovery_force
416
+ }
417
+ sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "add_document")
418
+ headers.merge!(sdk_headers)
419
+
420
+ params = {
421
+ "version" => @version
422
+ }
423
+
424
+ form_data = {}
425
+
426
+ unless file.nil?
427
+ unless file.instance_of?(StringIO) || file.instance_of?(File)
428
+ file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
429
+ end
430
+ filename = file.path if filename.nil? && file.respond_to?(:path)
431
+ form_data[:file] = HTTP::FormData::File.new(file, content_type: file_content_type.nil? ? "application/octet-stream" : file_content_type, filename: filename)
432
+ end
433
+
434
+ form_data[:metadata] = HTTP::FormData::Part.new(metadata.to_s, content_type: "text/plain") unless metadata.nil?
435
+
436
+ method_url = "/v2/projects/%s/collections/%s/documents" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(collection_id)]
437
+
438
+ response = request(
439
+ method: "POST",
440
+ url: method_url,
441
+ headers: headers,
442
+ params: params,
443
+ form: form_data,
444
+ accept_json: true
445
+ )
446
+ response
447
+ end
448
+
449
+ ##
450
+ # @!method update_document(project_id:, collection_id:, document_id:, file: nil, filename: nil, file_content_type: nil, metadata: nil, x_watson_discovery_force: nil)
451
+ # Update a document.
452
+ # Replace an existing document or add a document with a specified **document_id**.
453
+ # Starts ingesting a document with optional metadata.
454
+ #
455
+ # If the document is uploaded to a collection that has it's data shared with another
456
+ # collection, the **X-Watson-Discovery-Force** header must be set to `true`.
457
+ #
458
+ # **Note:** When uploading a new document with this method it automatically replaces
459
+ # any document stored with the same **document_id** if it exists.
460
+ #
461
+ # **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
463
+ # source such as Microsoft SharePoint.
464
+ # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
465
+ # Discovery administrative tooling.
466
+ # @param collection_id [String] The ID of the collection.
467
+ # @param document_id [String] The ID of the document.
468
+ # @param file [File] The content of the document to ingest. The maximum supported file size when adding
469
+ # 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
471
+ # rejected.
472
+ # @param filename [String] The filename for file.
473
+ # @param file_content_type [String] The content type of file.
474
+ # @param metadata [String] The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB
475
+ # are rejected. Example: ``` {
476
+ # "Creator": "Johnny Appleseed",
477
+ # "Subject": "Apples"
478
+ # } ```.
479
+ # @param x_watson_discovery_force [Boolean] When `true`, the uploaded document is added to the collection even if the data for
480
+ # that collection is shared with other collections.
481
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
482
+ def update_document(project_id:, collection_id:, document_id:, file: nil, filename: nil, file_content_type: nil, metadata: nil, x_watson_discovery_force: nil)
483
+ raise ArgumentError.new("project_id must be provided") if project_id.nil?
484
+
485
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
486
+
487
+ raise ArgumentError.new("document_id must be provided") if document_id.nil?
488
+
489
+ headers = {
490
+ "X-Watson-Discovery-Force" => x_watson_discovery_force
491
+ }
492
+ sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "update_document")
493
+ headers.merge!(sdk_headers)
494
+
495
+ params = {
496
+ "version" => @version
497
+ }
498
+
499
+ form_data = {}
500
+
501
+ unless file.nil?
502
+ unless file.instance_of?(StringIO) || file.instance_of?(File)
503
+ file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
504
+ end
505
+ filename = file.path if filename.nil? && file.respond_to?(:path)
506
+ form_data[:file] = HTTP::FormData::File.new(file, content_type: file_content_type.nil? ? "application/octet-stream" : file_content_type, filename: filename)
507
+ end
508
+
509
+ form_data[:metadata] = HTTP::FormData::Part.new(metadata.to_s, content_type: "text/plain") unless metadata.nil?
510
+
511
+ method_url = "/v2/projects/%s/collections/%s/documents/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(collection_id), ERB::Util.url_encode(document_id)]
512
+
513
+ response = request(
514
+ method: "POST",
515
+ url: method_url,
516
+ headers: headers,
517
+ params: params,
518
+ form: form_data,
519
+ accept_json: true
520
+ )
521
+ response
522
+ end
523
+
524
+ ##
525
+ # @!method delete_document(project_id:, collection_id:, document_id:, x_watson_discovery_force: nil)
526
+ # Delete a document.
527
+ # If the given document ID is invalid, or if the document is not found, then the a
528
+ # success response is returned (HTTP status code `200`) with the status set to
529
+ # 'deleted'.
530
+ #
531
+ # **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
533
+ # source such as Microsoft SharePoint.
534
+ # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
535
+ # Discovery administrative tooling.
536
+ # @param collection_id [String] The ID of the collection.
537
+ # @param document_id [String] The ID of the document.
538
+ # @param x_watson_discovery_force [Boolean] When `true`, the uploaded document is added to the collection even if the data for
539
+ # that collection is shared with other collections.
540
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
541
+ def delete_document(project_id:, collection_id:, document_id:, x_watson_discovery_force: nil)
542
+ raise ArgumentError.new("project_id must be provided") if project_id.nil?
543
+
544
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
545
+
546
+ raise ArgumentError.new("document_id must be provided") if document_id.nil?
547
+
548
+ headers = {
549
+ "X-Watson-Discovery-Force" => x_watson_discovery_force
550
+ }
551
+ sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "delete_document")
552
+ headers.merge!(sdk_headers)
553
+
554
+ params = {
555
+ "version" => @version
556
+ }
557
+
558
+ method_url = "/v2/projects/%s/collections/%s/documents/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(collection_id), ERB::Util.url_encode(document_id)]
559
+
560
+ response = request(
561
+ method: "DELETE",
562
+ url: method_url,
563
+ headers: headers,
564
+ params: params,
565
+ accept_json: true
566
+ )
567
+ response
568
+ end
569
+ #########################
570
+ # Training data
571
+ #########################
572
+
573
+ ##
574
+ # @!method list_training_queries(project_id:)
575
+ # List training queries.
576
+ # List the training queries for the specified project.
577
+ # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
578
+ # Discovery administrative tooling.
579
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
580
+ def list_training_queries(project_id:)
581
+ raise ArgumentError.new("project_id must be provided") if project_id.nil?
582
+
583
+ headers = {
584
+ }
585
+ sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "list_training_queries")
586
+ headers.merge!(sdk_headers)
587
+
588
+ params = {
589
+ "version" => @version
590
+ }
591
+
592
+ method_url = "/v2/projects/%s/training_data/queries" % [ERB::Util.url_encode(project_id)]
593
+
594
+ response = request(
595
+ method: "GET",
596
+ url: method_url,
597
+ headers: headers,
598
+ params: params,
599
+ accept_json: true
600
+ )
601
+ response
602
+ end
603
+
604
+ ##
605
+ # @!method delete_training_queries(project_id:)
606
+ # Delete training queries.
607
+ # Removes all training queries for the specified project.
608
+ # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
609
+ # Discovery administrative tooling.
610
+ # @return [nil]
611
+ def delete_training_queries(project_id:)
612
+ raise ArgumentError.new("project_id must be provided") if project_id.nil?
613
+
614
+ headers = {
615
+ }
616
+ sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "delete_training_queries")
617
+ headers.merge!(sdk_headers)
618
+
619
+ params = {
620
+ "version" => @version
621
+ }
622
+
623
+ method_url = "/v2/projects/%s/training_data/queries" % [ERB::Util.url_encode(project_id)]
624
+
625
+ request(
626
+ method: "DELETE",
627
+ url: method_url,
628
+ headers: headers,
629
+ params: params,
630
+ accept_json: false
631
+ )
632
+ nil
633
+ end
634
+
635
+ ##
636
+ # @!method create_training_query(project_id:, natural_language_query:, examples:, filter: nil)
637
+ # Create training query.
638
+ # Add a query to the training data for this project. The query can contain a filter
639
+ # and natural language query.
640
+ # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
641
+ # Discovery administrative tooling.
642
+ # @param natural_language_query [String] The natural text query for the training query.
643
+ # @param examples [Array[TrainingExample]] Array of training examples.
644
+ # @param filter [String] The filter used on the collection before the **natural_language_query** is
645
+ # applied.
646
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
647
+ def create_training_query(project_id:, natural_language_query:, examples:, filter: nil)
648
+ raise ArgumentError.new("project_id must be provided") if project_id.nil?
649
+
650
+ headers = {
651
+ }
652
+ sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "create_training_query")
653
+ headers.merge!(sdk_headers)
654
+
655
+ params = {
656
+ "version" => @version
657
+ }
658
+
659
+ data = {
660
+ "natural_language_query" => natural_language_query,
661
+ "examples" => examples,
662
+ "filter" => filter
663
+ }
664
+
665
+ method_url = "/v2/projects/%s/training_data/queries" % [ERB::Util.url_encode(project_id)]
666
+
667
+ response = request(
668
+ method: "POST",
669
+ url: method_url,
670
+ headers: headers,
671
+ params: params,
672
+ json: data,
673
+ accept_json: true
674
+ )
675
+ response
676
+ end
677
+
678
+ ##
679
+ # @!method get_training_query(project_id:, query_id:)
680
+ # Get a training data query.
681
+ # Get details for a specific training data query, including the query string and all
682
+ # examples.
683
+ # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
684
+ # Discovery administrative tooling.
685
+ # @param query_id [String] The ID of the query used for training.
686
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
687
+ def get_training_query(project_id:, query_id:)
688
+ raise ArgumentError.new("project_id must be provided") if project_id.nil?
689
+
690
+ raise ArgumentError.new("query_id must be provided") if query_id.nil?
691
+
692
+ headers = {
693
+ }
694
+ sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "get_training_query")
695
+ headers.merge!(sdk_headers)
696
+
697
+ params = {
698
+ "version" => @version
699
+ }
700
+
701
+ method_url = "/v2/projects/%s/training_data/queries/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(query_id)]
702
+
703
+ response = request(
704
+ method: "GET",
705
+ url: method_url,
706
+ headers: headers,
707
+ params: params,
708
+ accept_json: true
709
+ )
710
+ response
711
+ end
712
+
713
+ ##
714
+ # @!method update_training_query(project_id:, query_id:, natural_language_query:, examples:, filter: nil)
715
+ # Update a training query.
716
+ # Updates an existing training query and it's examples.
717
+ # @param project_id [String] The ID of the project. This information can be found from the deploy page of the
718
+ # Discovery administrative tooling.
719
+ # @param query_id [String] The ID of the query used for training.
720
+ # @param natural_language_query [String] The natural text query for the training query.
721
+ # @param examples [Array[TrainingExample]] Array of training examples.
722
+ # @param filter [String] The filter used on the collection before the **natural_language_query** is
723
+ # applied.
724
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
725
+ def update_training_query(project_id:, query_id:, natural_language_query:, examples:, filter: nil)
726
+ raise ArgumentError.new("project_id must be provided") if project_id.nil?
727
+
728
+ raise ArgumentError.new("query_id must be provided") if query_id.nil?
729
+
730
+ raise ArgumentError.new("natural_language_query must be provided") if natural_language_query.nil?
731
+
732
+ raise ArgumentError.new("examples must be provided") if examples.nil?
733
+
734
+ headers = {
735
+ }
736
+ sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "update_training_query")
737
+ headers.merge!(sdk_headers)
738
+
739
+ params = {
740
+ "version" => @version
741
+ }
742
+
743
+ data = {
744
+ "natural_language_query" => natural_language_query,
745
+ "examples" => examples,
746
+ "filter" => filter
747
+ }
748
+
749
+ method_url = "/v2/projects/%s/training_data/queries/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(query_id)]
750
+
751
+ response = request(
752
+ method: "POST",
753
+ url: method_url,
754
+ headers: headers,
755
+ params: params,
756
+ json: data,
757
+ accept_json: true
758
+ )
759
+ response
760
+ end
761
+ end
762
+ end