ibm_watson 0.1.3 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/ibm_watson/assistant_v1.rb +5 -5
- data/lib/ibm_watson/discovery_v1.rb +8 -8
- data/lib/ibm_watson/iam_token_manager.rb +5 -5
- data/lib/ibm_watson/language_translator_v3.rb +5 -5
- data/lib/ibm_watson/natural_language_classifier_v1.rb +5 -5
- data/lib/ibm_watson/natural_language_understanding_v1.rb +5 -5
- data/lib/ibm_watson/personality_insights_v3.rb +5 -5
- data/lib/ibm_watson/speech_to_text_v1.rb +5 -5
- data/lib/ibm_watson/text_to_speech_v1.rb +5 -5
- data/lib/ibm_watson/tone_analyzer_v3.rb +5 -5
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v3.rb +5 -5
- data/lib/ibm_watson/watson_service.rb +13 -13
- data/test/integration/test_iam_assistant_v1.rb +29 -29
- data/test/integration/test_visual_recognition_v3.rb +1 -1
- data/test/unit/test_iam_token_manager.rb +7 -7
- data/test/unit/test_language_translator_v3.rb +16 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25afe3adf84e90212b0b4f7e9a98651e25b3a5165f94a814e3ff899db82ee6f4
|
4
|
+
data.tar.gz: 4c1bcb3d15a29138cf78e9447245d3f740ecbc80a0ef8260498e4f0787e965d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a1e2d370f74a61eb68c658bcf07aed4e998db2989fafc397b9710b7aa9ae6c2697cd01747d3b53d28e2a4c6a36be731c6557b2b283f826c8153bbe159e42bf4
|
7
|
+
data.tar.gz: 3a7bad0a95abda16db5b9b85ac953473e6caf55f7b3d86d7302e72a1ecdb65e6e016f45189c79ab6ff2eb379556ddb5e3f2c7b915494ae9973e6d6e982d915b9
|
data/README.md
CHANGED
@@ -90,7 +90,7 @@ You supply either an IAM service **API key** or an **access token**:
|
|
90
90
|
# In the constructor, letting the SDK manage the IAM token
|
91
91
|
discovery = IBMWatson::DiscoveryV1.new(
|
92
92
|
version: "2017-10-16",
|
93
|
-
|
93
|
+
iam_apikey: "<iam_apikey>",
|
94
94
|
iam_url: "<iam_url>" # optional - the default value is https://iam.ng.bluemix.net/identity/token
|
95
95
|
)
|
96
96
|
```
|
@@ -98,7 +98,7 @@ discovery = IBMWatson::DiscoveryV1.new(
|
|
98
98
|
```ruby
|
99
99
|
# after instantiation, letting the SDK manage the IAM token
|
100
100
|
discovery = IBMWatson::DiscoveryV1.new(version: "2017-10-16")
|
101
|
-
discovery.
|
101
|
+
discovery._iam_apikey(iam_apikey: "<iam_apikey>")
|
102
102
|
```
|
103
103
|
|
104
104
|
#### Supplying the access token
|
@@ -59,7 +59,7 @@ module IBMWatson
|
|
59
59
|
# application locally or outside of Bluemix. When running on
|
60
60
|
# Bluemix, the credentials will be automatically loaded from the
|
61
61
|
# `VCAP_SERVICES` environment variable.
|
62
|
-
# @option args
|
62
|
+
# @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
|
63
63
|
# this API key is provided, the SDK will manage the token and handle the
|
64
64
|
# refreshing.
|
65
65
|
# @option args iam_access_token [String] An IAM access token is fully managed by the application.
|
@@ -76,7 +76,7 @@ module IBMWatson
|
|
76
76
|
defaults[:url] = "https://gateway.watsonplatform.net/assistant/api"
|
77
77
|
defaults[:username] = nil
|
78
78
|
defaults[:password] = nil
|
79
|
-
defaults[:
|
79
|
+
defaults[:iam_apikey] = nil
|
80
80
|
defaults[:iam_access_token] = nil
|
81
81
|
defaults[:iam_url] = nil
|
82
82
|
args = defaults.merge(args)
|
@@ -85,7 +85,7 @@ module IBMWatson
|
|
85
85
|
url: args[:url],
|
86
86
|
username: args[:username],
|
87
87
|
password: args[:password],
|
88
|
-
|
88
|
+
iam_apikey: args[:iam_apikey],
|
89
89
|
iam_access_token: args[:iam_access_token],
|
90
90
|
iam_url: args[:iam_url],
|
91
91
|
use_vcap_services: true
|
@@ -102,8 +102,8 @@ module IBMWatson
|
|
102
102
|
@watson_service._iam_access_token(iam_access_token: iam_access_token)
|
103
103
|
end
|
104
104
|
|
105
|
-
def
|
106
|
-
@watson_service.
|
105
|
+
def _iam_apikey(iam_apikey:)
|
106
|
+
@watson_service._iam_apikey(iam_apikey: iam_apikey)
|
107
107
|
end
|
108
108
|
|
109
109
|
# @return [DetailedResponse]
|
@@ -61,7 +61,7 @@ module IBMWatson
|
|
61
61
|
# application locally or outside of Bluemix. When running on
|
62
62
|
# Bluemix, the credentials will be automatically loaded from the
|
63
63
|
# `VCAP_SERVICES` environment variable.
|
64
|
-
# @option args
|
64
|
+
# @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
|
65
65
|
# this API key is provided, the SDK will manage the token and handle the
|
66
66
|
# refreshing.
|
67
67
|
# @option args iam_access_token [String] An IAM access token is fully managed by the application.
|
@@ -78,7 +78,7 @@ module IBMWatson
|
|
78
78
|
defaults[:url] = "https://gateway.watsonplatform.net/discovery/api"
|
79
79
|
defaults[:username] = nil
|
80
80
|
defaults[:password] = nil
|
81
|
-
defaults[:
|
81
|
+
defaults[:iam_apikey] = nil
|
82
82
|
defaults[:iam_access_token] = nil
|
83
83
|
defaults[:iam_url] = nil
|
84
84
|
args = defaults.merge(args)
|
@@ -87,7 +87,7 @@ module IBMWatson
|
|
87
87
|
url: args[:url],
|
88
88
|
username: args[:username],
|
89
89
|
password: args[:password],
|
90
|
-
|
90
|
+
iam_apikey: args[:iam_apikey],
|
91
91
|
iam_access_token: args[:iam_access_token],
|
92
92
|
iam_url: args[:iam_url],
|
93
93
|
use_vcap_services: true
|
@@ -104,8 +104,8 @@ module IBMWatson
|
|
104
104
|
@watson_service._iam_access_token(iam_access_token: iam_access_token)
|
105
105
|
end
|
106
106
|
|
107
|
-
def
|
108
|
-
@watson_service.
|
107
|
+
def _iam_apikey(iam_apikey:)
|
108
|
+
@watson_service._iam_apikey(iam_apikey: iam_apikey)
|
109
109
|
end
|
110
110
|
|
111
111
|
# @return [DetailedResponse]
|
@@ -1224,7 +1224,7 @@ module IBMWatson
|
|
1224
1224
|
"passages" => passages,
|
1225
1225
|
"aggregation" => aggregation,
|
1226
1226
|
"count" => count,
|
1227
|
-
"
|
1227
|
+
"return" => return_fields.to_a,
|
1228
1228
|
"offset" => offset,
|
1229
1229
|
"sort" => sort.to_a,
|
1230
1230
|
"highlight" => highlight,
|
@@ -1320,7 +1320,7 @@ module IBMWatson
|
|
1320
1320
|
"natural_language_query" => natural_language_query,
|
1321
1321
|
"aggregation" => aggregation,
|
1322
1322
|
"count" => count,
|
1323
|
-
"
|
1323
|
+
"return" => return_fields.to_a,
|
1324
1324
|
"offset" => offset,
|
1325
1325
|
"sort" => sort.to_a,
|
1326
1326
|
"highlight" => highlight,
|
@@ -1409,7 +1409,7 @@ module IBMWatson
|
|
1409
1409
|
"natural_language_query" => natural_language_query,
|
1410
1410
|
"aggregation" => aggregation,
|
1411
1411
|
"count" => count,
|
1412
|
-
"
|
1412
|
+
"return" => return_fields.to_a,
|
1413
1413
|
"offset" => offset,
|
1414
1414
|
"sort" => sort.to_a,
|
1415
1415
|
"highlight" => highlight,
|
@@ -16,8 +16,8 @@ REFRESH_TOKEN_GRANT_TYPE = "refresh_token"
|
|
16
16
|
# Class to manage IAM Token Authentication
|
17
17
|
class IAMTokenManager
|
18
18
|
attr_accessor :token_info, :user_access_token
|
19
|
-
def initialize(
|
20
|
-
@
|
19
|
+
def initialize(iam_apikey: nil, iam_access_token: nil, iam_url: nil)
|
20
|
+
@iam_apikey = iam_apikey
|
21
21
|
@user_access_token = iam_access_token
|
22
22
|
@iam_url = iam_url.nil? ? DEFAULT_IAM_URL : iam_url
|
23
23
|
@token_info = {
|
@@ -82,7 +82,7 @@ class IAMTokenManager
|
|
82
82
|
}
|
83
83
|
data = {
|
84
84
|
"grant_type" => REQUEST_TOKEN_GRANT_TYPE,
|
85
|
-
"apikey" => @
|
85
|
+
"apikey" => @iam_apikey,
|
86
86
|
"response_type" => REQUEST_TOKEN_RESPONSE_TYPE
|
87
87
|
}
|
88
88
|
response = request(
|
@@ -121,8 +121,8 @@ class IAMTokenManager
|
|
121
121
|
end
|
122
122
|
|
123
123
|
# Set the IAM api key
|
124
|
-
def
|
125
|
-
@
|
124
|
+
def _iam_apikey(iam_apikey:)
|
125
|
+
@iam_apikey = iam_apikey
|
126
126
|
end
|
127
127
|
|
128
128
|
# Check if currently stored token is expired.
|
@@ -61,7 +61,7 @@ module IBMWatson
|
|
61
61
|
# application locally or outside of Bluemix. When running on
|
62
62
|
# Bluemix, the credentials will be automatically loaded from the
|
63
63
|
# `VCAP_SERVICES` environment variable.
|
64
|
-
# @option args
|
64
|
+
# @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
|
65
65
|
# this API key is provided, the SDK will manage the token and handle the
|
66
66
|
# refreshing.
|
67
67
|
# @option args iam_access_token [String] An IAM access token is fully managed by the application.
|
@@ -78,7 +78,7 @@ module IBMWatson
|
|
78
78
|
defaults[:url] = "https://gateway.watsonplatform.net/language-translator/api"
|
79
79
|
defaults[:username] = nil
|
80
80
|
defaults[:password] = nil
|
81
|
-
defaults[:
|
81
|
+
defaults[:iam_apikey] = nil
|
82
82
|
defaults[:iam_access_token] = nil
|
83
83
|
defaults[:iam_url] = nil
|
84
84
|
args = defaults.merge(args)
|
@@ -87,7 +87,7 @@ module IBMWatson
|
|
87
87
|
url: args[:url],
|
88
88
|
username: args[:username],
|
89
89
|
password: args[:password],
|
90
|
-
|
90
|
+
iam_apikey: args[:iam_apikey],
|
91
91
|
iam_access_token: args[:iam_access_token],
|
92
92
|
iam_url: args[:iam_url],
|
93
93
|
use_vcap_services: true
|
@@ -104,8 +104,8 @@ module IBMWatson
|
|
104
104
|
@watson_service._iam_access_token(iam_access_token: iam_access_token)
|
105
105
|
end
|
106
106
|
|
107
|
-
def
|
108
|
-
@watson_service.
|
107
|
+
def _iam_apikey(iam_apikey:)
|
108
|
+
@watson_service._iam_apikey(iam_apikey: iam_apikey)
|
109
109
|
end
|
110
110
|
|
111
111
|
# @return [DetailedResponse]
|
@@ -50,7 +50,7 @@ module IBMWatson
|
|
50
50
|
# application locally or outside of Bluemix. When running on
|
51
51
|
# Bluemix, the credentials will be automatically loaded from the
|
52
52
|
# `VCAP_SERVICES` environment variable.
|
53
|
-
# @option args
|
53
|
+
# @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
|
54
54
|
# this API key is provided, the SDK will manage the token and handle the
|
55
55
|
# refreshing.
|
56
56
|
# @option args iam_access_token [String] An IAM access token is fully managed by the application.
|
@@ -66,7 +66,7 @@ module IBMWatson
|
|
66
66
|
defaults[:url] = "https://gateway.watsonplatform.net/natural-language-classifier/api"
|
67
67
|
defaults[:username] = nil
|
68
68
|
defaults[:password] = nil
|
69
|
-
defaults[:
|
69
|
+
defaults[:iam_apikey] = nil
|
70
70
|
defaults[:iam_access_token] = nil
|
71
71
|
defaults[:iam_url] = nil
|
72
72
|
args = defaults.merge(args)
|
@@ -75,7 +75,7 @@ module IBMWatson
|
|
75
75
|
url: args[:url],
|
76
76
|
username: args[:username],
|
77
77
|
password: args[:password],
|
78
|
-
|
78
|
+
iam_apikey: args[:iam_apikey],
|
79
79
|
iam_access_token: args[:iam_access_token],
|
80
80
|
iam_url: args[:iam_url],
|
81
81
|
use_vcap_services: true
|
@@ -91,8 +91,8 @@ module IBMWatson
|
|
91
91
|
@watson_service._iam_access_token(iam_access_token: iam_access_token)
|
92
92
|
end
|
93
93
|
|
94
|
-
def
|
95
|
-
@watson_service.
|
94
|
+
def _iam_apikey(iam_apikey:)
|
95
|
+
@watson_service._iam_apikey(iam_apikey: iam_apikey)
|
96
96
|
end
|
97
97
|
|
98
98
|
# @return [DetailedResponse]
|
@@ -65,7 +65,7 @@ module IBMWatson
|
|
65
65
|
# application locally or outside of Bluemix. When running on
|
66
66
|
# Bluemix, the credentials will be automatically loaded from the
|
67
67
|
# `VCAP_SERVICES` environment variable.
|
68
|
-
# @option args
|
68
|
+
# @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
|
69
69
|
# this API key is provided, the SDK will manage the token and handle the
|
70
70
|
# refreshing.
|
71
71
|
# @option args iam_access_token [String] An IAM access token is fully managed by the application.
|
@@ -82,7 +82,7 @@ module IBMWatson
|
|
82
82
|
defaults[:url] = "https://gateway.watsonplatform.net/natural-language-understanding/api"
|
83
83
|
defaults[:username] = nil
|
84
84
|
defaults[:password] = nil
|
85
|
-
defaults[:
|
85
|
+
defaults[:iam_apikey] = nil
|
86
86
|
defaults[:iam_access_token] = nil
|
87
87
|
defaults[:iam_url] = nil
|
88
88
|
args = defaults.merge(args)
|
@@ -91,7 +91,7 @@ module IBMWatson
|
|
91
91
|
url: args[:url],
|
92
92
|
username: args[:username],
|
93
93
|
password: args[:password],
|
94
|
-
|
94
|
+
iam_apikey: args[:iam_apikey],
|
95
95
|
iam_access_token: args[:iam_access_token],
|
96
96
|
iam_url: args[:iam_url],
|
97
97
|
use_vcap_services: true
|
@@ -108,8 +108,8 @@ module IBMWatson
|
|
108
108
|
@watson_service._iam_access_token(iam_access_token: iam_access_token)
|
109
109
|
end
|
110
110
|
|
111
|
-
def
|
112
|
-
@watson_service.
|
111
|
+
def _iam_apikey(iam_apikey:)
|
112
|
+
@watson_service._iam_apikey(iam_apikey: iam_apikey)
|
113
113
|
end
|
114
114
|
|
115
115
|
# @return [DetailedResponse]
|
@@ -76,7 +76,7 @@ module IBMWatson
|
|
76
76
|
# application locally or outside of Bluemix. When running on
|
77
77
|
# Bluemix, the credentials will be automatically loaded from the
|
78
78
|
# `VCAP_SERVICES` environment variable.
|
79
|
-
# @option args
|
79
|
+
# @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
|
80
80
|
# this API key is provided, the SDK will manage the token and handle the
|
81
81
|
# refreshing.
|
82
82
|
# @option args iam_access_token [String] An IAM access token is fully managed by the application.
|
@@ -93,7 +93,7 @@ module IBMWatson
|
|
93
93
|
defaults[:url] = "https://gateway.watsonplatform.net/personality-insights/api"
|
94
94
|
defaults[:username] = nil
|
95
95
|
defaults[:password] = nil
|
96
|
-
defaults[:
|
96
|
+
defaults[:iam_apikey] = nil
|
97
97
|
defaults[:iam_access_token] = nil
|
98
98
|
defaults[:iam_url] = nil
|
99
99
|
args = defaults.merge(args)
|
@@ -102,7 +102,7 @@ module IBMWatson
|
|
102
102
|
url: args[:url],
|
103
103
|
username: args[:username],
|
104
104
|
password: args[:password],
|
105
|
-
|
105
|
+
iam_apikey: args[:iam_apikey],
|
106
106
|
iam_access_token: args[:iam_access_token],
|
107
107
|
iam_url: args[:iam_url],
|
108
108
|
use_vcap_services: true
|
@@ -119,8 +119,8 @@ module IBMWatson
|
|
119
119
|
@watson_service._iam_access_token(iam_access_token: iam_access_token)
|
120
120
|
end
|
121
121
|
|
122
|
-
def
|
123
|
-
@watson_service.
|
122
|
+
def _iam_apikey(iam_apikey:)
|
123
|
+
@watson_service._iam_apikey(iam_apikey: iam_apikey)
|
124
124
|
end
|
125
125
|
|
126
126
|
# @return [DetailedResponse]
|
@@ -98,7 +98,7 @@ module IBMWatson
|
|
98
98
|
# application locally or outside of Bluemix. When running on
|
99
99
|
# Bluemix, the credentials will be automatically loaded from the
|
100
100
|
# `VCAP_SERVICES` environment variable.
|
101
|
-
# @option args
|
101
|
+
# @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
|
102
102
|
# this API key is provided, the SDK will manage the token and handle the
|
103
103
|
# refreshing.
|
104
104
|
# @option args iam_access_token [String] An IAM access token is fully managed by the application.
|
@@ -114,7 +114,7 @@ module IBMWatson
|
|
114
114
|
defaults[:url] = "https://stream.watsonplatform.net/speech-to-text/api"
|
115
115
|
defaults[:username] = nil
|
116
116
|
defaults[:password] = nil
|
117
|
-
defaults[:
|
117
|
+
defaults[:iam_apikey] = nil
|
118
118
|
defaults[:iam_access_token] = nil
|
119
119
|
defaults[:iam_url] = nil
|
120
120
|
args = defaults.merge(args)
|
@@ -123,7 +123,7 @@ module IBMWatson
|
|
123
123
|
url: args[:url],
|
124
124
|
username: args[:username],
|
125
125
|
password: args[:password],
|
126
|
-
|
126
|
+
iam_apikey: args[:iam_apikey],
|
127
127
|
iam_access_token: args[:iam_access_token],
|
128
128
|
iam_url: args[:iam_url],
|
129
129
|
use_vcap_services: true
|
@@ -139,8 +139,8 @@ module IBMWatson
|
|
139
139
|
@watson_service._iam_access_token(iam_access_token: iam_access_token)
|
140
140
|
end
|
141
141
|
|
142
|
-
def
|
143
|
-
@watson_service.
|
142
|
+
def _iam_apikey(iam_apikey:)
|
143
|
+
@watson_service._iam_apikey(iam_apikey: iam_apikey)
|
144
144
|
end
|
145
145
|
|
146
146
|
# @return [DetailedResponse]
|
@@ -99,7 +99,7 @@ module IBMWatson
|
|
99
99
|
# application locally or outside of Bluemix. When running on
|
100
100
|
# Bluemix, the credentials will be automatically loaded from the
|
101
101
|
# `VCAP_SERVICES` environment variable.
|
102
|
-
# @option args
|
102
|
+
# @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
|
103
103
|
# this API key is provided, the SDK will manage the token and handle the
|
104
104
|
# refreshing.
|
105
105
|
# @option args iam_access_token [String] An IAM access token is fully managed by the application.
|
@@ -115,7 +115,7 @@ module IBMWatson
|
|
115
115
|
defaults[:url] = "https://stream.watsonplatform.net/text-to-speech/api"
|
116
116
|
defaults[:username] = nil
|
117
117
|
defaults[:password] = nil
|
118
|
-
defaults[:
|
118
|
+
defaults[:iam_apikey] = nil
|
119
119
|
defaults[:iam_access_token] = nil
|
120
120
|
defaults[:iam_url] = nil
|
121
121
|
args = defaults.merge(args)
|
@@ -124,7 +124,7 @@ module IBMWatson
|
|
124
124
|
url: args[:url],
|
125
125
|
username: args[:username],
|
126
126
|
password: args[:password],
|
127
|
-
|
127
|
+
iam_apikey: args[:iam_apikey],
|
128
128
|
iam_access_token: args[:iam_access_token],
|
129
129
|
iam_url: args[:iam_url],
|
130
130
|
use_vcap_services: true
|
@@ -140,8 +140,8 @@ module IBMWatson
|
|
140
140
|
@watson_service._iam_access_token(iam_access_token: iam_access_token)
|
141
141
|
end
|
142
142
|
|
143
|
-
def
|
144
|
-
@watson_service.
|
143
|
+
def _iam_apikey(iam_apikey:)
|
144
|
+
@watson_service._iam_apikey(iam_apikey: iam_apikey)
|
145
145
|
end
|
146
146
|
|
147
147
|
# @return [DetailedResponse]
|
@@ -67,7 +67,7 @@ module IBMWatson
|
|
67
67
|
# application locally or outside of Bluemix. When running on
|
68
68
|
# Bluemix, the credentials will be automatically loaded from the
|
69
69
|
# `VCAP_SERVICES` environment variable.
|
70
|
-
# @option args
|
70
|
+
# @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
|
71
71
|
# this API key is provided, the SDK will manage the token and handle the
|
72
72
|
# refreshing.
|
73
73
|
# @option args iam_access_token [String] An IAM access token is fully managed by the application.
|
@@ -84,7 +84,7 @@ module IBMWatson
|
|
84
84
|
defaults[:url] = "https://gateway.watsonplatform.net/tone-analyzer/api"
|
85
85
|
defaults[:username] = nil
|
86
86
|
defaults[:password] = nil
|
87
|
-
defaults[:
|
87
|
+
defaults[:iam_apikey] = nil
|
88
88
|
defaults[:iam_access_token] = nil
|
89
89
|
defaults[:iam_url] = nil
|
90
90
|
args = defaults.merge(args)
|
@@ -93,7 +93,7 @@ module IBMWatson
|
|
93
93
|
url: args[:url],
|
94
94
|
username: args[:username],
|
95
95
|
password: args[:password],
|
96
|
-
|
96
|
+
iam_apikey: args[:iam_apikey],
|
97
97
|
iam_access_token: args[:iam_access_token],
|
98
98
|
iam_url: args[:iam_url],
|
99
99
|
use_vcap_services: true
|
@@ -110,8 +110,8 @@ module IBMWatson
|
|
110
110
|
@watson_service._iam_access_token(iam_access_token: iam_access_token)
|
111
111
|
end
|
112
112
|
|
113
|
-
def
|
114
|
-
@watson_service.
|
113
|
+
def _iam_apikey(iam_apikey:)
|
114
|
+
@watson_service._iam_apikey(iam_apikey: iam_apikey)
|
115
115
|
end
|
116
116
|
|
117
117
|
# @return [DetailedResponse]
|
data/lib/ibm_watson/version.rb
CHANGED
@@ -50,7 +50,7 @@ module IBMWatson
|
|
50
50
|
# "https://gateway.watsonplatform.net/visual-recognition/api").
|
51
51
|
# The base url may differ between Bluemix regions.
|
52
52
|
# @option args api_key [String] The API Key used to authenticate.
|
53
|
-
# @option args
|
53
|
+
# @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
|
54
54
|
# this API key is provided, the SDK will manage the token and handle the
|
55
55
|
# refreshing.
|
56
56
|
# @option args iam_access_token [String] An IAM access token is fully managed by the application.
|
@@ -66,7 +66,7 @@ module IBMWatson
|
|
66
66
|
defaults[:version] = nil
|
67
67
|
defaults[:url] = "https://gateway.watsonplatform.net/visual-recognition/api"
|
68
68
|
defaults[:api_key] = nil
|
69
|
-
defaults[:
|
69
|
+
defaults[:iam_apikey] = nil
|
70
70
|
defaults[:iam_access_token] = nil
|
71
71
|
defaults[:iam_url] = nil
|
72
72
|
args = defaults.merge(args)
|
@@ -74,7 +74,7 @@ module IBMWatson
|
|
74
74
|
vcap_services_name: "watson_vision_combined",
|
75
75
|
url: args[:url],
|
76
76
|
api_key: args[:api_key],
|
77
|
-
|
77
|
+
iam_apikey: args[:iam_apikey],
|
78
78
|
iam_access_token: args[:iam_access_token],
|
79
79
|
iam_url: args[:iam_url],
|
80
80
|
use_vcap_services: true
|
@@ -91,8 +91,8 @@ module IBMWatson
|
|
91
91
|
@watson_service._iam_access_token(iam_access_token: iam_access_token)
|
92
92
|
end
|
93
93
|
|
94
|
-
def
|
95
|
-
@watson_service.
|
94
|
+
def _iam_apikey(iam_apikey:)
|
95
|
+
@watson_service._iam_apikey(iam_apikey: iam_apikey)
|
96
96
|
end
|
97
97
|
|
98
98
|
# @return [DetailedResponse]
|
@@ -30,7 +30,7 @@ class WatsonService
|
|
30
30
|
use_vcap_services: true,
|
31
31
|
api_key: nil,
|
32
32
|
x_watson_learning_opt_out: false,
|
33
|
-
|
33
|
+
iam_apikey: nil,
|
34
34
|
iam_access_token: nil,
|
35
35
|
iam_url: nil
|
36
36
|
}
|
@@ -55,17 +55,17 @@ class WatsonService
|
|
55
55
|
@url = @vcap_service_credentials["url"]
|
56
56
|
@username = @vcap_service_credentials["username"] if @vcap_service_credentials.key?("username")
|
57
57
|
@password = @vcap_service_credentials["password"] if @vcap_service_credentials.key?("password")
|
58
|
-
@
|
58
|
+
@iam_apikey = @vcap_service_credentials["iam_apikey"] if @vcap_service_credentials.key?("iam_apikey")
|
59
59
|
@iam_access_token = @vcap_service_credentials["iam_access_token"] if @vcap_service_credentials.key?("iam_access_token")
|
60
60
|
@iam_url = @vcap_service_credentials["iam_url"] if @vcap_service_credentials.key?("iam_url")
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
if !vars[:iam_access_token].nil? || !vars[:
|
65
|
-
_token_manager(
|
64
|
+
if !vars[:iam_access_token].nil? || !vars[:iam_apikey].nil?
|
65
|
+
_token_manager(iam_apikey: vars[:iam_apikey], iam_access_token: vars[:iam_access_token], iam_url: vars[:iam_url])
|
66
66
|
elsif !vars[:username].nil? && !vars[:password].nil?
|
67
67
|
if vars[:username] == "apikey"
|
68
|
-
|
68
|
+
_iam_apikey(iam_apikey: vars[:password])
|
69
69
|
else
|
70
70
|
@username = vars[:username]
|
71
71
|
@password = vars[:password]
|
@@ -96,11 +96,11 @@ class WatsonService
|
|
96
96
|
headers.each_pair { |k, v| @conn.default_options.headers.add(k, v) }
|
97
97
|
end
|
98
98
|
|
99
|
-
def _token_manager(
|
100
|
-
@
|
99
|
+
def _token_manager(iam_apikey: nil, iam_access_token: nil, iam_url: nil)
|
100
|
+
@iam_apikey = iam_apikey
|
101
101
|
@iam_access_token = iam_access_token
|
102
102
|
@iam_url = iam_url
|
103
|
-
@token_manager = IAMTokenManager.new(
|
103
|
+
@token_manager = IAMTokenManager.new(iam_apikey: iam_apikey, iam_access_token: iam_access_token, iam_url: iam_url)
|
104
104
|
end
|
105
105
|
|
106
106
|
def _iam_access_token(iam_access_token:)
|
@@ -109,10 +109,10 @@ class WatsonService
|
|
109
109
|
@iam_access_token = iam_access_token
|
110
110
|
end
|
111
111
|
|
112
|
-
def
|
113
|
-
@token_manager&.
|
114
|
-
@token_manager = IAMTokenManager.new(
|
115
|
-
@
|
112
|
+
def _iam_apikey(iam_apikey:)
|
113
|
+
@token_manager&._iam_apikey(iam_apikey: iam_apikey)
|
114
|
+
@token_manager = IAMTokenManager.new(iam_apikey: iam_apikey) if @token_manager.nil?
|
115
|
+
@iam_apikey = iam_apikey
|
116
116
|
end
|
117
117
|
|
118
118
|
# @return [DetailedResponse]
|
@@ -133,7 +133,7 @@ class WatsonService
|
|
133
133
|
args[:headers].delete("Content-Type") if args.key?(:form) || args[:json].nil?
|
134
134
|
|
135
135
|
if @username == "apikey"
|
136
|
-
|
136
|
+
_iam_apikey(iam_apikey: @password)
|
137
137
|
@username = nil
|
138
138
|
end
|
139
139
|
|
@@ -11,8 +11,8 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
11
11
|
url: ENV["ASSISTANT_IAM_URL"],
|
12
12
|
version: "2018-02-16"
|
13
13
|
)
|
14
|
-
service.
|
15
|
-
service.
|
14
|
+
service._iam_apikey(iam_apikey: ENV["ASSISTANT_IAM_APIKEY"])
|
15
|
+
service._iam_apikey(iam_apikey: ENV["ASSISTANT_IAM_APIKEY"])
|
16
16
|
service.add_default_headers(
|
17
17
|
headers: {
|
18
18
|
"X-Watson-Learning-Opt-Out" => "1",
|
@@ -48,8 +48,8 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
48
48
|
url: ENV["ASSISTANT_IAM_URL"],
|
49
49
|
version: "2018-02-16"
|
50
50
|
)
|
51
|
-
service.
|
52
|
-
service.
|
51
|
+
service._iam_apikey(iam_apikey: ENV["ASSISTANT_IAM_APIKEY"])
|
52
|
+
service._iam_apikey(iam_apikey: ENV["ASSISTANT_IAM_APIKEY"])
|
53
53
|
service.add_default_headers(
|
54
54
|
headers: {
|
55
55
|
"X-Watson-Learning-Opt-Out" => "1",
|
@@ -65,7 +65,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
65
65
|
|
66
66
|
def test_list_workspaces
|
67
67
|
service = IBMWatson::AssistantV1.new(
|
68
|
-
|
68
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
69
69
|
url: ENV["ASSISTANT_IAM_URL"],
|
70
70
|
version: "2018-02-16"
|
71
71
|
)
|
@@ -83,7 +83,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
83
83
|
skip "Skip to allow for concurrent travis jobs"
|
84
84
|
service = IBMWatson::AssistantV1.new(
|
85
85
|
version: "2018-02-16",
|
86
|
-
|
86
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
87
87
|
url: ENV["ASSISTANT_IAM_URL"]
|
88
88
|
)
|
89
89
|
service.add_default_headers(
|
@@ -114,7 +114,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
114
114
|
|
115
115
|
def test_get_counterexample
|
116
116
|
service = IBMWatson::AssistantV1.new(
|
117
|
-
|
117
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
118
118
|
url: ENV["ASSISTANT_IAM_URL"],
|
119
119
|
version: "2018-02-16"
|
120
120
|
)
|
@@ -133,7 +133,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
133
133
|
|
134
134
|
def test_list_counterexamples
|
135
135
|
service = IBMWatson::AssistantV1.new(
|
136
|
-
|
136
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
137
137
|
url: ENV["ASSISTANT_IAM_URL"],
|
138
138
|
version: "2018-02-16"
|
139
139
|
)
|
@@ -152,7 +152,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
152
152
|
def test_create_update_delete_entity
|
153
153
|
skip "Skip to allow for concurrent travis jobs"
|
154
154
|
service = IBMWatson::AssistantV1.new(
|
155
|
-
|
155
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
156
156
|
url: ENV["ASSISTANT_IAM_URL"],
|
157
157
|
version: "2018-02-16"
|
158
158
|
)
|
@@ -188,7 +188,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
188
188
|
|
189
189
|
def test_get_entity
|
190
190
|
service = IBMWatson::AssistantV1.new(
|
191
|
-
|
191
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
192
192
|
url: ENV["ASSISTANT_IAM_URL"],
|
193
193
|
version: "2018-02-16"
|
194
194
|
)
|
@@ -208,7 +208,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
208
208
|
|
209
209
|
def test_list_entities
|
210
210
|
service = IBMWatson::AssistantV1.new(
|
211
|
-
|
211
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
212
212
|
url: ENV["ASSISTANT_IAM_URL"],
|
213
213
|
version: "2018-02-16"
|
214
214
|
)
|
@@ -228,7 +228,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
228
228
|
def test_create_update_delete_example
|
229
229
|
skip "Skip to allow for concurrent travis jobs"
|
230
230
|
service = IBMWatson::AssistantV1.new(
|
231
|
-
|
231
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
232
232
|
url: ENV["ASSISTANT_IAM_URL"],
|
233
233
|
version: "2018-02-16"
|
234
234
|
)
|
@@ -263,7 +263,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
263
263
|
|
264
264
|
def test_get_example
|
265
265
|
service = IBMWatson::AssistantV1.new(
|
266
|
-
|
266
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
267
267
|
url: ENV["ASSISTANT_IAM_URL"],
|
268
268
|
version: "2018-02-16"
|
269
269
|
)
|
@@ -283,7 +283,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
283
283
|
|
284
284
|
def test_list_examples
|
285
285
|
service = IBMWatson::AssistantV1.new(
|
286
|
-
|
286
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
287
287
|
url: ENV["ASSISTANT_IAM_URL"],
|
288
288
|
version: "2018-02-16"
|
289
289
|
)
|
@@ -303,7 +303,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
303
303
|
def test_create_update_delete_intent
|
304
304
|
skip "Skip to allow for concurrent travis jobs"
|
305
305
|
service = IBMWatson::AssistantV1.new(
|
306
|
-
|
306
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
307
307
|
url: ENV["ASSISTANT_IAM_URL"],
|
308
308
|
version: "2018-02-16"
|
309
309
|
)
|
@@ -337,7 +337,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
337
337
|
|
338
338
|
def test_get_intent
|
339
339
|
service = IBMWatson::AssistantV1.new(
|
340
|
-
|
340
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
341
341
|
url: ENV["ASSISTANT_IAM_URL"],
|
342
342
|
version: "2018-02-16"
|
343
343
|
)
|
@@ -357,7 +357,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
357
357
|
|
358
358
|
def test_list_intents
|
359
359
|
service = IBMWatson::AssistantV1.new(
|
360
|
-
|
360
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
361
361
|
url: ENV["ASSISTANT_IAM_URL"],
|
362
362
|
version: "2018-02-16"
|
363
363
|
)
|
@@ -376,7 +376,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
376
376
|
|
377
377
|
def test_list_logs
|
378
378
|
service = IBMWatson::AssistantV1.new(
|
379
|
-
|
379
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
380
380
|
url: ENV["ASSISTANT_IAM_URL"],
|
381
381
|
version: "2018-02-16"
|
382
382
|
)
|
@@ -394,7 +394,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
394
394
|
|
395
395
|
def test_list_all_logs
|
396
396
|
service = IBMWatson::AssistantV1.new(
|
397
|
-
|
397
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
398
398
|
url: ENV["ASSISTANT_IAM_URL"],
|
399
399
|
version: "2018-02-16"
|
400
400
|
)
|
@@ -412,7 +412,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
412
412
|
|
413
413
|
def test_message
|
414
414
|
service = IBMWatson::AssistantV1.new(
|
415
|
-
|
415
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
416
416
|
url: ENV["ASSISTANT_IAM_URL"],
|
417
417
|
version: "2018-02-16"
|
418
418
|
)
|
@@ -441,7 +441,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
441
441
|
def test_create_update_delete_synonym
|
442
442
|
skip "Skip to allow for concurrent travis jobs"
|
443
443
|
service = IBMWatson::AssistantV1.new(
|
444
|
-
|
444
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
445
445
|
url: ENV["ASSISTANT_IAM_URL"],
|
446
446
|
version: "2018-02-16"
|
447
447
|
)
|
@@ -479,7 +479,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
479
479
|
|
480
480
|
def test_get_synonym
|
481
481
|
service = IBMWatson::AssistantV1.new(
|
482
|
-
|
482
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
483
483
|
url: ENV["ASSISTANT_IAM_URL"],
|
484
484
|
version: "2018-02-16"
|
485
485
|
)
|
@@ -500,7 +500,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
500
500
|
|
501
501
|
def test_list_synonyms
|
502
502
|
service = IBMWatson::AssistantV1.new(
|
503
|
-
|
503
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
504
504
|
url: ENV["ASSISTANT_IAM_URL"],
|
505
505
|
version: "2018-02-16"
|
506
506
|
)
|
@@ -521,7 +521,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
521
521
|
def test_create_update_delete_value
|
522
522
|
skip "Skip to allow for concurrent travis jobs"
|
523
523
|
service = IBMWatson::AssistantV1.new(
|
524
|
-
|
524
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
525
525
|
url: ENV["ASSISTANT_IAM_URL"],
|
526
526
|
version: "2018-02-16"
|
527
527
|
)
|
@@ -558,7 +558,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
558
558
|
|
559
559
|
def test_get_value
|
560
560
|
service = IBMWatson::AssistantV1.new(
|
561
|
-
|
561
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
562
562
|
url: ENV["ASSISTANT_IAM_URL"],
|
563
563
|
version: "2018-02-16"
|
564
564
|
)
|
@@ -579,7 +579,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
579
579
|
|
580
580
|
def test_list_values
|
581
581
|
service = IBMWatson::AssistantV1.new(
|
582
|
-
|
582
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
583
583
|
url: ENV["ASSISTANT_IAM_URL"],
|
584
584
|
version: "2018-02-16"
|
585
585
|
)
|
@@ -600,7 +600,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
600
600
|
def test_dialog_nodes
|
601
601
|
skip "Skip to allow for concurrent travis jobs"
|
602
602
|
service = IBMWatson::AssistantV1.new(
|
603
|
-
|
603
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
604
604
|
url: ENV["ASSISTANT_IAM_URL"],
|
605
605
|
version: "2018-02-16"
|
606
606
|
)
|
@@ -637,7 +637,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
637
637
|
|
638
638
|
def test_delete_user_data
|
639
639
|
service = IBMWatson::AssistantV1.new(
|
640
|
-
|
640
|
+
iam_apikey: ENV["ASSISTANT_IAM_APIKEY"],
|
641
641
|
url: ENV["ASSISTANT_IAM_URL"],
|
642
642
|
version: "2018-02-16"
|
643
643
|
)
|
@@ -706,7 +706,7 @@ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
|
|
706
706
|
)
|
707
707
|
error_received = false
|
708
708
|
begin
|
709
|
-
service.
|
709
|
+
service._iam_apikey(iam_apikey: "bogus_api_key")
|
710
710
|
service.list_workspaces
|
711
711
|
rescue WatsonApiException => e
|
712
712
|
assert_equal("Provided API key could not be found", e.info["errorMessage"])
|
@@ -11,7 +11,7 @@ unless ENV["VISUAL_RECOGNITION_IAM_APIKEY"].nil? || ENV["VISUAL_RECOGNITION_IAM_
|
|
11
11
|
attr_accessor :service, :classifier_id
|
12
12
|
def before_all
|
13
13
|
@service = IBMWatson::VisualRecognitionV3.new(
|
14
|
-
|
14
|
+
iam_apikey: ENV["VISUAL_RECOGNITION_IAM_APIKEY"],
|
15
15
|
version: "2018-03-19",
|
16
16
|
url: ENV["VISUAL_RECOGNITION_IAM_URL"]
|
17
17
|
)
|
@@ -19,13 +19,13 @@ class IAMTokenManagerTest < Minitest::Test
|
|
19
19
|
}
|
20
20
|
|
21
21
|
token_manager = IAMTokenManager.new(
|
22
|
-
|
22
|
+
iam_apikey: "iam_apikey",
|
23
23
|
iam_access_token: "iam_access_token",
|
24
24
|
iam_url: iam_url
|
25
25
|
)
|
26
26
|
stub_request(:post, "https://iam.bluemix.net/identity/token")
|
27
27
|
.with(
|
28
|
-
body: { "apikey" => "
|
28
|
+
body: { "apikey" => "iam_apikey", "grant_type" => "urn:ibm:params:oauth:grant-type:apikey", "response_type" => "cloud_iam" },
|
29
29
|
headers: {
|
30
30
|
"Accept" => "application/json",
|
31
31
|
"Authorization" => "Basic Yng6Yng=",
|
@@ -47,7 +47,7 @@ class IAMTokenManagerTest < Minitest::Test
|
|
47
47
|
"refresh_token" => "jy4gl91BQ"
|
48
48
|
}
|
49
49
|
token_manager = IAMTokenManager.new(
|
50
|
-
|
50
|
+
iam_apikey: "iam_apikey",
|
51
51
|
iam_access_token: "iam_access_token",
|
52
52
|
iam_url: iam_url
|
53
53
|
)
|
@@ -67,7 +67,7 @@ class IAMTokenManagerTest < Minitest::Test
|
|
67
67
|
|
68
68
|
def test_is_token_expired
|
69
69
|
token_manager = IAMTokenManager.new(
|
70
|
-
|
70
|
+
iam_apikey: "iam_apikey",
|
71
71
|
iam_access_token: "iam_access_token",
|
72
72
|
iam_url: "iam_url"
|
73
73
|
)
|
@@ -86,7 +86,7 @@ class IAMTokenManagerTest < Minitest::Test
|
|
86
86
|
|
87
87
|
def test_is_refresh_token_expired
|
88
88
|
token_manager = IAMTokenManager.new(
|
89
|
-
|
89
|
+
iam_apikey: "iam_apikey",
|
90
90
|
iam_access_token: "iam_access_token",
|
91
91
|
iam_url: "iam_url"
|
92
92
|
)
|
@@ -106,7 +106,7 @@ class IAMTokenManagerTest < Minitest::Test
|
|
106
106
|
def test_get_token
|
107
107
|
iam_url = "https://iam.bluemix.net/identity/token"
|
108
108
|
token_manager = IAMTokenManager.new(
|
109
|
-
|
109
|
+
iam_apikey: "iam_apikey",
|
110
110
|
iam_url: iam_url
|
111
111
|
)
|
112
112
|
token_manager.user_access_token = "user_access_token"
|
@@ -123,7 +123,7 @@ class IAMTokenManagerTest < Minitest::Test
|
|
123
123
|
}
|
124
124
|
stub_request(:post, "https://iam.bluemix.net/identity/token")
|
125
125
|
.with(
|
126
|
-
body: { "apikey" => "
|
126
|
+
body: { "apikey" => "iam_apikey", "grant_type" => "urn:ibm:params:oauth:grant-type:apikey", "response_type" => "cloud_iam" },
|
127
127
|
headers: {
|
128
128
|
"Accept" => "application/json",
|
129
129
|
"Authorization" => "Basic Yng6Yng=",
|
@@ -11,7 +11,7 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
11
11
|
def test_translate_source_target
|
12
12
|
stub_request(:post, "https://iam.bluemix.net/identity/token")
|
13
13
|
.with(
|
14
|
-
body: { "apikey" => "
|
14
|
+
body: { "apikey" => "iam_apikey", "grant_type" => "urn:ibm:params:oauth:grant-type:apikey", "response_type" => "cloud_iam" },
|
15
15
|
headers: {
|
16
16
|
"Accept" => "application/json",
|
17
17
|
"Authorization" => "Basic Yng6Yng=",
|
@@ -31,7 +31,7 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
31
31
|
)
|
32
32
|
service = IBMWatson::LanguageTranslatorV3.new(
|
33
33
|
version: "2018-05-01",
|
34
|
-
|
34
|
+
iam_apikey: "iam_apikey"
|
35
35
|
)
|
36
36
|
expected = {
|
37
37
|
"character_count" => 19,
|
@@ -59,7 +59,7 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
59
59
|
def test_translate_model_id
|
60
60
|
stub_request(:post, "https://iam.bluemix.net/identity/token")
|
61
61
|
.with(
|
62
|
-
body: { "apikey" => "
|
62
|
+
body: { "apikey" => "iam_apikey", "grant_type" => "urn:ibm:params:oauth:grant-type:apikey", "response_type" => "cloud_iam" },
|
63
63
|
headers: {
|
64
64
|
"Accept" => "application/json",
|
65
65
|
"Authorization" => "Basic Yng6Yng=",
|
@@ -79,7 +79,7 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
79
79
|
)
|
80
80
|
service = IBMWatson::LanguageTranslatorV3.new(
|
81
81
|
version: "2018-05-01",
|
82
|
-
|
82
|
+
iam_apikey: "iam_apikey"
|
83
83
|
)
|
84
84
|
expected = {
|
85
85
|
"character_count" => 22,
|
@@ -110,7 +110,7 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
110
110
|
def test_identify
|
111
111
|
stub_request(:post, "https://iam.bluemix.net/identity/token")
|
112
112
|
.with(
|
113
|
-
body: { "apikey" => "
|
113
|
+
body: { "apikey" => "iam_apikey", "grant_type" => "urn:ibm:params:oauth:grant-type:apikey", "response_type" => "cloud_iam" },
|
114
114
|
headers: {
|
115
115
|
"Accept" => "application/json",
|
116
116
|
"Authorization" => "Basic Yng6Yng=",
|
@@ -130,7 +130,7 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
130
130
|
)
|
131
131
|
service = IBMWatson::LanguageTranslatorV3.new(
|
132
132
|
version: "2018-05-01",
|
133
|
-
|
133
|
+
iam_apikey: "iam_apikey"
|
134
134
|
)
|
135
135
|
expected = {
|
136
136
|
"languages" => [
|
@@ -167,7 +167,7 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
167
167
|
def test_list_identifiable_languages
|
168
168
|
stub_request(:post, "https://iam.bluemix.net/identity/token")
|
169
169
|
.with(
|
170
|
-
body: { "apikey" => "
|
170
|
+
body: { "apikey" => "iam_apikey", "grant_type" => "urn:ibm:params:oauth:grant-type:apikey", "response_type" => "cloud_iam" },
|
171
171
|
headers: {
|
172
172
|
"Accept" => "application/json",
|
173
173
|
"Authorization" => "Basic Yng6Yng=",
|
@@ -187,7 +187,7 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
187
187
|
)
|
188
188
|
service = IBMWatson::LanguageTranslatorV3.new(
|
189
189
|
version: "2018-05-01",
|
190
|
-
|
190
|
+
iam_apikey: "iam_apikey"
|
191
191
|
)
|
192
192
|
expected = {
|
193
193
|
"languages" => [
|
@@ -232,7 +232,7 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
232
232
|
def test_create_model
|
233
233
|
stub_request(:post, "https://iam.bluemix.net/identity/token")
|
234
234
|
.with(
|
235
|
-
body: { "apikey" => "
|
235
|
+
body: { "apikey" => "iam_apikey", "grant_type" => "urn:ibm:params:oauth:grant-type:apikey", "response_type" => "cloud_iam" },
|
236
236
|
headers: {
|
237
237
|
"Accept" => "application/json",
|
238
238
|
"Authorization" => "Basic Yng6Yng=",
|
@@ -252,7 +252,7 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
252
252
|
)
|
253
253
|
service = IBMWatson::LanguageTranslatorV3.new(
|
254
254
|
version: "2018-05-01",
|
255
|
-
|
255
|
+
iam_apikey: "iam_apikey"
|
256
256
|
)
|
257
257
|
expected = {
|
258
258
|
"status" => "available",
|
@@ -304,7 +304,7 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
304
304
|
def test_delete_model
|
305
305
|
stub_request(:post, "https://iam.bluemix.net/identity/token")
|
306
306
|
.with(
|
307
|
-
body: { "apikey" => "
|
307
|
+
body: { "apikey" => "iam_apikey", "grant_type" => "urn:ibm:params:oauth:grant-type:apikey", "response_type" => "cloud_iam" },
|
308
308
|
headers: {
|
309
309
|
"Accept" => "application/json",
|
310
310
|
"Authorization" => "Basic Yng6Yng=",
|
@@ -324,7 +324,7 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
324
324
|
)
|
325
325
|
service = IBMWatson::LanguageTranslatorV3.new(
|
326
326
|
version: "2018-05-01",
|
327
|
-
|
327
|
+
iam_apikey: "iam_apikey"
|
328
328
|
)
|
329
329
|
expected = {
|
330
330
|
"status" => "OK"
|
@@ -346,7 +346,7 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
346
346
|
def test_get_model
|
347
347
|
stub_request(:post, "https://iam.bluemix.net/identity/token")
|
348
348
|
.with(
|
349
|
-
body: { "apikey" => "
|
349
|
+
body: { "apikey" => "iam_apikey", "grant_type" => "urn:ibm:params:oauth:grant-type:apikey", "response_type" => "cloud_iam" },
|
350
350
|
headers: {
|
351
351
|
"Accept" => "application/json",
|
352
352
|
"Authorization" => "Basic Yng6Yng=",
|
@@ -366,7 +366,7 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
366
366
|
)
|
367
367
|
service = IBMWatson::LanguageTranslatorV3.new(
|
368
368
|
version: "2018-05-01",
|
369
|
-
|
369
|
+
iam_apikey: "iam_apikey"
|
370
370
|
)
|
371
371
|
expected = {
|
372
372
|
"status" => "available",
|
@@ -397,7 +397,7 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
397
397
|
def test_list_models
|
398
398
|
stub_request(:post, "https://iam.bluemix.net/identity/token")
|
399
399
|
.with(
|
400
|
-
body: { "apikey" => "
|
400
|
+
body: { "apikey" => "iam_apikey", "grant_type" => "urn:ibm:params:oauth:grant-type:apikey", "response_type" => "cloud_iam" },
|
401
401
|
headers: {
|
402
402
|
"Accept" => "application/json",
|
403
403
|
"Authorization" => "Basic Yng6Yng=",
|
@@ -417,7 +417,7 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
417
417
|
)
|
418
418
|
service = IBMWatson::LanguageTranslatorV3.new(
|
419
419
|
version: "2018-05-01",
|
420
|
-
|
420
|
+
iam_apikey: "iam_apikey"
|
421
421
|
)
|
422
422
|
expected = {
|
423
423
|
"models" => [
|