ibm_watson 1.2.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +33 -5
- data/lib/ibm_watson/assistant_v1.rb +153 -209
- data/lib/ibm_watson/assistant_v2.rb +168 -15
- data/lib/ibm_watson/compare_comply_v1.rb +11 -5
- data/lib/ibm_watson/discovery_v1.rb +14 -8
- data/lib/ibm_watson/discovery_v2.rb +605 -12
- data/lib/ibm_watson/language_translator_v3.rb +166 -47
- data/lib/ibm_watson/natural_language_classifier_v1.rb +10 -4
- data/lib/ibm_watson/natural_language_understanding_v1.rb +19 -15
- data/lib/ibm_watson/personality_insights_v3.rb +17 -11
- data/lib/ibm_watson/speech_to_text_v1.rb +323 -195
- data/lib/ibm_watson/text_to_speech_v1.rb +75 -59
- data/lib/ibm_watson/tone_analyzer_v3.rb +11 -5
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v3.rb +11 -5
- data/lib/ibm_watson/visual_recognition_v4.rb +199 -4
- data/test/integration/test_assistant_v2.rb +25 -0
- data/test/integration/test_compare_comply_v1.rb +1 -12
- data/test/integration/test_discovery_v2.rb +118 -6
- data/test/integration/test_language_translator_v3.rb +5 -0
- data/test/integration/test_speech_to_text_v1.rb +2 -0
- data/test/integration/test_visual_recognition_v4.rb +9 -0
- data/test/unit/test_assistant_v1.rb +98 -98
- data/test/unit/test_assistant_v2.rb +102 -8
- data/test/unit/test_compare_comply_v1.rb +20 -20
- data/test/unit/test_discovery_v1.rb +125 -125
- data/test/unit/test_discovery_v2.rb +262 -29
- data/test/unit/test_language_translator_v3.rb +85 -24
- data/test/unit/test_natural_language_classifier_v1.rb +17 -17
- data/test/unit/test_natural_language_understanding_v1.rb +10 -10
- data/test/unit/test_personality_insights_v3.rb +14 -10
- data/test/unit/test_speech_to_text_v1.rb +97 -97
- data/test/unit/test_text_to_speech_v1.rb +41 -41
- data/test/unit/test_tone_analyzer_v3.rb +12 -12
- data/test/unit/test_visual_recognition_v3.rb +16 -16
- data/test/unit/test_visual_recognition_v4.rb +117 -30
- metadata +5 -6
- data/test/unit/test_vcap_using_personality_insights.rb +0 -161
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# (C) Copyright IBM Corp. 2020.
|
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://api.us-south.assistant.watson.cloud.ibm.com"
|
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] =
|
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/
|
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/
|
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/
|
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/
|
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,24 @@ 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
|
159
|
-
#
|
160
|
-
#
|
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.
|
161
167
|
# @param assistant_id [String] Unique identifier of the assistant. To find the assistant ID in the Watson
|
162
168
|
# Assistant user interface, open the assistant settings and click **API Details**.
|
163
169
|
# For information about creating assistants, see the
|
164
|
-
# [documentation](https://cloud.ibm.com/docs/
|
170
|
+
# [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-add#assistant-add-task).
|
165
171
|
#
|
166
172
|
# **Note:** Currently, the v2 API does not support creating assistants.
|
167
173
|
# @param session_id [String] Unique identifier of the session.
|
168
174
|
# @param input [MessageInput] An input object that includes the input text.
|
169
|
-
# @param context [MessageContext]
|
170
|
-
#
|
171
|
-
#
|
175
|
+
# @param context [MessageContext] Context data for the conversation. You can use this property to set or modify
|
176
|
+
# context variables, which can also be accessed by dialog nodes. The context is
|
177
|
+
# stored by the assistant on a per-session basis.
|
178
|
+
#
|
179
|
+
# **Note:** The total size of the context data stored for a stateful session cannot
|
180
|
+
# exceed 100KB.
|
172
181
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
173
182
|
def message(assistant_id:, session_id:, input: nil, context: nil)
|
174
183
|
raise ArgumentError.new("assistant_id must be provided") if assistant_id.nil?
|
@@ -201,5 +210,149 @@ module IBMWatson
|
|
201
210
|
)
|
202
211
|
response
|
203
212
|
end
|
213
|
+
|
214
|
+
##
|
215
|
+
# @!method message_stateless(assistant_id:, input: nil, context: nil)
|
216
|
+
# Send user input to assistant (stateless).
|
217
|
+
# Send user input to an assistant and receive a response, with conversation state
|
218
|
+
# (including context data) managed by your application.
|
219
|
+
# @param assistant_id [String] Unique identifier of the assistant. To find the assistant ID in the Watson
|
220
|
+
# Assistant user interface, open the assistant settings and click **API Details**.
|
221
|
+
# For information about creating assistants, see the
|
222
|
+
# [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-add#assistant-add-task).
|
223
|
+
#
|
224
|
+
# **Note:** Currently, the v2 API does not support creating assistants.
|
225
|
+
# @param input [MessageInputStateless] An input object that includes the input text.
|
226
|
+
# @param context [MessageContextStateless] Context data for the conversation. You can use this property to set or modify
|
227
|
+
# context variables, which can also be accessed by dialog nodes. The context is not
|
228
|
+
# stored by the assistant. To maintain session state, include the context from the
|
229
|
+
# previous response.
|
230
|
+
#
|
231
|
+
# **Note:** The total size of the context data for a stateless session cannot exceed
|
232
|
+
# 250KB.
|
233
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
234
|
+
def message_stateless(assistant_id:, input: nil, context: nil)
|
235
|
+
raise ArgumentError.new("assistant_id must be provided") if assistant_id.nil?
|
236
|
+
|
237
|
+
headers = {
|
238
|
+
}
|
239
|
+
sdk_headers = Common.new.get_sdk_headers("conversation", "V2", "message_stateless")
|
240
|
+
headers.merge!(sdk_headers)
|
241
|
+
|
242
|
+
params = {
|
243
|
+
"version" => @version
|
244
|
+
}
|
245
|
+
|
246
|
+
data = {
|
247
|
+
"input" => input,
|
248
|
+
"context" => context
|
249
|
+
}
|
250
|
+
|
251
|
+
method_url = "/v2/assistants/%s/message" % [ERB::Util.url_encode(assistant_id)]
|
252
|
+
|
253
|
+
response = request(
|
254
|
+
method: "POST",
|
255
|
+
url: method_url,
|
256
|
+
headers: headers,
|
257
|
+
params: params,
|
258
|
+
json: data,
|
259
|
+
accept_json: true
|
260
|
+
)
|
261
|
+
response
|
262
|
+
end
|
263
|
+
#########################
|
264
|
+
# Logs
|
265
|
+
#########################
|
266
|
+
|
267
|
+
##
|
268
|
+
# @!method list_logs(assistant_id:, sort: nil, filter: nil, page_limit: nil, cursor: nil)
|
269
|
+
# List log events for an assistant.
|
270
|
+
# List the events from the log of an assistant.
|
271
|
+
#
|
272
|
+
# This method is available only with Premium plans.
|
273
|
+
# @param assistant_id [String] Unique identifier of the assistant. To find the assistant ID in the Watson
|
274
|
+
# Assistant user interface, open the assistant settings and click **API Details**.
|
275
|
+
# For information about creating assistants, see the
|
276
|
+
# [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-add#assistant-add-task).
|
277
|
+
#
|
278
|
+
# **Note:** Currently, the v2 API does not support creating assistants.
|
279
|
+
# @param sort [String] How to sort the returned log events. You can sort by **request_timestamp**. To
|
280
|
+
# reverse the sort order, prefix the parameter value with a minus sign (`-`).
|
281
|
+
# @param filter [String] A cacheable parameter that limits the results to those matching the specified
|
282
|
+
# filter. For more information, see the
|
283
|
+
# [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-filter-reference#filter-reference).
|
284
|
+
# @param page_limit [Fixnum] The number of records to return in each page of results.
|
285
|
+
# @param cursor [String] A token identifying the page of results to retrieve.
|
286
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
287
|
+
def list_logs(assistant_id:, sort: nil, filter: nil, page_limit: nil, cursor: nil)
|
288
|
+
raise ArgumentError.new("assistant_id must be provided") if assistant_id.nil?
|
289
|
+
|
290
|
+
headers = {
|
291
|
+
}
|
292
|
+
sdk_headers = Common.new.get_sdk_headers("conversation", "V2", "list_logs")
|
293
|
+
headers.merge!(sdk_headers)
|
294
|
+
|
295
|
+
params = {
|
296
|
+
"version" => @version,
|
297
|
+
"sort" => sort,
|
298
|
+
"filter" => filter,
|
299
|
+
"page_limit" => page_limit,
|
300
|
+
"cursor" => cursor
|
301
|
+
}
|
302
|
+
|
303
|
+
method_url = "/v2/assistants/%s/logs" % [ERB::Util.url_encode(assistant_id)]
|
304
|
+
|
305
|
+
response = request(
|
306
|
+
method: "GET",
|
307
|
+
url: method_url,
|
308
|
+
headers: headers,
|
309
|
+
params: params,
|
310
|
+
accept_json: true
|
311
|
+
)
|
312
|
+
response
|
313
|
+
end
|
314
|
+
#########################
|
315
|
+
# User data
|
316
|
+
#########################
|
317
|
+
|
318
|
+
##
|
319
|
+
# @!method delete_user_data(customer_id:)
|
320
|
+
# Delete labeled data.
|
321
|
+
# Deletes all data associated with a specified customer ID. The method has no effect
|
322
|
+
# if no data is associated with the customer ID.
|
323
|
+
#
|
324
|
+
# You associate a customer ID with data by passing the `X-Watson-Metadata` header
|
325
|
+
# with a request that passes data. For more information about personal data and
|
326
|
+
# customer IDs, see [Information
|
327
|
+
# security](https://cloud.ibm.com/docs/assistant?topic=assistant-information-security#information-security).
|
328
|
+
#
|
329
|
+
# This operation is limited to 4 requests per minute. For more information, see
|
330
|
+
# **Rate limiting**.
|
331
|
+
# @param customer_id [String] The customer ID for which all data is to be deleted.
|
332
|
+
# @return [nil]
|
333
|
+
def delete_user_data(customer_id:)
|
334
|
+
raise ArgumentError.new("customer_id must be provided") if customer_id.nil?
|
335
|
+
|
336
|
+
headers = {
|
337
|
+
}
|
338
|
+
sdk_headers = Common.new.get_sdk_headers("conversation", "V2", "delete_user_data")
|
339
|
+
headers.merge!(sdk_headers)
|
340
|
+
|
341
|
+
params = {
|
342
|
+
"version" => @version,
|
343
|
+
"customer_id" => customer_id
|
344
|
+
}
|
345
|
+
|
346
|
+
method_url = "/v2/user_data"
|
347
|
+
|
348
|
+
request(
|
349
|
+
method: "DELETE",
|
350
|
+
url: method_url,
|
351
|
+
headers: headers,
|
352
|
+
params: params,
|
353
|
+
accept_json: true
|
354
|
+
)
|
355
|
+
nil
|
356
|
+
end
|
204
357
|
end
|
205
358
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# (C) Copyright IBM Corp. 2020.
|
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://api.us-south.compare-comply.watson.cloud.ibm.com"
|
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] =
|
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/
|
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/
|
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. 2020.
|
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://api.us-south.discovery.watson.cloud.ibm.com"
|
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] =
|
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
|
#########################
|
@@ -1312,7 +1318,7 @@ module IBMWatson
|
|
1312
1318
|
# Query a collection.
|
1313
1319
|
# By using this method, you can construct long queries. For details, see the
|
1314
1320
|
# [Discovery
|
1315
|
-
# documentation](https://cloud.ibm.com/docs/
|
1321
|
+
# documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-concepts#query-concepts).
|
1316
1322
|
# @param environment_id [String] The ID of the environment.
|
1317
1323
|
# @param collection_id [String] The ID of the collection.
|
1318
1324
|
# @param filter [String] A cacheable query that excludes documents that don't mention the query content.
|
@@ -1432,7 +1438,7 @@ module IBMWatson
|
|
1432
1438
|
# Queries for notices (errors or warnings) that might have been generated by the
|
1433
1439
|
# system. Notices are generated when ingesting documents and performing relevance
|
1434
1440
|
# training. See the [Discovery
|
1435
|
-
# documentation](https://cloud.ibm.com/docs/
|
1441
|
+
# documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-concepts#query-concepts)
|
1436
1442
|
# for more details on the query language.
|
1437
1443
|
# @param environment_id [String] The ID of the environment.
|
1438
1444
|
# @param collection_id [String] The ID of the collection.
|
@@ -1532,7 +1538,7 @@ module IBMWatson
|
|
1532
1538
|
# Query multiple collections.
|
1533
1539
|
# By using this method, you can construct long queries that search multiple
|
1534
1540
|
# collection. For details, see the [Discovery
|
1535
|
-
# documentation](https://cloud.ibm.com/docs/
|
1541
|
+
# documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-concepts#query-concepts).
|
1536
1542
|
# @param environment_id [String] The ID of the environment.
|
1537
1543
|
# @param collection_ids [String] A comma-separated list of collection IDs to be queried against.
|
1538
1544
|
# @param filter [String] A cacheable query that excludes documents that don't mention the query content.
|
@@ -1646,7 +1652,7 @@ module IBMWatson
|
|
1646
1652
|
# Queries for notices (errors or warnings) that might have been generated by the
|
1647
1653
|
# system. Notices are generated when ingesting documents and performing relevance
|
1648
1654
|
# training. See the [Discovery
|
1649
|
-
# documentation](https://cloud.ibm.com/docs/
|
1655
|
+
# documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-concepts#query-concepts)
|
1650
1656
|
# for more details on the query language.
|
1651
1657
|
# @param environment_id [String] The ID of the environment.
|
1652
1658
|
# @param collection_ids [Array[String]] A comma-separated list of collection IDs to be queried against.
|
@@ -2184,7 +2190,7 @@ module IBMWatson
|
|
2184
2190
|
# You associate a customer ID with data by passing the **X-Watson-Metadata** header
|
2185
2191
|
# with a request that passes data. For more information about personal data and
|
2186
2192
|
# customer IDs, see [Information
|
2187
|
-
# security](https://cloud.ibm.com/docs/
|
2193
|
+
# security](https://cloud.ibm.com/docs/discovery?topic=discovery-information-security#information-security).
|
2188
2194
|
# @param customer_id [String] The customer ID for which all data is to be deleted.
|
2189
2195
|
# @return [nil]
|
2190
2196
|
def delete_user_data(customer_id:)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# (C) Copyright IBM Corp. 2020.
|
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.
|
@@ -14,11 +14,11 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
|
-
# IBM Watson™ Discovery
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
17
|
+
# IBM Watson™ Discovery is a cognitive search and content analytics engine that
|
18
|
+
# you can add to applications to identify patterns, trends and actionable insights to
|
19
|
+
# drive better decision-making. Securely unify structured and unstructured data with
|
20
|
+
# pre-enriched content, and use a simplified query language to eliminate the need for
|
21
|
+
# manual filtering of results.
|
22
22
|
|
23
23
|
require "concurrent"
|
24
24
|
require "erb"
|
@@ -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 = "https://api.us-south.discovery.watson.cloud.ibm.com"
|
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] =
|
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
|
#########################
|
@@ -99,6 +105,164 @@ module IBMWatson
|
|
99
105
|
)
|
100
106
|
response
|
101
107
|
end
|
108
|
+
|
109
|
+
##
|
110
|
+
# @!method create_collection(project_id:, name:, description: nil, language: nil, enrichments: nil)
|
111
|
+
# Create a collection.
|
112
|
+
# Create a new collection in the specified project.
|
113
|
+
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
114
|
+
# Discovery administrative tooling.
|
115
|
+
# @param name [String] The name of the collection.
|
116
|
+
# @param description [String] A description of the collection.
|
117
|
+
# @param language [String] The language of the collection.
|
118
|
+
# @param enrichments [Array[CollectionEnrichment]] An array of enrichments that are applied to this collection.
|
119
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
120
|
+
def create_collection(project_id:, name:, description: nil, language: nil, enrichments: nil)
|
121
|
+
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
122
|
+
|
123
|
+
raise ArgumentError.new("name must be provided") if name.nil?
|
124
|
+
|
125
|
+
headers = {
|
126
|
+
}
|
127
|
+
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "create_collection")
|
128
|
+
headers.merge!(sdk_headers)
|
129
|
+
|
130
|
+
params = {
|
131
|
+
"version" => @version
|
132
|
+
}
|
133
|
+
|
134
|
+
data = {
|
135
|
+
"name" => name,
|
136
|
+
"description" => description,
|
137
|
+
"language" => language,
|
138
|
+
"enrichments" => enrichments
|
139
|
+
}
|
140
|
+
|
141
|
+
method_url = "/v2/projects/%s/collections" % [ERB::Util.url_encode(project_id)]
|
142
|
+
|
143
|
+
response = request(
|
144
|
+
method: "POST",
|
145
|
+
url: method_url,
|
146
|
+
headers: headers,
|
147
|
+
params: params,
|
148
|
+
json: data,
|
149
|
+
accept_json: true
|
150
|
+
)
|
151
|
+
response
|
152
|
+
end
|
153
|
+
|
154
|
+
##
|
155
|
+
# @!method get_collection(project_id:, collection_id:)
|
156
|
+
# Get collection.
|
157
|
+
# Get details about the specified collection.
|
158
|
+
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
159
|
+
# Discovery administrative tooling.
|
160
|
+
# @param collection_id [String] The ID of the collection.
|
161
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
162
|
+
def get_collection(project_id:, collection_id:)
|
163
|
+
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
164
|
+
|
165
|
+
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
166
|
+
|
167
|
+
headers = {
|
168
|
+
}
|
169
|
+
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "get_collection")
|
170
|
+
headers.merge!(sdk_headers)
|
171
|
+
|
172
|
+
params = {
|
173
|
+
"version" => @version
|
174
|
+
}
|
175
|
+
|
176
|
+
method_url = "/v2/projects/%s/collections/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(collection_id)]
|
177
|
+
|
178
|
+
response = request(
|
179
|
+
method: "GET",
|
180
|
+
url: method_url,
|
181
|
+
headers: headers,
|
182
|
+
params: params,
|
183
|
+
accept_json: true
|
184
|
+
)
|
185
|
+
response
|
186
|
+
end
|
187
|
+
|
188
|
+
##
|
189
|
+
# @!method update_collection(project_id:, collection_id:, name: nil, description: nil, enrichments: nil)
|
190
|
+
# Update a collection.
|
191
|
+
# Updates the specified collection's name, description, and enrichments.
|
192
|
+
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
193
|
+
# Discovery administrative tooling.
|
194
|
+
# @param collection_id [String] The ID of the collection.
|
195
|
+
# @param name [String] The name of the collection.
|
196
|
+
# @param description [String] A description of the collection.
|
197
|
+
# @param enrichments [Array[CollectionEnrichment]] An array of enrichments that are applied to this collection.
|
198
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
199
|
+
def update_collection(project_id:, collection_id:, name: nil, description: nil, enrichments: nil)
|
200
|
+
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
201
|
+
|
202
|
+
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
203
|
+
|
204
|
+
headers = {
|
205
|
+
}
|
206
|
+
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "update_collection")
|
207
|
+
headers.merge!(sdk_headers)
|
208
|
+
|
209
|
+
params = {
|
210
|
+
"version" => @version
|
211
|
+
}
|
212
|
+
|
213
|
+
data = {
|
214
|
+
"name" => name,
|
215
|
+
"description" => description,
|
216
|
+
"enrichments" => enrichments
|
217
|
+
}
|
218
|
+
|
219
|
+
method_url = "/v2/projects/%s/collections/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(collection_id)]
|
220
|
+
|
221
|
+
response = request(
|
222
|
+
method: "POST",
|
223
|
+
url: method_url,
|
224
|
+
headers: headers,
|
225
|
+
params: params,
|
226
|
+
json: data,
|
227
|
+
accept_json: true
|
228
|
+
)
|
229
|
+
response
|
230
|
+
end
|
231
|
+
|
232
|
+
##
|
233
|
+
# @!method delete_collection(project_id:, collection_id:)
|
234
|
+
# Delete a collection.
|
235
|
+
# Deletes the specified collection from the project. All documents stored in the
|
236
|
+
# specified collection and not shared is also deleted.
|
237
|
+
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
238
|
+
# Discovery administrative tooling.
|
239
|
+
# @param collection_id [String] The ID of the collection.
|
240
|
+
# @return [nil]
|
241
|
+
def delete_collection(project_id:, collection_id:)
|
242
|
+
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
243
|
+
|
244
|
+
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
245
|
+
|
246
|
+
headers = {
|
247
|
+
}
|
248
|
+
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "delete_collection")
|
249
|
+
headers.merge!(sdk_headers)
|
250
|
+
|
251
|
+
params = {
|
252
|
+
"version" => @version
|
253
|
+
}
|
254
|
+
|
255
|
+
method_url = "/v2/projects/%s/collections/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(collection_id)]
|
256
|
+
|
257
|
+
request(
|
258
|
+
method: "DELETE",
|
259
|
+
url: method_url,
|
260
|
+
headers: headers,
|
261
|
+
params: params,
|
262
|
+
accept_json: false
|
263
|
+
)
|
264
|
+
nil
|
265
|
+
end
|
102
266
|
#########################
|
103
267
|
# Queries
|
104
268
|
#########################
|
@@ -107,7 +271,13 @@ module IBMWatson
|
|
107
271
|
# @!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
272
|
# Query a project.
|
109
273
|
# By using this method, you can construct queries. For details, see the [Discovery
|
110
|
-
# documentation](https://cloud.ibm.com/docs/
|
274
|
+
# documentation](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-query-concepts).
|
275
|
+
# The default query parameters are defined by the settings for this project, see the
|
276
|
+
# [Discovery
|
277
|
+
# documentation](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-project-defaults)
|
278
|
+
# for an overview of the standard default settings, and see [the Projects API
|
279
|
+
# documentation](#create-project) for details about how to set custom default query
|
280
|
+
# settings.
|
111
281
|
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
112
282
|
# Discovery administrative tooling.
|
113
283
|
# @param collection_ids [Array[String]] A comma-separated list of collection IDs to be queried against.
|
@@ -321,7 +491,7 @@ module IBMWatson
|
|
321
491
|
|
322
492
|
##
|
323
493
|
# @!method get_component_settings(project_id:)
|
324
|
-
#
|
494
|
+
# List component settings.
|
325
495
|
# Returns default configuration settings for components.
|
326
496
|
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
327
497
|
# Discovery administrative tooling.
|
@@ -399,7 +569,10 @@ module IBMWatson
|
|
399
569
|
# @param filename [String] The filename for file.
|
400
570
|
# @param file_content_type [String] The content type of file.
|
401
571
|
# @param metadata [String] The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB
|
402
|
-
# are rejected.
|
572
|
+
# are rejected.
|
573
|
+
#
|
574
|
+
#
|
575
|
+
# Example: ``` {
|
403
576
|
# "Creator": "Johnny Appleseed",
|
404
577
|
# "Subject": "Apples"
|
405
578
|
# } ```.
|
@@ -461,6 +634,9 @@ module IBMWatson
|
|
461
634
|
# **Note:** This operation only works on collections created to accept direct file
|
462
635
|
# uploads. It cannot be used to modify a collection that connects to an external
|
463
636
|
# source such as Microsoft SharePoint.
|
637
|
+
#
|
638
|
+
# **Note:** If an uploaded document is segmented, all segments will be overwritten,
|
639
|
+
# even if the updated version of the document has fewer segments.
|
464
640
|
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
465
641
|
# Discovery administrative tooling.
|
466
642
|
# @param collection_id [String] The ID of the collection.
|
@@ -472,7 +648,10 @@ module IBMWatson
|
|
472
648
|
# @param filename [String] The filename for file.
|
473
649
|
# @param file_content_type [String] The content type of file.
|
474
650
|
# @param metadata [String] The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB
|
475
|
-
# are rejected.
|
651
|
+
# are rejected.
|
652
|
+
#
|
653
|
+
#
|
654
|
+
# Example: ``` {
|
476
655
|
# "Creator": "Johnny Appleseed",
|
477
656
|
# "Subject": "Apples"
|
478
657
|
# } ```.
|
@@ -531,6 +710,9 @@ module IBMWatson
|
|
531
710
|
# **Note:** This operation only works on collections created to accept direct file
|
532
711
|
# uploads. It cannot be used to modify a collection that connects to an external
|
533
712
|
# source such as Microsoft SharePoint.
|
713
|
+
#
|
714
|
+
# **Note:** Segments of an uploaded document cannot be deleted individually. Delete
|
715
|
+
# all segments by deleting using the `parent_document_id` of a segment result.
|
534
716
|
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
535
717
|
# Discovery administrative tooling.
|
536
718
|
# @param collection_id [String] The ID of the collection.
|
@@ -762,5 +944,416 @@ module IBMWatson
|
|
762
944
|
)
|
763
945
|
response
|
764
946
|
end
|
947
|
+
#########################
|
948
|
+
# enrichments
|
949
|
+
#########################
|
950
|
+
|
951
|
+
##
|
952
|
+
# @!method list_enrichments(project_id:)
|
953
|
+
# List Enrichments.
|
954
|
+
# List the enrichments available to this project.
|
955
|
+
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
956
|
+
# Discovery administrative tooling.
|
957
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
958
|
+
def list_enrichments(project_id:)
|
959
|
+
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
960
|
+
|
961
|
+
headers = {
|
962
|
+
}
|
963
|
+
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "list_enrichments")
|
964
|
+
headers.merge!(sdk_headers)
|
965
|
+
|
966
|
+
params = {
|
967
|
+
"version" => @version
|
968
|
+
}
|
969
|
+
|
970
|
+
method_url = "/v2/projects/%s/enrichments" % [ERB::Util.url_encode(project_id)]
|
971
|
+
|
972
|
+
response = request(
|
973
|
+
method: "GET",
|
974
|
+
url: method_url,
|
975
|
+
headers: headers,
|
976
|
+
params: params,
|
977
|
+
accept_json: true
|
978
|
+
)
|
979
|
+
response
|
980
|
+
end
|
981
|
+
|
982
|
+
##
|
983
|
+
# @!method create_enrichment(project_id:, enrichment:, file: nil)
|
984
|
+
# Create an enrichment.
|
985
|
+
# Create an enrichment for use with the specified project/.
|
986
|
+
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
987
|
+
# Discovery administrative tooling.
|
988
|
+
# @param enrichment [CreateEnrichment]
|
989
|
+
# @param file [File] The enrichment file to upload.
|
990
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
991
|
+
def create_enrichment(project_id:, enrichment:, file: nil)
|
992
|
+
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
993
|
+
|
994
|
+
raise ArgumentError.new("enrichment must be provided") if enrichment.nil?
|
995
|
+
|
996
|
+
headers = {
|
997
|
+
}
|
998
|
+
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "create_enrichment")
|
999
|
+
headers.merge!(sdk_headers)
|
1000
|
+
|
1001
|
+
params = {
|
1002
|
+
"version" => @version
|
1003
|
+
}
|
1004
|
+
|
1005
|
+
form_data = {}
|
1006
|
+
|
1007
|
+
form_data[:enrichment] = HTTP::FormData::Part.new(enrichment.to_s, content_type: "application/json")
|
1008
|
+
|
1009
|
+
unless file.nil?
|
1010
|
+
unless file.instance_of?(StringIO) || file.instance_of?(File)
|
1011
|
+
file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
|
1012
|
+
end
|
1013
|
+
form_data[:file] = HTTP::FormData::File.new(file, content_type: "application/octet-stream", filename: file.respond_to?(:path) ? file.path : nil)
|
1014
|
+
end
|
1015
|
+
|
1016
|
+
method_url = "/v2/projects/%s/enrichments" % [ERB::Util.url_encode(project_id)]
|
1017
|
+
|
1018
|
+
response = request(
|
1019
|
+
method: "POST",
|
1020
|
+
url: method_url,
|
1021
|
+
headers: headers,
|
1022
|
+
params: params,
|
1023
|
+
form: form_data,
|
1024
|
+
accept_json: true
|
1025
|
+
)
|
1026
|
+
response
|
1027
|
+
end
|
1028
|
+
|
1029
|
+
##
|
1030
|
+
# @!method get_enrichment(project_id:, enrichment_id:)
|
1031
|
+
# Get enrichment.
|
1032
|
+
# Get details about a specific enrichment.
|
1033
|
+
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
1034
|
+
# Discovery administrative tooling.
|
1035
|
+
# @param enrichment_id [String] The ID of the enrichment.
|
1036
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1037
|
+
def get_enrichment(project_id:, enrichment_id:)
|
1038
|
+
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1039
|
+
|
1040
|
+
raise ArgumentError.new("enrichment_id must be provided") if enrichment_id.nil?
|
1041
|
+
|
1042
|
+
headers = {
|
1043
|
+
}
|
1044
|
+
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "get_enrichment")
|
1045
|
+
headers.merge!(sdk_headers)
|
1046
|
+
|
1047
|
+
params = {
|
1048
|
+
"version" => @version
|
1049
|
+
}
|
1050
|
+
|
1051
|
+
method_url = "/v2/projects/%s/enrichments/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(enrichment_id)]
|
1052
|
+
|
1053
|
+
response = request(
|
1054
|
+
method: "GET",
|
1055
|
+
url: method_url,
|
1056
|
+
headers: headers,
|
1057
|
+
params: params,
|
1058
|
+
accept_json: true
|
1059
|
+
)
|
1060
|
+
response
|
1061
|
+
end
|
1062
|
+
|
1063
|
+
##
|
1064
|
+
# @!method update_enrichment(project_id:, enrichment_id:, name:, description: nil)
|
1065
|
+
# Update an enrichment.
|
1066
|
+
# Updates an existing enrichment's name and description.
|
1067
|
+
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
1068
|
+
# Discovery administrative tooling.
|
1069
|
+
# @param enrichment_id [String] The ID of the enrichment.
|
1070
|
+
# @param name [String] A new name for the enrichment.
|
1071
|
+
# @param description [String] A new description for the enrichment.
|
1072
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1073
|
+
def update_enrichment(project_id:, enrichment_id:, name:, description: nil)
|
1074
|
+
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1075
|
+
|
1076
|
+
raise ArgumentError.new("enrichment_id must be provided") if enrichment_id.nil?
|
1077
|
+
|
1078
|
+
raise ArgumentError.new("name must be provided") if name.nil?
|
1079
|
+
|
1080
|
+
headers = {
|
1081
|
+
}
|
1082
|
+
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "update_enrichment")
|
1083
|
+
headers.merge!(sdk_headers)
|
1084
|
+
|
1085
|
+
params = {
|
1086
|
+
"version" => @version
|
1087
|
+
}
|
1088
|
+
|
1089
|
+
data = {
|
1090
|
+
"name" => name,
|
1091
|
+
"description" => description
|
1092
|
+
}
|
1093
|
+
|
1094
|
+
method_url = "/v2/projects/%s/enrichments/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(enrichment_id)]
|
1095
|
+
|
1096
|
+
response = request(
|
1097
|
+
method: "POST",
|
1098
|
+
url: method_url,
|
1099
|
+
headers: headers,
|
1100
|
+
params: params,
|
1101
|
+
json: data,
|
1102
|
+
accept_json: true
|
1103
|
+
)
|
1104
|
+
response
|
1105
|
+
end
|
1106
|
+
|
1107
|
+
##
|
1108
|
+
# @!method delete_enrichment(project_id:, enrichment_id:)
|
1109
|
+
# Delete an enrichment.
|
1110
|
+
# Deletes an existing enrichment from the specified project.
|
1111
|
+
#
|
1112
|
+
# **Note:** Only enrichments that have been manually created can be deleted.
|
1113
|
+
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
1114
|
+
# Discovery administrative tooling.
|
1115
|
+
# @param enrichment_id [String] The ID of the enrichment.
|
1116
|
+
# @return [nil]
|
1117
|
+
def delete_enrichment(project_id:, enrichment_id:)
|
1118
|
+
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1119
|
+
|
1120
|
+
raise ArgumentError.new("enrichment_id must be provided") if enrichment_id.nil?
|
1121
|
+
|
1122
|
+
headers = {
|
1123
|
+
}
|
1124
|
+
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "delete_enrichment")
|
1125
|
+
headers.merge!(sdk_headers)
|
1126
|
+
|
1127
|
+
params = {
|
1128
|
+
"version" => @version
|
1129
|
+
}
|
1130
|
+
|
1131
|
+
method_url = "/v2/projects/%s/enrichments/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(enrichment_id)]
|
1132
|
+
|
1133
|
+
request(
|
1134
|
+
method: "DELETE",
|
1135
|
+
url: method_url,
|
1136
|
+
headers: headers,
|
1137
|
+
params: params,
|
1138
|
+
accept_json: false
|
1139
|
+
)
|
1140
|
+
nil
|
1141
|
+
end
|
1142
|
+
#########################
|
1143
|
+
# projects
|
1144
|
+
#########################
|
1145
|
+
|
1146
|
+
##
|
1147
|
+
# @!method list_projects
|
1148
|
+
# List projects.
|
1149
|
+
# Lists existing projects for this instance.
|
1150
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1151
|
+
def list_projects
|
1152
|
+
headers = {
|
1153
|
+
}
|
1154
|
+
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "list_projects")
|
1155
|
+
headers.merge!(sdk_headers)
|
1156
|
+
|
1157
|
+
params = {
|
1158
|
+
"version" => @version
|
1159
|
+
}
|
1160
|
+
|
1161
|
+
method_url = "/v2/projects"
|
1162
|
+
|
1163
|
+
response = request(
|
1164
|
+
method: "GET",
|
1165
|
+
url: method_url,
|
1166
|
+
headers: headers,
|
1167
|
+
params: params,
|
1168
|
+
accept_json: true
|
1169
|
+
)
|
1170
|
+
response
|
1171
|
+
end
|
1172
|
+
|
1173
|
+
##
|
1174
|
+
# @!method create_project(name:, type:, default_query_parameters: nil)
|
1175
|
+
# Create a Project.
|
1176
|
+
# Create a new project for this instance.
|
1177
|
+
# @param name [String] The human readable name of this project.
|
1178
|
+
# @param type [String] The project type of this project.
|
1179
|
+
# @param default_query_parameters [DefaultQueryParams] Default query parameters for this project.
|
1180
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1181
|
+
def create_project(name:, type:, default_query_parameters: nil)
|
1182
|
+
raise ArgumentError.new("name must be provided") if name.nil?
|
1183
|
+
|
1184
|
+
raise ArgumentError.new("type must be provided") if type.nil?
|
1185
|
+
|
1186
|
+
headers = {
|
1187
|
+
}
|
1188
|
+
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "create_project")
|
1189
|
+
headers.merge!(sdk_headers)
|
1190
|
+
|
1191
|
+
params = {
|
1192
|
+
"version" => @version
|
1193
|
+
}
|
1194
|
+
|
1195
|
+
data = {
|
1196
|
+
"name" => name,
|
1197
|
+
"type" => type,
|
1198
|
+
"default_query_parameters" => default_query_parameters
|
1199
|
+
}
|
1200
|
+
|
1201
|
+
method_url = "/v2/projects"
|
1202
|
+
|
1203
|
+
response = request(
|
1204
|
+
method: "POST",
|
1205
|
+
url: method_url,
|
1206
|
+
headers: headers,
|
1207
|
+
params: params,
|
1208
|
+
json: data,
|
1209
|
+
accept_json: true
|
1210
|
+
)
|
1211
|
+
response
|
1212
|
+
end
|
1213
|
+
|
1214
|
+
##
|
1215
|
+
# @!method get_project(project_id:)
|
1216
|
+
# Get project.
|
1217
|
+
# Get details on the specified project.
|
1218
|
+
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
1219
|
+
# Discovery administrative tooling.
|
1220
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1221
|
+
def get_project(project_id:)
|
1222
|
+
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1223
|
+
|
1224
|
+
headers = {
|
1225
|
+
}
|
1226
|
+
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "get_project")
|
1227
|
+
headers.merge!(sdk_headers)
|
1228
|
+
|
1229
|
+
params = {
|
1230
|
+
"version" => @version
|
1231
|
+
}
|
1232
|
+
|
1233
|
+
method_url = "/v2/projects/%s" % [ERB::Util.url_encode(project_id)]
|
1234
|
+
|
1235
|
+
response = request(
|
1236
|
+
method: "GET",
|
1237
|
+
url: method_url,
|
1238
|
+
headers: headers,
|
1239
|
+
params: params,
|
1240
|
+
accept_json: true
|
1241
|
+
)
|
1242
|
+
response
|
1243
|
+
end
|
1244
|
+
|
1245
|
+
##
|
1246
|
+
# @!method update_project(project_id:, name: nil)
|
1247
|
+
# Update a project.
|
1248
|
+
# Update the specified project's name.
|
1249
|
+
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
1250
|
+
# Discovery administrative tooling.
|
1251
|
+
# @param name [String] The new name to give this project.
|
1252
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1253
|
+
def update_project(project_id:, name: nil)
|
1254
|
+
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1255
|
+
|
1256
|
+
headers = {
|
1257
|
+
}
|
1258
|
+
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "update_project")
|
1259
|
+
headers.merge!(sdk_headers)
|
1260
|
+
|
1261
|
+
params = {
|
1262
|
+
"version" => @version
|
1263
|
+
}
|
1264
|
+
|
1265
|
+
data = {
|
1266
|
+
"name" => name
|
1267
|
+
}
|
1268
|
+
|
1269
|
+
method_url = "/v2/projects/%s" % [ERB::Util.url_encode(project_id)]
|
1270
|
+
|
1271
|
+
response = request(
|
1272
|
+
method: "POST",
|
1273
|
+
url: method_url,
|
1274
|
+
headers: headers,
|
1275
|
+
params: params,
|
1276
|
+
json: data,
|
1277
|
+
accept_json: true
|
1278
|
+
)
|
1279
|
+
response
|
1280
|
+
end
|
1281
|
+
|
1282
|
+
##
|
1283
|
+
# @!method delete_project(project_id:)
|
1284
|
+
# Delete a project.
|
1285
|
+
# Deletes the specified project.
|
1286
|
+
#
|
1287
|
+
# **Important:** Deleting a project deletes everything that is part of the specified
|
1288
|
+
# project, including all collections.
|
1289
|
+
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
1290
|
+
# Discovery administrative tooling.
|
1291
|
+
# @return [nil]
|
1292
|
+
def delete_project(project_id:)
|
1293
|
+
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1294
|
+
|
1295
|
+
headers = {
|
1296
|
+
}
|
1297
|
+
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "delete_project")
|
1298
|
+
headers.merge!(sdk_headers)
|
1299
|
+
|
1300
|
+
params = {
|
1301
|
+
"version" => @version
|
1302
|
+
}
|
1303
|
+
|
1304
|
+
method_url = "/v2/projects/%s" % [ERB::Util.url_encode(project_id)]
|
1305
|
+
|
1306
|
+
request(
|
1307
|
+
method: "DELETE",
|
1308
|
+
url: method_url,
|
1309
|
+
headers: headers,
|
1310
|
+
params: params,
|
1311
|
+
accept_json: false
|
1312
|
+
)
|
1313
|
+
nil
|
1314
|
+
end
|
1315
|
+
#########################
|
1316
|
+
# userData
|
1317
|
+
#########################
|
1318
|
+
|
1319
|
+
##
|
1320
|
+
# @!method delete_user_data(customer_id:)
|
1321
|
+
# Delete labeled data.
|
1322
|
+
# Deletes all data associated with a specified customer ID. The method has no effect
|
1323
|
+
# if no data is associated with the customer ID.
|
1324
|
+
#
|
1325
|
+
# You associate a customer ID with data by passing the **X-Watson-Metadata** header
|
1326
|
+
# with a request that passes data. For more information about personal data and
|
1327
|
+
# customer IDs, see [Information
|
1328
|
+
# security](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-information-security#information-security).
|
1329
|
+
#
|
1330
|
+
#
|
1331
|
+
# **Note:** This method is only supported on IBM Cloud instances of Discovery.
|
1332
|
+
# @param customer_id [String] The customer ID for which all data is to be deleted.
|
1333
|
+
# @return [nil]
|
1334
|
+
def delete_user_data(customer_id:)
|
1335
|
+
raise ArgumentError.new("customer_id must be provided") if customer_id.nil?
|
1336
|
+
|
1337
|
+
headers = {
|
1338
|
+
}
|
1339
|
+
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "delete_user_data")
|
1340
|
+
headers.merge!(sdk_headers)
|
1341
|
+
|
1342
|
+
params = {
|
1343
|
+
"version" => @version,
|
1344
|
+
"customer_id" => customer_id
|
1345
|
+
}
|
1346
|
+
|
1347
|
+
method_url = "/v2/user_data"
|
1348
|
+
|
1349
|
+
request(
|
1350
|
+
method: "DELETE",
|
1351
|
+
url: method_url,
|
1352
|
+
headers: headers,
|
1353
|
+
params: params,
|
1354
|
+
accept_json: false
|
1355
|
+
)
|
1356
|
+
nil
|
1357
|
+
end
|
765
1358
|
end
|
766
1359
|
end
|