Skip to content

Commit e4151da

Browse files
authored
Merge pull request #554 from watson-developer-cloud/v2.0.0
Release V2.0.0
2 parents 37ce6aa + 4751664 commit e4151da

File tree

63 files changed

+2542
-3876
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2542
-3876
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[bumpversion]
22
current_version = 1.7.1
33
commit = True
4+
message = [skip ci] Bump version: {current_version} -> {new_version}
45

56
[bumpversion:file:watson_developer_cloud/version.py]
67
search = __version__ = '{current_version}'

README.md

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ Python client library to quickly get started with the various [Watson APIs][wdc]
1919
* [IAM](#iam)
2020
* [Username and password](#username-and-password)
2121
* [API key](#api-key)
22-
* [Deprecation notice](#deprecation-notice)
2322
* [Python version](#python-version)
2423
* [Changes for v1.0](#changes-for-v10)
24+
* [Changes for v2.0](#changes-for-v20)
2525
* [Migration](#migration)
2626
* [Configuring the http client](#configuring-the-http-client-supported-from-v110)
2727
* [Sending request headers](#sending-request-headers)
@@ -106,14 +106,14 @@ You supply either an IAM service **API key** or an **access token**:
106106
```python
107107
# In the constructor, letting the SDK manage the IAM token
108108
discovery = DiscoveryV1(version='2017-10-16',
109-
iam_api_key='<iam_api_key>',
109+
iam_apikey='<iam_apikey>',
110110
iam_url='<iam_url>') # optional - the default value is https://iam.bluemix.net/identity/token
111111
```
112112

113113
```python
114114
# after instantiation, letting the SDK manage the IAM token
115115
discovery = DiscoveryV1(version='2017-10-16')
116-
discovery.set_iam_api_key('<iam_api_key>')
116+
discovery.set_iam_apikey('<iam_apikey>')
117117
```
118118

119119
#### Supplying the access token
@@ -158,16 +158,30 @@ visual_recognition = VisualRecognitionV3(version='2018-05-22')
158158
visual_recognition.set_api_key('<api_key>')
159159
```
160160

161-
## Deprecation notice
162-
Language Translator v3 is now available. The v2 Language Translator API will no longer be available after July 31, 2018. To take advantage of the latest service enhancements, migrate to the v3 API. View the [Migrating to Language Translator v3](https://console.bluemix.net/docs/services/language-translator/migrating.html) page for more information.
163-
164161
## Python version
165162

166163
Tested on Python 2.7, 3.4, 3.5, and 3.6.
167164

168165
## Changes for v1.0
169166
Version 1.0 focuses on the move to programmatically-generated code for many of the services. See the [changelog](https://github.com/watson-developer-cloud/python-sdk/wiki/Changelog) for the details.
170167

168+
## Changes for v2.0
169+
`DetailedResponse` which contains the result, headers and HTTP status code is now the default response for all methods.
170+
```python
171+
from watson_developer_cloud import AssistantV1
172+
173+
assistant = AssistantV1(
174+
username='xxx',
175+
password='yyy',
176+
version='2017-04-21')
177+
178+
response = assistant.list_workspaces(headers={'Custom-Header': 'custom_value'})
179+
print(response.get_result())
180+
print(response.get_headers())
181+
print(response.get_status_code())
182+
```
183+
See the [changelog](https://github.com/watson-developer-cloud/python-sdk/wiki/Changelog) for the details.
184+
171185
## Migration
172186
This version includes many breaking changes as a result of standardizing behavior across the new generated services. Full details on migration from previous versions can be found [here](https://github.com/watson-developer-cloud/python-sdk/wiki/Migration).
173187

@@ -184,7 +198,7 @@ assistant = AssistantV1(
184198

185199
assistant.set_http_config({'timeout': 100})
186200
response = assistant.message(workspace_id=workspace_id, input={
187-
'text': 'What\'s the weather like?'})
201+
'text': 'What\'s the weather like?'}).get_result()
188202
print(json.dumps(response, indent=2))
189203
```
190204

@@ -205,11 +219,11 @@ assistant = AssistantV1(
205219
password='yyy',
206220
version='2017-04-21')
207221

208-
response = assistant.list_workspaces(headers={'Custom-Header': 'custom_value'})
222+
response = assistant.list_workspaces(headers={'Custom-Header': 'custom_value'}).get_result()
209223
```
210224

211225
## Parsing HTTP response info
212-
If you would like access to some HTTP response information along with the response model, you can set the `set_detailed_response()` to `True`
226+
If you would like access to some HTTP response information along with the response model, you can set the `set_detailed_response()` to `True`. Since Python SDK `v2.0`, it is set to `True`
213227
```python
214228
from watson_developer_cloud import AssistantV1
215229

@@ -219,29 +233,27 @@ assistant = AssistantV1(
219233
version='2017-04-21')
220234

221235
assistant.set_detailed_response(True)
222-
response = assistant.list_workspaces(headers={'Custom-Header': 'custom_value'})
236+
response = assistant.list_workspaces(headers={'Custom-Header': 'custom_value'}).get_result()
223237
print(response)
224238
```
225239

226240
This would give an output of `DetailedResponse` having the structure:
227241
```python
228242
{
229243
'result': <response returned by service>,
230-
'headers': { <http response headers> }
244+
'headers': { <http response headers> },
245+
'status_code': <http status code>
231246
}
232247
```
233-
You can use the `get_result()` and `get_headers()` to return the result and headers respectively.
248+
You can use the `get_result()`, `get_headers()` and get_status_code() to return the result, headers and status code respectively.
234249

235250
## Dependencies
236251

237252
* [requests]
238253
* `python_dateutil` >= 2.5.3
239254
* [responses] for testing
240255
* Following for web sockets support in speech to text
241-
* `autobahn` >= 0.10.9
242-
* `Twisted` >= 13.2.0
243-
* `pyOpenSSL` >= 16.2.0
244-
* `service-identity` >= 17.0.0
256+
* `websocket-client` 0.47.0
245257

246258
## Contributing
247259

appveyor.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
environment:
2+
3+
matrix:
4+
5+
- PYTHON: "C:\\Python35"
6+
- PYTHON: "C:\\Python27-x64"
7+
- PYTHON: "C:\\Python36-x64"
8+
9+
install:
10+
11+
# Install Python (from the official .msi of https://python.org) and pip when
12+
# not already installed.
13+
- ps: if (-not(Test-Path($env:PYTHON))) { & appveyor\install.ps1 }
14+
15+
# Prepend newly installed Python to the PATH of this build
16+
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
17+
18+
- "python -m pip install --upgrade pip"
19+
20+
- "pip install --editable ."
21+
22+
- "pip install -r requirements-dev.txt"
23+
24+
build: off
25+
26+
test_script:
27+
28+
- ps: py.test --reruns 3 --cov=watson_developer_cloud
29+
30+
deploy: off
31+
32+
matrix:
33+
fast_finish: true
34+

examples/README.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
## Examples
2-
To run the examples, you will need a `username`, `password`, and `url`. To get your service credentials, follow these steps:
3-
1. Log in to IBM Cloud at https://console.bluemix.net.
2+
To run the examples, you will need the appropriate service instance
43

5-
1. Create an instance of the service:
6-
1. In the IBM Cloud **Catalog**, select the Natural Language Classifier service.
7-
1. Click **Create**.
8-
9-
1. Copy your credentials:
10-
1. On the left side of the page, click **Service Credentials** to view your service credentials.
11-
1. Copy `username`, `password`, and `url` from these service credentials.
12-
13-
## Deprecation notice
14-
Language Translator v3 is now available. The v2 Language Translator API will no longer be available after July 31, 2018. To take advantage of the latest service enhancements, migrate to the v3 API. View the [Migrating to Language Translator v3](https://console.bluemix.net/docs/services/language-translator/migrating.html) page for more information.
4+
1. Go to the IBM Cloud [Dashboard](https://console.bluemix.net/dashboard/apps?category=ai) page.
5+
1. Either click an existing Watson service instance or click [**Create resource > AI**](https://console.bluemix.net/catalog/?category=ai) and create a service instance.
6+
1. Copy the `url` and either `apikey` or `username` and `password`. Click **Show** if the credentials are masked.

0 commit comments

Comments
 (0)