ibm_watson 1.2.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +33 -5
  3. data/lib/ibm_watson/assistant_v1.rb +153 -209
  4. data/lib/ibm_watson/assistant_v2.rb +168 -15
  5. data/lib/ibm_watson/compare_comply_v1.rb +11 -5
  6. data/lib/ibm_watson/discovery_v1.rb +14 -8
  7. data/lib/ibm_watson/discovery_v2.rb +605 -12
  8. data/lib/ibm_watson/language_translator_v3.rb +166 -47
  9. data/lib/ibm_watson/natural_language_classifier_v1.rb +10 -4
  10. data/lib/ibm_watson/natural_language_understanding_v1.rb +19 -15
  11. data/lib/ibm_watson/personality_insights_v3.rb +17 -11
  12. data/lib/ibm_watson/speech_to_text_v1.rb +323 -195
  13. data/lib/ibm_watson/text_to_speech_v1.rb +75 -59
  14. data/lib/ibm_watson/tone_analyzer_v3.rb +11 -5
  15. data/lib/ibm_watson/version.rb +1 -1
  16. data/lib/ibm_watson/visual_recognition_v3.rb +11 -5
  17. data/lib/ibm_watson/visual_recognition_v4.rb +199 -4
  18. data/test/integration/test_assistant_v2.rb +25 -0
  19. data/test/integration/test_compare_comply_v1.rb +1 -12
  20. data/test/integration/test_discovery_v2.rb +118 -6
  21. data/test/integration/test_language_translator_v3.rb +5 -0
  22. data/test/integration/test_speech_to_text_v1.rb +2 -0
  23. data/test/integration/test_visual_recognition_v4.rb +9 -0
  24. data/test/unit/test_assistant_v1.rb +98 -98
  25. data/test/unit/test_assistant_v2.rb +102 -8
  26. data/test/unit/test_compare_comply_v1.rb +20 -20
  27. data/test/unit/test_discovery_v1.rb +125 -125
  28. data/test/unit/test_discovery_v2.rb +262 -29
  29. data/test/unit/test_language_translator_v3.rb +85 -24
  30. data/test/unit/test_natural_language_classifier_v1.rb +17 -17
  31. data/test/unit/test_natural_language_understanding_v1.rb +10 -10
  32. data/test/unit/test_personality_insights_v3.rb +14 -10
  33. data/test/unit/test_speech_to_text_v1.rb +97 -97
  34. data/test/unit/test_text_to_speech_v1.rb +41 -41
  35. data/test/unit/test_tone_analyzer_v3.rb +12 -12
  36. data/test/unit/test_visual_recognition_v3.rb +16 -16
  37. data/test/unit/test_visual_recognition_v4.rb +117 -30
  38. metadata +5 -6
  39. data/test/unit/test_vcap_using_personality_insights.rb +0 -161
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (C) Copyright IBM Corp. 2020.
3
+ # (C) Copyright IBM Corp. 2018, 2020.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -14,23 +14,25 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- # The IBM® Text to Speech service provides APIs that use IBM's speech-synthesis
18
- # capabilities to synthesize text into natural-sounding speech in a variety of languages,
19
- # dialects, and voices. The service supports at least one male or female voice, sometimes
20
- # both, for each language. The audio is streamed back to the client with minimal delay.
17
+ # The IBM Watson™ Text to Speech service provides APIs that use IBM's
18
+ # speech-synthesis capabilities to synthesize text into natural-sounding speech in a
19
+ # variety of languages, dialects, and voices. The service supports at least one male or
20
+ # female voice, sometimes both, for each language. The audio is streamed back to the
21
+ # client with minimal delay.
21
22
  #
22
23
  # For speech synthesis, the service supports a synchronous HTTP Representational State
23
- # Transfer (REST) interface. It also supports a WebSocket interface that provides both
24
- # plain text and SSML input, including the SSML <mark> element and word timings.
25
- # SSML is an XML-based markup language that provides text annotation for speech-synthesis
26
- # applications.
24
+ # Transfer (REST) interface and a WebSocket interface. Both interfaces support plain text
25
+ # and SSML input. SSML is an XML-based markup language that provides text annotation for
26
+ # speech-synthesis applications. The WebSocket interface also supports the SSML
27
+ # <code>&lt;mark&gt;</code> element and word timings.
27
28
  #
