ibm_watson 0.9.2 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -104,19 +104,23 @@ module IBMWatson
104
104
  # `LT`, in all other plans the default is `S`.
105
105
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
106
106
  def create_environment(name:, description: nil, size: nil)
107
- raise ArgumentError("name must be provided") if name.nil?
107
+ raise ArgumentError.new("name must be provided") if name.nil?
108
108
 
109
109
  headers = {
110
110
  }
111
+
111
112
  params = {
112
113
  "version" => @version
113
114
  }
115
+
114
116
  data = {
115
117
  "name" => name,
116
118
  "description" => description,
117
119
  "size" => size
118
120
  }
121
+
119
122
  method_url = "/v1/environments"
123
+
120
124
  response = request(
121
125
  method: "POST",
122
126
  url: method_url,
@@ -137,11 +141,14 @@ module IBMWatson
137
141
  def list_environments(name: nil)
138
142
  headers = {
139
143
  }
144
+
140
145
  params = {
141
146
  "version" => @version,
142
147
  "name" => name
143
148
  }
149
+
144
150
  method_url = "/v1/environments"
151
+
145
152
  response = request(
146
153
  method: "GET",
147
154
  url: method_url,
@@ -158,14 +165,17 @@ module IBMWatson
158
165
  # @param environment_id [String] The ID of the environment.
159
166
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
160
167
  def get_environment(environment_id:)
161
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
168
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
162
169
 
163
170
  headers = {
164
171
  }
172
+
165
173
  params = {
166
174
  "version" => @version
167
175
  }
176
+
168
177
  method_url = "/v1/environments/%s" % [ERB::Util.url_encode(environment_id)]
178
+
169
179
  response = request(
170
180
  method: "GET",
171
181
  url: method_url,
@@ -189,19 +199,23 @@ module IBMWatson
189
199
  # decreased.
190
200
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
191
201
  def update_environment(environment_id:, name: nil, description: nil, size: nil)
192
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
202
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
193
203
 
194
204
  headers = {
195
205
  }
206
+
196
207
  params = {
197
208
  "version" => @version
198
209
  }
210
+
199
211
  data = {
200
212
  "name" => name,
201
213
  "description" => description,
202
214
  "size" => size
203
215
  }
216
+
204
217
  method_url = "/v1/environments/%s" % [ERB::Util.url_encode(environment_id)]
218
+
205
219
  response = request(
206
220
  method: "PUT",
207
221
  url: method_url,
@@ -219,14 +233,17 @@ module IBMWatson
219
233
  # @param environment_id [String] The ID of the environment.
220
234
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
221
235
  def delete_environment(environment_id:)
222
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
236
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
223
237
 
224
238
  headers = {
225
239
  }
240
+
226
241
  params = {
227
242
  "version" => @version
228
243
  }
244
+
229
245
  method_url = "/v1/environments/%s" % [ERB::Util.url_encode(environment_id)]
246
+
230
247
  response = request(
231
248
  method: "DELETE",
232
249
  url: method_url,
@@ -246,17 +263,20 @@ module IBMWatson
246
263
  # @param collection_ids [Array[String]] A comma-separated list of collection IDs to be queried against.
247
264
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
248
265
  def list_fields(environment_id:, collection_ids:)
249
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
266
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
250
267
 
251
- raise ArgumentError("collection_ids must be provided") if collection_ids.nil?
268
+ raise ArgumentError.new("collection_ids must be provided") if collection_ids.nil?
252
269
 
253
270
  headers = {
254
271
  }
272
+
255
273
  params = {
256
274
  "version" => @version,
257
275
  "collection_ids" => collection_ids.to_a
258
276
  }
277
+
259
278
  method_url = "/v1/environments/%s/fields" % [ERB::Util.url_encode(environment_id)]
279
+
260
280
  response = request(
261
281
  method: "GET",
262
282
  url: method_url,
@@ -288,7 +308,7 @@ module IBMWatson
288
308
  # @param environment_id [String] The ID of the environment.
289
309
  # @param name [String] The name of the configuration.
290
310
  # @param description [String] The description of the configuration, if available.
291
- # @param conversions [Conversions] The document conversion settings for the configuration.
311
+ # @param conversions [Conversions] Document conversion settings.
292
312
  # @param enrichments [Array[Enrichment]] An array of document enrichment settings for the configuration.
293
313
  # @param normalizations [Array[NormalizationOperation]] Defines operations that can be used to transform the final output JSON into a
294
314
  # normalized form. Operations are executed in the order that they appear in the
@@ -296,15 +316,17 @@ module IBMWatson
296
316
  # @param source [Source] Object containing source parameters for the configuration.
297
317
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
298
318
  def create_configuration(environment_id:, name:, description: nil, conversions: nil, enrichments: nil, normalizations: nil, source: nil)
299
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
319
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
300
320
 
301
- raise ArgumentError("name must be provided") if name.nil?
321
+ raise ArgumentError.new("name must be provided") if name.nil?
302
322
 
303
323
  headers = {
304
324
  }
325
+
305
326
  params = {
306
327
  "version" => @version
307
328
  }
329
+
308
330
  data = {
309
331
  "name" => name,
310
332
  "description" => description,
@@ -313,7 +335,9 @@ module IBMWatson
313
335
  "normalizations" => normalizations,
314
336
  "source" => source
315
337
  }
338
+
316
339
  method_url = "/v1/environments/%s/configurations" % [ERB::Util.url_encode(environment_id)]
340
+
317
341
  response = request(
318
342
  method: "POST",
319
343
  url: method_url,
@@ -333,15 +357,18 @@ module IBMWatson
333
357
  # @param name [String] Find configurations with the given name.
334
358
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
335
359
  def list_configurations(environment_id:, name: nil)
336
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
360
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
337
361
 
338
362
  headers = {
339
363
  }
364
+
340
365
  params = {
341
366
  "version" => @version,
342
367
  "name" => name
343
368
  }
369
+
344
370
  method_url = "/v1/environments/%s/configurations" % [ERB::Util.url_encode(environment_id)]
371
+
345
372
  response = request(
346
373
  method: "GET",
347
374
  url: method_url,
@@ -359,16 +386,19 @@ module IBMWatson
359
386
  # @param configuration_id [String] The ID of the configuration.
360
387
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
361
388
  def get_configuration(environment_id:, configuration_id:)
362
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
389
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
363
390
 
364
- raise ArgumentError("configuration_id must be provided") if configuration_id.nil?
391
+ raise ArgumentError.new("configuration_id must be provided") if configuration_id.nil?
365
392
 
366
393
  headers = {
367
394
  }
395
+
368
396
  params = {
369
397
  "version" => @version
370
398
  }
399
+
371
400
  method_url = "/v1/environments/%s/configurations/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(configuration_id)]
401
+
372
402
  response = request(
373
403
  method: "GET",
374
404
  url: method_url,
@@ -395,7 +425,7 @@ module IBMWatson
395
425
  # @param configuration_id [String] The ID of the configuration.
396
426
  # @param name [String] The name of the configuration.
397
427
  # @param description [String] The description of the configuration, if available.
398
- # @param conversions [Conversions] The document conversion settings for the configuration.
428
+ # @param conversions [Conversions] Document conversion settings.
399
429
  # @param enrichments [Array[Enrichment]] An array of document enrichment settings for the configuration.
400
430
  # @param normalizations [Array[NormalizationOperation]] Defines operations that can be used to transform the final output JSON into a
401
431
  # normalized form. Operations are executed in the order that they appear in the
@@ -403,17 +433,19 @@ module IBMWatson
403
433
  # @param source [Source] Object containing source parameters for the configuration.
404
434
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
405
435
  def update_configuration(environment_id:, configuration_id:, name:, description: nil, conversions: nil, enrichments: nil, normalizations: nil, source: nil)
406
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
436
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
407
437
 
408
- raise ArgumentError("configuration_id must be provided") if configuration_id.nil?
438
+ raise ArgumentError.new("configuration_id must be provided") if configuration_id.nil?
409
439
 
410
- raise ArgumentError("name must be provided") if name.nil?
440
+ raise ArgumentError.new("name must be provided") if name.nil?
411
441
 
412
442
  headers = {
413
443
  }
444
+
414
445
  params = {
415
446
  "version" => @version
416
447
  }
448
+
417
449
  data = {
418
450
  "name" => name,
419
451
  "description" => description,
@@ -422,7 +454,9 @@ module IBMWatson
422
454
  "normalizations" => normalizations,
423
455
  "source" => source
424
456
  }
457
+
425
458
  method_url = "/v1/environments/%s/configurations/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(configuration_id)]
459
+
426
460
  response = request(
427
461
  method: "PUT",
428
462
  url: method_url,
@@ -447,16 +481,19 @@ module IBMWatson
447
481
  # @param configuration_id [String] The ID of the configuration.
448
482
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
449
483
  def delete_configuration(environment_id:, configuration_id:)
450
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
484
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
451
485
 
452
- raise ArgumentError("configuration_id must be provided") if configuration_id.nil?
486
+ raise ArgumentError.new("configuration_id must be provided") if configuration_id.nil?
453
487
 
454
488
  headers = {
455
489
  }
490
+
456
491
  params = {
457
492
  "version" => @version
458
493
  }
494
+
459
495
  method_url = "/v1/environments/%s/configurations/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(configuration_id)]
496
+
460
497
  response = request(
461
498
  method: "DELETE",
462
499
  url: method_url,
@@ -504,37 +541,39 @@ module IBMWatson
504
541
  # @param filename [String] The filename for file.
505
542
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
506
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)
507
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
544
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
508
545
 
509
546
  headers = {
510
547
  }
548
+
511
549
  params = {
512
550
  "version" => @version,
513
551
  "step" => step,
514
552
  "configuration_id" => configuration_id
515
553
  }
554
+
555
+ form_data = {}
556
+
557
+ form_data[:configuration] = HTTP::FormData::Part.new(configuration.to_s, content_type: "text/plain") unless configuration.nil?
558
+
516
559
  unless file.nil?
517
- mime_type = file_content_type.nil? ? "application/octet-stream" : file_content_type
518
560
  unless file.instance_of?(StringIO) || file.instance_of?(File)
519
561
  file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
520
562
  end
521
- if filename
522
- 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)
523
- else
524
- file = file.instance_of?(StringIO) ? HTTP::FormData::File.new(file, content_type: mime_type) : HTTP::FormData::File.new(file.path, content_type: mime_type)
525
- end
563
+ filename = file.path if filename.nil? && file.respond_to?(:path)
564
+ form_data[:file] = HTTP::FormData::File.new(file, content_type: file_content_type.nil? ? "application/octet-stream" : file_content_type, filename: filename)
526
565
  end
566
+
567
+ form_data[:metadata] = HTTP::FormData::Part.new(metadata.to_s, content_type: "text/plain") unless metadata.nil?
568
+
527
569
  method_url = "/v1/environments/%s/preview" % [ERB::Util.url_encode(environment_id)]
570
+
528
571
  response = request(
529
572
  method: "POST",
530
573
  url: method_url,
531
574
  headers: headers,
532
575
  params: params,
533
- form: {
534
- configuration: configuration,
535
- file: file,
536
- metadata: metadata
537
- },
576
+ form: form_data,
538
577
  accept_json: true
539
578
  )
540
579
  response
@@ -554,22 +593,26 @@ module IBMWatson
554
593
  # 639-1 language code.
555
594
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
556
595
  def create_collection(environment_id:, name:, description: nil, configuration_id: nil, language: nil)
557
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
596
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
558
597
 
559
- raise ArgumentError("name must be provided") if name.nil?
598
+ raise ArgumentError.new("name must be provided") if name.nil?
560
599
 
561
600
  headers = {
562
601
  }
602
+
563
603
  params = {
564
604
  "version" => @version
565
605
  }
606
+
566
607
  data = {
567
608
  "name" => name,
568
609
  "description" => description,
569
610
  "configuration_id" => configuration_id,
570
611
  "language" => language
571
612
  }
613
+
572
614
  method_url = "/v1/environments/%s/collections" % [ERB::Util.url_encode(environment_id)]
615
+
573
616
  response = request(
574
617
  method: "POST",
575
618
  url: method_url,
@@ -589,15 +632,18 @@ module IBMWatson
589
632
  # @param name [String] Find collections with the given name.
590
633
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
591
634
  def list_collections(environment_id:, name: nil)
592
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
635
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
593
636
 
594
637
  headers = {
595
638
  }
639
+
596
640
  params = {
597
641
  "version" => @version,
598
642
  "name" => name
599
643
  }
644
+
600
645
  method_url = "/v1/environments/%s/collections" % [ERB::Util.url_encode(environment_id)]
646
+
601
647
  response = request(
602
648
  method: "GET",
603
649
  url: method_url,
@@ -615,16 +661,19 @@ module IBMWatson
615
661
  # @param collection_id [String] The ID of the collection.
616
662
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
617
663
  def get_collection(environment_id:, collection_id:)
618
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
664
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
619
665
 
620
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
666
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
621
667
 
622
668
  headers = {
623
669
  }
670
+
624
671
  params = {
625
672
  "version" => @version
626
673
  }
674
+
627
675
  method_url = "/v1/environments/%s/collections/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
676
+
628
677
  response = request(
629
678
  method: "GET",
630
679
  url: method_url,
@@ -645,21 +694,25 @@ module IBMWatson
645
694
  # @param configuration_id [String] The ID of the configuration in which the collection is to be updated.
646
695
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
647
696
  def update_collection(environment_id:, collection_id:, name:, description: nil, configuration_id: nil)
648
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
697
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
649
698
 
650
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
699
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
651
700
 
652
701
  headers = {
653
702
  }
703
+
654
704
  params = {
655
705
  "version" => @version
656
706
  }
707
+
657
708
  data = {
658
709
  "name" => name,
659
710
  "description" => description,
660
711
  "configuration_id" => configuration_id
661
712
  }
713
+
662
714
  method_url = "/v1/environments/%s/collections/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
715
+
663
716
  response = request(
664
717
  method: "PUT",
665
718
  url: method_url,
@@ -678,16 +731,19 @@ module IBMWatson
678
731
  # @param collection_id [String] The ID of the collection.
679
732
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
680
733
  def delete_collection(environment_id:, collection_id:)
681
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
734
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
682
735
 
683
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
736
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
684
737
 
685
738
  headers = {
686
739
  }
740
+
687
741
  params = {
688
742
  "version" => @version
689
743
  }
744
+
690
745
  method_url = "/v1/environments/%s/collections/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
746
+
691
747
  response = request(
692
748
  method: "DELETE",
693
749
  url: method_url,
@@ -706,16 +762,19 @@ module IBMWatson
706
762
  # @param collection_id [String] The ID of the collection.
707
763
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
708
764
  def list_collection_fields(environment_id:, collection_id:)
709
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
765
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
710
766
 
711
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
767
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
712
768
 
713
769
  headers = {
714
770
  }
771
+
715
772
  params = {
716
773
  "version" => @version
717
774
  }
775
+
718
776
  method_url = "/v1/environments/%s/collections/%s/fields" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
777
+
719
778
  response = request(
720
779
  method: "GET",
721
780
  url: method_url,
@@ -738,16 +797,19 @@ module IBMWatson
738
797
  # @param collection_id [String] The ID of the collection.
739
798
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
740
799
  def list_expansions(environment_id:, collection_id:)
741
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
800
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
742
801
 
743
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
802
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
744
803
 
745
804
  headers = {
746
805
  }
806
+
747
807
  params = {
748
808
  "version" => @version
749
809
  }
810
+
750
811
  method_url = "/v1/environments/%s/collections/%s/expansions" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
812
+
751
813
  response = request(
752
814
  method: "GET",
753
815
  url: method_url,
@@ -784,21 +846,25 @@ module IBMWatson
784
846
  # **expanded_terms** array.
785
847
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
786
848
  def create_expansions(environment_id:, collection_id:, expansions:)
787
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
849
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
788
850
 
789
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
851
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
790
852
 
791
- raise ArgumentError("expansions must be provided") if expansions.nil?
853
+ raise ArgumentError.new("expansions must be provided") if expansions.nil?
792
854
 
793
855
  headers = {
794
856
  }
857
+
795
858
  params = {
796
859
  "version" => @version
797
860
  }
861
+
798
862
  data = {
799
863
  "expansions" => expansions
800
864
  }
865
+
801
866
  method_url = "/v1/environments/%s/collections/%s/expansions" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
867
+
802
868
  response = request(
803
869
  method: "POST",
804
870
  url: method_url,
@@ -819,16 +885,19 @@ module IBMWatson
819
885
  # @param collection_id [String] The ID of the collection.
820
886
  # @return [nil]
821
887
  def delete_expansions(environment_id:, collection_id:)
822
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
888
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
823
889
 
824
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
890
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
825
891
 
826
892
  headers = {
827
893
  }
894
+
828
895
  params = {
829
896
  "version" => @version
830
897
  }
898
+
831
899
  method_url = "/v1/environments/%s/collections/%s/expansions" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
900
+
832
901
  request(
833
902
  method: "DELETE",
834
903
  url: method_url,
@@ -848,16 +917,19 @@ module IBMWatson
848
917
  # @param collection_id [String] The ID of the collection.
849
918
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
850
919
  def get_tokenization_dictionary_status(environment_id:, collection_id:)
851
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
920
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
852
921
 
853
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
922
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
854
923
 
855
924
  headers = {
856
925
  }
926
+
857
927
  params = {
858
928
  "version" => @version
859
929
  }
930
+
860
931
  method_url = "/v1/environments/%s/collections/%s/word_lists/tokenization_dictionary" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
932
+
861
933
  response = request(
862
934
  method: "GET",
863
935
  url: method_url,
@@ -879,19 +951,23 @@ module IBMWatson
879
951
  # `part_of_speech` the text is from.
880
952
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
881
953
  def create_tokenization_dictionary(environment_id:, collection_id:, tokenization_rules: nil)
882
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
954
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
883
955
 
884
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
956
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
885
957
 
886
958
  headers = {
887
959
  }
960
+
888
961
  params = {
889
962
  "version" => @version
890
963
  }
964
+
891
965
  data = {
892
966
  "tokenization_rules" => tokenization_rules
893
967
  }
968
+
894
969
  method_url = "/v1/environments/%s/collections/%s/word_lists/tokenization_dictionary" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
970
+
895
971
  response = request(
896
972
  method: "POST",
897
973
  url: method_url,
@@ -911,16 +987,19 @@ module IBMWatson
911
987
  # @param collection_id [String] The ID of the collection.
912
988
  # @return [nil]
913
989
  def delete_tokenization_dictionary(environment_id:, collection_id:)
914
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
990
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
915
991
 
916
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
992
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
917
993
 
918
994
  headers = {
919
995
  }
996
+
920
997
  params = {
921
998
  "version" => @version
922
999
  }
1000
+
923
1001
  method_url = "/v1/environments/%s/collections/%s/word_lists/tokenization_dictionary" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
1002
+
924
1003
  request(
925
1004
  method: "DELETE",
926
1005
  url: method_url,
@@ -977,36 +1056,37 @@ module IBMWatson
977
1056
  # @param filename [String] The filename for file.
978
1057
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
979
1058
  def add_document(environment_id:, collection_id:, file: nil, metadata: nil, file_content_type: nil, filename: nil)
980
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
1059
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
981
1060
 
982
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
1061
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
983
1062
 
984
1063
  headers = {
985
1064
  }
1065
+
986
1066
  params = {
987
1067
  "version" => @version
988
1068
  }
1069
+
1070
+ form_data = {}
1071
+
989
1072
  unless file.nil?
990
- mime_type = file_content_type.nil? ? "application/octet-stream" : file_content_type
991
1073
  unless file.instance_of?(StringIO) || file.instance_of?(File)
992
1074
  file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
993
1075
  end
994
- if filename
995
- 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)
996
- else
997
- file = file.instance_of?(StringIO) ? HTTP::FormData::File.new(file, content_type: mime_type) : HTTP::FormData::File.new(file.path, content_type: mime_type)
998
- end
1076
+ filename = file.path if filename.nil? && file.respond_to?(:path)
1077
+ form_data[:file] = HTTP::FormData::File.new(file, content_type: file_content_type.nil? ? "application/octet-stream" : file_content_type, filename: filename)
999
1078
  end
1079
+
1080
+ form_data[:metadata] = HTTP::FormData::Part.new(metadata.to_s, content_type: "text/plain") unless metadata.nil?
1081
+
1000
1082
  method_url = "/v1/environments/%s/collections/%s/documents" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
1083
+
1001
1084
  response = request(
1002
1085
  method: "POST",
1003
1086
  url: method_url,
1004
1087
  headers: headers,
1005
1088
  params: params,
1006
- form: {
1007
- file: file,
1008
- metadata: metadata
1009
- },
1089
+ form: form_data,
1010
1090
  accept_json: true
1011
1091
  )
1012
1092
  response
@@ -1024,18 +1104,21 @@ module IBMWatson
1024
1104
  # @param document_id [String] The ID of the document.
1025
1105
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1026
1106
  def get_document_status(environment_id:, collection_id:, document_id:)
1027
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
1107
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1028
1108
 
1029
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
1109
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
1030
1110
 
1031
- raise ArgumentError("document_id must be provided") if document_id.nil?
1111
+ raise ArgumentError.new("document_id must be provided") if document_id.nil?
1032
1112
 
1033
1113
  headers = {
1034
1114
  }
1115
+
1035
1116
  params = {
1036
1117
  "version" => @version
1037
1118
  }
1119
+
1038
1120
  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)]
1121
+
1039
1122
  response = request(
1040
1123
  method: "GET",
1041
1124
  url: method_url,
@@ -1067,38 +1150,39 @@ module IBMWatson
1067
1150
  # @param filename [String] The filename for file.
1068
1151
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1069
1152
  def update_document(environment_id:, collection_id:, document_id:, file: nil, metadata: nil, file_content_type: nil, filename: nil)
1070
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
1153
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1071
1154
 
1072
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
1155
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
1073
1156
 
1074
- raise ArgumentError("document_id must be provided") if document_id.nil?
1157
+ raise ArgumentError.new("document_id must be provided") if document_id.nil?
1075
1158
 
1076
1159
  headers = {
1077
1160
  }
1161
+
1078
1162
  params = {
1079
1163
  "version" => @version
1080
1164
  }
1165
+
1166
+ form_data = {}
1167
+
1081
1168
  unless file.nil?
1082
- mime_type = file_content_type.nil? ? "application/octet-stream" : file_content_type
1083
1169
  unless file.instance_of?(StringIO) || file.instance_of?(File)
1084
1170
  file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
1085
1171
  end
1086
- if filename
1087
- 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)
1088
- else
1089
- file = file.instance_of?(StringIO) ? HTTP::FormData::File.new(file, content_type: mime_type) : HTTP::FormData::File.new(file.path, content_type: mime_type)
1090
- end
1172
+ filename = file.path if filename.nil? && file.respond_to?(:path)
1173
+ form_data[:file] = HTTP::FormData::File.new(file, content_type: file_content_type.nil? ? "application/octet-stream" : file_content_type, filename: filename)
1091
1174
  end
1175
+
1176
+ form_data[:metadata] = HTTP::FormData::Part.new(metadata.to_s, content_type: "text/plain") unless metadata.nil?
1177
+
1092
1178
  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)]
1179
+
1093
1180
  response = request(
1094
1181
  method: "POST",
1095
1182
  url: method_url,
1096
1183
  headers: headers,
1097
1184
  params: params,
1098
- form: {
1099
- file: file,
1100
- metadata: metadata
1101
- },
1185
+ form: form_data,
1102
1186
  accept_json: true
1103
1187
  )
1104
1188
  response
@@ -1115,18 +1199,21 @@ module IBMWatson
1115
1199
  # @param document_id [String] The ID of the document.
1116
1200
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1117
1201
  def delete_document(environment_id:, collection_id:, document_id:)
1118
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
1202
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1119
1203
 
1120
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
1204
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
1121
1205
 
1122
- raise ArgumentError("document_id must be provided") if document_id.nil?
1206
+ raise ArgumentError.new("document_id must be provided") if document_id.nil?
1123
1207
 
1124
1208
  headers = {
1125
1209
  }
1210
+
1126
1211
  params = {
1127
1212
  "version" => @version
1128
1213
  }
1214
+
1129
1215
  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)]
1216
+
1130
1217
  response = request(
1131
1218
  method: "DELETE",
1132
1219
  url: method_url,
@@ -1208,16 +1295,18 @@ module IBMWatson
1208
1295
  # @param logging_opt_out [Boolean] If `true`, queries are not stored in the Discovery **Logs** endpoint.
1209
1296
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1210
1297
  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, collection_ids: nil, similar: nil, similar_document_ids: nil, similar_fields: nil, bias: nil, logging_opt_out: nil)
1211
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
1298
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1212
1299
 
1213
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
1300
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
1214
1301
 
1215
1302
  headers = {
1216
1303
  "X-Watson-Logging-Opt-Out" => logging_opt_out
1217
1304
  }
1305
+
1218
1306
  params = {
1219
1307
  "version" => @version
1220
1308
  }
1309
+
1221
1310
  data = {
1222
1311
  "filter" => filter,
1223
1312
  "query" => query,
@@ -1240,7 +1329,9 @@ module IBMWatson
1240
1329
  "similar.fields" => similar_fields,
1241
1330
  "bias" => bias
1242
1331
  }
1332
+
1243
1333
  method_url = "/v1/environments/%s/collections/%s/query" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
1334
+
1244
1335
  response = request(
1245
1336
  method: "POST",
1246
1337
  url: method_url,
@@ -1307,12 +1398,13 @@ module IBMWatson
1307
1398
  # comparison.
1308
1399
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1309
1400
  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)
1310
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
1401
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1311
1402
 
1312
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
1403
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
1313
1404
 
1314
1405
  headers = {
1315
1406
  }
1407
+
1316
1408
  params = {
1317
1409
  "version" => @version,
1318
1410
  "filter" => filter,
@@ -1333,7 +1425,9 @@ module IBMWatson
1333
1425
  "similar.document_ids" => similar_document_ids.to_a,
1334
1426
  "similar.fields" => similar_fields.to_a
1335
1427
  }
1428
+
1336
1429
  method_url = "/v1/environments/%s/collections/%s/notices" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
1430
+
1337
1431
  response = request(
1338
1432
  method: "GET",
1339
1433
  url: method_url,
@@ -1411,14 +1505,16 @@ module IBMWatson
1411
1505
  # @param logging_opt_out [Boolean] If `true`, queries are not stored in the Discovery **Logs** endpoint.
1412
1506
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1413
1507
  def federated_query(environment_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, collection_ids: nil, similar: nil, similar_document_ids: nil, similar_fields: nil, bias: nil, logging_opt_out: nil)
1414
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
1508
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1415
1509
 
1416
1510
  headers = {
1417
1511
  "X-Watson-Logging-Opt-Out" => logging_opt_out
1418
1512
  }
1513
+
1419
1514
  params = {
1420
1515
  "version" => @version
1421
1516
  }
1517
+
1422
1518
  data = {
1423
1519
  "filter" => filter,
1424
1520
  "query" => query,
@@ -1441,7 +1537,9 @@ module IBMWatson
1441
1537
  "similar.fields" => similar_fields,
1442
1538
  "bias" => bias
1443
1539
  }
1540
+
1444
1541
  method_url = "/v1/environments/%s/query" % [ERB::Util.url_encode(environment_id)]
1542
+
1445
1543
  response = request(
1446
1544
  method: "POST",
1447
1545
  url: method_url,
@@ -1502,12 +1600,13 @@ module IBMWatson
1502
1600
  # comparison.
1503
1601
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1504
1602
  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)
1505
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
1603
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1506
1604
 
1507
- raise ArgumentError("collection_ids must be provided") if collection_ids.nil?
1605
+ raise ArgumentError.new("collection_ids must be provided") if collection_ids.nil?
1508
1606
 
1509
1607
  headers = {
1510
1608
  }
1609
+
1511
1610
  params = {
1512
1611
  "version" => @version,
1513
1612
  "collection_ids" => collection_ids.to_a,
@@ -1525,7 +1624,9 @@ module IBMWatson
1525
1624
  "similar.document_ids" => similar_document_ids.to_a,
1526
1625
  "similar.fields" => similar_fields.to_a
1527
1626
  }
1627
+
1528
1628
  method_url = "/v1/environments/%s/notices" % [ERB::Util.url_encode(environment_id)]
1629
+
1529
1630
  response = request(
1530
1631
  method: "GET",
1531
1632
  url: method_url,
@@ -1555,15 +1656,17 @@ module IBMWatson
1555
1656
  # maximum number of evidence items per query is 10,000.
1556
1657
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1557
1658
  def query_entities(environment_id:, collection_id:, feature: nil, entity: nil, context: nil, count: nil, evidence_count: nil)
1558
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
1659
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1559
1660
 
1560
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
1661
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
1561
1662
 
1562
1663
  headers = {
1563
1664
  }
1665
+
1564
1666
  params = {
1565
1667
  "version" => @version
1566
1668
  }
1669
+
1567
1670
  data = {
1568
1671
  "feature" => feature,
1569
1672
  "entity" => entity,
@@ -1571,7 +1674,9 @@ module IBMWatson
1571
1674
  "count" => count,
1572
1675
  "evidence_count" => evidence_count
1573
1676
  }
1677
+
1574
1678
  method_url = "/v1/environments/%s/collections/%s/query_entities" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
1679
+
1575
1680
  response = request(
1576
1681
  method: "POST",
1577
1682
  url: method_url,
@@ -1605,15 +1710,17 @@ module IBMWatson
1605
1710
  # maximum number of evidence items per query is 10,000.
1606
1711
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1607
1712
  def query_relations(environment_id:, collection_id:, entities: nil, context: nil, sort: nil, filter: nil, count: nil, evidence_count: nil)
1608
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
1713
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1609
1714
 
1610
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
1715
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
1611
1716
 
1612
1717
  headers = {
1613
1718
  }
1719
+
1614
1720
  params = {
1615
1721
  "version" => @version
1616
1722
  }
1723
+
1617
1724
  data = {
1618
1725
  "entities" => entities,
1619
1726
  "context" => context,
@@ -1622,7 +1729,9 @@ module IBMWatson
1622
1729
  "count" => count,
1623
1730
  "evidence_count" => evidence_count
1624
1731
  }
1732
+
1625
1733
  method_url = "/v1/environments/%s/collections/%s/query_relations" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
1734
+
1626
1735
  response = request(
1627
1736
  method: "POST",
1628
1737
  url: method_url,
@@ -1645,16 +1754,19 @@ module IBMWatson
1645
1754
  # @param collection_id [String] The ID of the collection.
1646
1755
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1647
1756
  def list_training_data(environment_id:, collection_id:)
1648
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
1757
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1649
1758
 
1650
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
1759
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
1651
1760
 
1652
1761
  headers = {
1653
1762
  }
1763
+
1654
1764
  params = {
1655
1765
  "version" => @version
1656
1766
  }
1767
+
1657
1768
  method_url = "/v1/environments/%s/collections/%s/training_data" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
1769
+
1658
1770
  response = request(
1659
1771
  method: "GET",
1660
1772
  url: method_url,
@@ -1677,21 +1789,25 @@ module IBMWatson
1677
1789
  # @param examples [Array[TrainingExample]]
1678
1790
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1679
1791
  def add_training_data(environment_id:, collection_id:, natural_language_query: nil, filter: nil, examples: nil)
1680
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
1792
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1681
1793
 
1682
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
1794
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
1683
1795
 
1684
1796
  headers = {
1685
1797
  }
1798
+
1686
1799
  params = {
1687
1800
  "version" => @version
1688
1801
  }
1802
+
1689
1803
  data = {
1690
1804
  "natural_language_query" => natural_language_query,
1691
1805
  "filter" => filter,
1692
1806
  "examples" => examples
1693
1807
  }
1808
+
1694
1809
  method_url = "/v1/environments/%s/collections/%s/training_data" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
1810
+
1695
1811
  response = request(
1696
1812
  method: "POST",
1697
1813
  url: method_url,
@@ -1711,16 +1827,19 @@ module IBMWatson
1711
1827
  # @param collection_id [String] The ID of the collection.
1712
1828
  # @return [nil]
1713
1829
  def delete_all_training_data(environment_id:, collection_id:)
1714
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
1830
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1715
1831
 
1716
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
1832
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
1717
1833
 
1718
1834
  headers = {
1719
1835
  }
1836
+
1720
1837
  params = {
1721
1838
  "version" => @version
1722
1839
  }
1840
+
1723
1841
  method_url = "/v1/environments/%s/collections/%s/training_data" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
1842
+
1724
1843
  request(
1725
1844
  method: "DELETE",
1726
1845
  url: method_url,
@@ -1741,18 +1860,21 @@ module IBMWatson
1741
1860
  # @param query_id [String] The ID of the query used for training.
1742
1861
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1743
1862
  def get_training_data(environment_id:, collection_id:, query_id:)
1744
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
1863
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1745
1864
 
1746
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
1865
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
1747
1866
 
1748
- raise ArgumentError("query_id must be provided") if query_id.nil?
1867
+ raise ArgumentError.new("query_id must be provided") if query_id.nil?
1749
1868
 
1750
1869
  headers = {
1751
1870
  }
1871
+
1752
1872
  params = {
1753
1873
  "version" => @version
1754
1874
  }
1875
+
1755
1876
  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)]
1877
+
1756
1878
  response = request(
1757
1879
  method: "GET",
1758
1880
  url: method_url,
@@ -1773,18 +1895,21 @@ module IBMWatson
1773
1895
  # @param query_id [String] The ID of the query used for training.
1774
1896
  # @return [nil]
1775
1897
  def delete_training_data(environment_id:, collection_id:, query_id:)
1776
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
1898
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1777
1899
 
1778
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
1900
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
1779
1901
 
1780
- raise ArgumentError("query_id must be provided") if query_id.nil?
1902
+ raise ArgumentError.new("query_id must be provided") if query_id.nil?
1781
1903
 
1782
1904
  headers = {
1783
1905
  }
1906
+
1784
1907
  params = {
1785
1908
  "version" => @version
1786
1909
  }
1910
+
1787
1911
  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)]
1912
+
1788
1913
  request(
1789
1914
  method: "DELETE",
1790
1915
  url: method_url,
@@ -1804,18 +1929,21 @@ module IBMWatson
1804
1929
  # @param query_id [String] The ID of the query used for training.
1805
1930
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1806
1931
  def list_training_examples(environment_id:, collection_id:, query_id:)
1807
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
1932
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1808
1933
 
1809
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
1934
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
1810
1935
 
1811
- raise ArgumentError("query_id must be provided") if query_id.nil?
1936
+ raise ArgumentError.new("query_id must be provided") if query_id.nil?
1812
1937
 
1813
1938
  headers = {
1814
1939
  }
1940
+
1815
1941
  params = {
1816
1942
  "version" => @version
1817
1943
  }
1944
+
1818
1945
  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)]
1946
+
1819
1947
  response = request(
1820
1948
  method: "GET",
1821
1949
  url: method_url,
@@ -1838,23 +1966,27 @@ module IBMWatson
1838
1966
  # @param relevance [Fixnum]
1839
1967
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1840
1968
  def create_training_example(environment_id:, collection_id:, query_id:, document_id: nil, cross_reference: nil, relevance: nil)
1841
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
1969
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1842
1970
 
1843
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
1971
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
1844
1972
 
1845
- raise ArgumentError("query_id must be provided") if query_id.nil?
1973
+ raise ArgumentError.new("query_id must be provided") if query_id.nil?
1846
1974
 
1847
1975
  headers = {
1848
1976
  }
1977
+
1849
1978
  params = {
1850
1979
  "version" => @version
1851
1980
  }
1981
+
1852
1982
  data = {
1853
1983
  "document_id" => document_id,
1854
1984
  "cross_reference" => cross_reference,
1855
1985
  "relevance" => relevance
1856
1986
  }
1987
+
1857
1988
  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)]
1989
+
1858
1990
  response = request(
1859
1991
  method: "POST",
1860
1992
  url: method_url,
@@ -1876,20 +2008,23 @@ module IBMWatson
1876
2008
  # @param example_id [String] The ID of the document as it is indexed.
1877
2009
  # @return [nil]
1878
2010
  def delete_training_example(environment_id:, collection_id:, query_id:, example_id:)
1879
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
2011
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1880
2012
 
1881
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
2013
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
1882
2014
 
1883
- raise ArgumentError("query_id must be provided") if query_id.nil?
2015
+ raise ArgumentError.new("query_id must be provided") if query_id.nil?
1884
2016
 
1885
- raise ArgumentError("example_id must be provided") if example_id.nil?
2017
+ raise ArgumentError.new("example_id must be provided") if example_id.nil?
1886
2018
 
1887
2019
  headers = {
1888
2020
  }
2021
+
1889
2022
  params = {
1890
2023
  "version" => @version
1891
2024
  }
2025
+
1892
2026
  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)]
2027
+
1893
2028
  request(
1894
2029
  method: "DELETE",
1895
2030
  url: method_url,
@@ -1912,24 +2047,28 @@ module IBMWatson
1912
2047
  # @param relevance [Fixnum]
1913
2048
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1914
2049
  def update_training_example(environment_id:, collection_id:, query_id:, example_id:, cross_reference: nil, relevance: nil)
1915
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
2050
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1916
2051
 
1917
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
2052
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
1918
2053
 
1919
- raise ArgumentError("query_id must be provided") if query_id.nil?
2054
+ raise ArgumentError.new("query_id must be provided") if query_id.nil?
1920
2055
 
1921
- raise ArgumentError("example_id must be provided") if example_id.nil?
2056
+ raise ArgumentError.new("example_id must be provided") if example_id.nil?
1922
2057
 
1923
2058
  headers = {
1924
2059
  }
2060
+
1925
2061
  params = {
1926
2062
  "version" => @version
1927
2063
  }
2064
+
1928
2065
  data = {
1929
2066
  "cross_reference" => cross_reference,
1930
2067
  "relevance" => relevance
1931
2068
  }
2069
+
1932
2070
  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)]
2071
+
1933
2072
  response = request(
1934
2073
  method: "PUT",
1935
2074
  url: method_url,
@@ -1951,20 +2090,23 @@ module IBMWatson
1951
2090
  # @param example_id [String] The ID of the document as it is indexed.
1952
2091
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1953
2092
  def get_training_example(environment_id:, collection_id:, query_id:, example_id:)
1954
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
2093
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
1955
2094
 
1956
- raise ArgumentError("collection_id must be provided") if collection_id.nil?
2095
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
1957
2096
 
1958
- raise ArgumentError("query_id must be provided") if query_id.nil?
2097
+ raise ArgumentError.new("query_id must be provided") if query_id.nil?
1959
2098
 
1960
- raise ArgumentError("example_id must be provided") if example_id.nil?
2099
+ raise ArgumentError.new("example_id must be provided") if example_id.nil?
1961
2100
 
1962
2101
  headers = {
1963
2102
  }
2103
+
1964
2104
  params = {
1965
2105
  "version" => @version
1966
2106
  }
2107
+
1967
2108
  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)]
2109
+
1968
2110
  response = request(
1969
2111
  method: "GET",
1970
2112
  url: method_url,
@@ -1991,15 +2133,18 @@ module IBMWatson
1991
2133
  # @param customer_id [String] The customer ID for which all data is to be deleted.
1992
2134
  # @return [nil]
1993
2135
  def delete_user_data(customer_id:)
1994
- raise ArgumentError("customer_id must be provided") if customer_id.nil?
2136
+ raise ArgumentError.new("customer_id must be provided") if customer_id.nil?
1995
2137
 
1996
2138
  headers = {
1997
2139
  }
2140
+
1998
2141
  params = {
1999
2142
  "version" => @version,
2000
2143
  "customer_id" => customer_id
2001
2144
  }
2145
+
2002
2146
  method_url = "/v1/user_data"
2147
+
2003
2148
  request(
2004
2149
  method: "DELETE",
2005
2150
  url: method_url,
@@ -2020,23 +2165,27 @@ module IBMWatson
2020
2165
  # specific queries. For example, you can record which documents in the results set
2021
2166
  # were \"clicked\" by a user and when that click occured.
2022
2167
  # @param type [String] The event type to be created.
2023
- # @param data [EventData] Data object used to create a query event.
2168
+ # @param data [EventData] Query event data object.
2024
2169
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
2025
2170
  def create_event(type:, data:)
2026
- raise ArgumentError("type must be provided") if type.nil?
2171
+ raise ArgumentError.new("type must be provided") if type.nil?
2027
2172
 
2028
- raise ArgumentError("data must be provided") if data.nil?
2173
+ raise ArgumentError.new("data must be provided") if data.nil?
2029
2174
 
2030
2175
  headers = {
2031
2176
  }
2177
+
2032
2178
  params = {
2033
2179
  "version" => @version
2034
2180
  }
2181
+
2035
2182
  data = {
2036
2183
  "type" => type,
2037
2184
  "data" => data
2038
2185
  }
2186
+
2039
2187
  method_url = "/v1/events"
2188
+
2040
2189
  response = request(
2041
2190
  method: "POST",
2042
2191
  url: method_url,
@@ -2072,6 +2221,7 @@ module IBMWatson
2072
2221
  def query_log(filter: nil, query: nil, count: nil, offset: nil, sort: nil)
2073
2222
  headers = {
2074
2223
  }
2224
+
2075
2225
  params = {
2076
2226
  "version" => @version,
2077
2227
  "filter" => filter,
@@ -2080,7 +2230,9 @@ module IBMWatson
2080
2230
  "offset" => offset,
2081
2231
  "sort" => sort.to_a
2082
2232
  }
2233
+
2083
2234
  method_url = "/v1/logs"
2235
+
2084
2236
  response = request(
2085
2237
  method: "GET",
2086
2238
  url: method_url,
@@ -2105,13 +2257,16 @@ module IBMWatson
2105
2257
  def get_metrics_query(start_time: nil, end_time: nil, result_type: nil)
2106
2258
  headers = {
2107
2259
  }
2260
+
2108
2261
  params = {
2109
2262
  "version" => @version,
2110
2263
  "start_time" => start_time,
2111
2264
  "end_time" => end_time,
2112
2265
  "result_type" => result_type
2113
2266
  }
2267
+
2114
2268
  method_url = "/v1/metrics/number_of_queries"
2269
+
2115
2270
  response = request(
2116
2271
  method: "GET",
2117
2272
  url: method_url,
@@ -2137,13 +2292,16 @@ module IBMWatson
2137
2292
  def get_metrics_query_event(start_time: nil, end_time: nil, result_type: nil)
2138
2293
  headers = {
2139
2294
  }
2295
+
2140
2296
  params = {
2141
2297
  "version" => @version,
2142
2298
  "start_time" => start_time,
2143
2299
  "end_time" => end_time,
2144
2300
  "result_type" => result_type
2145
2301
  }
2302
+
2146
2303
  method_url = "/v1/metrics/number_of_queries_with_event"
2304
+
2147
2305
  response = request(
2148
2306
  method: "GET",
2149
2307
  url: method_url,
@@ -2168,13 +2326,16 @@ module IBMWatson
2168
2326
  def get_metrics_query_no_results(start_time: nil, end_time: nil, result_type: nil)
2169
2327
  headers = {
2170
2328
  }
2329
+
2171
2330
  params = {
2172
2331
  "version" => @version,
2173
2332
  "start_time" => start_time,
2174
2333
  "end_time" => end_time,
2175
2334
  "result_type" => result_type
2176
2335
  }
2336
+
2177
2337
  method_url = "/v1/metrics/number_of_queries_with_no_search_results"
2338
+
2178
2339
  response = request(
2179
2340
  method: "GET",
2180
2341
  url: method_url,
@@ -2201,13 +2362,16 @@ module IBMWatson
2201
2362
  def get_metrics_event_rate(start_time: nil, end_time: nil, result_type: nil)
2202
2363
  headers = {
2203
2364
  }
2365
+
2204
2366
  params = {
2205
2367
  "version" => @version,
2206
2368
  "start_time" => start_time,
2207
2369
  "end_time" => end_time,
2208
2370
  "result_type" => result_type
2209
2371
  }
2372
+
2210
2373
  method_url = "/v1/metrics/event_rate"
2374
+
2211
2375
  response = request(
2212
2376
  method: "GET",
2213
2377
  url: method_url,
@@ -2230,11 +2394,14 @@ module IBMWatson
2230
2394
  def get_metrics_query_token_event(count: nil)
2231
2395
  headers = {
2232
2396
  }
2397
+
2233
2398
  params = {
2234
2399
  "version" => @version,
2235
2400
  "count" => count
2236
2401
  }
2402
+
2237
2403
  method_url = "/v1/metrics/top_query_tokens_with_event_rate"
2404
+
2238
2405
  response = request(
2239
2406
  method: "GET",
2240
2407
  url: method_url,
@@ -2258,14 +2425,17 @@ module IBMWatson
2258
2425
  # @param environment_id [String] The ID of the environment.
2259
2426
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
2260
2427
  def list_credentials(environment_id:)
2261
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
2428
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
2262
2429
 
2263
2430
  headers = {
2264
2431
  }
2432
+
2265
2433
  params = {
2266
2434
  "version" => @version
2267
2435
  }
2436
+
2268
2437
  method_url = "/v1/environments/%s/credentials" % [ERB::Util.url_encode(environment_id)]
2438
+
2269
2439
  response = request(
2270
2440
  method: "GET",
2271
2441
  url: method_url,
@@ -2296,18 +2466,22 @@ module IBMWatson
2296
2466
  # Obtain credentials for your source from the administrator of the source.
2297
2467
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
2298
2468
  def create_credentials(environment_id:, source_type: nil, credential_details: nil)
2299
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
2469
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
2300
2470
 
2301
2471
  headers = {
2302
2472
  }
2473
+
2303
2474
  params = {
2304
2475
  "version" => @version
2305
2476
  }
2477
+
2306
2478
  data = {
2307
2479
  "source_type" => source_type,
2308
2480
  "credential_details" => credential_details
2309
2481
  }
2482
+
2310
2483
  method_url = "/v1/environments/%s/credentials" % [ERB::Util.url_encode(environment_id)]
2484
+
2311
2485
  response = request(
2312
2486
  method: "POST",
2313
2487
  url: method_url,
@@ -2330,16 +2504,19 @@ module IBMWatson
2330
2504
  # @param credential_id [String] The unique identifier for a set of source credentials.
2331
2505
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
2332
2506
  def get_credentials(environment_id:, credential_id:)
2333
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
2507
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
2334
2508
 
2335
- raise ArgumentError("credential_id must be provided") if credential_id.nil?
2509
+ raise ArgumentError.new("credential_id must be provided") if credential_id.nil?
2336
2510
 
2337
2511
  headers = {
2338
2512
  }
2513
+
2339
2514
  params = {
2340
2515
  "version" => @version
2341
2516
  }
2517
+
2342
2518
  method_url = "/v1/environments/%s/credentials/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(credential_id)]
2519
+
2343
2520
  response = request(
2344
2521
  method: "GET",
2345
2522
  url: method_url,
@@ -2370,20 +2547,24 @@ module IBMWatson
2370
2547
  # Obtain credentials for your source from the administrator of the source.
2371
2548
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
2372
2549
  def update_credentials(environment_id:, credential_id:, source_type: nil, credential_details: nil)
2373
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
2550
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
2374
2551
 
2375
- raise ArgumentError("credential_id must be provided") if credential_id.nil?
2552
+ raise ArgumentError.new("credential_id must be provided") if credential_id.nil?
2376
2553
 
2377
2554
  headers = {
2378
2555
  }
2556
+
2379
2557
  params = {
2380
2558
  "version" => @version
2381
2559
  }
2560
+
2382
2561
  data = {
2383
2562
  "source_type" => source_type,
2384
2563
  "credential_details" => credential_details
2385
2564
  }
2565
+
2386
2566
  method_url = "/v1/environments/%s/credentials/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(credential_id)]
2567
+
2387
2568
  response = request(
2388
2569
  method: "PUT",
2389
2570
  url: method_url,
@@ -2403,16 +2584,19 @@ module IBMWatson
2403
2584
  # @param credential_id [String] The unique identifier for a set of source credentials.
2404
2585
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
2405
2586
  def delete_credentials(environment_id:, credential_id:)
2406
- raise ArgumentError("environment_id must be provided") if environment_id.nil?
2587
+ raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
2407
2588
 
2408
- raise ArgumentError("credential_id must be provided") if credential_id.nil?
2589
+ raise ArgumentError.new("credential_id must be provided") if credential_id.nil?
2409
2590
 
2410
2591
  headers = {
2411
2592
  }
2593
+
2412
2594
  params = {
2413
2595
  "version" => @version
2414
2596
  }
2597
+
2415
2598
  method_url = "/v1/environments/%s/credentials/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(credential_id)]
2599
+
2416
2600
  response = request(
2417
2601
  method: "DELETE",
2418
2602
  url: method_url,