Skip to content

Commit b9b32ef

Browse files
author
childish-sambino
authored
feat!: Merge branch '8.0.0-rc' to main (#702)
1 parent e7b851e commit b9b32ef

File tree

1,367 files changed

+199761
-239316
lines changed

Some content is hidden

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

1,367 files changed

+199761
-239316
lines changed

.github/workflows/test-and-deploy.yml

+12-7
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,11 @@ on:
1313
jobs:
1414
test:
1515
name: Test
16+
runs-on: ubuntu-latest
1617
timeout-minutes: 20
1718
strategy:
1819
matrix:
1920
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
20-
os: [ubuntu-latest]
21-
# Need to pin ubuntu version for python 3.6 (see https://github.com/actions/setup-python/issues/544#issuecomment-1332535877)
22-
# Change this to use ubuntu-latest for all python versions after deprecating python 3.6
23-
include:
24-
- python-version: '3.6'
25-
os: 'ubuntu-20.04'
26-
runs-on: ${{ matrix.os }}
2721
steps:
2822
- name: Checkout twilio-python
2923
uses: actions/checkout@v3
@@ -43,6 +37,17 @@ jobs:
4337
- name: Run the tests
4438
run: make test-with-coverage
4539

40+
- name: Run Cluster Tests
41+
if: (!github.event.pull_request.head.repo.fork)
42+
env:
43+
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }}
44+
TWILIO_API_KEY: ${{ secrets.TWILIO_CLUSTER_TEST_API_KEY}}
45+
TWILIO_API_SECRET: ${{ secrets.TWILIO_CLUSTER_TEST_API_KEY_SECRET }}
46+
TWILIO_FROM_NUMBER: ${{ secrets.TWILIO_FROM_NUMBER }}
47+
TWILIO_TO_NUMBER: ${{ secrets.TWILIO_TO_NUMBER }}
48+
TWILIO_AUTH_TOKEN: ${{ secrets.TWILIO_AUTH_TOKEN }}
49+
run: make cluster-test
50+
4651
- name: Verify docs generation
4752
run: make docs
4853

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ docs/source/_rst
3838
.python-version
3939

4040
README.md.bak
41+
42+
**/.openapi-generator*

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.6
1+
FROM python:3.7
22

33
ENV PYTHONUNBUFFERED 1
44

Makefile

+20-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
.PHONY: clean install analysis test test-install test-docker develop docs docs-install
1+
.PHONY: clean install analysis test test-install test-docker develop docs docs-install prettier prettier-check
22

33
venv:
4-
@python --version || (echo "Python is not installed, Python 3.6+"; exit 1);
4+
@python --version || (echo "Python is not installed, Python 3.7+"; exit 1);
55
virtualenv --python=python venv
66

77
install: venv
@@ -12,23 +12,25 @@ test-install: install
1212

1313
test-docker:
1414
docker build -t twilio/twilio-python .
15-
docker run twilio/twilio-python pytest tests
15+
docker run twilio/twilio-python pytest tests --ignore=tests/cluster
1616

1717
develop: venv
1818
. venv/bin/activate; pip install -e . --use-mirrors
1919
. venv/bin/activate; pip install -r tests/requirements.txt
2020

2121
analysis:
22-
. venv/bin/activate; flake8 --ignore=E123,E126,E128,E501,W391,W291,W293,F401 tests
23-
. venv/bin/activate; flake8 --ignore=E402,F401,W391,W291,W293 twilio --max-line-length=300
22+
. venv/bin/activate; flake8 --ignore=E123,E126,E128,E501,W391,W291,W293,F401,W503,E203 tests
23+
. venv/bin/activate; flake8 --ignore=E402,F401,W391,W291,W293,W503,E203 twilio --max-line-length=300
2424

25-
test: analysis
26-
. venv/bin/activate; pytest tests
25+
test: analysis prettier-check
26+
. venv/bin/activate; pytest tests --ignore=tests/cluster
2727