28
- # The service also offers a customization interface. You can use the interface to define
29
- # sounds-like or phonetic translations for words. A sounds-like translation consists of
30
- # one or more words that, when combined, sound like the word. A phonetic translation is
31
- # based on the SSML phoneme format for representing a word. You can specify a phonetic
32
- # translation in standard International Phonetic Alphabet (IPA) representation or in the
33
- # proprietary IBM Symbolic Phonetic Representation (SPR).
29
+ # The service offers a customization interface that you can use to define sounds-like or
30
+ # phonetic translations for words. A sounds-like translation consists of one or more words
31
+ # that, when combined, sound like the word. A phonetic translation is based on the SSML
32
+ # phoneme format for representing a word. You can specify a phonetic translation in
33
+ # standard International Phonetic Alphabet (IPA) representation or in the proprietary IBM
34
+ # Symbolic Phonetic Representation (SPR). The Arabic, Chinese, Dutch, and Korean languages
35
+ # support only IPA.
34
36
 
35
37
  require "concurrent"
36
38
  require "erb"
@@ -44,6 +46,8 @@ module IBMWatson
44
46
  # The Text to Speech V1 service.
45
47
  class TextToSpeechV1 < IBMCloudSdkCore::BaseService
46
48
  include Concurrent::Async
49
+ DEFAULT_SERVICE_NAME = "text_to_speech"
50
+ DEFAULT_SERVICE_URL = "https://api.us-south.text-to-speech.watson.cloud.ibm.com"
47
51
  ##
48
52
  # @!method initialize(args)
49
53
  # Construct a new client for the Text to Speech service.
@@ -52,15 +56,19 @@ module IBMWatson
52
56
  # @option args service_url [String] The base service URL to use when contacting the service.
53
57
  # The base service_url may differ between IBM Cloud regions.
54
58
  # @option args authenticator [Object] The Authenticator instance to be configured for this service.
59
+ # @option args service_name [String] The name of the service to configure. Will be used as the key to load
60
+ # any external configuration, if applicable.
55
61
  def initialize(args = {})
56
62
  @__async_initialized__ = false
57
63
  defaults = {}
58
- defaults[:service_url] = "https://stream.watsonplatform.net/text-to-speech/api"
64
+ defaults[:service_url] = DEFAULT_SERVICE_URL
65
+ defaults[:service_name] = DEFAULT_SERVICE_NAME
59
66
  defaults[:authenticator] = nil
67
+ user_service_url = args[:service_url] unless args[:service_url].nil?
60
68
  args = defaults.merge(args)
61
- args[:service_name] = "text_to_speech"
62
69
  args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
63
70
  super
71
+ @service_url = user_service_url unless user_service_url.nil?
64
72
  end
65
73
 
66
74
  #########################
@@ -71,11 +79,13 @@ module IBMWatson
71
79
  # @!method list_voices
72
80
  # List voices.
73
81
  # Lists all voices available for use with the service. The information includes the
74
- # name, language, gender, and other details about the voice. To see information
75
- # about a specific voice, use the **Get a voice** method.
82
+ # name, language, gender, and other details about the voice. The ordering of the
83
+ # list of voices can change from call to call; do not rely on an alphabetized or
84
+ # static list of voices. To see information about a specific voice, use the **Get a
85
+ # voice** method.
76
86
  #
77
87
  # **See also:** [Listing all available
78
- # voices](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-voices#listVoices).
88
+ # voices](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices#listVoices).
79
89
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
80
90
  def list_voices
