You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the Python server SDK for Vonage's API. To use it you'll
12
-
need a Vonage account. Sign up [for free at vonage.com][signup].
11
+
This is the Python server SDK to help you use Vonage APIs in your Python application. To use it you'll need a Vonage account. [Sign up for free on the Vonage site](https://ui.idp.vonage.com/ui/auth/registration).
12
+
13
+
### Contents:
13
14
14
15
-[Installation](#installation)
15
16
-[Migration Guides](#migration-guides)
@@ -35,6 +36,7 @@ need a Vonage account. Sign up [for free at vonage.com][signup].
@@ -1405,7 +1406,7 @@ The following is a list of Vonage APIs and whether the Python SDK provides suppo
1405
1406
1406
1407
[asyncio](https://docs.python.org/3/library/asyncio.html) is a library to write **concurrent** code using the **async/await** syntax.
1407
1408
1408
-
We don't currently support asyncio in the Python SDK but we are planning to do so in upcoming releases.
1409
+
We don't currently support asyncio in the Python SDK.
1409
1410
1410
1411
## Contributing
1411
1412
@@ -1414,13 +1415,13 @@ We :heart: contributions! But if you plan to work on something big or controvers
1414
1415
We recommend working on `vonage-python-sdk` with a [virtualenv][virtualenv]. The following command will install all the Python dependencies you need to run the tests:
1415
1416
1416
1417
```bash
1417
-
make install
1418
+
pip install -r requirements.txt
1418
1419
```
1419
1420
1420
1421
The tests are all written with pytest. You run them with:
1421
1422
1422
1423
```bash
1423
-
make test
1424
+
pytest -v
1424
1425
```
1425
1426
1426
1427
We use [Black](https://black.readthedocs.io/en/stable/index.html) for code formatting, with our config in the `pyproject.toml` file. To ensure a PR follows the right format, you can set up and use our pre-commit settings with
@@ -1433,10 +1434,11 @@ Then when you commit code, if it's not in the right format, it will be automatic
1433
1434
1434
1435
## License
1435
1436
1436
-
This library is released under the [Apache License][license].
1437
+
This library is released under the [Apache License](license).
Copy file name to clipboardExpand all lines: V3_TO_V4_SDK_MIGRATION_GUIDE.md
+57-11Lines changed: 57 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
# Vonage Python SDK v3 to v4 Migration Guide
2
2
3
-
This is a guide to help you migrate from using v3 of the Vonage Python SDK to using the new v4 `vonage` package. It has feature parity with the v3 package and contains many enhancements and structural changes. We will only be supporting v4 from its release.
3
+
This is a guide to help you migrate from using v3 of the Vonage Python SDK to using the new v4 `vonage` package. It has feature parity with the v3 package and contains many enhancements and structural changes. We will only be supporting v4 from the time of its full release.
4
4
5
-
The Vonage Python SDK (`vonage`) contains methods and data models to help you use many of Vonage's APIs. It also includes support for the new network APIs announced by Vonage.
5
+
The Vonage Python SDK (`vonage`) contains methods and data models to help you use many of Vonage's APIs. It also includes support for the new mobile network APIs announced by Vonage.
6
6
7
7
## Contents
8
8
@@ -12,7 +12,10 @@ The Vonage Python SDK (`vonage`) contains methods and data models to help you us
12
12
-[Accessing API Methods](#accessing-api-methods)
13
13
-[Accessing API Data Models](#accessing-api-data-models)
14
14
-[Response Objects](#response-objects)
15
-
-[API Changes](#API-changes)
15
+
-[Error Handling](#error-handling)
16
+
-[General API Changes](#general-API-changes)
17
+
-[Specific API Changes](#specific-api-changes)
18
+
-[Method Name Changes](#method-name-changes)
16
19
-[Additional Resources](#additional-resources)
17
20
18
21
## Structural Changes and Enhancements
@@ -46,7 +49,7 @@ You will notice that the dependent Vonage packages have been installed as well.
46
49
47
50
## Configuration
48
51
49
-
To get started with the v4 SDK, you'll need to initialize an instance of the `vonage.Vonage` class. This can then be used to access API methods. You need to provide authentication information and can optionally provide configuration options for the HTTP Client that's used (that is in the `vonage-http-client` package). This section will break all of this down then provide an example.
52
+
To get started with the v4 SDK, you'll need to initialize an instance of the `vonage.Vonage` class. This can then be used to access API methods. You need to provide authentication information and can optionally provide configuration options for the HTTP Client used to make requests to Vonage APIs. This section will break all of this down then provide an example.
However, some APIs with a lot of models have them located under the `vonage_api_package.models` package, e.g. `vonage-messages`, `vonage-voice` and `vonage-video`. To access these, simply import from `.models`, e.g. to send an image via Facebook Messenger do this:
126
+
However, some APIs with a lot of models have them located under the `vonage_api_package.models` package, e.g. `vonage-messages`, `vonage-voice` and `vonage-video`. To access these, simply import from `vonage_api_package.models`, e.g. to send an image via Facebook Messenger do this:
124
127
125
128
```python
126
129
from vonage_messages.models import MessengerImage, MessengerOptions, MessengerResource
Response fields are also converted into snake_case where applicable, so as to be more pythonic. This means they won't necessarily match the API one-to-one.
156
159
157
-
## API Changes
160
+
## Error Handling
161
+
162
+
In v3 of the SDK, most HTTP client errors gave a general `HttpClientError`. In v4 these are finer-grained. Errors in v4 inherit from the general `VonageError` but are more specific and finer-grained, E.g. a `RateLimitedError` when the SDK receives an HTTP 429 response.
163
+
164
+
These errors will have a descriptive message and will also include the response object returned to the SDK, accessed by `HttpClientError.response` etc.
165
+
166
+
Some API packages have their own errors for specific cases too.
167
+
168
+
For older Vonage APIs that always return an HTTP 200, error handling logic has been included to give a similar experience to the newer APIs.
169
+
170
+
## General API Changes
158
171
159
172
In v3, you access `vonage.Client`. In v4, it's `vonage.Vonage`.
160
173
161
174
The methods to get and set host attributes in v3 e.g. `vonage.Client.api_host` have been removed. You now get these options in v4 via the `vonage.Vonage.http_client`. Set these options in v4 by adding the options you want to the `vonage.HttpClientOptions` data model when initializing a `vonage.Vonage` object.
162
175
163
-
Rather than just returning a `ClientError` when an HTTP Client error is thrown, we now throw more specific errors with more information.
176
+
## Specific API Changes
177
+
178
+
### Video API
179
+
180
+
Methods have been added to help you work with the Live Captions, Audio Connector and Experience Composer APIs. See the [Video API samples](video/README.md) for more information.
164
181
165
-
### Specific API Changes
182
+
### Voice API
183
+
184
+
Methods have been added to help you moderate a voice call:
185
+
186
+
-`voice.hangup`
187
+
-`voice.mute`
188
+
-`voice.unmute`
189
+
-`voice.earmuff`
190
+
-`voice.unearmuff`
191
+
192
+
See the [Voice API samples](voice/README.md) for more information.
193
+
194
+
### Network Number Verification API
166
195
167
196
The process for verifying a number using the Network Number Verification API has been simplified. In v3 it was required to exchange a code for a token then use this token in the verify request. In v4, these steps are combined so both functions are taken care of in the `NetworkNumberVerification.verify` method.
168
197
169
-
Verify v2 functionality is accessed from `verify2` in v3 and `verify_v2` in v4.
198
+
### Verify V2 API
199
+
200
+
Verify v2 functionality is accessed from `vonage_client.verify2` in v3 and `vonage_client.verify_v2` in v4.
201
+
202
+
### SMS API
170
203
171
-
SMS message signing/verifying signatures code in `vonage.Client` in v3 has been moved into the `vonage-http-client` package in v4. This can be accessed via the `vonage` package as we import the `vonage-http-client.Auth` class into its namespace.
204
+
Code for signing/verifying signatures of SMS messages that was in the `vonage.Client` class in v3 has been moved into the `vonage-http-client` package in v4. This can be accessed via the `vonage` package as we import the `vonage-http-client.Auth` class into its namespace.
Some methods from v3 have had their names changed in v4. Assuming you access all methods from the `vonage.Vonage` class in v4 with `vonage.Vonage.api_method` or the `vonage.Client` class in v3 with `vonage.Client.api_method`, this table details the changes:
180
213
@@ -195,6 +228,19 @@ Some methods from v3 have had their names changed in v4. Assuming you access all
0 commit comments