ibm_watson 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ibm_watson/assistant_v1.rb +1 -145
- data/lib/ibm_watson/assistant_v2.rb +95 -5
- data/lib/ibm_watson/compare_comply_v1.rb +1 -1
- data/lib/ibm_watson/discovery_v1.rb +1 -1
- data/lib/ibm_watson/discovery_v2.rb +590 -9
- data/lib/ibm_watson/language_translator_v3.rb +153 -48
- data/lib/ibm_watson/natural_language_classifier_v1.rb +1 -1
- data/lib/ibm_watson/natural_language_understanding_v1.rb +7 -9
- data/lib/ibm_watson/personality_insights_v3.rb +1 -1
- data/lib/ibm_watson/speech_to_text_v1.rb +40 -34
- data/lib/ibm_watson/text_to_speech_v1.rb +18 -11
- data/lib/ibm_watson/tone_analyzer_v3.rb +1 -1
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v3.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v4.rb +1 -1
- data/test/integration/test_assistant_v2.rb +18 -0
- data/test/integration/test_discovery_v2.rb +118 -6
- data/test/integration/test_language_translator_v3.rb +5 -0
- data/test/unit/test_assistant_v1.rb +98 -98
- data/test/unit/test_assistant_v2.rb +40 -12
- 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 -14
- 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 +40 -40
- metadata +2 -2
@@ -34,7 +34,7 @@ module IBMWatson
|
|
34
34
|
class AssistantV2 < IBMCloudSdkCore::BaseService
|
35
35
|
include Concurrent::Async
|
36
36
|
DEFAULT_SERVICE_NAME = "assistant"
|
37
|
-
DEFAULT_SERVICE_URL = "https://
|
37
|
+
DEFAULT_SERVICE_URL = "https://api.us-south.assistant.watson.cloud.ibm.com"
|
38
38
|
##
|
39
39
|
# @!method initialize(args)
|
40
40
|
# Construct a new client for the Assistant service.
|
@@ -164,8 +164,6 @@ module IBMWatson
|
|
164
164
|
# Send user input to an assistant and receive a response, with conversation state
|
165
165
|
# (including context data) stored by Watson Assistant for the duration of the
|
166
166
|
# session.
|
167
|
-
#
|
168
|
-
# There is no rate limit for this operation.
|
169
167
|
# @param assistant_id [String] Unique identifier of the assistant. To find the assistant ID in the Watson
|
170
168
|
# Assistant user interface, open the assistant settings and click **API Details**.
|
171
169
|
# For information about creating assistants, see the
|
@@ -218,8 +216,6 @@ module IBMWatson
|
|
218
216
|
# Send user input to assistant (stateless).
|
219
217
|
# Send user input to an assistant and receive a response, with conversation state
|
220
218
|
# (including context data) managed by your application.
|
221
|
-
#
|
222
|
-
# There is no rate limit for this operation.
|
223
219
|
# @param assistant_id [String] Unique identifier of the assistant. To find the assistant ID in the Watson
|
224
220
|
# Assistant user interface, open the assistant settings and click **API Details**.
|
225
221
|
# For information about creating assistants, see the
|
@@ -264,5 +260,99 @@ module IBMWatson
|
|
264
260
|
)
|
265
261
|
response
|
266
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
|
267
357
|
end
|
268
358
|
end
|
@@ -30,7 +30,7 @@ module IBMWatson
|
|
30
30
|
class CompareComplyV1 < IBMCloudSdkCore::BaseService
|
31
31
|
include Concurrent::Async
|
32
32
|
DEFAULT_SERVICE_NAME = "compare_comply"
|
33
|
-
DEFAULT_SERVICE_URL = "https://
|
33
|
+
DEFAULT_SERVICE_URL = "https://api.us-south.compare-comply.watson.cloud.ibm.com"
|
34
34
|
##
|
35
35
|
# @!method initialize(args)
|
36
36
|
# Construct a new client for the Compare Comply service.
|
@@ -33,7 +33,7 @@ module IBMWatson
|
|
33
33
|
class DiscoveryV1 < IBMCloudSdkCore::BaseService
|
34
34
|
include Concurrent::Async
|
35
35
|
DEFAULT_SERVICE_NAME = "discovery"
|
36
|
-
DEFAULT_SERVICE_URL = "https://
|
36
|
+
DEFAULT_SERVICE_URL = "https://api.us-south.discovery.watson.cloud.ibm.com"
|
37
37
|
##
|
38
38
|
# @!method initialize(args)
|
39
39
|
# Construct a new client for the Discovery service.
|
@@ -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"
|
@@ -33,7 +33,7 @@ module IBMWatson
|
|
33
33
|
class DiscoveryV2 < IBMCloudSdkCore::BaseService
|
34
34
|
include Concurrent::Async
|
35
35
|
DEFAULT_SERVICE_NAME = "discovery"
|
36
|
-
DEFAULT_SERVICE_URL =
|
36
|
+
DEFAULT_SERVICE_URL = "https://api.us-south.discovery.watson.cloud.ibm.com"
|
37
37
|
##
|
38
38
|
# @!method initialize(args)
|
39
39
|
# Construct a new client for the Discovery service.
|
@@ -105,6 +105,164 @@ module IBMWatson
|
|
105
105
|
)
|
106
106
|
response
|
107
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
|
108
266
|
#########################
|
109
267
|
# Queries
|
110
268
|
#########################
|
@@ -114,6 +272,12 @@ module IBMWatson
|
|
114
272
|
# Query a project.
|
115
273
|
# By using this method, you can construct queries. For details, see the [Discovery
|
116
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.
|
117
281
|
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
118
282
|
# Discovery administrative tooling.
|
119
283
|
# @param collection_ids [Array[String]] A comma-separated list of collection IDs to be queried against.
|
@@ -327,7 +491,7 @@ module IBMWatson
|
|
327
491
|
|
328
492
|
##
|
329
493
|
# @!method get_component_settings(project_id:)
|
330
|
-
#
|
494
|
+
# List component settings.
|
331
495
|
# Returns default configuration settings for components.
|
332
496
|
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
333
497
|
# Discovery administrative tooling.
|
@@ -405,7 +569,10 @@ module IBMWatson
|
|
405
569
|
# @param filename [String] The filename for file.
|
406
570
|
# @param file_content_type [String] The content type of file.
|
407
571
|
# @param metadata [String] The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB
|
408
|
-
# are rejected.
|
572
|
+
# are rejected.
|
573
|
+
#
|
574
|
+
#
|
575
|
+
# Example: ``` {
|
409
576
|
# "Creator": "Johnny Appleseed",
|
410
577
|
# "Subject": "Apples"
|
411
578
|
# } ```.
|
@@ -481,7 +648,10 @@ module IBMWatson
|
|
481
648
|
# @param filename [String] The filename for file.
|
482
649
|
# @param file_content_type [String] The content type of file.
|
483
650
|
# @param metadata [String] The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB
|
484
|
-
# are rejected.
|
651
|
+
# are rejected.
|
652
|
+
#
|
653
|
+
#
|
654
|
+
# Example: ``` {
|
485
655
|
# "Creator": "Johnny Appleseed",
|
486
656
|
# "Subject": "Apples"
|
487
657
|
# } ```.
|
@@ -774,5 +944,416 @@ module IBMWatson
|
|
774
944
|
)
|
775
945
|
response
|
776
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
|
777
1358
|
end
|
778
1359
|
end
|