81
91
  headers = {
@@ -104,7 +114,7 @@ module IBMWatson
104
114
  # **List voices** method.
105
115
  #
106
116
  # **See also:** [Listing a specific
107
- # voice](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-voices#listVoice).
117
+ # voice](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices#listVoice).
108
118
  # @param voice [String] The voice for which information is to be returned.
109
119
  # @param customization_id [String] The customization ID (GUID) of a custom voice model for which information is to be
110
120
  # returned. You must make the request with credentials for the instance of the
@@ -150,7 +160,7 @@ module IBMWatson
150
160
  # specify. The service returns the synthesized audio stream as an array of bytes.
151
161
  #
152
162
  # **See also:** [The HTTP
153
- # interface](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-usingHTTP#usingHTTP).
163
+ # interface](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-usingHTTP#usingHTTP).
154
164
  #
155
165
  #
156
166
  # ### Audio formats (accept types)
@@ -198,7 +208,7 @@ module IBMWatson
198
208
  #
199
209
  # For more information about specifying an audio format, including additional
200
210
  # details about some of the formats, see [Audio
201
- # formats](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-audioFormats#audioFormats).
211
+ # formats](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-audioFormats#audioFormats).
202
212
  #
203
213
  #
204
214
  # ### Warning messages
@@ -216,10 +226,10 @@ module IBMWatson
216
226
  # description.
217
227
  # @param voice [String] The voice to use for synthesis.
218
228
  # @param customization_id [String] The customization ID (GUID) of a custom voice model to use for the synthesis. If a
219
- # custom voice model is specified, it is guaranteed to work only if it matches the
220
- # language of the indicated voice. You must make the request with credentials for
221
- # the instance of the service that owns the custom model. Omit the parameter to use
222
- # the specified voice with no customization.
229
+ # custom voice model is specified, it works only if it matches the language of the
230
+ # indicated voice. You must make the request with credentials for the instance of
231
+ # the service that owns the custom model. Omit the parameter to use the specified
232
+ # voice with no customization.
223
233
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
224
234
  def synthesize(text:, accept: nil, voice: nil, customization_id: nil)
225
235
  raise ArgumentError.new("text must be provided") if text.nil?
@@ -263,17 +273,17 @@ module IBMWatson
263
273
  # specific voice to see the default translation for the language of that voice or
264
274
  # for a specific custom voice model to see the translation for that voice model.
265
275
  #
266
- # **Note:** This method is currently a beta release. The method does not support the
267
- # Arabic, Chinese, and Dutch languages.
276
+ # **Note:** This method is currently a beta release.
268
277
  #
269
278
  # **See also:** [Querying a word from a
270
- # language](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuWordsQueryLanguage).
279
+ # language](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordsQueryLanguage).
271
280
  # @param text [String] The word for which the pronunciation is requested.
272
281
  # @param voice [String] A voice that specifies the language in which the pronunciation is to be returned.
273
282
  # All voices for the same language (for example, `en-US`) return the same
274
283
  # translation.
275
- # @param format [String] The phoneme format in which to return the pronunciation. Omit the parameter to
276
- # obtain the pronunciation in the default format.
284
+ # @param format [String] The phoneme format in which to return the pronunciation. The Arabic, Chinese,
285
+ # Dutch, and Korean languages support only IPA. Omit the parameter to obtain the
286
+ # pronunciation in the default format.
277
287
  # @param customization_id [String] The customization ID (GUID) of a custom voice model for which the pronunciation is
278
288
  # to be returned. The language of a specified custom model must match the language
279
289
  # of the specified voice. If the word is not defined in the specified custom model,
@@ -320,14 +330,15 @@ module IBMWatson
320
330
  # model. The model is owned by the instance of the service whose credentials are
321
331
  # used to create it.
322
332
  #
323
- # **Note:** This method is currently a beta release. The service does not support
324
- # voice model customization for the Arabic, Chinese, and Dutch languages.
333
+ # **Note:** This method is currently a beta release.
325
334
  #
326
335
  # **See also:** [Creating a custom
327
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customModels#cuModelsCreate).
336
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsCreate).
328
337
  # @param name [String] The name of the new custom voice model.
329
- # @param language [String] The language of the new custom voice model. Omit the parameter to use the the
330
- # default language, `en-US`.
338
+ # @param language [String] The language of the new custom voice model. You create a custom voice model for a
339
+ # specific language, not for a specific voice. A custom model can be used with any
340
+ # voice, standard or neural, for its specified language. Omit the parameter to use
341
+ # the the default language, `en-US`.
331
342
  # @param description [String] A description of the new custom voice model. Specifying a description is
332
343
  # recommended.
333
344
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
@@ -370,7 +381,7 @@ module IBMWatson
370
381
  # **Note:** This method is currently a beta release.
371
382
  #
372
383
  # **See also:** [Querying all custom
373
- # models](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customModels#cuModelsQueryAll).
384
+ # models](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsQueryAll).
374
385
  # @param language [String] The language for which custom voice models that are owned by the requesting
375
386
  # credentials are to be returned. Omit the parameter to see all custom voice models
376
387
  # that are owned by the requester.
@@ -425,11 +436,11 @@ module IBMWatson
425
436
  #
426
437
  # **See also:**
427
438
  # * [Updating a custom