28-
test-with-coverage:
28+
test-with-coverage: prettier-check
2929
. venv/bin/activate; \
30-
pytest --cov=twilio tests; \
31-
coverage xml --omit 'twilio/rest/*' -o coverage.xml
30+
pytest --cov-config=setup.cfg --cov-report xml --cov=twilio tests --ignore=tests/cluster
31+
32+
cluster-test:
33+
. venv/bin/activate; pytest tests/cluster
3234

3335
docs-install:
3436
. venv/bin/activate; pip install -r tests/requirements.txt
@@ -54,6 +56,14 @@ clean:
5456
nopyc:
5557
find . -name \*.pyc -delete
5658

59+
prettier:
60+
. venv/bin/activate; autoflake --remove-all-unused-imports -i -r --exclude venv .
61+
. venv/bin/activate; black .
62+
63+
prettier-check:
64+
. venv/bin/activate; autoflake --check-diff --quiet --remove-all-unused-imports -r --exclude venv .
65+
. venv/bin/activate; black --check .
66+
5767
API_DEFINITIONS_SHA=$(shell git log --oneline | grep Regenerated | head -n1 | cut -d ' ' -f 5)
5868
CURRENT_TAG=$(shell expr "${GITHUB_TAG}" : ".*-rc.*" >/dev/null && echo "rc" || echo "latest")
5969
docker-build:

README.md

