ibm_watson 1.1.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (C) Copyright IBM Corp. 2019.
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.
@@ -20,17 +20,18 @@
20
20
  # both, for each language. The audio is streamed back to the client with minimal delay.
21
21
  #
22
22
  # 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.
23
+ # Transfer (REST) interface and a WebSocket interface. Both interfaces support plain text
24
+ # and SSML input. SSML is an XML-based markup language that provides text annotation for
25
+ # speech-synthesis applications. The WebSocket interface also supports the SSML
26
+ # <code>&lt;mark&gt;</code> element and word timings.
27
27
  #
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).
28
+ # The service offers a customization interface that you can use to define sounds-like or
29
+ # phonetic translations for words. A sounds-like translation consists of one or more words
30
+ # that, when combined, sound like the word. A phonetic translation is based on the SSML
31
+ # phoneme format for representing a word. You can specify a phonetic translation in
32
+ # standard International Phonetic Alphabet (IPA) representation or in the proprietary IBM
33
+ # Symbolic Phonetic Representation (SPR). The Arabic, Chinese, Dutch, and Korean languages
34
+ # support only IPA.
34
35
 
35
36
  require "concurrent"
36
37
  require "erb"
@@ -44,6 +45,8 @@ module IBMWatson
44
45
  # The Text to Speech V1 service.
45
46
  class TextToSpeechV1 < IBMCloudSdkCore::BaseService
46
47
  include Concurrent::Async
48
+ DEFAULT_SERVICE_NAME = "text_to_speech"
49
+ DEFAULT_SERVICE_URL = "https://stream.watsonplatform.net/text-to-speech/api"
47
50
  ##
48
51
  # @!method initialize(args)
49
52
  # Construct a new client for the Text to Speech service.
@@ -52,15 +55,19 @@ module IBMWatson
52
55
  # @option args service_url [String] The base service URL to use when contacting the service.
53
56
  # The base service_url may differ between IBM Cloud regions.
54
57
  # @option args authenticator [Object] The Authenticator instance to be configured for this service.
58
+ # @option args service_name [String] The name of the service to configure. Will be used as the key to load
59
+ # any external configuration, if applicable.
55
60
  def initialize(args = {})
56
61
  @__async_initialized__ = false
57
62
  defaults = {}
58
- defaults[:service_url] = "https://stream.watsonplatform.net/text-to-speech/api"
63
+ defaults[:service_url] = DEFAULT_SERVICE_URL
64
+ defaults[:service_name] = DEFAULT_SERVICE_NAME
59
65
  defaults[:authenticator] = nil
66
+ user_service_url = args[:service_url] unless args[:service_url].nil?
60
67
  args = defaults.merge(args)
61
- args[:service_name] = "text_to_speech"
62
68
  args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
63
69
  super
70
+ @service_url = user_service_url unless user_service_url.nil?
64
71
  end
65
72
 
66
73
  #########################
@@ -75,7 +82,7 @@ module IBMWatson
75
82
  # about a specific voice, use the **Get a voice** method.
76
83
  #
77
84
  # **See also:** [Listing all available
78
- # voices](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-voices#listVoices).
85
+ # voices](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices#listVoices).
79
86
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
80
87
  def list_voices
81
88
  headers = {
@@ -104,7 +111,7 @@ module IBMWatson
104
111
  # **List voices** method.
105
112
  #
106
113
  # **See also:** [Listing a specific
107
- # voice](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-voices#listVoice).
114
+ # voice](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices#listVoice).
108
115
  # @param voice [String] The voice for which information is to be returned.
109
116
  # @param customization_id [String] The customization ID (GUID) of a custom voice model for which information is to be
110
117
  # returned. You must make the request with credentials for the instance of the
@@ -150,7 +157,7 @@ module IBMWatson
150
157
  # specify. The service returns the synthesized audio stream as an array of bytes.
151
158
  #
152
159
  # **See also:** [The HTTP
153
- # interface](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-usingHTTP#usingHTTP).
160
+ # interface](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-usingHTTP#usingHTTP).
154
161
  #
155
162
  #
156
163
  # ### Audio formats (accept types)
@@ -198,7 +205,7 @@ module IBMWatson
198
205
  #
199
206
  # For more information about specifying an audio format, including additional
200
207
  # 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).
208
+ # formats](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-audioFormats#audioFormats).
202
209
  #
203
210
  #
204
211
  # ### Warning messages
@@ -216,10 +223,10 @@ module IBMWatson
216
223
  # description.
217
224
  # @param voice [String] The voice to use for synthesis.
218
225
  # @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.
226
+ # custom voice model is specified, it works only if it matches the language of the
227
+ # indicated voice. You must make the request with credentials for the instance of
228
+ # the service that owns the custom model. Omit the parameter to use the specified
229
+ # voice with no customization.
223
230
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
224
231
  def synthesize(text:, accept: nil, voice: nil, customization_id: nil)
225
232
  raise ArgumentError.new("text must be provided") if text.nil?
@@ -266,13 +273,14 @@ module IBMWatson
266
273
  # **Note:** This method is currently a beta release.
267
274
  #
268
275
  # **See also:** [Querying a word from a
269
- # language](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuWordsQueryLanguage).
276
+ # language](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordsQueryLanguage).
270
277
  # @param text [String] The word for which the pronunciation is requested.
271
278
  # @param voice [String] A voice that specifies the language in which the pronunciation is to be returned.
272
279
  # All voices for the same language (for example, `en-US`) return the same
273
280
  # translation.
274
- # @param format [String] The phoneme format in which to return the pronunciation. Omit the parameter to
275
- # obtain the pronunciation in the default format.
281
+ # @param format [String] The phoneme format in which to return the pronunciation. The Arabic, Chinese,
282
+ # Dutch, and Korean languages support only IPA. Omit the parameter to obtain the
283
+ # pronunciation in the default format.
276
284
  # @param customization_id [String] The customization ID (GUID) of a custom voice model for which the pronunciation is
277
285
  # to be returned. The language of a specified custom model must match the language
278
286
  # of the specified voice. If the word is not defined in the specified custom model,
@@ -322,10 +330,12 @@ module IBMWatson
322
330
  # **Note:** This method is currently a beta release.
323
331
  #
324
332
  # **See also:** [Creating a custom
325
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customModels#cuModelsCreate).
333
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsCreate).
326
334
  # @param name [String] The name of the new custom voice model.