428
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customModels#cuModelsUpdate)
439
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsUpdate)
429
440
  # * [Adding words to a Japanese custom
430
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuJapaneseAdd)
441
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuJapaneseAdd)
431
442
  # * [Understanding
432
- # customization](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customIntro#customIntro).
443
+ # customization](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customIntro#customIntro).
433
444
  # @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
434
445
  # with credentials for the instance of the service that owns the custom model.
435
446
  # @param name [String] A new name for the custom voice model.
@@ -475,7 +486,7 @@ module IBMWatson
475
486
  # **Note:** This method is currently a beta release.
476
487
  #
477
488
  # **See also:** [Querying a custom
478
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customModels#cuModelsQuery).
489
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsQuery).
479
490
  # @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
480
491
  # with credentials for the instance of the service that owns the custom model.
481
492
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
@@ -507,7 +518,7 @@ module IBMWatson
507
518
  # **Note:** This method is currently a beta release.
508
519
  #
509
520
  # **See also:** [Deleting a custom
510
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customModels#cuModelsDelete).
521
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsDelete).
511
522
  # @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
512
523
  # with credentials for the instance of the service that owns the custom model.
513
524
  # @return [nil]
@@ -560,11 +571,11 @@ module IBMWatson
560
571
  #
561
572
  # **See also:**
562
573
  # * [Adding multiple words to a custom
563
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuWordsAdd)
574
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordsAdd)
564
575
  # * [Adding words to a Japanese custom
565
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuJapaneseAdd)
576
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuJapaneseAdd)
566
577
  # * [Understanding
567
- # customization](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customIntro#customIntro).
578
+ # customization](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customIntro#customIntro).
568
579
  # @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
569
580
  # with credentials for the instance of the service that owns the custom model.
570
581
  # @param words [Array[Word]] The **Add custom words** method accepts an array of `Word` objects. Each object
@@ -613,7 +624,7 @@ module IBMWatson
613
624
  # **Note:** This method is currently a beta release.
614
625
  #
615
626
  # **See also:** [Querying all words from a custom
616
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuWordsQueryModel).
627
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordsQueryModel).
617
628
  # @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
618
629
  # with credentials for the instance of the service that owns the custom model.
619
630
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
@@ -663,24 +674,25 @@ module IBMWatson
663
674
  #
664
675
  # **See also:**
665
676
  # * [Adding a single word to a custom
666
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuWordAdd)
677
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordAdd)
667
678
  # * [Adding words to a Japanese custom
668
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuJapaneseAdd)
679
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuJapaneseAdd)
669
680
  # * [Understanding
670
- # customization](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customIntro#customIntro).
681
+ # customization](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customIntro#customIntro).
671
682
  # @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
672
683
  # with credentials for the instance of the service that owns the custom model.
673
684
  # @param word [String] The word that is to be added or updated for the custom voice model.
674
685
  # @param translation [String] The phonetic or sounds-like translation for the word. A phonetic translation is
675
686
  # based on the SSML format for representing the phonetic string of a word either as
676
- # an IPA translation or as an IBM SPR translation. A sounds-like is one or more
677
- # words that, when combined, sound like the word.
687
+ # an IPA translation or as an IBM SPR translation. The Arabic, Chinese, Dutch, and
688
+ # Korean languages support only IPA. A sounds-like is one or more words that, when
689
+ # combined, sound like the word.
678
690
  # @param part_of_speech [String] **Japanese only.** The part of speech for the word. The service uses the value to
679
691
  # produce the correct intonation for the word. You can create only a single entry,
680
692
  # with or without a single part of speech, for any word; you cannot create multiple
681
693
  # entries with different parts of speech for the same word. For more information,
682
694
  # see [Working with Japanese
683
- # entries](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-rules#jaNotes).
695
+ # entries](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-rules#jaNotes).
684
696
  # @return [nil]
685
697
  def add_word(customization_id:, word:, translation:, part_of_speech: nil)
686
698
  raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
@@ -721,7 +733,7 @@ module IBMWatson
721
733
  # **Note:** This method is currently a beta release.
722
734
  #
723
735
  # **See also:** [Querying a single word from a custom
724
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuWordQueryModel).
736
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordQueryModel).
725
737
  # @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
726
738
  # with credentials for the instance of the service that owns the custom model.
727
739
  # @param word [String] The word that is to be queried from the custom voice model.
@@ -757,7 +769,7 @@ module IBMWatson
757
769
  # **Note:** This method is currently a beta release.