+46-16
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ Please consult the [official migration guide](https://www.twilio.com/docs/librar
2323

2424
This library supports the following Python implementations:
2525

26-
* Python 3.6
2726
* Python 3.7
2827
* Python 3.8
2928
* Python 3.9
@@ -59,15 +58,26 @@ Getting started with the Twilio API couldn't be easier. Create a
5958

6059
### API Credentials
6160

62-
The `Twilio` needs your Twilio credentials. You can either pass these
61+
The `Twilio` client needs your Twilio credentials. You can either pass these
6362
directly to the constructor (see the code below) or via environment variables.
6463

64+
Authenticating with Account SID and Auth Token:
6565
```python
6666
from twilio.rest import Client
6767

68-
account = "ACXXXXXXXXXXXXXXXXX"
69-
token = "YYYYYYYYYYYYYYYYYY"
70-
client = Client(account, token)
68+
account_sid = "ACXXXXXXXXXXXXXXXXX"
69+
auth_token = "YYYYYYYYYYYYYYYYYY"
70+
client = Client(account_sid, auth_token)
71+
```
72+
73+
Authenticating with API Key and API Secret:
74+
```python
75+
from twilio.rest import Client
76+
77+
api_key = "XXXXXXXXXXXXXXXXX"
78+
api_secret = "YYYYYYYYYYYYYYYYYY"
79+
account_sid = "ACXXXXXXXXXXXXXXXXX"
80+
client = Client(api_key, api_secret, account_sid)
7181
```
7282

7383
Alternatively, a `Client` constructor without these parameters will
@@ -112,9 +122,9 @@ This will result in the `hostname` transforming from `api.twilio.com` to `api.sy
112122
```python
113123
from twilio.rest import Client
114124

115-
account = "ACXXXXXXXXXXXXXXXXX"
116-
token = "YYYYYYYYYYYYYYYYYY"
117-
client = Client(account, token)
125+
username = "ACXXXXXXXXXXXXXXXXX"
126+
password = "YYYYYYYYYYYYYYYYYY"
127+
client = Client(username, password)
118128

119129
call = client.calls.create(to="9991231234",
120130
from_="9991231234",
@@ -127,22 +137,42 @@ print(call.sid)
127137
```python
128138
from twilio.rest import Client
129139

130-
account = "ACXXXXXXXXXXXXXXXXX"
131-
token = "YYYYYYYYYYYYYYYYYY"
132-
client = Client(account, token)
140+
username = "ACXXXXXXXXXXXXXXXXX"
141+
password = "YYYYYYYYYYYYYYYYYY"
142+
client = Client(username, password)
133143

134144
message = client.messages.create(to="+12316851234", from_="+15555555555",
135145
body="Hello there!")
136146
```
137147

148+
### Asynchronous API Requests
149+
150+
By default, the Twilio Client will make synchronous requests to the Twilio API. To allow for asynchronous, non-blocking requests, we've included an optional asynchronous HTTP client. When used with the Client and the accompanying `*_async` methods, requests made to the Twilio API will be performed asynchronously.
151+
152+
```python
153+
from twilio.http.async_http_client import AsyncTwilioHttpClient
154+
from twilio.rest import Client
155+
156+
async def main():
157+
username = "ACXXXXXXXXXXXXXXXXX"
158+
password = "YYYYYYYYYYYYYYYYYY"
159+
http_client = AsyncTwilioHttpClient()
160+
client = Client(username, password, http_client=http_client)
161+
162+
message = await client.messages.create_async(to="+12316851234", from_="+15555555555",
163+
body="Hello there!")
164+
165+
asyncio.run(main())
166+
```
167+
138168
### Enable Debug Logging
139169

140170
Log the API request and response data to the console:
141171

142172
```python
143173
import logging
144174

145-
client = Client(account, token)
175+
client = Client(username, password)
146176
logging.basicConfig()
147177
client.http_client.logger.setLevel(logging.INFO)
148178
```
@@ -152,7 +182,7 @@ Log the API request and response data to a file:
152182
```python
153183
import logging
154184

155-
client = Client(account, token)
185+
client = Client(username, password)
156186
logging.basicConfig(filename='./log.txt')
157187
client.http_client.logger.setLevel(logging.INFO)
158188
```
@@ -163,9 +193,9 @@ client.http_client.logger.setLevel(logging.INFO)
163193
from twilio.rest import Client
164194
from twilio.base.exceptions import TwilioRestException
165195

166-
account = "ACXXXXXXXXXXXXXXXXX"
167-
token = "YYYYYYYYYYYYYYYYYY"
168-
client = Client(account, token)
196+
username = "ACXXXXXXXXXXXXXXXXX"
197+
password = "YYYYYYYYYYYYYYYYYY"
198+
client = Client(username, password)
169199

170200
try:
171201
message = client.messages.create(to="+12316851234", from_="+15555555555",

UPGRADE.md

+91-19
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,122 @@
33
_`MAJOR` version bumps will have upgrade notes
44
posted here._
55

6-
[2021-09-22] 6.x.x to 7.x.x
7-
---------------------------
6+
## [2023-04-05] 7.x.x to 8.x.x
7+
8+
- **Supported Python versions updated**
9+
- Dropped support for Python 3.6 ([#632](https://github.com/twilio/twilio-python/pull/632))
10+
- Python 3.7 is the new required minimum version to use twilio-python helper library
11+
- **Deletion of TwiML Voice Deprecated Methods ([#643](https://github.com/twilio/twilio-python/pull/643))**
12+
13+
- [`<Refer>`](https://www.twilio.com/docs/voice/twiml/refer)
14+
- `Refer.refer_sip()` replaced by `Refer.sip()`
15+
- [`<Say>`](https://www.twilio.com/docs/voice/twiml/say/text-speech#generating-ssml-via-helper-libraries)
16+
17+
- `Say.ssml_break()` replaced by `Say.break_()`
18+
- `Say.ssml_emphasis()` replaced by `Say.emphasis()`
19+
- `Say.ssml_lang()` replaced by `Say.lang()`
20+
- `Say.ssml_p()` replaced by `Say.p()`
21+
- `Say.ssml_phoneme()` replaced by `Say.phoneme()`
22+
- `Say.ssml_prosody()` replaced by `Say.prosody()`
23+
- `Say.ssml_s()` replaced by `Say.s()`
24+
- `Say.ssml_say_as()` replaced by `Say.say_as()`
25+
- `Say.ssml_sub()` replaced by `Say.sub()`
26+
- `Say.ssml_w()` replaced by `Say.w()`
27+
28+
Old:
29+
30+
```python
31+
from twilio.twiml.voice_response import VoiceResponse
32+
resp = VoiceResponse()
33+
say = resp.say("Hello")
34+
say.ssml_emphasis("you")
35+
```
36+
37+
New:
38+
39+
```python
40+
from twilio.twiml.voice_response import VoiceResponse
41+
resp = VoiceResponse()
42+
say = resp.say("Hello")
43+
say.emphasis("you")
44+
```
45+
46+
- **JWT token building deprecations ([#644](https://github.com/twilio/twilio-python/pull/644))**
47+
- `ConversationsGrant` has been deprecated in favor of `VoiceGrant`
48+
- `IpMessagingGrant` has been removed
49+
- `twilio.rest.api.v2010.account.available_phone_number` has been renamed to `twilio.rest.api.v2010.account.available_phone_number_country`
50+
- **[TaskRouter Workers Statistics](https://www.twilio.com/docs/taskrouter/api/worker/statistics) operations updated ([#653](https://github.com/twilio/twilio-python/pull/653))**
51+
52+
- Cumulative and Real-Time Workers Statistics no longer accept a WorkerSid
53+
- `GET /v1/Workspaces/{WorkspaceSid}/Workers/CumulativeStatistics`
54+
55+
Old: `client.taskrouter.v1.workspaces('WS...').workers('WK...).cumulative_statistics()`
56+
57+
New: `client.taskrouter.v1.workspaces('WS...').workers.cumulative_statistics()`
58+
59+
- `GET /v1/Workspaces/{WorkspaceSid}/Workers/RealTimeStatistics`
60+
61+
Old: `client.taskrouter.v1.workspaces('WS...').workers('WK...).real_time_statistics()`
62+
63+
New: `client.taskrouter.v1.workspaces('WS...').workers.real_time_statistics()`
64+
65+
- **Internal refactor of `instance._properties`**
66+
- Instance properties moved out of the generic `_properties` dict ([#696](https://github.com/twilio/twilio-python/pull/696))
67+
- This is an implementation detail that should not be depended upon
68+
69+
## [2021-09-22] 6.x.x to 7.x.x
70+
871
### Overview
72+
973
Version `7.x.x` is the first version that officially drops support for Python versions 2.7, 3.4, and 3.5.
10-
#### Removal of files and dependencies that were added to support Python 2.7, 3.4, and 3.5:
74+
75+
#### Removal of files and dependencies that were added to support Python 2.7, 3.4, and 3.5
76+
1177
- [Six](https://github.com/twilio/twilio-python/pull/560/files#diff-4d7c51b1efe9043e44439a949dfd92e5827321b34082903477fd04876edb7552L4)
12-
- Removed use of `u` a fake unicode literal
13-
- Removed use of `b` a fake bytes literal
14-
- Removed `PY3` a boolean indicating if the code is running on Python 3
15-
- `text_type` type for representing (Unicode) textual data --> `str`
16-
- `iteritems` returns an iterator over dictionary’s items --> `items`
17-
- `string_types` possible types for text data like basestring() in Python 2 and str in Python 3.--> `str`
78+
- Removed use of `u` a fake unicode literal
79+
- Removed use of `b` a fake bytes literal
80+
- Removed `PY3` a boolean indicating if the code is running on Python 3
81+
- `text_type` type for representing (Unicode) textual data --> `str`
82+
- `iteritems` returns an iterator over dictionary’s items --> `items`
83+
- `string_types` possible types for text data like basestring() in Python 2 and str in Python 3.--> `str`
1884
- [twilio/compat.py](https://github.com/twilio/twilio-python/pull/560/files?file-filters%5B%5D=.md&file-filters%5B%5D=.py&file-filters%5B%5D=.toml&file-filters%5B%5D=.txt&file-filters%5B%5D=.yml&file-filters%5B%5D=No+extension#diff-e327449701a8717c94e1a084cdfc7dbf334c634cddf3867058b8f991d2de52c1L1)
19-
- `from twilio.compat import urlencode` --> `from urllib.parse import urlencode`
20-
- `izip` --> `zip`
85+
- `from twilio.compat import urlencode` --> `from urllib.parse import urlencode`
86+
- `izip` --> `zip`
2187
- [twilio/jwt/compat.py](https://github.com/twilio/twilio-python/pull/560/files?file-filters%5B%5D=.md&file-filters%5B%5D=.py&file-filters%5B%5D=.toml&file-filters%5B%5D=.txt&file-filters%5B%5D=.yml&file-filters%5B%5D=No+extension#diff-03276a6bdd4ecdf37ab6bedf60032dd05f640e1b470e4353badc787d80ba73d5L1)
22-
- Removed `compat.compare_digest`
23-
- [twilio/jwt/__init__.py](https://github.com/twilio/twilio-python/pull/560/files?file-filters%5B%5D=.ini&file-filters%5B%5D=.py&file-filters%5B%5D=.yml#diff-9152dd65476e69cc34a307781d5cef195070f48da5670ed0934fd34a9ac91150L12-L16)
24-
- Removed import for `simplejson` and `json`
88+
- Removed `compat.compare_digest`
89+
- [twilio/jwt/**init**.py](https://github.com/twilio/twilio-python/pull/560/files?file-filters%5B%5D=.ini&file-filters%5B%5D=.py&file-filters%5B%5D=.yml#diff-9152dd65476e69cc34a307781d5cef195070f48da5670ed0934fd34a9ac91150L12-L16)
90+
- Removed import for `simplejson` and `json`
2591
2692
#### Updated dependencies
93+
2794
- [Updated PyJWT to >=2.0.0](https://github.com/twilio/twilio-python/pull/560/files#diff-4d7c51b1efe9043e44439a949dfd92e5827321b34082903477fd04876edb7552L6)
2895
29-
### CHANGED - [Remove the ability to override the `algorithm` in `Jwt.to_jwt()`](https://github.com/twilio/twilio-python/pull/560/commits/dab158f429015e0894217d6503f55b517c27c474).
30-
#### Removed the ability to override the algorithm while using a jwt access token:
96+
### CHANGED - [Remove the ability to override the `algorithm` in `Jwt.to_jwt()`](https://github.com/twilio/twilio-python/pull/560/commits/dab158f429015e0894217d6503f55b517c27c474)
97+
98+
#### Removed the ability to override the algorithm while using a jwt access token
99+
31100
```python
32101
// 6.x.x
33102
from twilio.jwt.access_token import AccessToken
34103
token.to_jwt(algorithm='HS512')
35104
```
105+
36106
```python
37107
// 7.x.x
38108
from twilio.jwt.access_token import AccessToken
39109
token.to_jwt()
40110
```
41111
42-
[2017-09-28] 6.6.x to 6.7.x
43-
---------------------------
112+
## [2017-09-28] 6.6.x to 6.7.x
44113
45-
### CHANGED - `Body` parameter on Chat `Message` creation is no longer required.
114+
### CHANGED - `Body` parameter on Chat `Message` creation is no longer required
46115
47116
#### Rationale
117+
48118
This was changed to add support for sending media in Chat messages, users can now either provide a `body` or a `media_sid`.
49119
50120
#### 6.6.x
121+
51122
```python
52123
from twilio.rest import Client
53124
@@ -56,6 +127,7 @@ client.chat.v2.services('IS123').channels('CH123').messages.create("this is the
56127
```
57128
58129
#### 6.7.x
130+
59131
```python
60132
from twilio.rest import Client
61133

0 commit comments

Comments
 (0)