327
- # @param language [String] The language of the new custom voice model. Omit the parameter to use the the
328
- # default language, `en-US`.
335
+ # @param language [String] The language of the new custom voice model. You create a custom voice model for a
336
+ # specific language, not for a specific voice. A custom model can be used with any
337
+ # voice, standard or neural, for its specified language. Omit the parameter to use
338
+ # the the default language, `en-US`.
329
339
  # @param description [String] A description of the new custom voice model. Specifying a description is
330
340
  # recommended.
331
341
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
@@ -368,7 +378,7 @@ module IBMWatson
368
378
  # **Note:** This method is currently a beta release.
369
379
  #
370
380
  # **See also:** [Querying all custom
371
- # models](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customModels#cuModelsQueryAll).
381
+ # models](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsQueryAll).
372
382
  # @param language [String] The language for which custom voice models that are owned by the requesting
373
383
  # credentials are to be returned. Omit the parameter to see all custom voice models
374
384
  # that are owned by the requester.
@@ -423,11 +433,11 @@ module IBMWatson
423
433
  #
424
434
  # **See also:**
425
435
  # * [Updating a custom
426
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customModels#cuModelsUpdate)
436
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsUpdate)
427
437
  # * [Adding words to a Japanese custom
428
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuJapaneseAdd)
438
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuJapaneseAdd)
429
439
  # * [Understanding
430
- # customization](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customIntro#customIntro).
440
+ # customization](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customIntro#customIntro).
431
441
  # @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
432
442
  # with credentials for the instance of the service that owns the custom model.
433
443
  # @param name [String] A new name for the custom voice model.
@@ -473,7 +483,7 @@ module IBMWatson
473
483
  # **Note:** This method is currently a beta release.
474
484
  #
475
485
  # **See also:** [Querying a custom
476
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customModels#cuModelsQuery).
486
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsQuery).
477
487
  # @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
478
488
  # with credentials for the instance of the service that owns the custom model.
479
489
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
@@ -505,7 +515,7 @@ module IBMWatson
505
515
  # **Note:** This method is currently a beta release.
506
516
  #
507
517
  # **See also:** [Deleting a custom
508
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customModels#cuModelsDelete).
518
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsDelete).
509
519
  # @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
510
520
  # with credentials for the instance of the service that owns the custom model.
511
521
  # @return [nil]
@@ -558,11 +568,11 @@ module IBMWatson
558
568
  #
559
569
  # **See also:**
560
570
  # * [Adding multiple words to a custom
561
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuWordsAdd)
571
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordsAdd)
562
572
  # * [Adding words to a Japanese custom
563
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuJapaneseAdd)
573
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuJapaneseAdd)
564
574
  # * [Understanding
565
- # customization](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customIntro#customIntro).
575
+ # customization](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customIntro#customIntro).
566
576
  # @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
567
577
  # with credentials for the instance of the service that owns the custom model.
568
578
  # @param words [Array[Word]] The **Add custom words** method accepts an array of `Word` objects. Each object
@@ -611,7 +621,7 @@ module IBMWatson
611
621
  # **Note:** This method is currently a beta release.
612
622
  #
613
623
  # **See also:** [Querying all words from a custom
614
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuWordsQueryModel).
624
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordsQueryModel).
615
625
  # @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
616
626
  # with credentials for the instance of the service that owns the custom model.
617
627
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
@@ -661,24 +671,25 @@ module IBMWatson
661
671
  #
662
672
  # **See also:**
663
673
  # * [Adding a single word to a custom
664
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuWordAdd)
674
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordAdd)
665
675
  # * [Adding words to a Japanese custom
666
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuJapaneseAdd)
676
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuJapaneseAdd)
667
677
  # * [Understanding