758
770
  #
759
771
  # **See also:** [Deleting a word from a custom
760
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuWordDelete).
772
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordDelete).
761
773
  # @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
762
774
  # with credentials for the instance of the service that owns the custom model.
763
775
  # @param word [String] The word that is to be deleted from the custom voice model.
@@ -793,13 +805,17 @@ module IBMWatson
793
805
  # deletes all data for the customer ID, regardless of the method by which the
794
806
  # information was added. The method has no effect if no data is associated with the
795
807
  # customer ID. You must issue the request with credentials for the same instance of
796
- # the service that was used to associate the customer ID with the data.
808
+ # the service that was used to associate the customer ID with the data. You
809
+ # associate a customer ID with data by passing the `X-Watson-Metadata` header with a
810
+ # request that passes the data.
797
811
  #
798
- # You associate a customer ID with data by passing the `X-Watson-Metadata` header
799
- # with a request that passes the data.
812
+ # **Note:** If you delete an instance of the service from the service console, all
813
+ # data associated with that service instance is automatically deleted. This includes
814
+ # all custom voice models and word/translation pairs, and all data related to speech
815
+ # synthesis requests.
800
816
  #
801
817
  # **See also:** [Information
802
- # security](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-information-security#information-security).
818
+ # security](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-information-security#information-security).
803
819
  # @param customer_id [String] The customer ID for which all data is to be deleted.
804
820
  # @return [nil]
805
821
  def delete_user_data(customer_id:)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (C) Copyright IBM Corp. 2020.
3
+ # (C) Copyright IBM Corp. 2018, 2020.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -38,6 +38,8 @@ module IBMWatson
38
38
  # The Tone Analyzer V3 service.
39
39
  class ToneAnalyzerV3 < IBMCloudSdkCore::BaseService
40
40
  include Concurrent::Async
41
+ DEFAULT_SERVICE_NAME = "tone_analyzer"
42
+ DEFAULT_SERVICE_URL = "https://api.us-south.tone-analyzer.watson.cloud.ibm.com"
41
43
  ##
42
44
  # @!method initialize(args)
43
45
  # Construct a new client for the Tone Analyzer service.
@@ -56,19 +58,23 @@ module IBMWatson
56
58
  # @option args service_url [String] The base service URL to use when contacting the service.
57
59
  # The base service_url may differ between IBM Cloud regions.
58
60
  # @option args authenticator [Object] The Authenticator instance to be configured for this service.
61
+ # @option args service_name [String] The name of the service to configure. Will be used as the key to load
62
+ # any external configuration, if applicable.
59
63
  def initialize(args = {})
60
64
  @__async_initialized__ = false
61
65
  defaults = {}
62
66
  defaults[:version] = nil
63
- defaults[:service_url] = "https://gateway.watsonplatform.net/tone-analyzer/api"
67
+ defaults[:service_url] = DEFAULT_SERVICE_URL
68
+ defaults[:service_name] = DEFAULT_SERVICE_NAME
64
69
  defaults[:authenticator] = nil
70
+ user_service_url = args[:service_url] unless args[:service_url].nil?
65
71
  args = defaults.merge(args)
66
72
  @version = args[:version]
67
73
  raise ArgumentError.new("version must be provided") if @version.nil?
68
74
 
69
- args[:service_name] = "tone_analyzer"
70
75
  args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
71
76
  super
77
+ @service_url = user_service_url unless user_service_url.nil?
72
78
  end
73
79
 
74
80
  #########################
@@ -97,7 +103,7 @@ module IBMWatson
97
103
  # analyzes only the textual content.
98
104
  #
99
105
  # **See also:** [Using the general-purpose
100
- # endpoint](https://cloud.ibm.com/docs/services/tone-analyzer?topic=tone-analyzer-utgpe#utgpe).
106
+ # endpoint](https://cloud.ibm.com/docs/tone-analyzer?topic=tone-analyzer-utgpe#utgpe).
101
107
  # @param tone_input [ToneInput] JSON, plain text, or HTML input that contains the content to be analyzed. For JSON
102
108
  # input, provide an object of type `ToneInput`.
103
109
  # @param content_type [String] The type of the input. A character encoding can be specified by including a
@@ -177,7 +183,7 @@ module IBMWatson
177
183
  # character encoding for JSON content is effectively always UTF-8.
178
184
  #
