ibm_watson 1.0.0.rc2 → 1.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +33 -27
  3. data/lib/ibm_watson/assistant_v1.rb +6 -80
  4. data/lib/ibm_watson/assistant_v2.rb +6 -38
  5. data/lib/ibm_watson/compare_comply_v1.rb +6 -47
  6. data/lib/ibm_watson/discovery_v1.rb +12 -297
  7. data/lib/ibm_watson/language_translator_v3.rb +6 -41
  8. data/lib/ibm_watson/natural_language_classifier_v1.rb +6 -35
  9. data/lib/ibm_watson/natural_language_understanding_v1.rb +6 -38
  10. data/lib/ibm_watson/personality_insights_v3.rb +6 -30
  11. data/lib/ibm_watson/speech_to_text_v1.rb +9 -130
  12. data/lib/ibm_watson/text_to_speech_v1.rb +6 -50
  13. data/lib/ibm_watson/tone_analyzer_v3.rb +6 -31
  14. data/lib/ibm_watson/version.rb +1 -1
  15. data/lib/ibm_watson/visual_recognition_v3.rb +8 -103
  16. data/lib/ibm_watson/websocket/speech_to_text_websocket_listener.rb +5 -5
  17. data/lib/ibm_watson.rb +9 -0
  18. data/test/integration/test_assistant_v1.rb +1 -1
  19. data/test/integration/test_assistant_v2.rb +1 -1
  20. data/test/integration/test_compare_comply_v1.rb +1 -1
  21. data/test/integration/test_discovery_v1.rb +1 -4
  22. data/test/integration/test_language_translator_v3.rb +1 -1
  23. data/test/integration/test_natural_language_classifier_v1.rb +1 -1
  24. data/test/integration/test_natural_language_understanding_v1.rb +1 -1
  25. data/test/integration/test_personality_insights_v3.rb +1 -1
  26. data/test/integration/test_speech_to_text_v1.rb +2 -2
  27. data/test/integration/test_text_to_speech_v1.rb +1 -1
  28. data/test/integration/test_tone_analyzer_v3.rb +1 -1
  29. data/test/integration/test_visual_recognition_v3.rb +1 -8
  30. data/test/unit/test_assistant_v1.rb +45 -45
  31. data/test/unit/test_assistant_v2.rb +3 -3
  32. data/test/unit/test_compare_comply_v1.rb +12 -12
  33. data/test/unit/test_configure_http_client.rb +37 -13
  34. data/test/unit/test_discovery_v1.rb +47 -139
  35. data/test/unit/test_language_translator_v3.rb +13 -26
  36. data/test/unit/test_natural_language_classifier_v1.rb +2 -2
  37. data/test/unit/test_natural_language_understanding_v1.rb +5 -5
  38. data/test/unit/test_personality_insights_v3.rb +8 -8
  39. data/test/unit/test_speech_to_text_v1.rb +21 -21
  40. data/test/unit/test_text_to_speech_v1.rb +5 -5
  41. data/test/unit/test_tone_analyzer_v3.rb +9 -9
  42. data/test/unit/test_vcap_using_personality_insights.rb +8 -8
  43. data/test/unit/test_visual_recognition_v3.rb +8 -75
  44. metadata +4 -4
@@ -55,46 +55,17 @@ module IBMWatson
55
55
  # Construct a new client for the Speech to Text service.
56
56
  #
57
57
  # @param args [Hash] The args to initialize with