668
- # customization](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customIntro#customIntro).
678
+ # customization](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customIntro#customIntro).
669
679
  # @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
670
680
  # with credentials for the instance of the service that owns the custom model.
671
681
  # @param word [String] The word that is to be added or updated for the custom voice model.
672
682
  # @param translation [String] The phonetic or sounds-like translation for the word. A phonetic translation is
673
683
  # based on the SSML format for representing the phonetic string of a word either as
674
- # an IPA translation or as an IBM SPR translation. A sounds-like is one or more
675
- # words that, when combined, sound like the word.
684
+ # an IPA translation or as an IBM SPR translation. The Arabic, Chinese, Dutch, and
685
+ # Korean languages support only IPA. A sounds-like is one or more words that, when
686
+ # combined, sound like the word.
676
687
  # @param part_of_speech [String] **Japanese only.** The part of speech for the word. The service uses the value to
677
688
  # produce the correct intonation for the word. You can create only a single entry,
678
689
  # with or without a single part of speech, for any word; you cannot create multiple
679
690
  # entries with different parts of speech for the same word. For more information,
680
691
  # see [Working with Japanese
681
- # entries](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-rules#jaNotes).
692
+ # entries](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-rules#jaNotes).
682
693
  # @return [nil]
683
694
  def add_word(customization_id:, word:, translation:, part_of_speech: nil)
684
695
  raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
@@ -719,7 +730,7 @@ module IBMWatson
719
730
  # **Note:** This method is currently a beta release.
720
731
  #
721
732
  # **See also:** [Querying a single word from a custom
722
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuWordQueryModel).
733
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordQueryModel).
723
734
  # @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
724
735
  # with credentials for the instance of the service that owns the custom model.
725
736
  # @param word [String] The word that is to be queried from the custom voice model.
@@ -755,7 +766,7 @@ module IBMWatson
755
766
  # **Note:** This method is currently a beta release.
756
767
  #
757
768
  # **See also:** [Deleting a word from a custom
758
- # model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuWordDelete).
769
+ # model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordDelete).
759
770
  # @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
760
771
  # with credentials for the instance of the service that owns the custom model.
761
772
  # @param word [String] The word that is to be deleted from the custom voice model.
@@ -797,7 +808,7 @@ module IBMWatson
797
808
  # with a request that passes the data.
798
809
  #
799
810
  # **See also:** [Information
800
- # security](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-information-security#information-security).
811
+ # security](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-information-security#information-security).
801
812
  # @param customer_id [String] The customer ID for which all data is to be deleted.
802
813
  # @return [nil]
803
814
  def delete_user_data(customer_id:)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (C) Copyright IBM Corp. 2019.
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://gateway.watsonplatform.net/tone-analyzer/api"
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.1.0"
4
+ VERSION = "1.5.0"
5
5
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (C) Copyright IBM Corp. 2019.
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://gateway.watsonplatform.net/visual-recognition/api"
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
  #########################
@@ -177,7 +183,8 @@ module IBMWatson
177
183
  #
178
184
  # Specify the parameter name by appending `_positive_examples` to the class name.
179
185
  # For example, `goldenretriever_positive_examples` creates the class
180
- # **goldenretriever**.
186
+ # **goldenretriever**. The string cannot contain the following characters: ``$ * - {
187
+ # } \ | / ' " ` [ ]``.
181
188
  #
182
189
  # Include at least 10 images in .jpg or .png format. The minimum recommended image
183
190
  # resolution is 32X32 pixels. The maximum number of images is 10,000 images or 100
@@ -304,7 +311,7 @@ module IBMWatson
304
311
  # Update a custom classifier by adding new positive or negative classes or by adding
305
312
  # new images to existing classes. You must supply at least one set of positive or
306
313
  # negative examples. For details, see [Updating custom
307
- # 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).
308
315
  #
309
316
  # Encode all names in UTF-8 if they contain non-ASCII characters (.zip and image
310
317
  # file names, and classifier and class names). The service assumes UTF-8 encoding if
@@ -328,7 +335,8 @@ module IBMWatson
328
335
  #
329
336
  # Specify the parameter name by appending `_positive_examples` to the class name.
330
337
  # For example, `goldenretriever_positive_examples` creates the class
331
- # `goldenretriever`.
338
+ # `goldenretriever`. The string cannot contain the following characters: ``$ * - { }
339
+ # \ | / ' " ` [ ]``.
332
340
  #
333
341
  # Include at least 10 images in .jpg or .png format. The minimum recommended image
334
342
  # resolution is 32X32 pixels. The maximum number of images is 10,000 images or 100
@@ -462,7 +470,7 @@ module IBMWatson
462
470
  # You associate a customer ID with data by passing the `X-Watson-Metadata` header
463
471
  # with a request that passes data. For more information about personal data and
464
472
  # customer IDs, see [Information
465
- # 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).
466
474
  # @param customer_id [String] The customer ID for which all data is to be deleted.
467
475
  # @return [nil]
468
476
  def delete_user_data(customer_id:)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (C) Copyright IBM Corp. 2019.
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://gateway.watsonplatform.net/visual-recognition/api"
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:)