179
185
  # **See also:** [Using the customer-engagement
180
- # endpoint](https://cloud.ibm.com/docs/services/tone-analyzer?topic=tone-analyzer-utco#utco).
186
+ # endpoint](https://cloud.ibm.com/docs/tone-analyzer?topic=tone-analyzer-utco#utco).
181
187
  # @param utterances [Array[Utterance]] An array of `Utterance` objects that provides the input content that the service
182
188
  # is to analyze.
183
189
  # @param content_language [String] The language of the input text for the request: English or French. Regional
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IBMWatson
4
- VERSION = "1.2.0"
4
+ VERSION = "1.6.0"
5
5
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (C) Copyright IBM Corp. 2020.
3
+ # (C) Copyright IBM Corp. 2018, 2020.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -30,6 +30,8 @@ module IBMWatson
30
30
  # The Visual Recognition V3 service.
31
31
  class VisualRecognitionV3 < IBMCloudSdkCore::BaseService
32
32
  include Concurrent::Async
33
+ DEFAULT_SERVICE_NAME = "visual_recognition"
34
+ DEFAULT_SERVICE_URL = "https://api.us-south.visual-recognition.watson.cloud.ibm.com"
33
35
  ##
34
36
  # @!method initialize(args)
35
37
  # Construct a new client for the Visual Recognition service.
@@ -48,19 +50,23 @@ module IBMWatson
48
50
  # @option args service_url [String] The base service URL to use when contacting the service.
49
51
  # The base service_url may differ between IBM Cloud regions.
50
52
  # @option args authenticator [Object] The Authenticator instance to be configured for this service.
53
+ # @option args service_name [String] The name of the service to configure. Will be used as the key to load
54
+ # any external configuration, if applicable.
51
55
  def initialize(args = {})
52
56
  @__async_initialized__ = false
53
57
  defaults = {}
54
58
  defaults[:version] = nil
55
- defaults[:service_url] = "https://gateway.watsonplatform.net/visual-recognition/api"
59
+ defaults[:service_url] = DEFAULT_SERVICE_URL
60
+ defaults[:service_name] = DEFAULT_SERVICE_NAME
56
61
  defaults[:authenticator] = nil
62
+ user_service_url = args[:service_url] unless args[:service_url].nil?
57
63
  args = defaults.merge(args)
58
64
  @version = args[:version]
59
65
  raise ArgumentError.new("version must be provided") if @version.nil?
60
66
 
61
- args[:service_name] = "visual_recognition"
62
67
  args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
63
68
  super
69
+ @service_url = user_service_url unless user_service_url.nil?
64
70
  end
65
71
 
66
72
  #########################
@@ -305,7 +311,7 @@ module IBMWatson
305
311
  # Update a custom classifier by adding new positive or negative classes or by adding
306
312
  # new images to existing classes. You must supply at least one set of positive or
307
313
  # negative examples. For details, see [Updating custom
308
- # classifiers](https://cloud.ibm.com/docs/services/visual-recognition?topic=visual-recognition-customizing#updating-custom-classifiers).
314
+ # classifiers](https://cloud.ibm.com/docs/visual-recognition?topic=visual-recognition-customizing#updating-custom-classifiers).
309
315
  #
310
316
  # Encode all names in UTF-8 if they contain non-ASCII characters (.zip and image
311
317
  # file names, and classifier and class names). The service assumes UTF-8 encoding if
@@ -464,7 +470,7 @@ module IBMWatson
464
470
  # You associate a customer ID with data by passing the `X-Watson-Metadata` header
465
471
  # with a request that passes data. For more information about personal data and
466
472
  # customer IDs, see [Information
467
- # security](https://cloud.ibm.com/docs/services/visual-recognition?topic=visual-recognition-information-security).
473
+ # security](https://cloud.ibm.com/docs/visual-recognition?topic=visual-recognition-information-security).
468
474
  # @param customer_id [String] The customer ID for which all data is to be deleted.
469
475
  # @return [nil]
470
476
  def delete_user_data(customer_id:)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (C) Copyright IBM Corp. 2020.
3
+ # (C) Copyright IBM Corp. 2019, 2020.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -29,6 +29,8 @@ module IBMWatson
29
29
  # The Visual Recognition V4 service.
30
30
  class VisualRecognitionV4 < IBMCloudSdkCore::BaseService
31
31
  include Concurrent::Async