58
- # @option args url [String] The base url to use when contacting the service (e.g.
59
- # "https://stream.watsonplatform.net/speech-to-text/api").
60
- # The base url may differ between IBM Cloud regions.
61
- # @option args username [String] The username used to authenticate with the service.
62
- # Username and password credentials are only required to run your
63
- # application locally or outside of IBM Cloud. When running on
64
- # IBM Cloud, the credentials will be automatically loaded from the
65
- # `VCAP_SERVICES` environment variable.
66
- # @option args password [String] The password used to authenticate with the service.
67
- # Username and password credentials are only required to run your
68
- # application locally or outside of IBM Cloud. When running on
69
- # IBM Cloud, the credentials will be automatically loaded from the
70
- # `VCAP_SERVICES` environment variable.
71
- # @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
72
- # this API key is provided, the SDK will manage the token and handle the
73
- # refreshing.
74
- # @option args iam_access_token [String] An IAM access token is fully managed by the application.
75
- # Responsibility falls on the application to refresh the token, either before
76
- # it expires or reactively upon receiving a 401 from the service as any requests
77
- # made with an expired token will fail.
78
- # @option args iam_url [String] An optional URL for the IAM service API. Defaults to
79
- # 'https://iam.cloud.ibm.com/identity/token'.
80
- # @option args iam_client_id [String] An optional client id for the IAM service API.
81
- # @option args iam_client_secret [String] An optional client secret for the IAM service API.
82
- # @option args icp4d_access_token [STRING] A ICP4D(IBM Cloud Pak for Data) access token is
83
- # fully managed by the application. Responsibility falls on the application to
84
- # refresh the token, either before it expires or reactively upon receiving a 401
85
- # from the service as any requests made with an expired token will fail.
86
- # @option args icp4d_url [STRING] In order to use an SDK-managed token with ICP4D authentication, this
87
- # URL must be passed in.
88
- # @option args authentication_type [STRING] Specifies the authentication pattern to use. Values that it
89
- # takes are basic, iam or icp4d.
58
+ # @option args service_url [String] The base service URL to use when contacting the service.
59
+ # The base service_url may differ between IBM Cloud regions.
60
+ # @option args authenticator [Object] The Authenticator instance to be configured for this service.
90
61
  def initialize(args = {})
91
62
  @__async_initialized__ = false
92
63
  defaults = {}
93
- defaults[:url] = "https://stream.watsonplatform.net/speech-to-text/api"
64
+ defaults[:service_url] = "https://stream.watsonplatform.net/speech-to-text/api"
94
65
  defaults[:authenticator] = nil
95
- defaults[:authentication_type] = nil
96
66
  args = defaults.merge(args)
97
- args[:display_name] = "Speech to Text"
67
+ args[:service_name] = "speech_to_text"
68
+ args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
98
69
  super
99
70
  end
100
71
 
@@ -120,7 +91,6 @@ module IBMWatson
120
91
 
121
92
  method_url = "/v1/models"
122
93
 
