Skip to content

Commit 072ab86

Browse files
authored
Merge pull request #568 from watson-developer-cloud/release-2.1.1
Release 2.1.0
2 parents 002e16d + 339f74b commit 072ab86

21 files changed

Lines changed: 2024 additions & 45 deletions

README.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Python client library to quickly get started with the various [Watson APIs][wdc]
2525
* [Changes for v2.0](#changes-for-v20)
2626
* [Migration](#migration)
2727
* [Configuring the http client](#configuring-the-http-client-supported-from-v110)
28+
* [Disable SSL certificate verification](#disable-ssl-certificate-verification)
2829
* [Sending request headers](#sending-request-headers)
2930
* [Parsing HTTP response info](#parsing-http-response-info)
3031
* [Dependencies](#dependencies)
@@ -106,40 +107,42 @@ You supply either an IAM service **API key** or an **access token**:
106107

107108
```python
108109
# In the constructor, letting the SDK manage the IAM token
109-
discovery = DiscoveryV1(version='2017-10-16',
110+
discovery = DiscoveryV1(version='2018-08-01',
111+
url='<url_as_per_region>',
110112
iam_apikey='<iam_apikey>',
111113
iam_url='<iam_url>') # optional - the default value is https://iam.bluemix.net/identity/token
112114
```
113115

114116
```python
115117
# after instantiation, letting the SDK manage the IAM token
116-
discovery = DiscoveryV1(version='2017-10-16')
118+
discovery = DiscoveryV1(version='2018-08-01', url='<url_as_per_region>')
117119
discovery.set_iam_apikey('<iam_apikey>')
118120
```
119121

120122
#### Supplying the access token
121123
```python
122124
# in the constructor, assuming control of managing IAM token
123-
discovery = DiscoveryV1(version='2017-10-16',
125+
discovery = DiscoveryV1(version='2018-08-01',
126+
url='<url_as_per_region>',
124127
iam_access_token='<iam_access_token>')
125128
```
126129

127130
```python
128131
# after instantiation, assuming control of managing IAM token
129-
discovery = DiscoveryV1(version='2017-10-16')
132+
discovery = DiscoveryV1(version='2018-08-01', url='<url_as_per_region>')
130133
discovery.set_iam_access_token('<access_token>')
131134
```
132135

133136
### Username and password
134137
```python
135138
from watson_developer_cloud import DiscoveryV1
136139
# In the constructor
137-
discovery = DiscoveryV1(version='2017-10-16', username='<username>', password='<password>')
140+
discovery = DiscoveryV1(version='2018-08-01', url='<url_as_per_region>', username='<username>', password='<password>')
138141
```
139142

140143
```python
141144
# After instantiation
142-
discovery = DiscoveryV1(version='2017-10-16')
145+
discovery = DiscoveryV1(version='2018-08-01', url='<url_as_per_region>')
143146
discovery.set_username_and_password('<username>', '<password>')
144147
```
145148

@@ -150,12 +153,12 @@ discovery.set_username_and_password('<username>', '<password>')
150153
```python
151154
from watson_developer_cloud import VisualRecognitionV3
152155
# In the constructor
153-
visual_recognition = VisualRecognitionV3(version='2018-05-22', api_key='<api_key>')
156+
visual_recognition = VisualRecognitionV3(version='2018-03-19', url='<url_as_per_region>', api_key='<api_key>')
154157
```
155158

156159
```python
157160
# After instantiation
158-
visual_recognition = VisualRecognitionV3(version='2018-05-22')
161+
visual_recognition = VisualRecognitionV3(version='2018-03-19')
159162
visual_recognition.set_api_key('<api_key>')
160163
```
161164

@@ -174,7 +177,8 @@ from watson_developer_cloud import AssistantV1
174177
assistant = AssistantV1(
175178
username='xxx',
176179
password='yyy',
177-
version='2017-04-21')
180+
url='<url_as_per_region>',
181+
version='2018-07-10')
178182

179183
response = assistant.list_workspaces(headers={'Custom-Header': 'custom_value'})
180184
print(response.get_result())
@@ -195,14 +199,22 @@ from watson_developer_cloud import AssistantV1
195199
assistant = AssistantV1(
196200
username='xxx',
197201
password='yyy',
198-
version='2017-04-21')
202+
url='<url_as_per_region>',
203+
version='2018-07-10')
199204

200205
assistant.set_http_config({'timeout': 100})
201206
response = assistant.message(workspace_id=workspace_id, input={
202207
'text': 'What\'s the weather like?'}).get_result()
203208
print(json.dumps(response, indent=2))
204209
```
205210

211+
## Disable SSL certificate verification
212+
For ICP(IBM Cloud Private), you can disable the SSL certificate verification by:
213+
214+
```python
215+
service.disable_SSL_verification()
216+
```
217+
206218
## Sending request headers
207219
Custom headers can be passed in any request in the form of a `dict` as:
208220
```python
@@ -218,7 +230,8 @@ from watson_developer_cloud import AssistantV1
218230
assistant = AssistantV1(
219231
username='xxx',
220232
password='yyy',
221-
version='2017-04-21')
233+
url='<url_as_per_region>',
234+
version='2018-07-10')
222235

223236
response = assistant.list_workspaces(headers={'Custom-Header': 'custom_value'}).get_result()
224237
```
@@ -231,7 +244,8 @@ from watson_developer_cloud import AssistantV1
231244
assistant = AssistantV1(
232245
username='xxx',
233246
password='yyy',
234-
version='2017-04-21')
247+
url='<url_as_per_region>',
248+
version='2018-07-10')
235249

236250
assistant.set_detailed_response(True)
237251
response = assistant.list_workspaces(headers={'Custom-Header': 'custom_value'}).get_result()

examples/assistant_v1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# If service instance provides API key authentication
66
# assistant = AssistantV1(
7-
# version='2017-04-21',
7+
# version='2018-07-10',
88
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
99
# url='https://gateway.watsonplatform.net/assistant/api',
1010
# iam_apikey='iam_apikey')
@@ -14,7 +14,7 @@
1414
password='YOUR SERVICE PASSWORD',
1515
## url is optional, and defaults to the URL below. Use the correct URL for your region.
1616
# url='https://gateway.watsonplatform.net/assistant/api',
17-
version='2017-04-21')
17+
version='2018-07-10')
1818

1919
#########################
2020
# Workspaces

examples/assistant_v2.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from __future__ import print_function
2+
import json
3+
from watson_developer_cloud import AssistantV2
4+
5+
# If service instance provides API key authentication
6+
# assistant = AssistantV2(
7+
# version='2017-04-21',
8+
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
9+
# url='https://gateway.watsonplatform.net/assistant/api',
10+
# iam_apikey='iam_apikey')
11+
12+
assistant = AssistantV2(
13+
username='YOUR SERVICE USERNAME',
14+
password='YOUR SERVICE PASSWORD',
15+
## url is optional, and defaults to the URL below. Use the correct URL for your region.
16+
url='https://gateway.watsonplatform.net/assistant/api',
17+
version='2017-04-21')
18+
19+
#########################
20+
# Sessions
21+
#########################
22+
23+
session = assistant.create_session("<YOUR ASSISTANT ID>").get_result()
24+
print(json.dumps(session, indent=2))
25+
26+
assistant.delete_session("<YOUR ASSISTANT ID>", "<YOUR SESSION ID>").get_result()
27+
28+
#########################
29+
# Message
30+
#########################
31+
32+
message = assistant.message(
33+
"<YOUR ASSISTANT ID>",
34+
"<YOUR SESSION ID>",
35+
input={'text': 'What\'s the weather like?'},
36+
context={
37+
'metadata': {
38+
'deployment': 'myDeployment'
39+
}
40+
}).get_result()
41+
print(json.dumps(message, indent=2))

examples/conversation_v1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## If service instance provides API key authentication
66
# conversation = ConversationV1(
7-
# version='2018-02-16',
7+
# version='2018-07-10',
88
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
99
# url='https://gateway.watsonplatform.net/conversation/api',
1010
# iam_apikey='iam_apikey')
@@ -14,7 +14,7 @@
1414
password='YOUR SERVICE PASSWORD',
1515
## url is optional, and defaults to the URL below. Use the correct URL for your region.
1616
# url='https://gateway.watsonplatform.net/conversation/api',
17-
version='2018-02-16')
17+
version='2018-07-10')
1818

1919
# When you send multiple requests for the same conversation, include the
2020
# context object from the previous response.

examples/discovery_v1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
# If service instance provides API key authentication
77
# discovery = DiscoveryV1(
8-
# version='2017-10-16',
8+
# version='2018-08-01',
99
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
1010
# url='https://gateway.watsonplatform.net/discovery/api',
1111
# iam_apikey='iam_apikey')
1212

1313
discovery = DiscoveryV1(
14-
version='2017-10-16',
14+
version='2018-08-01',
1515
## url is optional, and defaults to the URL below. Use the correct URL for your region.
1616
# url='https://gateway.watsonplatform.net/discovery/api',
1717
username='YOUR SERVICE USERNAME',

examples/language_translator_v3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
from watson_developer_cloud import LanguageTranslatorV3
55

66
# language_translator = LanguageTranslatorV3(
7-
# version='2018-05-31',
7+
# version='2018-05-01.',
88
# ### url is optional, and defaults to the URL below. Use the correct URL for your region.
99
# # url='https://gateway.watsonplatform.net/language-translator/api',
1010
# iam_apikey='your_apikey')
1111

1212
# Authenticate with username/password if your service instance doesn't provide an API key
1313
language_translator = LanguageTranslatorV3(
14-
version='2018-05-31',
14+
version='2018-05-01.',
1515
username='YOUR SERVICE USERNAME',
1616
password='YOUR SERVICE PASSWORD')
1717

examples/microphone-speech-to-text.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ def recognize_using_weboscket(*args):
7474
mycallback = MyRecognizeCallback()
7575
speech_to_text.recognize_using_websocket(audio=audio_source,
7676
content_type='audio/l16; rate=44100',
77-
recognize_callback=mycallback)
77+
recognize_callback=mycallback,
78+
interim_results=True)
7879

7980
###############################################
8081
#### Prepare the for recording using Pyaudio ##

examples/natural_language_understanding_v1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
# If service instance provides API key authentication
77
# service = NaturalLanguageUnderstandingV1(
8-
# version='2017-02-27',
8+
# version='2018-03-16',
99
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
1010
# url='https://gateway.watsonplatform.net/natural-language-understanding/api',
1111
# iam_apikey='your_apikey')
1212

1313
service = NaturalLanguageUnderstandingV1(
14-
version='2017-02-27',
14+
version='2018-03-16',
1515
## url is optional, and defaults to the URL below. Use the correct URL for your region.
1616
# url='https://gateway.watsonplatform.net/natural-language-understanding/api',
1717
username='YOUR SERVICE USERNAME',

examples/personality_insights_v3.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,26 @@
66
import json
77
from os.path import join, dirname
88
from watson_developer_cloud import PersonalityInsightsV3
9+
import csv
910

1011
# # If service instance provides API key authentication
1112
# service = PersonalityInsightsV3(
12-
# version='2016-10-20',
13+
# version='2017-10-13',
1314
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
1415
# url='https://gateway.watsonplatform.net/personality-insights/api',
1516
# iam_apikey='your_apikey')
1617

1718
service = PersonalityInsightsV3(
18-
version='2016-10-20',
19+
version='2017-10-13',
1920
## url is optional, and defaults to the URL below. Use the correct URL for your region.
2021
# url='https://gateway.watsonplatform.net/personality-insights/api',
2122
username='YOUR SERVICE USERNAME',
2223
password='YOUR SERVICE PASSWORD')
2324

25+
############################
26+
# Profile with JSON output #
27+
############################
28+
2429
with open(join(dirname(__file__), '../resources/personality-v3.json')) as \
2530
profile_json:
2631
profile = service.profile(
@@ -30,3 +35,21 @@
3035
consumption_preferences=True).get_result()
3136

3237
print(json.dumps(profile, indent=2))
38+
39+
###########################
40+
# Profile with CSV output #
41+
###########################
42+
43+
with open(join(dirname(__file__), '../resources/personality-v3.json')) as \
44+
profile_json:
45+
response = service.profile(
46+
profile_json.read(),
47+
content_type='application/json',
48+
accept="text/csv",
49+
csv_headers=True).get_result()
50+
51+
profile = response.content
52+
cr = csv.reader(profile.splitlines())
53+
my_list = list(cr)
54+
for row in my_list:
55+
print(row)

examples/tone_analyzer_v3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
# service = ToneAnalyzerV3(
99
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
1010
# url='https://gateway.watsonplatform.net/tone-analyzer/api',
11-
# version='2017-09-26',
11+
# version='2017-09-21',
1212
# iam_apikey='your_apikey')
1313

1414
service = ToneAnalyzerV3(
1515
## url is optional, and defaults to the URL below. Use the correct URL for your region.
1616
# url='https://gateway.watsonplatform.net/tone-analyzer/api',
1717
username='YOUR SERVICE USERNAME',
1818
password='YOUR SERVICE PASSWORD',
19-
version='2017-09-26')
19+
version='2017-09-21')
2020

2121
print("\ntone_chat() example 1:\n")
2222
utterances = [{

0 commit comments

Comments
 (0)