ibm_watson 0.1.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.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +258 -0
  3. data/bin/console +14 -0
  4. data/bin/setup +8 -0
  5. data/lib/ibm_watson.rb +16 -0
  6. data/lib/ibm_watson/assistant_v1.rb +1997 -0
  7. data/lib/ibm_watson/detailed_response.rb +21 -0
  8. data/lib/ibm_watson/discovery_v1.rb +2039 -0
  9. data/lib/ibm_watson/iam_token_manager.rb +166 -0
  10. data/lib/ibm_watson/language_translator_v3.rb +411 -0
  11. data/lib/ibm_watson/natural_language_classifier_v1.rb +309 -0
  12. data/lib/ibm_watson/natural_language_understanding_v1.rb +297 -0
  13. data/lib/ibm_watson/personality_insights_v3.rb +260 -0
  14. data/lib/ibm_watson/speech_to_text_v1.rb +2153 -0
  15. data/lib/ibm_watson/text_to_speech_v1.rb +716 -0
  16. data/lib/ibm_watson/tone_analyzer_v3.rb +287 -0
  17. data/lib/ibm_watson/version.rb +3 -0
  18. data/lib/ibm_watson/visual_recognition_v3.rb +579 -0
  19. data/lib/ibm_watson/watson_api_exception.rb +41 -0
  20. data/lib/ibm_watson/watson_service.rb +180 -0
  21. data/lib/ibm_watson/websocket/recognize_callback.rb +32 -0
  22. data/lib/ibm_watson/websocket/speech_to_text_websocket_listener.rb +162 -0
  23. data/rakefile +45 -0
  24. data/test/integration/test_assistant_v1.rb +645 -0
  25. data/test/integration/test_discovery_v1.rb +200 -0
  26. data/test/integration/test_iam_assistant_v1.rb +707 -0
  27. data/test/integration/test_language_translator_v3.rb +81 -0
  28. data/test/integration/test_natural_language_classifier_v1.rb +69 -0
  29. data/test/integration/test_natural_language_understanding_v1.rb +98 -0
  30. data/test/integration/test_personality_insights_v3.rb +95 -0
  31. data/test/integration/test_speech_to_text_v1.rb +187 -0
  32. data/test/integration/test_text_to_speech_v1.rb +81 -0
  33. data/test/integration/test_tone_analyzer_v3.rb +72 -0
  34. data/test/integration/test_visual_recognition_v3.rb +64 -0
  35. data/test/test_helper.rb +22 -0
  36. data/test/unit/test_assistant_v1.rb +1598 -0
  37. data/test/unit/test_discovery_v1.rb +1144 -0
  38. data/test/unit/test_iam_token_manager.rb +165 -0
  39. data/test/unit/test_language_translator_v3.rb +461 -0
  40. data/test/unit/test_natural_language_classifier_v1.rb +187 -0
  41. data/test/unit/test_natural_language_understanding_v1.rb +132 -0
  42. data/test/unit/test_personality_insights_v3.rb +172 -0
  43. data/test/unit/test_speech_to_text_v1.rb +755 -0
  44. data/test/unit/test_text_to_speech_v1.rb +336 -0
  45. data/test/unit/test_tone_analyzer_v3.rb +200 -0
  46. data/test/unit/test_vcap_using_personality_insights.rb +150 -0
  47. data/test/unit/test_visual_recognition_v3.rb +345 -0
  48. metadata +302 -0
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require("json")
4
+
5
+ # Custom class for objects returned from API calls
6
+ class DetailedResponse
7
+ attr_reader :status, :headers, :result
8
+ def initialize(status: nil, headers: nil, body: nil, response: nil)
9
+ if status.nil? || headers.nil? || body.nil?
10
+ @status = response.code
11
+ @headers = response.headers.to_h
12
+ @headers = response.headers.to_hash if response.headers.respond_to?("to_hash")
13
+ @result = response.body.to_s
14
+ @result = JSON.parse(response.body.to_s) if !response.body.to_s.empty? && @headers.key?("Content-Type") && @headers["Content-Type"].start_with?("application/json")
15
+ else
16
+ @status = status
17
+ @headers = headers
18
+ @result = body
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,2039 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 IBM All Rights Reserved.
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
+ # The IBM Watson™ Discovery Service is a cognitive search and content analytics
18
+ # engine that you can add to applications to identify patterns, trends and actionable
19
+ # insights to drive better decision-making. Securely unify structured and unstructured
20
+ # data with pre-enriched content, and use a simplified query language to eliminate the
21
+ # need for manual filtering of results.
22
+
23
+ require "concurrent"
24
+ require "erb"
25
+ require "json"
26
+ require_relative "./detailed_response"
27
+
28
+ require_relative "./watson_service"
29
+
30
+ module IBMWatson
31
+ ##
32
+ # The Discovery V1 service.
33
+ class DiscoveryV1
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 url [String] The base url to use when contacting the service (e.g.
51
+ # "https://gateway.watsonplatform.net/discovery/api").
52
+ # The base url may differ between Bluemix regions.
53
+ # @option args username [String] The username used to authenticate with the service.
54
+ # Username and password credentials are only required to run your
55
+ # application locally or outside of Bluemix. When running on
56
+ # Bluemix, the credentials will be automatically loaded from the
57
+ # `VCAP_SERVICES` environment variable.
58
+ # @option args password [String] The password used to authenticate with the service.
59
+ # Username and password credentials are only required to run your
60
+ # application locally or outside of Bluemix. When running on
61
+ # Bluemix, the credentials will be automatically loaded from the
62
+ # `VCAP_SERVICES` environment variable.
63
+ # @option args iam_api_key [String] An API key that can be used to request IAM tokens. If
64
+ # this API key is provided, the SDK will manage the token and handle the
65
+ # refreshing.
66
+ # @option args iam_access_token [String] An IAM access token is fully managed by the application.
67
+ # Responsibility falls on the application to refresh the token, either before
68
+ # it expires or reactively upon receiving a 401 from the service as any requests
69
+ # made with an expired token will fail.
70
+ # @option args iam_url [String] An optional URL for the IAM service API. Defaults to
71
+ # 'https://iam.ng.bluemix.net/identity/token'.
72
+ def initialize(args = {})
73
+ @__async_initialized__ = false
74
+ super()
75
+ defaults = {}
76
+ defaults[:version] = nil
77
+ defaults[:url] = "https://gateway.watsonplatform.net/discovery/api"
78
+ defaults[:username] = nil
79
+ defaults[:password] = nil
80
+ defaults[:iam_api_key] = nil
81
+ defaults[:iam_access_token] = nil
82
+ defaults[:iam_url] = nil
83
+ args = defaults.merge(args)
84
+ @watson_service = WatsonService.new(
85
+ vcap_services_name: "discovery",
86
+ url: args[:url],
87
+ username: args[:username],
88
+ password: args[:password],
89
+ iam_api_key: args[:iam_api_key],
90
+ iam_access_token: args[:iam_access_token],
91
+ iam_url: args[:iam_url],
92
+ use_vcap_services: true
93
+ )
94
+ @version = args[:version]
95
+ end
96
+
97
+ # :nocov:
98
+ def add_default_headers(headers: {})
99
+ @watson_service.add_default_headers(headers: headers)
100
+ end
101
+
102
+ def _iam_access_token(iam_access_token:)
103
+ @watson_service._iam_access_token(iam_access_token: iam_access_token)
104
+ end
105
+
106
+ def _iam_api_key(iam_api_key:)
107
+ @watson_service._iam_api_key(iam_api_key: iam_api_key)
108
+ end
109
+
110
+ # @return [DetailedResponse]
111
+ def request(args)
112
+ @watson_service.request(args)
113
+ end
114
+
115
+ # @note Chainable
116
+ # @param headers [Hash] Custom headers to be sent with the request
117
+ # @return [self]
118
+ def headers(headers)
119
+ @watson_service.headers(headers)
120
+ self
121
+ end
122
+
123
+ def password=(password)
124
+ @watson_service.password = password
125
+ end
126
+
127
+ def password
128
+ @watson_service.password
129
+ end
130
+
131
+ def username=(username)
132
+ @watson_service.username = username
133
+ end
134
+
135
+ def username
136
+ @watson_service.username
137
+ end
138
+
139
+ def url=(url)
140
+ @watson_service.url = url
141
+ end
142
+
143
+ def url
144
+ @watson_service.url
145
+ end
146
+ # :nocov:
147
+ #########################
148
+ # Environments
149
+ #########################
150
+
151
+ ##
152
+ # @!method create_environment(name:, description: nil, size: nil)
153
+ # Create an environment.
154
+ # Creates a new environment for private data. An environment must be created before
155
+ # collections can be created.
156
+ #
157
+ # **Note**: You can create only one environment for private data per service
158
+ # instance. An attempt to create another environment results in an error.
159
+ # @param name [String] Name that identifies the environment.
160
+ # @param description [String] Description of the environment.
161
+ # @param size [Fixnum] **Deprecated**: Size of the environment.
162
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
163
+ def create_environment(name:, description: nil, size: nil)
164
+ raise ArgumentError("name must be provided") if name.nil?
165
+ headers = {
166
+ }
167
+ params = {
168
+ "version" => @version
169
+ }
170
+ data = {
171
+ "name" => name,
172
+ "description" => description,
173
+ "size" => size
174
+ }
175
+ method_url = "/v1/environments"
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 list_environments(name: nil)
189
+ # List environments.
190
+ # List existing environments for the service instance.
191
+ # @param name [String] Show only the environment with the given name.
192
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
193
+ def list_environments(name: nil)
194
+ headers = {
195
+ }
196
+ params = {
197
+ "version" => @version,
198
+ "name" => name
199
+ }
200
+ method_url = "/v1/environments"
201
+ response = request(
202
+ method: "GET",
203
+ url: method_url,
204
+ headers: headers,
205
+ params: params,
206
+ accept_json: true
207
+ )
208
+ response
209
+ end
210
+
211
+ ##
212
+ # @!method get_environment(environment_id:)
213
+ # Get environment info.
214
+ # @param environment_id [String] The ID of the environment.
215
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
216
+ def get_environment(environment_id:)
217
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
218
+ headers = {
219
+ }
220
+ params = {
221
+ "version" => @version
222
+ }
223
+ method_url = "/v1/environments/%s" % [ERB::Util.url_encode(environment_id)]
224
+ response = request(
225
+ method: "GET",
226
+ url: method_url,
227
+ headers: headers,
228
+ params: params,
229
+ accept_json: true
230
+ )
231
+ response
232
+ end
233
+
234
+ ##
235
+ # @!method update_environment(environment_id:, name: nil, description: nil)
236
+ # Update an environment.
237
+ # Updates an environment. The environment's **name** and **description** parameters
238
+ # can be changed. You must specify a **name** for the environment.
239
+ # @param environment_id [String] The ID of the environment.
240
+ # @param name [String] Name that identifies the environment.
241
+ # @param description [String] Description of the environment.
242
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
243
+ def update_environment(environment_id:, name: nil, description: nil)
244
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
245
+ headers = {
246
+ }
247
+ params = {
248
+ "version" => @version
249
+ }
250
+ data = {
251
+ "name" => name,
252
+ "description" => description
253
+ }
254
+ method_url = "/v1/environments/%s" % [ERB::Util.url_encode(environment_id)]
255
+ response = request(
256
+ method: "PUT",
257
+ url: method_url,
258
+ headers: headers,
259
+ params: params,
260
+ json: data,
261
+ accept_json: true
262
+ )
263
+ response
264
+ end
265
+
266
+ ##
267
+ # @!method delete_environment(environment_id:)
268
+ # Delete environment.
269
+ # @param environment_id [String] The ID of the environment.
270
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
271
+ def delete_environment(environment_id:)
272
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
273
+ headers = {
274
+ }
275
+ params = {
276
+ "version" => @version
277
+ }
278
+ method_url = "/v1/environments/%s" % [ERB::Util.url_encode(environment_id)]
279
+ response = request(
280
+ method: "DELETE",
281
+ url: method_url,
282
+ headers: headers,
283
+ params: params,
284
+ accept_json: true
285
+ )
286
+ response
287
+ end
288
+
289
+ ##
290
+ # @!method list_fields(environment_id:, collection_ids:)
291
+ # List fields across collections.
292
+ # Gets a list of the unique fields (and their types) stored in the indexes of the
293
+ # specified collections.
294
+ # @param environment_id [String] The ID of the environment.
295
+ # @param collection_ids [Array[String]] A comma-separated list of collection IDs to be queried against.
296
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
297
+ def list_fields(environment_id:, collection_ids:)
298
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
299
+ raise ArgumentError("collection_ids must be provided") if collection_ids.nil?
300
+ headers = {
301
+ }
302
+ params = {
303
+ "version" => @version,
304
+ "collection_ids" => collection_ids.to_a
305
+ }
306
+ method_url = "/v1/environments/%s/fields" % [ERB::Util.url_encode(environment_id)]
307
+ response = request(
308
+ method: "GET",
309
+ url: method_url,
310
+ headers: headers,
311
+ params: params,
312
+ accept_json: true
313
+ )
314
+ response
315
+ end
316
+ #########################
317
+ # Configurations
318
+ #########################
319
+
320
+ ##
321
+ # @!method create_configuration(environment_id:, name:, description: nil, conversions: nil, enrichments: nil, normalizations: nil, source: nil)
322
+ # Add configuration.
323
+ # Creates a new configuration.
324
+ #
325
+ # If the input configuration contains the **configuration_id**, **created**, or
326
+ # **updated** properties, then they are ignored and overridden by the system, and an
327
+ # error is not returned so that the overridden fields do not need to be removed when
328
+ # copying a configuration.
329
+ #
330
+ # The configuration can contain unrecognized JSON fields. Any such fields are
331
+ # ignored and do not generate an error. This makes it easier to use newer
332
+ # configuration files with older versions of the API and the service. It also makes
333
+ # it possible for the tooling to add additional metadata and information to the
334
+ # configuration.
335
+ # @param environment_id [String] The ID of the environment.
336
+ # @param name [String] The name of the configuration.
337
+ # @param description [String] The description of the configuration, if available.
338
+ # @param conversions [Conversions] The document conversion settings for the configuration.
339
+ # @param enrichments [Array[Enrichment]] An array of document enrichment settings for the configuration.
340
+ # @param normalizations [Array[NormalizationOperation]] Defines operations that can be used to transform the final output JSON into a
341
+ # normalized form. Operations are executed in the order that they appear in the
342
+ # array.
343
+ # @param source [Source] Object containing source parameters for the configuration.
344
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
345
+ def create_configuration(environment_id:, name:, description: nil, conversions: nil, enrichments: nil, normalizations: nil, source: nil)
346
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
347
+ raise ArgumentError("name must be provided") if name.nil?
348
+ headers = {
349
+ }
350
+ params = {
351
+ "version" => @version
352
+ }
353
+ data = {
354
+ "name" => name,
355
+ "description" => description,
356
+ "conversions" => conversions,
357
+ "enrichments" => enrichments,
358
+ "normalizations" => normalizations,
359
+ "source" => source
360
+ }
361
+ method_url = "/v1/environments/%s/configurations" % [ERB::Util.url_encode(environment_id)]
362
+ response = request(
363
+ method: "POST",
364
+ url: method_url,
365
+ headers: headers,
366
+ params: params,
367
+ json: data,
368
+ accept_json: true
369
+ )
370
+ response
371
+ end
372
+
373
+ ##
374
+ # @!method list_configurations(environment_id:, name: nil)
375
+ # List configurations.
376
+ # Lists existing configurations for the service instance.
377
+ # @param environment_id [String] The ID of the environment.
378
+ # @param name [String] Find configurations with the given name.
379
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
380
+ def list_configurations(environment_id:, name: nil)
381
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
382
+ headers = {
383
+ }
384
+ params = {
385
+ "version" => @version,
386
+ "name" => name
387
+ }
388
+ method_url = "/v1/environments/%s/configurations" % [ERB::Util.url_encode(environment_id)]
389
+ response = request(
390
+ method: "GET",
391
+ url: method_url,
392
+ headers: headers,
393
+ params: params,
394
+ accept_json: true
395
+ )
396
+ response
397
+ end
398
+
399
+ ##
400
+ # @!method get_configuration(environment_id:, configuration_id:)
401
+ # Get configuration details.
402
+ # @param environment_id [String] The ID of the environment.
403
+ # @param configuration_id [String] The ID of the configuration.
404
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
405
+ def get_configuration(environment_id:, configuration_id:)
406
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
407
+ raise ArgumentError("configuration_id must be provided") if configuration_id.nil?
408
+ headers = {
409
+ }
410
+ params = {
411
+ "version" => @version
412
+ }
413
+ method_url = "/v1/environments/%s/configurations/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(configuration_id)]
414
+ response = request(
415
+ method: "GET",
416
+ url: method_url,
417
+ headers: headers,
418
+ params: params,
419
+ accept_json: true
420
+ )
421
+ response
422
+ end
423
+
424
+ ##
425
+ # @!method update_configuration(environment_id:, configuration_id:, name:, description: nil, conversions: nil, enrichments: nil, normalizations: nil, source: nil)
426
+ # Update a configuration.
427
+ # Replaces an existing configuration.
428
+ # * Completely replaces the original configuration.
429
+ # * The **configuration_id**, **updated**, and **created** fields are accepted in
430
+ # the request, but they are ignored, and an error is not generated. It is also
431
+ # acceptable for users to submit an updated configuration with none of the three
432
+ # properties.
433
+ # * Documents are processed with a snapshot of the configuration as it was at the
434
+ # time the document was submitted to be ingested. This means that already submitted
435
+ # documents will not see any updates made to the configuration.
436
+ # @param environment_id [String] The ID of the environment.
437
+ # @param configuration_id [String] The ID of the configuration.
438
+ # @param name [String] The name of the configuration.
439
+ # @param description [String] The description of the configuration, if available.
440
+ # @param conversions [Conversions] The document conversion settings for the configuration.
441
+ # @param enrichments [Array[Enrichment]] An array of document enrichment settings for the configuration.
442
+ # @param normalizations [Array[NormalizationOperation]] Defines operations that can be used to transform the final output JSON into a
443
+ # normalized form. Operations are executed in the order that they appear in the
444
+ # array.
445
+ # @param source [Source] Object containing source parameters for the configuration.
446
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
447
+ def update_configuration(environment_id:, configuration_id:, name:, description: nil, conversions: nil, enrichments: nil, normalizations: nil, source: nil)
448
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
449
+ raise ArgumentError("configuration_id must be provided") if configuration_id.nil?
450
+ raise ArgumentError("name must be provided") if name.nil?
451
+ headers = {
452
+ }
453
+ params = {
454
+ "version" => @version
455
+ }
456
+ data = {
457
+ "name" => name,
458
+ "description" => description,
459
+ "conversions" => conversions,
460
+ "enrichments" => enrichments,
461
+ "normalizations" => normalizations,
462
+ "source" => source
463
+ }
464
+ method_url = "/v1/environments/%s/configurations/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(configuration_id)]
465
+ response = request(
466
+ method: "PUT",
467
+ url: method_url,
468
+ headers: headers,
469
+ params: params,
470
+ json: data,
471
+ accept_json: true
472
+ )
473
+ response
474
+ end
475
+
476
+ ##
477
+ # @!method delete_configuration(environment_id:, configuration_id:)
478
+ # Delete a configuration.
479
+ # The deletion is performed unconditionally. A configuration deletion request
480
+ # succeeds even if the configuration is referenced by a collection or document
481
+ # ingestion. However, documents that have already been submitted for processing
482
+ # continue to use the deleted configuration. Documents are always processed with a
483
+ # snapshot of the configuration as it existed at the time the document was
484
+ # submitted.
485
+ # @param environment_id [String] The ID of the environment.
486
+ # @param configuration_id [String] The ID of the configuration.
487
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
488
+ def delete_configuration(environment_id:, configuration_id:)
489
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
490
+ raise ArgumentError("configuration_id must be provided") if configuration_id.nil?
491
+ headers = {
492
+ }
493
+ params = {
494
+ "version" => @version
495
+ }
496
+ method_url = "/v1/environments/%s/configurations/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(configuration_id)]
497
+ response = request(
498
+ method: "DELETE",
499
+ url: method_url,
500
+ headers: headers,
501
+ params: params,
502
+ accept_json: true
503
+ )
504
+ response
505
+ end
506
+ #########################
507
+ # Test your configuration on a document
508
+ #########################
509
+
510
+ ##
511
+ # @!method test_configuration_in_environment(environment_id:, configuration: nil, step: nil, configuration_id: nil, file: nil, metadata: nil, file_content_type: nil, filename: nil)
512
+ # Test configuration.
513
+ # Runs a sample document through the default or your configuration and returns
514
+ # diagnostic information designed to help you understand how the document was
515
+ # processed. The document is not added to the index.
516
+ # @param environment_id [String] The ID of the environment.
517
+ # @param configuration [String] The configuration to use to process the document. If this part is provided, then
518
+ # the provided configuration is used to process the document. If the
519
+ # **configuration_id** is also provided (both are present at the same time), then
520
+ # request is rejected. The maximum supported configuration size is 1 MB.
521
+ # Configuration parts larger than 1 MB are rejected.
522
+ # See the `GET /configurations/{configuration_id}` operation for an example
523
+ # configuration.
524
+ # @param step [String] Specify to only run the input document through the given step instead of running
525
+ # the input document through the entire ingestion workflow. Valid values are
526
+ # `convert`, `enrich`, and `normalize`.
527
+ # @param configuration_id [String] The ID of the configuration to use to process the document. If the
528
+ # **configuration** form part is also provided (both are present at the same time),
529
+ # then the request will be rejected.
530
+ # @param file [File] The content of the document to ingest. The maximum supported file size is 50
531
+ # megabytes. Files larger than 50 megabytes is rejected.
532
+ # @param metadata [String] If you're using the Data Crawler to upload your documents, you can test a document
533
+ # against the type of metadata that the Data Crawler might send. The maximum
534
+ # supported metadata file size is 1 MB. Metadata parts larger than 1 MB are
535
+ # rejected.
536
+ # Example: ``` {
537
+ # \"Creator\": \"Johnny Appleseed\",
538
+ # \"Subject\": \"Apples\"
539
+ # } ```.
540
+ # @param file_content_type [String] The content type of file.
541
+ # @param filename [String] The filename for file.
542
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
543
+ def test_configuration_in_environment(environment_id:, configuration: nil, step: nil, configuration_id: nil, file: nil, metadata: nil, file_content_type: nil, filename: nil)
544
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
545
+ headers = {
546
+ }
547
+ params = {
548
+ "version" => @version,
549
+ "step" => step,
550
+ "configuration_id" => configuration_id
551
+ }
552
+ unless file.nil?
553
+ mime_type = file_content_type.nil? ? "application/octet-stream" : file_content_type
554
+ unless file.instance_of?(StringIO) || file.instance_of?(File)
555
+ file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
556
+ end
557
+ if filename
558
+ file = file.instance_of?(StringIO) ? HTTP::FormData::File.new(file, content_type: mime_type, filename: filename) : HTTP::FormData::File.new(file.path, content_type: mime_type, filename: filename)
559
+ else
560
+ file = file.instance_of?(StringIO) ? HTTP::FormData::File.new(file, content_type: mime_type) : HTTP::FormData::File.new(file.path, content_type: mime_type)
561
+ end
562
+ end
563
+ method_url = "/v1/environments/%s/preview" % [ERB::Util.url_encode(environment_id)]
564
+ response = request(
565
+ method: "POST",
566
+ url: method_url,
567
+ headers: headers,
568
+ params: params,
569
+ form: {
570
+ configuration: configuration,
571
+ file: file,
572
+ metadata: metadata
573
+ },
574
+ accept_json: true
575
+ )
576
+ response
577
+ end
578
+ #########################
579
+ # Collections
580
+ #########################
581
+
582
+ ##
583
+ # @!method create_collection(environment_id:, name:, description: nil, configuration_id: nil, language: nil)
584
+ # Create a collection.
585
+ # @param environment_id [String] The ID of the environment.
586
+ # @param name [String] The name of the collection to be created.
587
+ # @param description [String] A description of the collection.
588
+ # @param configuration_id [String] The ID of the configuration in which the collection is to be created.
589
+ # @param language [String] The language of the documents stored in the collection, in the form of an ISO
590
+ # 639-1 language code.
591
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
592
+ def create_collection(environment_id:, name:, description: nil, configuration_id: nil, language: nil)
593
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
594
+ raise ArgumentError("name must be provided") if name.nil?
595
+ headers = {
596
+ }
597
+ params = {
598
+ "version" => @version
599
+ }
600
+ data = {
601
+ "name" => name,
602
+ "description" => description,
603
+ "configuration_id" => configuration_id,
604
+ "language" => language
605
+ }
606
+ method_url = "/v1/environments/%s/collections" % [ERB::Util.url_encode(environment_id)]
607
+ response = request(
608
+ method: "POST",
609
+ url: method_url,
610
+ headers: headers,
611
+ params: params,
612
+ json: data,
613
+ accept_json: true
614
+ )
615
+ response
616
+ end
617
+
618
+ ##
619
+ # @!method list_collections(environment_id:, name: nil)
620
+ # List collections.
621
+ # Lists existing collections for the service instance.
622
+ # @param environment_id [String] The ID of the environment.
623
+ # @param name [String] Find collections with the given name.
624
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
625
+ def list_collections(environment_id:, name: nil)
626
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
627
+ headers = {
628
+ }
629
+ params = {
630
+ "version" => @version,
631
+ "name" => name
632
+ }
633
+ method_url = "/v1/environments/%s/collections" % [ERB::Util.url_encode(environment_id)]
634
+ response = request(
635
+ method: "GET",
636
+ url: method_url,
637
+ headers: headers,
638
+ params: params,
639
+ accept_json: true
640
+ )
641
+ response
642
+ end
643
+
644
+ ##
645
+ # @!method get_collection(environment_id:, collection_id:)
646
+ # Get collection details.
647
+ # @param environment_id [String] The ID of the environment.
648
+ # @param collection_id [String] The ID of the collection.
649
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
650
+ def get_collection(environment_id:, collection_id:)
651
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
652
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
653
+ headers = {
654
+ }
655
+ params = {
656
+ "version" => @version
657
+ }
658
+ method_url = "/v1/environments/%s/collections/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
659
+ response = request(
660
+ method: "GET",
661
+ url: method_url,
662
+ headers: headers,
663
+ params: params,
664
+ accept_json: true
665
+ )
666
+ response
667
+ end
668
+
669
+ ##
670
+ # @!method update_collection(environment_id:, collection_id:, name:, description: nil, configuration_id: nil)
671
+ # Update a collection.
672
+ # @param environment_id [String] The ID of the environment.
673
+ # @param collection_id [String] The ID of the collection.
674
+ # @param name [String] The name of the collection.
675
+ # @param description [String] A description of the collection.
676
+ # @param configuration_id [String] The ID of the configuration in which the collection is to be updated.
677
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
678
+ def update_collection(environment_id:, collection_id:, name:, description: nil, configuration_id: nil)
679
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
680
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
681
+ headers = {
682
+ }
683
+ params = {
684
+ "version" => @version
685
+ }
686
+ data = {
687
+ "name" => name,
688
+ "description" => description,
689
+ "configuration_id" => configuration_id
690
+ }
691
+ method_url = "/v1/environments/%s/collections/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
692
+ response = request(
693
+ method: "PUT",
694
+ url: method_url,
695
+ headers: headers,
696
+ params: params,
697
+ json: data,
698
+ accept_json: true
699
+ )
700
+ response
701
+ end
702
+
703
+ ##
704
+ # @!method delete_collection(environment_id:, collection_id:)
705
+ # Delete a collection.
706
+ # @param environment_id [String] The ID of the environment.
707
+ # @param collection_id [String] The ID of the collection.
708
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
709
+ def delete_collection(environment_id:, collection_id:)
710
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
711
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
712
+ headers = {
713
+ }
714
+ params = {
715
+ "version" => @version
716
+ }
717
+ method_url = "/v1/environments/%s/collections/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
718
+ response = request(
719
+ method: "DELETE",
720
+ url: method_url,
721
+ headers: headers,
722
+ params: params,
723
+ accept_json: true
724
+ )
725
+ response
726
+ end
727
+
728
+ ##
729
+ # @!method list_collection_fields(environment_id:, collection_id:)
730
+ # List collection fields.
731
+ # Gets a list of the unique fields (and their types) stored in the index.
732
+ # @param environment_id [String] The ID of the environment.
733
+ # @param collection_id [String] The ID of the collection.
734
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
735
+ def list_collection_fields(environment_id:, collection_id:)
736
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
737
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
738
+ headers = {
739
+ }
740
+ params = {
741
+ "version" => @version
742
+ }
743
+ method_url = "/v1/environments/%s/collections/%s/fields" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
744
+ response = request(
745
+ method: "GET",
746
+ url: method_url,
747
+ headers: headers,
748
+ params: params,
749
+ accept_json: true
750
+ )
751
+ response
752
+ end
753
+ #########################
754
+ # Expansions
755
+ #########################
756
+
757
+ ##
758
+ # @!method list_expansions(environment_id:, collection_id:)
759
+ # Get the expansion list.
760
+ # Returns the current expansion list for the specified collection. If an expansion
761
+ # list is not specified, an object with empty expansion arrays is returned.
762
+ # @param environment_id [String] The ID of the environment.
763
+ # @param collection_id [String] The ID of the collection.
764
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
765
+ def list_expansions(environment_id:, collection_id:)
766
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
767
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
768
+ headers = {
769
+ }
770
+ params = {
771
+ "version" => @version
772
+ }
773
+ method_url = "/v1/environments/%s/collections/%s/expansions" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
774
+ response = request(
775
+ method: "GET",
776
+ url: method_url,
777
+ headers: headers,
778
+ params: params,
779
+ accept_json: true
780
+ )
781
+ response
782
+ end
783
+
784
+ ##
785
+ # @!method create_expansions(environment_id:, collection_id:, expansions:)
786
+ # Create or update expansion list.
787
+ # Create or replace the Expansion list for this collection. The maximum number of
788
+ # expanded terms per collection is `500`.
789
+ # The current expansion list is replaced with the uploaded content.
790
+ # @param environment_id [String] The ID of the environment.
791
+ # @param collection_id [String] The ID of the collection.
792
+ # @param expansions [Array[Expansion]] An array of query expansion definitions.
793
+ #
794
+ # Each object in the **expansions** array represents a term or set of terms that
795
+ # will be expanded into other terms. Each expansion object can be configured as
796
+ # bidirectional or unidirectional. Bidirectional means that all terms are expanded
797
+ # to all other terms in the object. Unidirectional means that a set list of terms
798
+ # can be expanded into a second list of terms.
799
+ #
800
+ # To create a bi-directional expansion specify an **expanded_terms** array. When
801
+ # found in a query, all items in the **expanded_terms** array are then expanded to
802
+ # the other items in the same array.
803
+ #
804
+ # To create a uni-directional expansion, specify both an array of **input_terms**
805
+ # and an array of **expanded_terms**. When items in the **input_terms** array are
806
+ # present in a query, they are expanded using the items listed in the
807
+ # **expanded_terms** array.
808
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
809
+ def create_expansions(environment_id:, collection_id:, expansions:)
810
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
811
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
812
+ raise ArgumentError("expansions must be provided") if expansions.nil?
813
+ headers = {
814
+ }
815
+ params = {
816
+ "version" => @version
817
+ }
818
+ data = {
819
+ "expansions" => expansions
820
+ }
821
+ method_url = "/v1/environments/%s/collections/%s/expansions" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
822
+ response = request(
823
+ method: "POST",
824
+ url: method_url,
825
+ headers: headers,
826
+ params: params,
827
+ json: data,
828
+ accept_json: true
829
+ )
830
+ response
831
+ end
832
+
833
+ ##
834
+ # @!method delete_expansions(environment_id:, collection_id:)
835
+ # Delete the expansion list.
836
+ # Remove the expansion information for this collection. The expansion list must be
837
+ # deleted to disable query expansion for a collection.
838
+ # @param environment_id [String] The ID of the environment.
839
+ # @param collection_id [String] The ID of the collection.
840
+ # @return [nil]
841
+ def delete_expansions(environment_id:, collection_id:)
842
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
843
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
844
+ headers = {
845
+ }
846
+ params = {
847
+ "version" => @version
848
+ }
849
+ method_url = "/v1/environments/%s/collections/%s/expansions" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
850
+ request(
851
+ method: "DELETE",
852
+ url: method_url,
853
+ headers: headers,
854
+ params: params,
855
+ accept_json: true
856
+ )
857
+ nil
858
+ end
859
+ #########################
860
+ # Documents
861
+ #########################
862
+
863
+ ##
864
+ # @!method add_document(environment_id:, collection_id:, file: nil, metadata: nil, file_content_type: nil, filename: nil)
865
+ # Add a document.
866
+ # Add a document to a collection with optional metadata.
867
+ #
868
+ # * The **version** query parameter is still required.
869
+ #
870
+ # * Returns immediately after the system has accepted the document for processing.
871
+ #
872
+ # * The user must provide document content, metadata, or both. If the request is
873
+ # missing both document content and metadata, it is rejected.
874
+ #
875
+ # * The user can set the **Content-Type** parameter on the **file** part to
876
+ # indicate the media type of the document. If the **Content-Type** parameter is
877
+ # missing or is one of the generic media types (for example,
878
+ # `application/octet-stream`), then the service attempts to automatically detect the
879
+ # document's media type.
880
+ #
881
+ # * The following field names are reserved and will be filtered out if present
882
+ # after normalization: `id`, `score`, `highlight`, and any field with the prefix of:
883
+ # `_`, `+`, or `-`
884
+ #
885
+ # * Fields with empty name values after normalization are filtered out before
886
+ # indexing.
887
+ #
888
+ # * Fields containing the following characters after normalization are filtered
889
+ # out before indexing: `#` and `,`.
890
+ # @param environment_id [String] The ID of the environment.
891
+ # @param collection_id [String] The ID of the collection.
892
+ # @param file [File] The content of the document to ingest. The maximum supported file size is 50
893
+ # megabytes. Files larger than 50 megabytes is rejected.
894
+ # @param metadata [String] If you're using the Data Crawler to upload your documents, you can test a document
895
+ # against the type of metadata that the Data Crawler might send. The maximum
896
+ # supported metadata file size is 1 MB. Metadata parts larger than 1 MB are
897
+ # rejected.
898
+ # Example: ``` {
899
+ # \"Creator\": \"Johnny Appleseed\",
900
+ # \"Subject\": \"Apples\"
901
+ # } ```.
902
+ # @param file_content_type [String] The content type of file.
903
+ # @param filename [String] The filename for file.
904
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
905
+ def add_document(environment_id:, collection_id:, file: nil, metadata: nil, file_content_type: nil, filename: nil)
906
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
907
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
908
+ headers = {
909
+ }
910
+ params = {
911
+ "version" => @version
912
+ }
913
+ unless file.nil?
914
+ mime_type = file_content_type.nil? ? "application/octet-stream" : file_content_type
915
+ unless file.instance_of?(StringIO) || file.instance_of?(File)
916
+ file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
917
+ end
918
+ if filename
919
+ file = file.instance_of?(StringIO) ? HTTP::FormData::File.new(file, content_type: mime_type, filename: filename) : HTTP::FormData::File.new(file.path, content_type: mime_type, filename: filename)
920
+ else
921
+ file = file.instance_of?(StringIO) ? HTTP::FormData::File.new(file, content_type: mime_type) : HTTP::FormData::File.new(file.path, content_type: mime_type)
922
+ end
923
+ end
924
+ method_url = "/v1/environments/%s/collections/%s/documents" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
925
+ response = request(
926
+ method: "POST",
927
+ url: method_url,
928
+ headers: headers,
929
+ params: params,
930
+ form: {
931
+ file: file,
932
+ metadata: metadata
933
+ },
934
+ accept_json: true
935
+ )
936
+ response
937
+ end
938
+
939
+ ##
940
+ # @!method get_document_status(environment_id:, collection_id:, document_id:)
941
+ # Get document details.
942
+ # Fetch status details about a submitted document. **Note:** this operation does not
943
+ # return the document itself. Instead, it returns only the document's processing
944
+ # status and any notices (warnings or errors) that were generated when the document
945
+ # was ingested. Use the query API to retrieve the actual document content.
946
+ # @param environment_id [String] The ID of the environment.
947
+ # @param collection_id [String] The ID of the collection.
948
+ # @param document_id [String] The ID of the document.
949
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
950
+ def get_document_status(environment_id:, collection_id:, document_id:)
951
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
952
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
953
+ raise ArgumentError("document_id must be provided") if document_id.nil?
954
+ headers = {
955
+ }
956
+ params = {
957
+ "version" => @version
958
+ }
959
+ method_url = "/v1/environments/%s/collections/%s/documents/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id), ERB::Util.url_encode(document_id)]
960
+ response = request(
961
+ method: "GET",
962
+ url: method_url,
963
+ headers: headers,
964
+ params: params,
965
+ accept_json: true
966
+ )
967
+ response
968
+ end
969
+
970
+ ##
971
+ # @!method update_document(environment_id:, collection_id:, document_id:, file: nil, metadata: nil, file_content_type: nil, filename: nil)
972
+ # Update a document.
973
+ # Replace an existing document. Starts ingesting a document with optional metadata.
974
+ # @param environment_id [String] The ID of the environment.
975
+ # @param collection_id [String] The ID of the collection.
976
+ # @param document_id [String] The ID of the document.
977
+ # @param file [File] The content of the document to ingest. The maximum supported file size is 50
978
+ # megabytes. Files larger than 50 megabytes is rejected.
979
+ # @param metadata [String] If you're using the Data Crawler to upload your documents, you can test a document
980
+ # against the type of metadata that the Data Crawler might send. The maximum
981
+ # supported metadata file size is 1 MB. Metadata parts larger than 1 MB are
982
+ # rejected.
983
+ # Example: ``` {
984
+ # \"Creator\": \"Johnny Appleseed\",
985
+ # \"Subject\": \"Apples\"
986
+ # } ```.
987
+ # @param file_content_type [String] The content type of file.
988
+ # @param filename [String] The filename for file.
989
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
990
+ def update_document(environment_id:, collection_id:, document_id:, file: nil, metadata: nil, file_content_type: nil, filename: nil)
991
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
992
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
993
+ raise ArgumentError("document_id must be provided") if document_id.nil?
994
+ headers = {
995
+ }
996
+ params = {
997
+ "version" => @version
998
+ }
999
+ unless file.nil?
1000
+ mime_type = file_content_type.nil? ? "application/octet-stream" : file_content_type
1001
+ unless file.instance_of?(StringIO) || file.instance_of?(File)
1002
+ file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
1003
+ end
1004
+ if filename
1005
+ file = file.instance_of?(StringIO) ? HTTP::FormData::File.new(file, content_type: mime_type, filename: filename) : HTTP::FormData::File.new(file.path, content_type: mime_type, filename: filename)
1006
+ else
1007
+ file = file.instance_of?(StringIO) ? HTTP::FormData::File.new(file, content_type: mime_type) : HTTP::FormData::File.new(file.path, content_type: mime_type)
1008
+ end
1009
+ end
1010
+ method_url = "/v1/environments/%s/collections/%s/documents/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id), ERB::Util.url_encode(document_id)]
1011
+ response = request(
1012
+ method: "POST",
1013
+ url: method_url,
1014
+ headers: headers,
1015
+ params: params,
1016
+ form: {
1017
+ file: file,
1018
+ metadata: metadata
1019
+ },
1020
+ accept_json: true
1021
+ )
1022
+ response
1023
+ end
1024
+
1025
+ ##
1026
+ # @!method delete_document(environment_id:, collection_id:, document_id:)
1027
+ # Delete a document.
1028
+ # If the given document ID is invalid, or if the document is not found, then the a
1029
+ # success response is returned (HTTP status code `200`) with the status set to
1030
+ # 'deleted'.
1031
+ # @param environment_id [String] The ID of the environment.
1032
+ # @param collection_id [String] The ID of the collection.
1033
+ # @param document_id [String] The ID of the document.
1034
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1035
+ def delete_document(environment_id:, collection_id:, document_id:)
1036
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1037
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
1038
+ raise ArgumentError("document_id must be provided") if document_id.nil?
1039
+ headers = {
1040
+ }
1041
+ params = {
1042
+ "version" => @version
1043
+ }
1044
+ method_url = "/v1/environments/%s/collections/%s/documents/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id), ERB::Util.url_encode(document_id)]
1045
+ response = request(
1046
+ method: "DELETE",
1047
+ url: method_url,
1048
+ headers: headers,
1049
+ params: params,
1050
+ accept_json: true
1051
+ )
1052
+ response
1053
+ end
1054
+ #########################
1055
+ # Queries
1056
+ #########################
1057
+
1058
+ ##
1059
+ # @!method query(environment_id:, collection_id:, filter: nil, query: nil, natural_language_query: nil, passages: nil, aggregation: nil, count: nil, return_fields: nil, offset: nil, sort: nil, highlight: nil, passages_fields: nil, passages_count: nil, passages_characters: nil, deduplicate: nil, deduplicate_field: nil, similar: nil, similar_document_ids: nil, similar_fields: nil)
1060
+ # Query your collection.
1061
+ # After your content is uploaded and enriched by the Discovery service, you can
1062
+ # build queries to search your content. For details, see the [Discovery service
1063
+ # documentation](https://console.bluemix.net/docs/services/discovery/using.html).
1064
+ # @param environment_id [String] The ID of the environment.
1065
+ # @param collection_id [String] The ID of the collection.
1066
+ # @param filter [String] A cacheable query that limits the documents returned to exclude any documents that
1067
+ # don't mention the query content. Filter searches are better for metadata type
1068
+ # searches and when you are trying to get a sense of concepts in the data set.
1069
+ # @param query [String] A query search returns all documents in your data set with full enrichments and
1070
+ # full text, but with the most relevant documents listed first. Use a query search
1071
+ # when you want to find the most relevant search results. You cannot use
1072
+ # **natural_language_query** and **query** at the same time.
1073
+ # @param natural_language_query [String] A natural language query that returns relevant documents by utilizing training
1074
+ # data and natural language understanding. You cannot use **natural_language_query**
1075
+ # and **query** at the same time.
1076
+ # @param passages [Boolean] A passages query that returns the most relevant passages from the results.
1077
+ # @param aggregation [String] An aggregation search uses combinations of filters and query search to return an
1078
+ # exact answer. Aggregations are useful for building applications, because you can
1079
+ # use them to build lists, tables, and time series. For a full list of possible
1080
+ # aggregrations, see the Query reference.
1081
+ # @param count [Fixnum] Number of documents to return.
1082
+ # @param return_fields [Array[String]] A comma separated list of the portion of the document hierarchy to return.
1083
+ # @param offset [Fixnum] The number of query results to skip at the beginning. For example, if the total
1084
+ # number of results that are returned is 10, and the offset is 8, it returns the
1085
+ # last two results.
1086
+ # @param sort [Array[String]] A comma separated list of fields in the document to sort on. You can optionally
1087
+ # specify a sort direction by prefixing the field with `-` for descending or `+` for
1088
+ # ascending. Ascending is the default sort direction if no prefix is specified.
1089
+ # @param highlight [Boolean] When true a highlight field is returned for each result which contains the fields
1090
+ # that match the query with `<em></em>` tags around the matching query terms.
1091
+ # Defaults to false.
1092
+ # @param passages_fields [Array[String]] A comma-separated list of fields that passages are drawn from. If this parameter
1093
+ # not specified, then all top-level fields are included.
1094
+ # @param passages_count [Fixnum] The maximum number of passages to return. The search returns fewer passages if the
1095
+ # requested total is not found. The default is `10`. The maximum is `100`.
1096
+ # @param passages_characters [Fixnum] The approximate number of characters that any one passage will have. The default
1097
+ # is `400`. The minimum is `50`. The maximum is `2000`.
1098
+ # @param deduplicate [Boolean] When `true` and used with a Watson Discovery News collection, duplicate results
1099
+ # (based on the contents of the **title** field) are removed. Duplicate comparison
1100
+ # is limited to the current query only; **offset** is not considered. This parameter
1101
+ # is currently Beta functionality.
1102
+ # @param deduplicate_field [String] When specified, duplicate results based on the field specified are removed from
1103
+ # the returned results. Duplicate comparison is limited to the current query only,
1104
+ # **offset** is not considered. This parameter is currently Beta functionality.
1105
+ # @param similar [Boolean] When `true`, results are returned based on their similarity to the document IDs
1106
+ # specified in the **similar.document_ids** parameter.
1107
+ # @param similar_document_ids [Array[String]] A comma-separated list of document IDs that will be used to find similar
1108
+ # documents.
1109
+ #
1110
+ # **Note:** If the **natural_language_query** parameter is also specified, it will
1111
+ # be used to expand the scope of the document similarity search to include the
1112
+ # natural language query. Other query parameters, such as **filter** and **query**
1113
+ # are subsequently applied and reduce the query scope.
1114
+ # @param similar_fields [Array[String]] A comma-separated list of field names that will be used as a basis for comparison
1115
+ # to identify similar documents. If not specified, the entire document is used for
1116
+ # comparison.
1117
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1118
+ def query(environment_id:, collection_id:, filter: nil, query: nil, natural_language_query: nil, passages: nil, aggregation: nil, count: nil, return_fields: nil, offset: nil, sort: nil, highlight: nil, passages_fields: nil, passages_count: nil, passages_characters: nil, deduplicate: nil, deduplicate_field: nil, similar: nil, similar_document_ids: nil, similar_fields: nil)
1119
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1120
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
1121
+ headers = {
1122
+ }
1123
+ params = {
1124
+ "version" => @version,
1125
+ "filter" => filter,
1126
+ "query" => query,
1127
+ "natural_language_query" => natural_language_query,
1128
+ "passages" => passages,
1129
+ "aggregation" => aggregation,
1130
+ "count" => count,
1131
+ "return" => return_fields.to_a,
1132
+ "offset" => offset,
1133
+ "sort" => sort.to_a,
1134
+ "highlight" => highlight,
1135
+ "passages.fields" => passages_fields.to_a,
1136
+ "passages.count" => passages_count,
1137
+ "passages.characters" => passages_characters,
1138
+ "deduplicate" => deduplicate,
1139
+ "deduplicate.field" => deduplicate_field,
1140
+ "similar" => similar,
1141
+ "similar.document_ids" => similar_document_ids.to_a,
1142
+ "similar.fields" => similar_fields.to_a
1143
+ }
1144
+ method_url = "/v1/environments/%s/collections/%s/query" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
1145
+ response = request(
1146
+ method: "GET",
1147
+ url: method_url,
1148
+ headers: headers,
1149
+ params: params,
1150
+ accept_json: true
1151
+ )
1152
+ response
1153
+ end
1154
+
1155
+ ##
1156
+ # @!method query_notices(environment_id:, collection_id:, filter: nil, query: nil, natural_language_query: nil, passages: nil, aggregation: nil, count: nil, return_fields: nil, offset: nil, sort: nil, highlight: nil, passages_fields: nil, passages_count: nil, passages_characters: nil, deduplicate_field: nil, similar: nil, similar_document_ids: nil, similar_fields: nil)
1157
+ # Query system notices.
1158
+ # Queries for notices (errors or warnings) that might have been generated by the
1159
+ # system. Notices are generated when ingesting documents and performing relevance
1160
+ # training. See the [Discovery service
1161
+ # documentation](https://console.bluemix.net/docs/services/discovery/using.html) for
1162
+ # more details on the query language.
1163
+ # @param environment_id [String] The ID of the environment.
1164
+ # @param collection_id [String] The ID of the collection.
1165
+ # @param filter [String] A cacheable query that limits the documents returned to exclude any documents that
1166
+ # don't mention the query content. Filter searches are better for metadata type
1167
+ # searches and when you are trying to get a sense of concepts in the data set.
1168
+ # @param query [String] A query search returns all documents in your data set with full enrichments and
1169
+ # full text, but with the most relevant documents listed first. Use a query search
1170
+ # when you want to find the most relevant search results. You cannot use
1171
+ # **natural_language_query** and **query** at the same time.
1172
+ # @param natural_language_query [String] A natural language query that returns relevant documents by utilizing training
1173
+ # data and natural language understanding. You cannot use **natural_language_query**
1174
+ # and **query** at the same time.
1175
+ # @param passages [Boolean] A passages query that returns the most relevant passages from the results.
1176
+ # @param aggregation [String] An aggregation search uses combinations of filters and query search to return an
1177
+ # exact answer. Aggregations are useful for building applications, because you can
1178
+ # use them to build lists, tables, and time series. For a full list of possible
1179
+ # aggregrations, see the Query reference.
1180
+ # @param count [Fixnum] Number of documents to return.
1181
+ # @param return_fields [Array[String]] A comma separated list of the portion of the document hierarchy to return.
1182
+ # @param offset [Fixnum] The number of query results to skip at the beginning. For example, if the total
1183
+ # number of results that are returned is 10, and the offset is 8, it returns the
1184
+ # last two results.
1185
+ # @param sort [Array[String]] A comma separated list of fields in the document to sort on. You can optionally
1186
+ # specify a sort direction by prefixing the field with `-` for descending or `+` for
1187
+ # ascending. Ascending is the default sort direction if no prefix is specified.
1188
+ # @param highlight [Boolean] When true a highlight field is returned for each result which contains the fields
1189
+ # that match the query with `<em></em>` tags around the matching query terms.
1190
+ # Defaults to false.
1191
+ # @param passages_fields [Array[String]] A comma-separated list of fields that passages are drawn from. If this parameter
1192
+ # not specified, then all top-level fields are included.
1193
+ # @param passages_count [Fixnum] The maximum number of passages to return. The search returns fewer passages if the
1194
+ # requested total is not found. The default is `10`. The maximum is `100`.
1195
+ # @param passages_characters [Fixnum] The approximate number of characters that any one passage will have. The default
1196
+ # is `400`. The minimum is `50`. The maximum is `2000`.
1197
+ # @param deduplicate_field [String] When specified, duplicate results based on the field specified are removed from
1198
+ # the returned results. Duplicate comparison is limited to the current query only,
1199
+ # **offset** is not considered. This parameter is currently Beta functionality.
1200
+ # @param similar [Boolean] When `true`, results are returned based on their similarity to the document IDs
1201
+ # specified in the **similar.document_ids** parameter.
1202
+ # @param similar_document_ids [Array[String]] A comma-separated list of document IDs that will be used to find similar
1203
+ # documents.
1204
+ #
1205
+ # **Note:** If the **natural_language_query** parameter is also specified, it will
1206
+ # be used to expand the scope of the document similarity search to include the
1207
+ # natural language query. Other query parameters, such as **filter** and **query**
1208
+ # are subsequently applied and reduce the query scope.
1209
+ # @param similar_fields [Array[String]] A comma-separated list of field names that will be used as a basis for comparison
1210
+ # to identify similar documents. If not specified, the entire document is used for
1211
+ # comparison.
1212
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1213
+ def query_notices(environment_id:, collection_id:, filter: nil, query: nil, natural_language_query: nil, passages: nil, aggregation: nil, count: nil, return_fields: nil, offset: nil, sort: nil, highlight: nil, passages_fields: nil, passages_count: nil, passages_characters: nil, deduplicate_field: nil, similar: nil, similar_document_ids: nil, similar_fields: nil)
1214
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1215
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
1216
+ headers = {
1217
+ }
1218
+ params = {
1219
+ "version" => @version,
1220
+ "filter" => filter,
1221
+ "query" => query,
1222
+ "natural_language_query" => natural_language_query,
1223
+ "passages" => passages,
1224
+ "aggregation" => aggregation,
1225
+ "count" => count,
1226
+ "return_fields" => return_fields.to_a,
1227
+ "offset" => offset,
1228
+ "sort" => sort.to_a,
1229
+ "highlight" => highlight,
1230
+ "passages.fields" => passages_fields.to_a,
1231
+ "passages.count" => passages_count,
1232
+ "passages.characters" => passages_characters,
1233
+ "deduplicate.field" => deduplicate_field,
1234
+ "similar" => similar,
1235
+ "similar.document_ids" => similar_document_ids.to_a,
1236
+ "similar.fields" => similar_fields.to_a
1237
+ }
1238
+ method_url = "/v1/environments/%s/collections/%s/notices" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
1239
+ response = request(
1240
+ method: "GET",
1241
+ url: method_url,
1242
+ headers: headers,
1243
+ params: params,
1244
+ accept_json: true
1245
+ )
1246
+ response
1247
+ end
1248
+
1249
+ ##
1250
+ # @!method federated_query(environment_id:, collection_ids:, filter: nil, query: nil, natural_language_query: nil, aggregation: nil, count: nil, return_fields: nil, offset: nil, sort: nil, highlight: nil, deduplicate: nil, deduplicate_field: nil, similar: nil, similar_document_ids: nil, similar_fields: nil, passages: nil, passages_fields: nil, passages_count: nil, passages_characters: nil)
1251
+ # Query documents in multiple collections.
1252
+ # See the [Discovery service
1253
+ # documentation](https://console.bluemix.net/docs/services/discovery/using.html) for
1254
+ # more details.
1255
+ # @param environment_id [String] The ID of the environment.
1256
+ # @param collection_ids [Array[String]] A comma-separated list of collection IDs to be queried against.
1257
+ # @param filter [String] A cacheable query that limits the documents returned to exclude any documents that
1258
+ # don't mention the query content. Filter searches are better for metadata type
1259
+ # searches and when you are trying to get a sense of concepts in the data set.
1260
+ # @param query [String] A query search returns all documents in your data set with full enrichments and
1261
+ # full text, but with the most relevant documents listed first. Use a query search
1262
+ # when you want to find the most relevant search results. You cannot use
1263
+ # **natural_language_query** and **query** at the same time.
1264
+ # @param natural_language_query [String] A natural language query that returns relevant documents by utilizing training
1265
+ # data and natural language understanding. You cannot use **natural_language_query**
1266
+ # and **query** at the same time.
1267
+ # @param aggregation [String] An aggregation search uses combinations of filters and query search to return an
1268
+ # exact answer. Aggregations are useful for building applications, because you can
1269
+ # use them to build lists, tables, and time series. For a full list of possible
1270
+ # aggregrations, see the Query reference.
1271
+ # @param count [Fixnum] Number of documents to return.
1272
+ # @param return_fields [Array[String]] A comma separated list of the portion of the document hierarchy to return.
1273
+ # @param offset [Fixnum] The number of query results to skip at the beginning. For example, if the total
1274
+ # number of results that are returned is 10, and the offset is 8, it returns the
1275
+ # last two results.
1276
+ # @param sort [Array[String]] A comma separated list of fields in the document to sort on. You can optionally
1277
+ # specify a sort direction by prefixing the field with `-` for descending or `+` for
1278
+ # ascending. Ascending is the default sort direction if no prefix is specified.
1279
+ # @param highlight [Boolean] When true a highlight field is returned for each result which contains the fields
1280
+ # that match the query with `<em></em>` tags around the matching query terms.
1281
+ # Defaults to false.
1282
+ # @param deduplicate [Boolean] When `true` and used with a Watson Discovery News collection, duplicate results
1283
+ # (based on the contents of the **title** field) are removed. Duplicate comparison
1284
+ # is limited to the current query only; **offset** is not considered. This parameter
1285
+ # is currently Beta functionality.
1286
+ # @param deduplicate_field [String] When specified, duplicate results based on the field specified are removed from
1287
+ # the returned results. Duplicate comparison is limited to the current query only,
1288
+ # **offset** is not considered. This parameter is currently Beta functionality.
1289
+ # @param similar [Boolean] When `true`, results are returned based on their similarity to the document IDs
1290
+ # specified in the **similar.document_ids** parameter.
1291
+ # @param similar_document_ids [Array[String]] A comma-separated list of document IDs that will be used to find similar
1292
+ # documents.
1293
+ #
1294
+ # **Note:** If the **natural_language_query** parameter is also specified, it will
1295
+ # be used to expand the scope of the document similarity search to include the
1296
+ # natural language query. Other query parameters, such as **filter** and **query**
1297
+ # are subsequently applied and reduce the query scope.
1298
+ # @param similar_fields [Array[String]] A comma-separated list of field names that will be used as a basis for comparison
1299
+ # to identify similar documents. If not specified, the entire document is used for
1300
+ # comparison.
1301
+ # @param passages [Boolean] A passages query that returns the most relevant passages from the results.
1302
+ # @param passages_fields [Array[String]] A comma-separated list of fields that passages are drawn from. If this parameter
1303
+ # not specified, then all top-level fields are included.
1304
+ # @param passages_count [Fixnum] The maximum number of passages to return. The search returns fewer passages if the
1305
+ # requested total is not found. The default is `10`. The maximum is `100`.
1306
+ # @param passages_characters [Fixnum] The approximate number of characters that any one passage will have. The default
1307
+ # is `400`. The minimum is `50`. The maximum is `2000`.
1308
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1309
+ def federated_query(environment_id:, collection_ids:, filter: nil, query: nil, natural_language_query: nil, aggregation: nil, count: nil, return_fields: nil, offset: nil, sort: nil, highlight: nil, deduplicate: nil, deduplicate_field: nil, similar: nil, similar_document_ids: nil, similar_fields: nil, passages: nil, passages_fields: nil, passages_count: nil, passages_characters: nil)
1310
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1311
+ raise ArgumentError("collection_ids must be provided") if collection_ids.nil?
1312
+ headers = {
1313
+ }
1314
+ params = {
1315
+ "version" => @version,
1316
+ "collection_ids" => collection_ids.to_a,
1317
+ "filter" => filter,
1318
+ "query" => query,
1319
+ "natural_language_query" => natural_language_query,
1320
+ "aggregation" => aggregation,
1321
+ "count" => count,
1322
+ "return_fields" => return_fields.to_a,
1323
+ "offset" => offset,
1324
+ "sort" => sort.to_a,
1325
+ "highlight" => highlight,
1326
+ "deduplicate" => deduplicate,
1327
+ "deduplicate.field" => deduplicate_field,
1328
+ "similar" => similar,
1329
+ "similar.document_ids" => similar_document_ids.to_a,
1330
+ "similar.fields" => similar_fields.to_a,
1331
+ "passages" => passages,
1332
+ "passages.fields" => passages_fields.to_a,
1333
+ "passages.count" => passages_count,
1334
+ "passages.characters" => passages_characters
1335
+ }
1336
+ method_url = "/v1/environments/%s/query" % [ERB::Util.url_encode(environment_id)]
1337
+ response = request(
1338
+ method: "GET",
1339
+ url: method_url,
1340
+ headers: headers,
1341
+ params: params,
1342
+ accept_json: true
1343
+ )
1344
+ response
1345
+ end
1346
+
1347
+ ##
1348
+ # @!method federated_query_notices(environment_id:, collection_ids:, filter: nil, query: nil, natural_language_query: nil, aggregation: nil, count: nil, return_fields: nil, offset: nil, sort: nil, highlight: nil, deduplicate_field: nil, similar: nil, similar_document_ids: nil, similar_fields: nil)
1349
+ # Query multiple collection system notices.
1350
+ # Queries for notices (errors or warnings) that might have been generated by the
1351
+ # system. Notices are generated when ingesting documents and performing relevance
1352
+ # training. See the [Discovery service
1353
+ # documentation](https://console.bluemix.net/docs/services/discovery/using.html) for
1354
+ # more details on the query language.
1355
+ # @param environment_id [String] The ID of the environment.
1356
+ # @param collection_ids [Array[String]] A comma-separated list of collection IDs to be queried against.
1357
+ # @param filter [String] A cacheable query that limits the documents returned to exclude any documents that
1358
+ # don't mention the query content. Filter searches are better for metadata type
1359
+ # searches and when you are trying to get a sense of concepts in the data set.
1360
+ # @param query [String] A query search returns all documents in your data set with full enrichments and
1361
+ # full text, but with the most relevant documents listed first. Use a query search
1362
+ # when you want to find the most relevant search results. You cannot use
1363
+ # **natural_language_query** and **query** at the same time.
1364
+ # @param natural_language_query [String] A natural language query that returns relevant documents by utilizing training
1365
+ # data and natural language understanding. You cannot use **natural_language_query**
1366
+ # and **query** at the same time.
1367
+ # @param aggregation [String] An aggregation search uses combinations of filters and query search to return an
1368
+ # exact answer. Aggregations are useful for building applications, because you can
1369
+ # use them to build lists, tables, and time series. For a full list of possible
1370
+ # aggregrations, see the Query reference.
1371
+ # @param count [Fixnum] Number of documents to return.
1372
+ # @param return_fields [Array[String]] A comma separated list of the portion of the document hierarchy to return.
1373
+ # @param offset [Fixnum] The number of query results to skip at the beginning. For example, if the total
1374
+ # number of results that are returned is 10, and the offset is 8, it returns the
1375
+ # last two results.
1376
+ # @param sort [Array[String]] A comma separated list of fields in the document to sort on. You can optionally
1377
+ # specify a sort direction by prefixing the field with `-` for descending or `+` for
1378
+ # ascending. Ascending is the default sort direction if no prefix is specified.
1379
+ # @param highlight [Boolean] When true a highlight field is returned for each result which contains the fields
1380
+ # that match the query with `<em></em>` tags around the matching query terms.
1381
+ # Defaults to false.
1382
+ # @param deduplicate_field [String] When specified, duplicate results based on the field specified are removed from
1383
+ # the returned results. Duplicate comparison is limited to the current query only,
1384
+ # **offset** is not considered. This parameter is currently Beta functionality.
1385
+ # @param similar [Boolean] When `true`, results are returned based on their similarity to the document IDs
1386
+ # specified in the **similar.document_ids** parameter.
1387
+ # @param similar_document_ids [Array[String]] A comma-separated list of document IDs that will be used to find similar
1388
+ # documents.
1389
+ #
1390
+ # **Note:** If the **natural_language_query** parameter is also specified, it will
1391
+ # be used to expand the scope of the document similarity search to include the
1392
+ # natural language query. Other query parameters, such as **filter** and **query**
1393
+ # are subsequently applied and reduce the query scope.
1394
+ # @param similar_fields [Array[String]] A comma-separated list of field names that will be used as a basis for comparison
1395
+ # to identify similar documents. If not specified, the entire document is used for
1396
+ # comparison.
1397
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1398
+ def federated_query_notices(environment_id:, collection_ids:, filter: nil, query: nil, natural_language_query: nil, aggregation: nil, count: nil, return_fields: nil, offset: nil, sort: nil, highlight: nil, deduplicate_field: nil, similar: nil, similar_document_ids: nil, similar_fields: nil)
1399
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1400
+ raise ArgumentError("collection_ids must be provided") if collection_ids.nil?
1401
+ headers = {
1402
+ }
1403
+ params = {
1404
+ "version" => @version,
1405
+ "collection_ids" => collection_ids.to_a,
1406
+ "filter" => filter,
1407
+ "query" => query,
1408
+ "natural_language_query" => natural_language_query,
1409
+ "aggregation" => aggregation,
1410
+ "count" => count,
1411
+ "return_fields" => return_fields.to_a,
1412
+ "offset" => offset,
1413
+ "sort" => sort.to_a,
1414
+ "highlight" => highlight,
1415
+ "deduplicate.field" => deduplicate_field,
1416
+ "similar" => similar,
1417
+ "similar.document_ids" => similar_document_ids.to_a,
1418
+ "similar.fields" => similar_fields.to_a
1419
+ }
1420
+ method_url = "/v1/environments/%s/notices" % [ERB::Util.url_encode(environment_id)]
1421
+ response = request(
1422
+ method: "GET",
1423
+ url: method_url,
1424
+ headers: headers,
1425
+ params: params,
1426
+ accept_json: true
1427
+ )
1428
+ response
1429
+ end
1430
+
1431
+ ##
1432
+ # @!method query_entities(environment_id:, collection_id:, feature: nil, entity: nil, context: nil, count: nil, evidence_count: nil)
1433
+ # Knowledge Graph entity query.
1434
+ # See the [Knowledge Graph
1435
+ # documentation](https://console.bluemix.net/docs/services/discovery/building-kg.html)
1436
+ # for more details.
1437
+ # @param environment_id [String] The ID of the environment.
1438
+ # @param collection_id [String] The ID of the collection.
1439
+ # @param feature [String] The entity query feature to perform. Supported features are `disambiguate` and
1440
+ # `similar_entities`.
1441
+ # @param entity [QueryEntitiesEntity] A text string that appears within the entity text field.
1442
+ # @param context [QueryEntitiesContext] Entity text to provide context for the queried entity and rank based on that
1443
+ # association. For example, if you wanted to query the city of London in England
1444
+ # your query would look for `London` with the context of `England`.
1445
+ # @param count [Fixnum] The number of results to return. The default is `10`. The maximum is `1000`.
1446
+ # @param evidence_count [Fixnum] The number of evidence items to return for each result. The default is `0`. The
1447
+ # maximum number of evidence items per query is 10,000.
1448
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1449
+ def query_entities(environment_id:, collection_id:, feature: nil, entity: nil, context: nil, count: nil, evidence_count: nil)
1450
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1451
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
1452
+ headers = {
1453
+ }
1454
+ params = {
1455
+ "version" => @version
1456
+ }
1457
+ data = {
1458
+ "feature" => feature,
1459
+ "entity" => entity,
1460
+ "context" => context,
1461
+ "count" => count,
1462
+ "evidence_count" => evidence_count
1463
+ }
1464
+ method_url = "/v1/environments/%s/collections/%s/query_entities" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
1465
+ response = request(
1466
+ method: "POST",
1467
+ url: method_url,
1468
+ headers: headers,
1469
+ params: params,
1470
+ json: data,
1471
+ accept_json: true
1472
+ )
1473
+ response
1474
+ end
1475
+
1476
+ ##
1477
+ # @!method query_relations(environment_id:, collection_id:, entities: nil, context: nil, sort: nil, filter: nil, count: nil, evidence_count: nil)
1478
+ # Knowledge Graph relationship query.
1479
+ # See the [Knowledge Graph
1480
+ # documentation](https://console.bluemix.net/docs/services/discovery/building-kg.html)
1481
+ # for more details.
1482
+ # @param environment_id [String] The ID of the environment.
1483
+ # @param collection_id [String] The ID of the collection.
1484
+ # @param entities [Array[QueryRelationsEntity]] An array of entities to find relationships for.
1485
+ # @param context [QueryEntitiesContext] Entity text to provide context for the queried entity and rank based on that
1486
+ # association. For example, if you wanted to query the city of London in England
1487
+ # your query would look for `London` with the context of `England`.
1488
+ # @param sort [String] The sorting method for the relationships, can be `score` or `frequency`.
1489
+ # `frequency` is the number of unique times each entity is identified. The default
1490
+ # is `score`.
1491
+ # @param filter [QueryRelationsFilter] Filters to apply to the relationship query.
1492
+ # @param count [Fixnum] The number of results to return. The default is `10`. The maximum is `1000`.
1493
+ # @param evidence_count [Fixnum] The number of evidence items to return for each result. The default is `0`. The
1494
+ # maximum number of evidence items per query is 10,000.
1495
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1496
+ def query_relations(environment_id:, collection_id:, entities: nil, context: nil, sort: nil, filter: nil, count: nil, evidence_count: nil)
1497
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1498
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
1499
+ headers = {
1500
+ }
1501
+ params = {
1502
+ "version" => @version
1503
+ }
1504
+ data = {
1505
+ "entities" => entities,
1506
+ "context" => context,
1507
+ "sort" => sort,
1508
+ "filter" => filter,
1509
+ "count" => count,
1510
+ "evidence_count" => evidence_count
1511
+ }
1512
+ method_url = "/v1/environments/%s/collections/%s/query_relations" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
1513
+ response = request(
1514
+ method: "POST",
1515
+ url: method_url,
1516
+ headers: headers,
1517
+ params: params,
1518
+ json: data,
1519
+ accept_json: true
1520
+ )
1521
+ response
1522
+ end
1523
+ #########################
1524
+ # Training data
1525
+ #########################
1526
+
1527
+ ##
1528
+ # @!method list_training_data(environment_id:, collection_id:)
1529
+ # List training data.
1530
+ # Lists the training data for the specified collection.
1531
+ # @param environment_id [String] The ID of the environment.
1532
+ # @param collection_id [String] The ID of the collection.
1533
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1534
+ def list_training_data(environment_id:, collection_id:)
1535
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1536
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
1537
+ headers = {
1538
+ }
1539
+ params = {
1540
+ "version" => @version
1541
+ }
1542
+ method_url = "/v1/environments/%s/collections/%s/training_data" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
1543
+ response = request(
1544
+ method: "GET",
1545
+ url: method_url,
1546
+ headers: headers,
1547
+ params: params,
1548
+ accept_json: true
1549
+ )
1550
+ response
1551
+ end
1552
+
1553
+ ##
1554
+ # @!method add_training_data(environment_id:, collection_id:, natural_language_query: nil, filter: nil, examples: nil)
1555
+ # Add query to training data.
1556
+ # Adds a query to the training data for this collection. The query can contain a
1557
+ # filter and natural language query.
1558
+ # @param environment_id [String] The ID of the environment.
1559
+ # @param collection_id [String] The ID of the collection.
1560
+ # @param natural_language_query [String]
1561
+ # @param filter [String]
1562
+ # @param examples [Array[TrainingExample]]
1563
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1564
+ def add_training_data(environment_id:, collection_id:, natural_language_query: nil, filter: nil, examples: nil)
1565
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1566
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
1567
+ headers = {
1568
+ }
1569
+ params = {
1570
+ "version" => @version
1571
+ }
1572
+ data = {
1573
+ "natural_language_query" => natural_language_query,
1574
+ "filter" => filter,
1575
+ "examples" => examples
1576
+ }
1577
+ method_url = "/v1/environments/%s/collections/%s/training_data" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
1578
+ response = request(
1579
+ method: "POST",
1580
+ url: method_url,
1581
+ headers: headers,
1582
+ params: params,
1583
+ json: data,
1584
+ accept_json: true
1585
+ )
1586
+ response
1587
+ end
1588
+
1589
+ ##
1590
+ # @!method delete_all_training_data(environment_id:, collection_id:)
1591
+ # Delete all training data.
1592
+ # Deletes all training data from a collection.
1593
+ # @param environment_id [String] The ID of the environment.
1594
+ # @param collection_id [String] The ID of the collection.
1595
+ # @return [nil]
1596
+ def delete_all_training_data(environment_id:, collection_id:)
1597
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1598
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
1599
+ headers = {
1600
+ }
1601
+ params = {
1602
+ "version" => @version
1603
+ }
1604
+ method_url = "/v1/environments/%s/collections/%s/training_data" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
1605
+ request(
1606
+ method: "DELETE",
1607
+ url: method_url,
1608
+ headers: headers,
1609
+ params: params,
1610
+ accept_json: true
1611
+ )
1612
+ nil
1613
+ end
1614
+
1615
+ ##
1616
+ # @!method get_training_data(environment_id:, collection_id:, query_id:)
1617
+ # Get details about a query.
1618
+ # Gets details for a specific training data query, including the query string and
1619
+ # all examples.
1620
+ # @param environment_id [String] The ID of the environment.
1621
+ # @param collection_id [String] The ID of the collection.
1622
+ # @param query_id [String] The ID of the query used for training.
1623
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1624
+ def get_training_data(environment_id:, collection_id:, query_id:)
1625
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1626
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
1627
+ raise ArgumentError("query_id must be provided") if query_id.nil?
1628
+ headers = {
1629
+ }
1630
+ params = {
1631
+ "version" => @version
1632
+ }
1633
+ method_url = "/v1/environments/%s/collections/%s/training_data/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id), ERB::Util.url_encode(query_id)]
1634
+ response = request(
1635
+ method: "GET",
1636
+ url: method_url,
1637
+ headers: headers,
1638
+ params: params,
1639
+ accept_json: true
1640
+ )
1641
+ response
1642
+ end
1643
+
1644
+ ##
1645
+ # @!method delete_training_data(environment_id:, collection_id:, query_id:)
1646
+ # Delete a training data query.
1647
+ # Removes the training data query and all associated examples from the training data
1648
+ # set.
1649
+ # @param environment_id [String] The ID of the environment.
1650
+ # @param collection_id [String] The ID of the collection.
1651
+ # @param query_id [String] The ID of the query used for training.
1652
+ # @return [nil]
1653
+ def delete_training_data(environment_id:, collection_id:, query_id:)
1654
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1655
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
1656
+ raise ArgumentError("query_id must be provided") if query_id.nil?
1657
+ headers = {
1658
+ }
1659
+ params = {
1660
+ "version" => @version
1661
+ }
1662
+ method_url = "/v1/environments/%s/collections/%s/training_data/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id), ERB::Util.url_encode(query_id)]
1663
+ request(
1664
+ method: "DELETE",
1665
+ url: method_url,
1666
+ headers: headers,
1667
+ params: params,
1668
+ accept_json: true
1669
+ )
1670
+ nil
1671
+ end
1672
+
1673
+ ##
1674
+ # @!method list_training_examples(environment_id:, collection_id:, query_id:)
1675
+ # List examples for a training data query.
1676
+ # List all examples for this training data query.
1677
+ # @param environment_id [String] The ID of the environment.
1678
+ # @param collection_id [String] The ID of the collection.
1679
+ # @param query_id [String] The ID of the query used for training.
1680
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1681
+ def list_training_examples(environment_id:, collection_id:, query_id:)
1682
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1683
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
1684
+ raise ArgumentError("query_id must be provided") if query_id.nil?
1685
+ headers = {
1686
+ }
1687
+ params = {
1688
+ "version" => @version
1689
+ }
1690
+ method_url = "/v1/environments/%s/collections/%s/training_data/%s/examples" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id), ERB::Util.url_encode(query_id)]
1691
+ response = request(
1692
+ method: "GET",
1693
+ url: method_url,
1694
+ headers: headers,
1695
+ params: params,
1696
+ accept_json: true
1697
+ )
1698
+ response
1699
+ end
1700
+
1701
+ ##
1702
+ # @!method create_training_example(environment_id:, collection_id:, query_id:, document_id: nil, cross_reference: nil, relevance: nil)
1703
+ # Add example to training data query.
1704
+ # Adds a example to this training data query.
1705
+ # @param environment_id [String] The ID of the environment.
1706
+ # @param collection_id [String] The ID of the collection.
1707
+ # @param query_id [String] The ID of the query used for training.
1708
+ # @param document_id [String]
1709
+ # @param cross_reference [String]
1710
+ # @param relevance [Fixnum]
1711
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1712
+ def create_training_example(environment_id:, collection_id:, query_id:, document_id: nil, cross_reference: nil, relevance: nil)
1713
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1714
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
1715
+ raise ArgumentError("query_id must be provided") if query_id.nil?
1716
+ headers = {
1717
+ }
1718
+ params = {
1719
+ "version" => @version
1720
+ }
1721
+ data = {
1722
+ "document_id" => document_id,
1723
+ "cross_reference" => cross_reference,
1724
+ "relevance" => relevance
1725
+ }
1726
+ method_url = "/v1/environments/%s/collections/%s/training_data/%s/examples" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id), ERB::Util.url_encode(query_id)]
1727
+ response = request(
1728
+ method: "POST",
1729
+ url: method_url,
1730
+ headers: headers,
1731
+ params: params,
1732
+ json: data,
1733
+ accept_json: true
1734
+ )
1735
+ response
1736
+ end
1737
+
1738
+ ##
1739
+ # @!method delete_training_example(environment_id:, collection_id:, query_id:, example_id:)
1740
+ # Delete example for training data query.
1741
+ # Deletes the example document with the given ID from the training data query.
1742
+ # @param environment_id [String] The ID of the environment.
1743
+ # @param collection_id [String] The ID of the collection.
1744
+ # @param query_id [String] The ID of the query used for training.
1745
+ # @param example_id [String] The ID of the document as it is indexed.
1746
+ # @return [nil]
1747
+ def delete_training_example(environment_id:, collection_id:, query_id:, example_id:)
1748
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1749
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
1750
+ raise ArgumentError("query_id must be provided") if query_id.nil?
1751
+ raise ArgumentError("example_id must be provided") if example_id.nil?
1752
+ headers = {
1753
+ }
1754
+ params = {
1755
+ "version" => @version
1756
+ }
1757
+ method_url = "/v1/environments/%s/collections/%s/training_data/%s/examples/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id), ERB::Util.url_encode(query_id), ERB::Util.url_encode(example_id)]
1758
+ request(
1759
+ method: "DELETE",
1760
+ url: method_url,
1761
+ headers: headers,
1762
+ params: params,
1763
+ accept_json: true
1764
+ )
1765
+ nil
1766
+ end
1767
+
1768
+ ##
1769
+ # @!method update_training_example(environment_id:, collection_id:, query_id:, example_id:, cross_reference: nil, relevance: nil)
1770
+ # Change label or cross reference for example.
1771
+ # Changes the label or cross reference query for this training data example.
1772
+ # @param environment_id [String] The ID of the environment.
1773
+ # @param collection_id [String] The ID of the collection.
1774
+ # @param query_id [String] The ID of the query used for training.
1775
+ # @param example_id [String] The ID of the document as it is indexed.
1776
+ # @param cross_reference [String]
1777
+ # @param relevance [Fixnum]
1778
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1779
+ def update_training_example(environment_id:, collection_id:, query_id:, example_id:, cross_reference: nil, relevance: nil)
1780
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1781
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
1782
+ raise ArgumentError("query_id must be provided") if query_id.nil?
1783
+ raise ArgumentError("example_id must be provided") if example_id.nil?
1784
+ headers = {
1785
+ }
1786
+ params = {
1787
+ "version" => @version
1788
+ }
1789
+ data = {
1790
+ "cross_reference" => cross_reference,
1791
+ "relevance" => relevance
1792
+ }
1793
+ method_url = "/v1/environments/%s/collections/%s/training_data/%s/examples/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id), ERB::Util.url_encode(query_id), ERB::Util.url_encode(example_id)]
1794
+ response = request(
1795
+ method: "PUT",
1796
+ url: method_url,
1797
+ headers: headers,
1798
+ params: params,
1799
+ json: data,
1800
+ accept_json: true
1801
+ )
1802
+ response
1803
+ end
1804
+
1805
+ ##
1806
+ # @!method get_training_example(environment_id:, collection_id:, query_id:, example_id:)
1807
+ # Get details for training data example.
1808
+ # Gets the details for this training example.
1809
+ # @param environment_id [String] The ID of the environment.
1810
+ # @param collection_id [String] The ID of the collection.
1811
+ # @param query_id [String] The ID of the query used for training.
1812
+ # @param example_id [String] The ID of the document as it is indexed.
1813
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1814
+ def get_training_example(environment_id:, collection_id:, query_id:, example_id:)
1815
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1816
+ raise ArgumentError("collection_id must be provided") if collection_id.nil?
1817
+ raise ArgumentError("query_id must be provided") if query_id.nil?
1818
+ raise ArgumentError("example_id must be provided") if example_id.nil?
1819
+ headers = {
1820
+ }
1821
+ params = {
1822
+ "version" => @version
1823
+ }
1824
+ method_url = "/v1/environments/%s/collections/%s/training_data/%s/examples/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id), ERB::Util.url_encode(query_id), ERB::Util.url_encode(example_id)]
1825
+ response = request(
1826
+ method: "GET",
1827
+ url: method_url,
1828
+ headers: headers,
1829
+ params: params,
1830
+ accept_json: true
1831
+ )
1832
+ response
1833
+ end
1834
+ #########################
1835
+ # User data
1836
+ #########################
1837
+
1838
+ ##
1839
+ # @!method delete_user_data(customer_id:)
1840
+ # Delete labeled data.
1841
+ # Deletes all data associated with a specified customer ID. The method has no effect
1842
+ # if no data is associated with the customer ID.
1843
+ #
1844
+ # You associate a customer ID with data by passing the **X-Watson-Metadata** header
1845
+ # with a request that passes data. For more information about personal data and
1846
+ # customer IDs, see [Information
1847
+ # security](https://console.bluemix.net/docs/services/discovery/information-security.html).
1848
+ # @param customer_id [String] The customer ID for which all data is to be deleted.
1849
+ # @return [nil]
1850
+ def delete_user_data(customer_id:)
1851
+ raise ArgumentError("customer_id must be provided") if customer_id.nil?
1852
+ headers = {
1853
+ }
1854
+ params = {
1855
+ "version" => @version,
1856
+ "customer_id" => customer_id
1857
+ }
1858
+ method_url = "/v1/user_data"
1859
+ request(
1860
+ method: "DELETE",
1861
+ url: method_url,
1862
+ headers: headers,
1863
+ params: params,
1864
+ accept_json: true
1865
+ )
1866
+ nil
1867
+ end
1868
+ #########################
1869
+ # Credentials
1870
+ #########################
1871
+
1872
+ ##
1873
+ # @!method list_credentials(environment_id:)
1874
+ # List credentials.
1875
+ # List all the source credentials that have been created for this service instance.
1876
+ #
1877
+ # **Note:** All credentials are sent over an encrypted connection and encrypted at
1878
+ # rest.
1879
+ # @param environment_id [String] The ID of the environment.
1880
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1881
+ def list_credentials(environment_id:)
1882
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1883
+ headers = {
1884
+ }
1885
+ params = {
1886
+ "version" => @version
1887
+ }
1888
+ method_url = "/v1/environments/%s/credentials" % [ERB::Util.url_encode(environment_id)]
1889
+ response = request(
1890
+ method: "GET",
1891
+ url: method_url,
1892
+ headers: headers,
1893
+ params: params,
1894
+ accept_json: true
1895
+ )
1896
+ response
1897
+ end
1898
+
1899
+ ##
1900
+ # @!method create_credentials(environment_id:, source_type: nil, credential_details: nil)
1901
+ # Create credentials.
1902
+ # Creates a set of credentials to connect to a remote source. Created credentials
1903
+ # are used in a configuration to associate a collection with the remote source.
1904
+ #
1905
+ # **Note:** All credentials are sent over an encrypted connection and encrypted at
1906
+ # rest.
1907
+ # @param environment_id [String] The ID of the environment.
1908
+ # @param source_type [String] The source that this credentials object connects to.
1909
+ # - `box` indicates the credentials are used to connect an instance of Enterprise
1910
+ # Box.
1911
+ # - `salesforce` indicates the credentials are used to connect to Salesforce.
1912
+ # - `sharepoint` indicates the credentials are used to connect to Microsoft
1913
+ # SharePoint Online.
1914
+ # @param credential_details [CredentialDetails] Object containing details of the stored credentials.
1915
+ #
1916
+ # Obtain credentials for your source from the administrator of the source.
1917
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1918
+ def create_credentials(environment_id:, source_type: nil, credential_details: nil)
1919
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1920
+ headers = {
1921
+ }
1922
+ params = {
1923
+ "version" => @version
1924
+ }
1925
+ data = {
1926
+ "source_type" => source_type,
1927
+ "credential_details" => credential_details
1928
+ }
1929
+ method_url = "/v1/environments/%s/credentials" % [ERB::Util.url_encode(environment_id)]
1930
+ response = request(
1931
+ method: "POST",
1932
+ url: method_url,
1933
+ headers: headers,
1934
+ params: params,
1935
+ json: data,
1936
+ accept_json: true
1937
+ )
1938
+ response
1939
+ end
1940
+
1941
+ ##
1942
+ # @!method get_credentials(environment_id:, credential_id:)
1943
+ # View Credentials.
1944
+ # Returns details about the specified credentials.
1945
+ #
1946
+ # **Note:** Secure credential information such as a password or SSH key is never
1947
+ # returned and must be obtained from the source system.
1948
+ # @param environment_id [String] The ID of the environment.
1949
+ # @param credential_id [String] The unique identifier for a set of source credentials.
1950
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1951
+ def get_credentials(environment_id:, credential_id:)
1952
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1953
+ raise ArgumentError("credential_id must be provided") if credential_id.nil?
1954
+ headers = {
1955
+ }
1956
+ params = {
1957
+ "version" => @version
1958
+ }
1959
+ method_url = "/v1/environments/%s/credentials/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(credential_id)]
1960
+ response = request(
1961
+ method: "GET",
1962
+ url: method_url,
1963
+ headers: headers,
1964
+ params: params,
1965
+ accept_json: true
1966
+ )
1967
+ response
1968
+ end
1969
+
1970
+ ##
1971
+ # @!method update_credentials(environment_id:, credential_id:, source_type: nil, credential_details: nil)
1972
+ # Update credentials.
1973
+ # Updates an existing set of source credentials.
1974
+ #
1975
+ # **Note:** All credentials are sent over an encrypted connection and encrypted at
1976
+ # rest.
1977
+ # @param environment_id [String] The ID of the environment.
1978
+ # @param credential_id [String] The unique identifier for a set of source credentials.
1979
+ # @param source_type [String] The source that this credentials object connects to.
1980
+ # - `box` indicates the credentials are used to connect an instance of Enterprise
1981
+ # Box.
1982
+ # - `salesforce` indicates the credentials are used to connect to Salesforce.
1983
+ # - `sharepoint` indicates the credentials are used to connect to Microsoft
1984
+ # SharePoint Online.
1985
+ # @param credential_details [CredentialDetails] Object containing details of the stored credentials.
1986
+ #
1987
+ # Obtain credentials for your source from the administrator of the source.
1988
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1989
+ def update_credentials(environment_id:, credential_id:, source_type: nil, credential_details: nil)
1990
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
1991
+ raise ArgumentError("credential_id must be provided") if credential_id.nil?
1992
+ headers = {
1993
+ }
1994
+ params = {
1995
+ "version" => @version
1996
+ }
1997
+ data = {
1998
+ "source_type" => source_type,
1999
+ "credential_details" => credential_details
2000
+ }
2001
+ method_url = "/v1/environments/%s/credentials/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(credential_id)]
2002
+ response = request(
2003
+ method: "PUT",
2004
+ url: method_url,
2005
+ headers: headers,
2006
+ params: params,
2007
+ json: data,
2008
+ accept_json: true
2009
+ )
2010
+ response
2011
+ end
2012
+
2013
+ ##
2014
+ # @!method delete_credentials(environment_id:, credential_id:)
2015
+ # Delete credentials.
2016
+ # Deletes a set of stored credentials from your Discovery instance.
2017
+ # @param environment_id [String] The ID of the environment.
2018
+ # @param credential_id [String] The unique identifier for a set of source credentials.
2019
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
2020
+ def delete_credentials(environment_id:, credential_id:)
2021
+ raise ArgumentError("environment_id must be provided") if environment_id.nil?
2022
+ raise ArgumentError("credential_id must be provided") if credential_id.nil?
2023
+ headers = {
2024
+ }
2025
+ params = {
2026
+ "version" => @version
2027
+ }
2028
+ method_url = "/v1/environments/%s/credentials/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(credential_id)]
2029
+ response = request(
2030
+ method: "DELETE",
2031
+ url: method_url,
2032
+ headers: headers,
2033
+ params: params,
2034
+ accept_json: true
2035
+ )
2036
+ response
2037
+ end
2038
+ end
2039
+ end