123
- headers = authenticator.authenticate(headers)
124
94
  response = request(
125
95
  method: "GET",
126
96
  url: method_url,
@@ -152,7 +122,6 @@ module IBMWatson
152
122
 
153
123
  method_url = "/v1/models/%s" % [ERB::Util.url_encode(model_id)]
154
124
 
155
- headers = authenticator.authenticate(headers)
156
125
  response = request(
157
126
  method: "GET",
158
127
  url: method_url,
@@ -426,7 +395,6 @@ module IBMWatson
426
395
 
427
396
  method_url = "/v1/recognize"
428
397
 
429
- headers = authenticator.authenticate(headers)
430
398
  response = request(
431
399
  method: "POST",
432
400
  url: method_url,
@@ -536,8 +504,7 @@ module IBMWatson
536
504
  require_relative("./websocket/speech_to_text_websocket_listener.rb")
537
505
  headers = {}
538
506
  headers = conn.default_options.headers.to_hash unless conn.default_options.headers.to_hash.empty?
539
- headers = authenticator.authenticate(headers)
540
- url = @url.gsub("https:", "wss:")
507
+ service_url = @service_url.gsub("https:", "wss:")
541
508
  params = {
542
509
  "model" => model,
543
510
  "customization_id" => customization_id,
@@ -547,7 +514,7 @@ module IBMWatson
547
514
  "base_model_version" => base_model_version
548
515
  }
549
516
  params.delete_if { |_, v| v.nil? }
550
- url += "/v1/recognize?" + HTTP::URI.form_encode(params)
517
+ service_url += "/v1/recognize?" + HTTP::URI.form_encode(params)
551
518
  options = {
552
519
  "content_type" => content_type,
553
520
  "inactivity_timeout" => inactivity_timeout,
@@ -568,58 +535,8 @@ module IBMWatson
568
535
  "audio_metrics" => audio_metrics
569
536
  }
570
537
  options.delete_if { |_, v| v.nil? }
571
- WebSocketClient.new(audio: audio, chunk_data: chunk_data, options: options, recognize_callback: recognize_callback, url: url, headers: headers, disable_ssl_verification: @disable_ssl_verification)
538
+ WebSocketClient.new(audio: audio, chunk_data: chunk_data, options: options, recognize_callback: recognize_callback, service_url: service_url, headers: headers, disable_ssl_verification: @disable_ssl_verification)
572
539
  end
573
-
574
- # :nocov:
575
- # @deprecated This will method be removed in the next major release. Use {#recognize_using_websocket} instead.
576
- def recognize_with_websocket(
577
- content_type:,
578
- recognize_callback:,
579
- audio: nil,
580
- chunk_data: false,
581
- model: nil,
582
- customization_id: nil,
583
- acoustic_customization_id: nil,
584
- customization_weight: nil,
585
- base_model_version: nil,
586
- inactivity_timeout: nil,
587
- interim_results: nil,
588
- keywords: nil,
589
- keywords_threshold: nil,
590
- max_alternatives: nil,
591
- word_alternatives_threshold: nil,
592
- word_confidence: nil,
593
- timestamps: nil,
594
- profanity_filter: nil,
595
- smart_formatting: nil,
596
- speaker_labels: nil
597
- )
598
- Kernel.warn("[DEPRECATION] `recognize_with_websocket` is deprecated and will be removed in the next major release. Please use `recognize_using_websocket` instead.")
599
- recognize_using_websocket(
600
- audio: audio,
601
- chunk_data: chunk_data,
602
- content_type: content_type,
603
- model: model,
604
- recognize_callback: recognize_callback,
605
- customization_id: customization_id,
606
- acoustic_customization_id: acoustic_customization_id,
607
- customization_weight: customization_weight,
608
- base_model_version: base_model_version,
609
- inactivity_timeout: inactivity_timeout,
610
- interim_results: interim_results,
611
- keywords: keywords,
612
- keywords_threshold: keywords_threshold,
613
- max_alternatives: max_alternatives,
614
- word_alternatives_threshold: word_alternatives_threshold,
615
- word_confidence: word_confidence,
616
- timestamps: timestamps,
617
- profanity_filter: profanity_filter,
618
- smart_formatting: smart_formatting,
619
- speaker_labels: speaker_labels
620
- )
621
- end
622
- # :nocov:
623
540
  #########################
624
541
  # Asynchronous
625
542
  #########################
@@ -687,7 +604,6 @@ module IBMWatson
687
604
 
688
605
  method_url = "/v1/register_callback"
689
606
 
690
- headers = authenticator.authenticate(headers)
691
607
  response = request(
692
608
  method: "POST",
693
609
  url: method_url,
@@ -723,7 +639,6 @@ module IBMWatson
723
639
 
724
640
  method_url = "/v1/unregister_callback"
725
641
 
726
- headers = authenticator.authenticate(headers)
727
642
  request(
728
643
  method: "POST",
729
644
  url: method_url,
@@ -1060,7 +975,6 @@ module IBMWatson
1060
975
 
1061
976
  method_url = "/v1/recognitions"
1062
977
 
1063
- headers = authenticator.authenticate(headers)
1064
978
  response = request(
1065
979
  method: "POST",
1066
980
  url: method_url,
@@ -1095,7 +1009,6 @@ module IBMWatson
1095
1009
 
1096
1010
  method_url = "/v1/recognitions"
1097
1011
 
1098
- headers = authenticator.authenticate(headers)
1099
1012
  response = request(
1100
1013
  method: "GET",
1101
1014
  url: method_url,
@@ -1136,7 +1049,6 @@ module IBMWatson
1136
1049
 
1137
1050
  method_url = "/v1/recognitions/%s" % [ERB::Util.url_encode(id)]
1138
1051
 
1139
- headers = authenticator.authenticate(headers)
1140
1052
  response = request(
1141
1053
  method: "GET",
1142
1054
  url: method_url,
@@ -1171,7 +1083,6 @@ module IBMWatson
1171
1083
 
1172
1084
  method_url = "/v1/recognitions/%s" % [ERB::Util.url_encode(id)]
1173
1085
 
1174
- headers = authenticator.authenticate(headers)
1175
1086
  request(
1176
1087
  method: "DELETE",
1177
1088
  url: method_url,
@@ -1247,7 +1158,6 @@ module IBMWatson
1247
1158
 
1248
1159
  method_url = "/v1/customizations"
1249
1160
 
1250
- headers = authenticator.authenticate(headers)
1251
1161
  response = request(
1252
1162
  method: "POST",
1253
1163
  url: method_url,
@@ -1285,7 +1195,6 @@ module IBMWatson
1285
1195
 
1286
1196
  method_url = "/v1/customizations"
1287
1197
 
1288
- headers = authenticator.authenticate(headers)
1289
1198
  response = request(
1290
1199
  method: "GET",
1291
1200
  url: method_url,
@@ -1318,7 +1227,6 @@ module IBMWatson
1318
1227
 
1319
1228
  method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
1320
1229
 
1321
- headers = authenticator.authenticate(headers)
1322
1230
  response = request(
1323
1231
  method: "GET",
1324
1232
  url: method_url,
@@ -1352,7 +1260,6 @@ module IBMWatson
1352
1260
 
1353
1261
  method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
1354
1262
 
1355
- headers = authenticator.authenticate(headers)
1356
1263
  request(
1357
1264
  method: "DELETE",
1358
1265
  url: method_url,
@@ -1441,7 +1348,6 @@ module IBMWatson
1441
1348
 
1442
1349
  method_url = "/v1/customizations/%s/train" % [ERB::Util.url_encode(customization_id)]
1443
1350
 
1444
- headers = authenticator.authenticate(headers)
1445
1351
  response = request(
1446
1352
  method: "POST",
1447
1353
  url: method_url,
@@ -1478,7 +1384,6 @@ module IBMWatson
1478
1384
 
1479
1385
  method_url = "/v1/customizations/%s/reset" % [ERB::Util.url_encode(customization_id)]
1480
1386
 
1481
- headers = authenticator.authenticate(headers)
1482
1387
  request(
1483
1388
  method: "POST",
1484
1389
  url: method_url,
@@ -1523,7 +1428,6 @@ module IBMWatson
1523
1428
 
1524
1429
  method_url = "/v1/customizations/%s/upgrade_model" % [ERB::Util.url_encode(customization_id)]
1525
1430
 
1526
- headers = authenticator.authenticate(headers)
1527
1431
  request(
1528
1432
  method: "POST",
1529
1433
  url: method_url,
@@ -1560,7 +1464,6 @@ module IBMWatson
1560
1464
 
1561
1465
  method_url = "/v1/customizations/%s/corpora" % [ERB::Util.url_encode(customization_id)]
1562
1466
 
1563
- headers = authenticator.authenticate(headers)
1564
1467
  response = request(
1565
1468
  method: "GET",
1566
1469
  url: method_url,
@@ -1677,7 +1580,6 @@ module IBMWatson
1677
1580
 
1678
1581
  method_url = "/v1/customizations/%s/corpora/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(corpus_name)]
1679
1582
 
1680
- headers = authenticator.authenticate(headers)
1681
1583
  request(
1682
1584
  method: "POST",
1683
1585
  url: method_url,
@@ -1716,7 +1618,6 @@ module IBMWatson
1716
1618
 
1717
1619
  method_url = "/v1/customizations/%s/corpora/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(corpus_name)]
1718
1620
 
1719
- headers = authenticator.authenticate(headers)
1720
1621
  response = request(
1721
1622
  method: "GET",
1722
1623
  url: method_url,
@@ -1757,7 +1658,6 @@ module IBMWatson
1757
1658
 
1758
1659
  method_url = "/v1/customizations/%s/corpora/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(corpus_name)]
1759
1660
 
1760
- headers = authenticator.authenticate(headers)
1761
1661
  request(
1762
1662
  method: "DELETE",
1763
1663
  url: method_url,
@@ -1814,7 +1714,6 @@ module IBMWatson
1814
1714
 
1815
1715
  method_url = "/v1/customizations/%s/words" % [ERB::Util.url_encode(customization_id)]
1816
1716
 
1817
- headers = authenticator.authenticate(headers)
1818
1717
  response = request(
1819
1718
  method: "GET",
1820
1719
  url: method_url,
@@ -1906,7 +1805,6 @@ module IBMWatson
1906
1805
 
1907
1806
  method_url = "/v1/customizations/%s/words" % [ERB::Util.url_encode(customization_id)]
1908
1807
 
1909
- headers = authenticator.authenticate(headers)
1910
1808
  request(
1911
1809
  method: "POST",
1912
1810
  url: method_url,
@@ -2003,7 +1901,6 @@ module IBMWatson
2003
1901
 
2004
1902
  method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word_name)]
2005
1903
 
2006
- headers = authenticator.authenticate(headers)
2007
1904
  request(
2008
1905
  method: "PUT",
2009
1906
  url: method_url,
@@ -2042,7 +1939,6 @@ module IBMWatson
2042
1939
 
2043
1940
  method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word_name)]
2044
1941
 
2045
- headers = authenticator.authenticate(headers)
2046
1942
  response = request(
2047
1943
  method: "GET",
2048
1944
  url: method_url,
@@ -2084,7 +1980,6 @@ module IBMWatson
2084
1980
 
2085
1981
  method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word_name)]
2086
1982
 
2087
- headers = authenticator.authenticate(headers)
2088
1983
  request(
2089
1984
  method: "DELETE",
2090
1985
  url: method_url,
@@ -2121,7 +2016,6 @@ module IBMWatson
2121
2016
 
2122
2017
  method_url = "/v1/customizations/%s/grammars" % [ERB::Util.url_encode(customization_id)]
2123
2018
 
2124
- headers = authenticator.authenticate(headers)
2125
2019
  response = request(
2126
2020
  method: "GET",
2127
2021
  url: method_url,
@@ -2233,7 +2127,6 @@ module IBMWatson
2233
2127
 
2234
2128
  method_url = "/v1/customizations/%s/grammars/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(grammar_name)]
2235
2129
 
2236
- headers = authenticator.authenticate(headers)
2237
2130
  request(
2238
2131
  method: "POST",
2239
2132
  url: method_url,
@@ -2272,7 +2165,6 @@ module IBMWatson
2272
2165
 
2273
2166
  method_url = "/v1/customizations/%s/grammars/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(grammar_name)]
2274
2167
 
2275
- headers = authenticator.authenticate(headers)
2276
2168
  response = request(
2277
2169
  method: "GET",
2278
2170
  url: method_url,
@@ -2312,7 +2204,6 @@ module IBMWatson
2312
2204
 
2313
2205
  method_url = "/v1/customizations/%s/grammars/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(grammar_name)]
2314
2206
 
2315
- headers = authenticator.authenticate(headers)
2316
2207
  request(
2317
2208
  method: "DELETE",
2318
2209
  url: method_url,
@@ -2368,7 +2259,6 @@ module IBMWatson
2368
2259
 
2369
2260
  method_url = "/v1/acoustic_customizations"
2370
2261
 
2371
- headers = authenticator.authenticate(headers)
2372
2262
  response = request(
2373
2263
  method: "POST",
2374
2264
  url: method_url,
@@ -2406,7 +2296,6 @@ module IBMWatson
2406
2296
 
2407
2297
  method_url = "/v1/acoustic_customizations"
2408
2298
 
2409
- headers = authenticator.authenticate(headers)
2410
2299
  response = request(
2411
2300
  method: "GET",
2412
2301
  url: method_url,
@@ -2439,7 +2328,6 @@ module IBMWatson
2439
2328
 
2440
2329
  method_url = "/v1/acoustic_customizations/%s" % [ERB::Util.url_encode(customization_id)]
2441
2330
 
2442
- headers = authenticator.authenticate(headers)
2443
2331
  response = request(
2444
2332
  method: "GET",
2445
2333
  url: method_url,
@@ -2473,7 +2361,6 @@ module IBMWatson
2473
2361
 
2474
2362
  method_url = "/v1/acoustic_customizations/%s" % [ERB::Util.url_encode(customization_id)]
2475
2363
 
2476
- headers = authenticator.authenticate(headers)
2477
2364
  request(
2478
2365
  method: "DELETE",
2479
2366
  url: method_url,
@@ -2565,7 +2452,6 @@ module IBMWatson
2565
2452
 
2566
2453
  method_url = "/v1/acoustic_customizations/%s/train" % [ERB::Util.url_encode(customization_id)]
2567
2454
 
2568
- headers = authenticator.authenticate(headers)
2569
2455
  response = request(
2570
2456
  method: "POST",
2571
2457
  url: method_url,
@@ -2604,7 +2490,6 @@ module IBMWatson
2604
2490
 
2605
2491
  method_url = "/v1/acoustic_customizations/%s/reset" % [ERB::Util.url_encode(customization_id)]
2606
2492
 
2607
- headers = authenticator.authenticate(headers)
2608
2493
  request(
2609
2494
  method: "POST",
2610
2495
  url: method_url,
@@ -2673,7 +2558,6 @@ module IBMWatson
2673
2558
 
2674
2559
  method_url = "/v1/acoustic_customizations/%s/upgrade_model" % [ERB::Util.url_encode(customization_id)]
2675
2560
 
2676
- headers = authenticator.authenticate(headers)
2677
2561
  request(
2678
2562
  method: "POST",
2679
2563
  url: method_url,
@@ -2713,7 +2597,6 @@ module IBMWatson
2713
2597
 
2714
2598
  method_url = "/v1/acoustic_customizations/%s/audio" % [ERB::Util.url_encode(customization_id)]
2715
2599
 
2716
- headers = authenticator.authenticate(headers)
2717
2600
  response = request(
2718
2601
  method: "GET",
2719
2602
  url: method_url,
@@ -2897,7 +2780,6 @@ module IBMWatson
2897
2780
 
2898
2781
  method_url = "/v1/acoustic_customizations/%s/audio/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(audio_name)]
2899
2782
 
2900
- headers = authenticator.authenticate(headers)
2901
2783
  request(
2902
2784
  method: "POST",
2903
2785
  url: method_url,
@@ -2952,7 +2834,6 @@ module IBMWatson
2952
2834
 
2953
2835
  method_url = "/v1/acoustic_customizations/%s/audio/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(audio_name)]
2954
2836
 
2955
- headers = authenticator.authenticate(headers)
2956
2837
  response = request(
2957
2838
  method: "GET",
2958
2839
  url: method_url,
@@ -2994,7 +2875,6 @@ module IBMWatson
2994
2875
 
2995
2876
  method_url = "/v1/acoustic_customizations/%s/audio/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(audio_name)]
2996
2877
 
2997
- headers = authenticator.authenticate(headers)
2998
2878
  request(
2999
2879
  method: "DELETE",
3000
2880
  url: method_url,
@@ -3037,7 +2917,6 @@ module IBMWatson
3037
2917
 
3038
2918
  method_url = "/v1/user_data"
3039
2919
 
3040
- headers = authenticator.authenticate(headers)
3041
2920
  request(
3042
2921
  method: "DELETE",
3043
2922
  url: method_url,
@@ -49,46 +49,17 @@ module IBMWatson
49
49
  # Construct a new client for the Text to Speech service.
50
50
  #
51
51
  # @param args [Hash] The args to initialize with
52
- # @option args url [String] The base url to use when contacting the service (e.g.
53
- # "https://stream.watsonplatform.net/text-to-speech/api").
54
- # The base url may differ between IBM Cloud regions.
55
- # @option args username [String] The username used to authenticate with the service.
56
- # Username and password credentials are only required to run your
57
- # application locally or outside of IBM Cloud. When running on
58
- # IBM Cloud, the credentials will be automatically loaded from the
59
- # `VCAP_SERVICES` environment variable.
60
- # @option args password [String] The password used to authenticate with the service.
61
- # Username and password credentials are only required to run your
62
- # application locally or outside of IBM Cloud. When running on
63
- # IBM Cloud, the credentials will be automatically loaded from the
64
- # `VCAP_SERVICES` environment variable.
65
- # @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
66
- # this API key is provided, the SDK will manage the token and handle the
67
- # refreshing.
68
- # @option args iam_access_token [String] An IAM access token is fully managed by the application.
69
- # Responsibility falls on the application to refresh the token, either before
70
- # it expires or reactively upon receiving a 401 from the service as any requests
71
- # made with an expired token will fail.
72
- # @option args iam_url [String] An optional URL for the IAM service API. Defaults to
73
- # 'https://iam.cloud.ibm.com/identity/token'.
74
- # @option args iam_client_id [String] An optional client id for the IAM service API.
75
- # @option args iam_client_secret [String] An optional client secret for the IAM service API.
76
- # @option args icp4d_access_token [STRING] A ICP4D(IBM Cloud Pak for Data) access token is
77
- # fully managed by the application. Responsibility falls on the application to
78
- # refresh the token, either before it expires or reactively upon receiving a 401
79
- # from the service as any requests made with an expired token will fail.
80
- # @option args icp4d_url [STRING] In order to use an SDK-managed token with ICP4D authentication, this
81
- # URL must be passed in.
82
- # @option args authentication_type [STRING] Specifies the authentication pattern to use. Values that it
83
- # takes are basic, iam or icp4d.
52
+ # @option args service_url [String] The base service URL to use when contacting the service.
53
+ # The base service_url may differ between IBM Cloud regions.
54
+ # @option args authenticator [Object] The Authenticator instance to be configured for this service.
84
55
  def initialize(args = {})
85
56
  @__async_initialized__ = false
86
57
  defaults = {}
87
- defaults[:url] = "https://stream.watsonplatform.net/text-to-speech/api"
58
+ defaults[:service_url] = "https://stream.watsonplatform.net/text-to-speech/api"
88
59
  defaults[:authenticator] = nil
89
- defaults[:authentication_type] = nil
90
60
  args = defaults.merge(args)
91
- args[:display_name] = "Text to Speech"
61
+ args[:service_name] = "text_to_speech"
62
+ args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
92
63
  super
93
64
  end
94
65
 
@@ -114,7 +85,6 @@ module IBMWatson
114
85
 
115
86
  method_url = "/v1/voices"
116
87
 
117
- headers = authenticator.authenticate(headers)
118
88
  response = request(
119
89
  method: "GET",
120
90
  url: method_url,
@@ -155,7 +125,6 @@ module IBMWatson
155
125
 
156
126
  method_url = "/v1/voices/%s" % [ERB::Util.url_encode(voice)]
157
127
 
158
- headers = authenticator.authenticate(headers)
159
128
  response = request(
160
129
  method: "GET",
161
130
  url: method_url,
@@ -293,7 +262,6 @@ module IBMWatson
293
262
 
294
263
  method_url = "/v1/synthesize"
295
264
 
296
- headers = authenticator.authenticate(headers)
297
265
  response = request(
298
266
  method: "POST",
299
267
  url: method_url,
@@ -351,7 +319,6 @@ module IBMWatson
351
319
 
352
320
  method_url = "/v1/pronunciation"
353
321
 
354
- headers = authenticator.authenticate(headers)
355
322
  response = request(
356
323
  method: "GET",
357
324
  url: method_url,
@@ -399,7 +366,6 @@ module IBMWatson
399
366
 
400
367
  method_url = "/v1/customizations"
401
368
 
402
- headers = authenticator.authenticate(headers)
403
369
  response = request(
404
370
  method: "POST",
405
371
  url: method_url,
@@ -440,7 +406,6 @@ module IBMWatson
440
406
 
441
407
  method_url = "/v1/customizations"
442
408
 
443
- headers = authenticator.authenticate(headers)
444
409
  response = request(
445
410
  method: "GET",
446
411
  url: method_url,
@@ -508,7 +473,6 @@ module IBMWatson
508
473
 
509
474
  method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
510
475
 
511
- headers = authenticator.authenticate(headers)
512
476
  request(
513
477
  method: "POST",
514
478
  url: method_url,
@@ -544,7 +508,6 @@ module IBMWatson
544
508
 
545
509
  method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
546
510
 
547
- headers = authenticator.authenticate(headers)
548
511
  response = request(
549
512
  method: "GET",
550
513
  url: method_url,
@@ -577,7 +540,6 @@ module IBMWatson
577
540
 
578
541
  method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
579
542
 
580
- headers = authenticator.authenticate(headers)
581
543
  request(
582
544
  method: "DELETE",
583
545
  url: method_url,
@@ -649,7 +611,6 @@ module IBMWatson
649
611
 
650
612
  method_url = "/v1/customizations/%s/words" % [ERB::Util.url_encode(customization_id)]
651
613
 
652
- headers = authenticator.authenticate(headers)
653
614
  request(
654
615
  method: "POST",
655
616
  url: method_url,
@@ -685,7 +646,6 @@ module IBMWatson
685
646
 
686
647
  method_url = "/v1/customizations/%s/words" % [ERB::Util.url_encode(customization_id)]
687
648
 
688
- headers = authenticator.authenticate(headers)
689
649
  response = request(
690
650
  method: "GET",
691
651
  url: method_url,
@@ -760,7 +720,6 @@ module IBMWatson
760
720
 
761
721
  method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word)]
762
722
 
763
- headers = authenticator.authenticate(headers)
764
723
  request(
765
724
  method: "PUT",
766
725
  url: method_url,
@@ -798,7 +757,6 @@ module IBMWatson
798
757
 
799
758
  method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word)]
800
759
 
801
- headers = authenticator.authenticate(headers)
802
760
  response = request(
803
761
  method: "GET",
804
762
  url: method_url,
@@ -835,7 +793,6 @@ module IBMWatson
835
793
 
836
794
  method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word)]
837
795
 
838
- headers = authenticator.authenticate(headers)
839
796
  request(
840
797
  method: "DELETE",
841
798
  url: method_url,
@@ -878,7 +835,6 @@ module IBMWatson
878
835
 
879
836
  method_url = "/v1/user_data"
880
837
 
881
- headers = authenticator.authenticate(headers)
882
838
  request(
883
839
  method: "DELETE",
884
840
  url: method_url,
@@ -53,44 +53,21 @@ module IBMWatson
53
53
  # Instead, specify a version date that is compatible with your
54
54
  # application, and don't change it until your application is
55
55
  # ready for a later version.
56
- # @option args url [String] The base url to use when contacting the service (e.g.
57
- # "https://gateway.watsonplatform.net/tone-analyzer/api").
58
- # The base url may differ between IBM Cloud regions.
59
- # @option args username [String] The username used to authenticate with the service.
60
- # Username and password credentials are only required to run your
61
- # application locally or outside of IBM Cloud. When running on
62
- # IBM Cloud, the credentials will be automatically loaded from the
63
- # `VCAP_SERVICES` environment variable.
64
- # @option args password [String] The password used to authenticate with the service.
65
- # Username and password credentials are only required to run your
66
- # application locally or outside of IBM Cloud. When running on
67
- # IBM Cloud, the credentials will be automatically loaded from the
68
- # `VCAP_SERVICES` environment variable.
69
- # @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
70
- # this API key is provided, the SDK will manage the token and handle the
71
- # refreshing.
72
- # @option args iam_access_token [String] An IAM access token is fully managed by the application.
73
- # Responsibility falls on the application to refresh the token, either before
74
- # it expires or reactively upon receiving a 401 from the service as any requests
75
- # made with an expired token will fail.
76
- # @option args iam_url [String] An optional URL for the IAM service API. Defaults to
77
- # 'https://iam.cloud.ibm.com/identity/token'.
78
- # @option args iam_client_id [String] An optional client id for the IAM service API.
79
- # @option args iam_client_secret [String] An optional client secret for the IAM service API.
80
- # @option args authentication_type [STRING] Specifies the authentication pattern to use. Values that it
81
- # takes are basic, iam or icp4d.
56
+ # @option args service_url [String] The base service URL to use when contacting the service.
57
+ # The base service_url may differ between IBM Cloud regions.
58
+ # @option args authenticator [Object] The Authenticator instance to be configured for this service.
82
59
  def initialize(args = {})
83
60
  @__async_initialized__ = false
84
61
  defaults = {}
85
62
  defaults[:version] = nil
86
- defaults[:url] = "https://gateway.watsonplatform.net/tone-analyzer/api"
63
+ defaults[:service_url] = "https://gateway.watsonplatform.net/tone-analyzer/api"
87
64
  defaults[:authenticator] = nil
88
- defaults[:authentication_type] = nil
89
65
  args = defaults.merge(args)
90
66
  @version = args[:version]
91
67
  raise ArgumentError.new("version must be provided") if @version.nil?
92
68
 
93
- args[:display_name] = "Tone Analyzer"
69
+ args[:service_name] = "tone_analyzer"
70
+ args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
94
71
  super
95
72
  end
96
73
 
@@ -172,7 +149,6 @@ module IBMWatson
172
149
 
173
150
  method_url = "/v3/tone"
174
151
 
175
- headers = authenticator.authenticate(headers)
176
152
  response = request(
177
153
  method: "POST",
178
154
  url: method_url,
@@ -235,7 +211,6 @@ module IBMWatson
235
211
 
236
212
  method_url = "/v3/tone_chat"
237
213
 
238
- headers = authenticator.authenticate(headers)
239
214
  response = request(
240
215
  method: "POST",
241
216
  url: method_url,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IBMWatson
4
- VERSION = "1.0.0.rc2"
4
+ VERSION = "1.0.0.rc3"
5
5
  end