Skip to content

Commit fb32f46

Browse files
committed
make data models accessible from top level
1 parent 7139a4e commit fb32f46

24 files changed

+116
-100
lines changed

Diff for: .github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
27+
python: ["3.9", "3.10", "3.11", "3.12"]
2828
os: ["ubuntu-latest"]
2929
steps:
3030
- name: Clone repo

Diff for: README.md

+26-29
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,12 @@ verify_signature(TOKEN, SIGNATURE_SECRET) # Returns a boolean
405405

406406
## Messages API
407407

408-
409408
### How to Construct a Message
410409

411-
In order to send a message, you must construct a message object of the correct type. These are all found under `vonage_messages.models`.
410+
In order to send a message, you must construct a message object of the correct type.
412411

413412
```python
414-
from vonage_messages.models import Sms
413+
from vonage_messages import Sms
415414

416415
message = Sms(
417416
from_='Vonage APIs',
@@ -435,7 +434,7 @@ Some message types have submodels with additional fields. In this case, import t
435434
e.g.
436435

437436
```python
438-
from vonage_messages.models import MessengerImage, MessengerOptions, MessengerResource
437+
from vonage_messages import MessengerImage, MessengerOptions, MessengerResource
439438

440439
messenger = MessengerImage(
441440
to='1234567890',
@@ -451,7 +450,7 @@ To send a message, access the `Messages.send` method via the main Vonage object,
451450

452451
```python
453452
from vonage import Auth, Vonage
454-
from vonage_messages.models import Sms
453+
from vonage_messages import Sms
455454

456455
vonage_client = Vonage(Auth(application_id='my-application-id', private_key='my-private-key'))
457456

@@ -970,12 +969,10 @@ response = vonage_client.verify_legacy.request_network_unblock('23410')
970969

971970
## Video API
972971

973-
You will use the custom Pydantic data models to make most of the API calls in this package. They are accessed from the `vonage_video.models` package.
974-
975972
### Generate a Client Token
976973

977974
```python
978-
from vonage_video.models import TokenOptions
975+
from vonage_video import TokenOptions
979976

980977
token_options = TokenOptions(session_id='your_session_id', role='publisher')
981978
client_token = vonage_client.video.generate_client_token(token_options)
@@ -984,7 +981,7 @@ client_token = vonage_client.video.generate_client_token(token_options)
984981
### Create a Session
985982

986983
```python
987-
from vonage_video.models import SessionOptions
984+
from vonage_video import SessionOptions
988985

989986
session_options = SessionOptions(media_mode='routed')
990987
video_session = vonage_client.video.create_session(session_options)
@@ -1005,7 +1002,7 @@ stream_info = vonage_client.video.get_stream(session_id='your_session_id', strea
10051002
### Change Stream Layout
10061003

10071004
```python
1008-
from vonage_video.models import StreamLayoutOptions
1005+
from vonage_video import StreamLayoutOptions
10091006

10101007
layout_options = StreamLayoutOptions(type='bestFit')
10111008
updated_streams = vonage_client.video.change_stream_layout(session_id='your_session_id', stream_layout_options=layout_options)
@@ -1014,7 +1011,7 @@ updated_streams = vonage_client.video.change_stream_layout(session_id='your_sess
10141011
### Send a Signal
10151012

10161013
```python
1017-
from vonage_video.models import SignalData
1014+
from vonage_video import SignalData
10181015

10191016
signal_data = SignalData(type='chat', data='Hello, World!')
10201017
vonage_client.video.send_signal(session_id='your_session_id', data=signal_data)
@@ -1047,7 +1044,7 @@ vonage_client.video.disable_mute_all_streams(session_id='your_session_id')
10471044
### Start Captions
10481045

10491046
```python
1050-
from vonage_video.models import CaptionsOptions
1047+
from vonage_video import CaptionsOptions
10511048

10521049
captions_options = CaptionsOptions(language='en-US')
10531050
captions_data = vonage_client.video.start_captions(captions_options)
@@ -1056,7 +1053,7 @@ captions_data = vonage_client.video.start_captions(captions_options)
10561053
### Stop Captions
10571054

10581055
```python
1059-
from vonage_video.models import CaptionsData
1056+
from vonage_video import CaptionsData
10601057

10611058
captions_data = CaptionsData(captions_id='your_captions_id')
10621059
vonage_client.video.stop_captions(captions_data)
@@ -1065,7 +1062,7 @@ vonage_client.video.stop_captions(captions_data)
10651062
### Start Audio Connector
10661063

10671064
```python
1068-
from vonage_video.models import AudioConnectorOptions
1065+
from vonage_video import AudioConnectorOptions
10691066

10701067
audio_connector_options = AudioConnectorOptions(session_id='your_session_id', token='your_token', url='https://example.com')
10711068
audio_connector_data = vonage_client.video.start_audio_connector(audio_connector_options)
@@ -1074,7 +1071,7 @@ audio_connector_data = vonage_client.video.start_audio_connector(audio_connector
10741071
### Start Experience Composer
10751072

10761073
```python
1077-
from vonage_video.models import ExperienceComposerOptions
1074+
from vonage_video import ExperienceComposerOptions
10781075

10791076
experience_composer_options = ExperienceComposerOptions(session_id='your_session_id', token='your_token', url='https://example.com')
10801077
experience_composer = vonage_client.video.start_experience_composer(experience_composer_options)
@@ -1083,7 +1080,7 @@ experience_composer = vonage_client.video.start_experience_composer(experience_c
10831080
### List Experience Composers
10841081

10851082
```python
1086-
from vonage_video.models import ListExperienceComposersFilter
1083+
from vonage_video import ListExperienceComposersFilter
10871084

10881085
filter = ListExperienceComposersFilter(page_size=10)
10891086
experience_composers, count, next_page_offset = vonage_client.video.list_experience_composers(filter)
@@ -1105,7 +1102,7 @@ vonage_client.video.stop_experience_composer(experience_composer_id='experience_
11051102
### List Archives
11061103

11071104
```python
1108-
from vonage_video.models import ListArchivesFilter
1105+
from vonage_video import ListArchivesFilter
11091106

11101107
filter = ListArchivesFilter(offset=2)
11111108
archives, count, next_page_offset = vonage_client.video.list_archives(filter)
@@ -1115,7 +1112,7 @@ print(archives)
11151112
### Start Archive
11161113

11171114
```python
1118-
from vonage_video.models import CreateArchiveRequest
1115+
from vonage_video import CreateArchiveRequest
11191116

11201117
archive_options = CreateArchiveRequest(session_id='your_session_id', name='My Archive')
11211118
archive = vonage_client.video.start_archive(archive_options)
@@ -1137,7 +1134,7 @@ vonage_client.video.delete_archive(archive_id='your_archive_id')
11371134
### Add Stream to Archive
11381135

11391136
```python
1140-
from vonage_video.models import AddStreamRequest
1137+
from vonage_video import AddStreamRequest
11411138

11421139
add_stream_request = AddStreamRequest(stream_id='your_stream_id')
11431140
vonage_client.video.add_stream_to_archive(archive_id='your_archive_id', params=add_stream_request)
@@ -1159,7 +1156,7 @@ print(archive)
11591156
### Change Archive Layout
11601157

11611158
```python
1162-
from vonage_video.models import ComposedLayout
1159+
from vonage_video import ComposedLayout
11631160

11641161
layout = ComposedLayout(type='bestFit')
11651162
archive = vonage_client.video.change_archive_layout(archive_id='your_archive_id', layout=layout)
@@ -1169,7 +1166,7 @@ print(archive)
11691166
### List Broadcasts
11701167

11711168
```python
1172-
from vonage_video.models import ListBroadcastsFilter
1169+
from vonage_video import ListBroadcastsFilter
11731170

11741171
filter = ListBroadcastsFilter(page_size=10)
11751172
broadcasts, count, next_page_offset = vonage_client.video.list_broadcasts(filter)
@@ -1179,7 +1176,7 @@ print(broadcasts)
11791176
### Start Broadcast
11801177

11811178
```python
1182-
from vonage_video.models import CreateBroadcastRequest, BroadcastOutputSettings, BroadcastHls, BroadcastRtmp
1179+
from vonage_video import CreateBroadcastRequest, BroadcastOutputSettings, BroadcastHls, BroadcastRtmp
11831180

11841181
broadcast_options = CreateBroadcastRequest(session_id='your_session_id', outputs=BroadcastOutputSettings(
11851182
hls=BroadcastHls(dvr=True, low_latency=False),
@@ -1213,7 +1210,7 @@ print(broadcast)
12131210
### Change Broadcast Layout
12141211

12151212
```python
1216-
from vonage_video.models import ComposedLayout
1213+
from vonage_video import ComposedLayout
12171214

12181215
layout = ComposedLayout(type='bestFit')
12191216
broadcast = vonage_client.video.change_broadcast_layout(broadcast_id='your_broadcast_id', layout=layout)
@@ -1223,7 +1220,7 @@ print(broadcast)
12231220
### Add Stream to Broadcast
12241221

12251222
```python
1226-
from vonage_video.models import AddStreamRequest
1223+
from vonage_video import AddStreamRequest
12271224

12281225
add_stream_request = AddStreamRequest(stream_id='your_stream_id')
12291226
vonage_client.video.add_stream_to_broadcast(broadcast_id='your_broadcast_id', params=add_stream_request)
@@ -1238,7 +1235,7 @@ vonage_client.video.remove_stream_from_broadcast(broadcast_id='your_broadcast_id
12381235
### Initiate SIP Call
12391236

12401237
```python
1241-
from vonage_video.models import InitiateSipRequest, SipOptions, SipAuth
1238+
from vonage_video import InitiateSipRequest, SipOptions, SipAuth
12421239

12431240
sip_request_params = InitiateSipRequest(
12441241
session_id='your_session_id',
@@ -1281,7 +1278,7 @@ vonage_client.video.play_dtmf(session_id=session_id, digits=digits, connection_i
12811278
To create a call, you must pass an instance of the `CreateCallRequest` model to the `create_call` method. If supplying an NCCO, import the NCCO actions you want to use and pass them in as a list to the `ncco` model field.
12821279

12831280
```python
1284-
from vonage_voice.models import CreateCallRequest, Talk
1281+
from vonage_voice import CreateCallRequest, Talk
12851282

12861283
ncco = [Talk(text='Hello world', loop=3, language='en-GB')]
12871284

@@ -1303,7 +1300,7 @@ print(response.model_dump())
13031300
calls, next_record_index = vonage_client.voice.list_calls()
13041301

13051302
# Specify filtering options
1306-
from vonage_voice.models import ListCallsFilter
1303+
from vonage_voice import ListCallsFilter
13071304

13081305
call_filter = ListCallsFilter(
13091306
status='completed',
@@ -1364,7 +1361,7 @@ vonage_client.voice.unearmuff('UUID')
13641361
### Play Audio Into a Call
13651362

13661363
```python
1367-
from vonage_voice.models import AudioStreamOptions
1364+
from vonage_voice import AudioStreamOptions
13681365

13691366
# Only the `stream_url` option is required
13701367
options = AudioStreamOptions(
@@ -1382,7 +1379,7 @@ vonage_client.voice.stop_audio_stream('UUID')
13821379
### Play TTS Into a Call
13831380

13841381
```python
1385-
from vonage_voice.models import TtsStreamOptions
1382+
from vonage_voice import TtsStreamOptions
13861383

13871384
# Only the `text` field is required
13881385
options = TtsStreamOptions(

Diff for: messages/CHANGES.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 1.4.0
2+
- Make all models originally accessed by `vonage_messages.models.***` available at the top level of the package, i.e. `vonage_messages.***`
3+
14
# 1.3.0
25
- Add support for API key/secret header authentication
36
- Updated dependency versions

Diff for: messages/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ It is recommended to use this as part of the main `vonage` package. The examples
88

99
### How to Construct a Message
1010

11-
In order to send a message, you must construct a message object of the correct type. These are all found under `vonage_messages.models`.
11+
In order to send a message, you must construct a message object of the correct type.
1212

1313
```python
14-
from vonage_messages.models import Sms
14+
from vonage_messages import Sms
1515

1616
message = Sms(
1717
from_='Vonage APIs',
@@ -35,7 +35,7 @@ Some message types have submodels with additional fields. In this case, import t
3535
e.g.
3636

3737
```python
38-
from vonage_messages.models import MessengerImage, MessengerOptions, MessengerResource
38+
from vonage_messages import MessengerImage, MessengerOptions, MessengerResource
3939

4040
messenger = MessengerImage(
4141
to='1234567890',
@@ -51,7 +51,7 @@ To send a message, access the `Messages.send` method via the main Vonage object,
5151

5252
```python
5353
from vonage import Auth, Vonage
54-
from vonage_messages.models import Sms
54+
from vonage_messages import Sms
5555

5656
vonage_client = Vonage(Auth(application_id='my-application-id', private_key='my-private-key'))
5757

Diff for: messages/src/vonage_messages/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from . import models
1+
from . import models # Import models to access the module directly
22
from .messages import Messages
3+
from .models import * # Need this to directly expose data models
34
from .responses import SendMessageResponse
45

56
__all__ = ['models', 'Messages', 'SendMessageResponse']

Diff for: messages/src/vonage_messages/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.3.0'
1+
__version__ = '1.4.0'

Diff for: messages/tests/test_messages.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22

33
import responses
44
from pytest import raises
5-
from vonage_http_client.auth import Auth
6-
from vonage_http_client.errors import HttpRequestError
7-
from vonage_http_client.http_client import HttpClient, HttpClientOptions
8-
from vonage_messages.messages import Messages
9-
from vonage_messages.models import Sms
10-
from vonage_messages.models.messenger import (
5+
from vonage_http_client import Auth, HttpClient, HttpClientOptions, HttpRequestError
6+
from vonage_messages import (
7+
Messages,
118
MessengerImage,
129
MessengerOptions,
1310
MessengerResource,
11+
SendMessageResponse,
12+
Sms,
1413
)
15-
from vonage_messages.responses import SendMessageResponse
1614

1715
from testutils import build_response, get_mock_api_key_auth, get_mock_jwt_auth
1816

Diff for: pants.ci.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
colors = true
33

44
[python]
5-
interpreter_constraints = ['>=3.8']
5+
interpreter_constraints = ['>=3.9']

Diff for: pants.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ interpreter_constraints = ['==3.12.*']
2727
args = ['-vv', '--no-header']
2828

2929
[coverage-py]
30-
interpreter_constraints = ['>=3.8']
30+
interpreter_constraints = ['>=3.9']
3131
report = ['html', 'console']
3232

3333
[black]
3434
args = ['--line-length=90', '--skip-string-normalization']
35-
interpreter_constraints = ['>=3.8']
35+
interpreter_constraints = ['>=3.9']
3636

3737
[isort]
3838
args = ['--profile=black', '--line-length=90']
39-
interpreter_constraints = ['>=3.8']
39+
interpreter_constraints = ['>=3.9']
4040

4141
[docformatter]
4242
args = ['--wrap-summaries=90', '--wrap-descriptions=90']
43-
interpreter_constraints = ['>=3.8']
43+
interpreter_constraints = ['>=3.9']
4444

4545
[autoflake]
46-
interpreter_constraints = ['>=3.8']
46+
interpreter_constraints = ['>=3.9']

Diff for: video/CHANGES.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 1.2.0
2+
- Make all models originally accessed by `vonage_video.models.***` available at the top level of the package, i.e. `vonage_video.***`
3+
14
# 1.1.0
25
- Add new `max_bitrate` field for archives
36

Diff for: video/OPENTOK_TO_VONAGE_MIGRATION.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ vonage_client.video.video_api_method...
6060

6161
## Accessing Video API Data Models
6262

63-
You can access data models for the Video API, e.g. as arguments to video methods, by importing them from the `vonage_video.models` package, e.g.
63+
You can access data models for the Video API, e.g. as arguments to video methods, by importing them from the `vonage_video` package, e.g.
6464

6565
```python
66-
from vonage_video.models import SessionOptions
66+
from vonage_video import SessionOptions
6767

6868
session_options = SessionOptions(...)
6969

@@ -78,7 +78,7 @@ vonage_client.video.create_session(session_options)
7878

7979
There are some changes to methods between the `opentok` SDK and the Video API implementation in the `vonage-video` SDK.
8080

81-
- Any positional parameters in method signatures have been replaced with data models in the `vonage-video` package, stored at `vonage_video.models`.
81+
- Any positional parameters in method signatures have been replaced with data models in the `vonage-video` package.
8282
- Methods now return responses as Pydantic data models.
8383
- Some methods have been renamed, for clarity and/or to better reflect what the method does. These are listed below:
8484

0 commit comments

Comments
 (0)