32
+ DEFAULT_SERVICE_NAME = "visual_recognition"
33
+ DEFAULT_SERVICE_URL = "https://api.us-south.visual-recognition.watson.cloud.ibm.com"
32
34
  ##
33
35
  # @!method initialize(args)
34
36
  # Construct a new client for the Visual Recognition service.
@@ -47,19 +49,23 @@ module IBMWatson
47
49
  # @option args service_url [String] The base service URL to use when contacting the service.
48
50
  # The base service_url may differ between IBM Cloud regions.
49
51
  # @option args authenticator [Object] The Authenticator instance to be configured for this service.
52
+ # @option args service_name [String] The name of the service to configure. Will be used as the key to load
53
+ # any external configuration, if applicable.
50
54
  def initialize(args = {})
51
55
  @__async_initialized__ = false
52
56
  defaults = {}
53
57
  defaults[:version] = nil
54
- defaults[:service_url] = "https://gateway.watsonplatform.net/visual-recognition/api"
58
+ defaults[:service_url] = DEFAULT_SERVICE_URL
59
+ defaults[:service_name] = DEFAULT_SERVICE_NAME
55
60
  defaults[:authenticator] = nil
61
+ user_service_url = args[:service_url] unless args[:service_url].nil?
56
62
  args = defaults.merge(args)
57
63
  @version = args[:version]
58
64
  raise ArgumentError.new("version must be provided") if @version.nil?
59
65
 
60
- args[:service_name] = "visual_recognition"
61
66
  args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
62
67
  super
68
+ @service_url = user_service_url unless user_service_url.nil?
63
69
  end
64
70
 
65
71
  #########################
@@ -319,6 +325,51 @@ module IBMWatson
319
325
  )
320
326
  nil
321
327
  end
328
+
329
+ ##
330
+ # @!method get_model_file(collection_id:, feature:, model_format:)
331
+ # Get a model.
332
+ # Download a model that you can deploy to detect objects in images. The collection
333
+ # must include a generated model, which is indicated in the response for the
334
+ # collection details as `"rscnn_ready": true`. If the value is `false`, train or
335
+ # retrain the collection to generate the model.
336
+ #
337
+ # Currently, the model format is specific to Android apps. For more information
338
+ # about how to deploy the model to your app, see the [Watson Visual Recognition on
339
+ # Android](https://github.com/matt-ny/rscnn) project in GitHub.
340
+ # @param collection_id [String] The identifier of the collection.
341
+ # @param feature [String] The feature for the model.
342
+ # @param model_format [String] The format of the returned model.
343
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
344
+ def get_model_file(collection_id:, feature:, model_format:)
345
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
346
+
347
+ raise ArgumentError.new("feature must be provided") if feature.nil?
348
+
349
+ raise ArgumentError.new("model_format must be provided") if model_format.nil?
350
+
351
+ headers = {
352
+ }
353
+ sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "get_model_file")
354
+ headers.merge!(sdk_headers)
355
+
356
+ params = {
357
+ "version" => @version,
358
+ "feature" => feature,
359
+ "model_format" => model_format
360
+ }
361
+
362
+ method_url = "/v4/collections/%s/model" % [ERB::Util.url_encode(collection_id)]
363
+
364
+ response = request(
365
+ method: "GET",
366
+ url: method_url,
367
+ headers: headers,
368
+ params: params,
369
+ accept_json: false
370
+ )
371
+ response
372
+ end
322
373
  #########################
323
374
  # Images
324
375
  #########################
@@ -529,6 +580,150 @@ module IBMWatson
529
580
  response
530
581
  end
531
582
  #########################
583
+ # Objects
584
+ #########################
585
+
586
+ ##
587
+ # @!method list_object_metadata(collection_id:)
588
+ # List object metadata.
589
+ # Retrieves a list of object names in a collection.
590
+ # @param collection_id [String] The identifier of the collection.
591
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
592
+ def list_object_metadata(collection_id:)
593
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
594
+
595
+ headers = {
596
+ }
597
+ sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "list_object_metadata")
598
+ headers.merge!(sdk_headers)
599
+
600
+ params = {
601
+ "version" => @version
602
+ }
603
+
604
+ method_url = "/v4/collections/%s/objects" % [ERB::Util.url_encode(collection_id)]
605
+
606
+ response = request(
607
+ method: "GET",
608
+ url: method_url,
609
+ headers: headers,
610
+ params: params,
611
+ accept_json: true
612
+ )
613
+ response
614
+ end
615
+
616
+ ##
617
+ # @!method update_object_metadata(collection_id:, object:, new_object:)
618
+ # Update an object name.
619
+ # Update the name of an object. A successful request updates the training data for
620
+ # all images that use the object.
621
+ # @param collection_id [String] The identifier of the collection.
622
+ # @param object [String] The name of the object.
623
+ # @param new_object [String] The updated name of the object. The name can contain alphanumeric, underscore,
624
+ # hyphen, space, and dot characters. It cannot begin with the reserved prefix
625
+ # `sys-`.
626
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
627
+ def update_object_metadata(collection_id:, object:, new_object:)
628
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
629
+
630
+ raise ArgumentError.new("object must be provided") if object.nil?
631
+
632
+ raise ArgumentError.new("new_object must be provided") if new_object.nil?
633
+
634
+ headers = {
635
+ }
636
+ sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "update_object_metadata")
637
+ headers.merge!(sdk_headers)
638
+
639
+ params = {
640
+ "version" => @version
641
+ }
642
+
643
+ data = {
644
+ "object" => new_object
645
+ }
646
+
647
+ method_url = "/v4/collections/%s/objects/%s" % [ERB::Util.url_encode(collection_id), ERB::Util.url_encode(object)]
648
+
649
+ response = request(
650
+ method: "POST",
651
+ url: method_url,
652
+ headers: headers,
653
+ params: params,
654
+ json: data,
655
+ accept_json: true
656
+ )
657
+ response
658
+ end
659
+
660
+ ##
661
+ # @!method get_object_metadata(collection_id:, object:)
662
+ # Get object metadata.
663
+ # Get the number of bounding boxes for a single object in a collection.
664
+ # @param collection_id [String] The identifier of the collection.
665
+ # @param object [String] The name of the object.
666
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
667
+ def get_object_metadata(collection_id:, object:)
668
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
669
+
670
+ raise ArgumentError.new("object must be provided") if object.nil?
671
+
672
+ headers = {
673
+ }
674
+ sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "get_object_metadata")
675
+ headers.merge!(sdk_headers)
676
+
677
+ params = {
678
+ "version" => @version
679
+ }
680
+
681
+ method_url = "/v4/collections/%s/objects/%s" % [ERB::Util.url_encode(collection_id), ERB::Util.url_encode(object)]
682
+
683
+ response = request(
684
+ method: "GET",
685
+ url: method_url,
686
+ headers: headers,
687
+ params: params,
688
+ accept_json: true
689
+ )
690
+ response
691
+ end
692
+
693
+ ##
694
+ # @!method delete_object(collection_id:, object:)
695
+ # Delete an object.
696
+ # Delete one object from a collection. A successful request deletes the training
697
+ # data from all images that use the object.
698
+ # @param collection_id [String] The identifier of the collection.
699
+ # @param object [String] The name of the object.
700
+ # @return [nil]
701
+ def delete_object(collection_id:, object:)
702
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
703
+
704
+ raise ArgumentError.new("object must be provided") if object.nil?
705
+
706
+ headers = {
707
+ }
708
+ sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "delete_object")
709
+ headers.merge!(sdk_headers)
710
+
711
+ params = {
712
+ "version" => @version
713
+ }
714
+
715
+ method_url = "/v4/collections/%s/objects/%s" % [ERB::Util.url_encode(collection_id), ERB::Util.url_encode(object)]
716
+
717
+ request(
718
+ method: "DELETE",
719
+ url: method_url,
720
+ headers: headers,
721
+ params: params,
722
+ accept_json: true
723
+ )
724
+ nil
725
+ end
726
+ #########################
532
727
  # Training
533
728
  #########################
534
729
 
@@ -660,7 +855,7 @@ module IBMWatson
660
855
  # You associate a customer ID with data by passing the `X-Watson-Metadata` header
661
856
  # with a request that passes data. For more information about personal data and
662
857
  # customer IDs, see [Information
663
- # security](https://cloud.ibm.com/docs/services/visual-recognition?topic=visual-recognition-information-security).
858
+ # security](https://cloud.ibm.com/docs/visual-recognition?topic=visual-recognition-information-security).
664
859
  # @param customer_id [String] The customer ID for which all data is to be deleted.
665
860
  # @return [nil]
666
861
  def delete_user_data(customer_id:)