-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* DEVEXP-340/DEVEXP-471 - automated CI/CD release to PyPI and async library replacement (#29) * DEVEXP-464 update verification API with backwards compat (#36) * fix: recursion error (#38) * [SMS] service plan id version of the API (#17) * relese: bump the package version
- Loading branch information
Showing
69 changed files
with
1,148 additions
and
344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Release Python SDK | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
env: | ||
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | ||
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
- name: Install packaging tools | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install twine | ||
pip install poetry | ||
- name: Build package | ||
run: | | ||
poetry build | ||
- name: Verify package | ||
run: | | ||
twine check dist/* | ||
- name: Release package | ||
run: | | ||
twine upload dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import httpx | ||
from sinch.core.ports.http_transport import AsyncHTTPTransport, HttpRequest | ||
from sinch.core.endpoint import HTTPEndpoint | ||
from sinch.core.models.http_response import HTTPResponse | ||
|
||
|
||
class HTTPXTransport(AsyncHTTPTransport): | ||
def __init__(self, sinch): | ||
super().__init__(sinch) | ||
self.http_session = None | ||
|
||
async def request(self, endpoint: HTTPEndpoint) -> HTTPResponse: | ||
request_data: HttpRequest = self.prepare_request(endpoint) | ||
request_data: HttpRequest = await self.authenticate(endpoint, request_data) | ||
|
||
if not self.http_session: | ||
self.http_session = httpx.AsyncClient() | ||
|
||
self.sinch.configuration.logger.debug( | ||
f"Async HTTP {request_data.http_method} call with headers:" | ||
f" {request_data.headers} and body: {request_data.request_body} to URL: {request_data.url}" | ||
) | ||
|
||
if isinstance(request_data.request_body, str): | ||
response = await self.http_session.request( | ||
method=request_data.http_method, | ||
headers=request_data.headers, | ||
url=request_data.url, | ||
content=request_data.request_body, | ||
auth=request_data.auth, | ||
params=request_data.query_params, | ||
timeout=self.sinch.configuration.connection_timeout | ||
) | ||
else: | ||
response = await self.http_session.request( | ||
method=request_data.http_method, | ||
headers=request_data.headers, | ||
url=request_data.url, | ||
data=request_data.request_body, | ||
auth=request_data.auth, | ||
params=request_data.query_params, | ||
timeout=self.sinch.configuration.connection_timeout, | ||
) | ||
|
||
response_body = self.deserialize_json_response(response) | ||
|
||
self.sinch.configuration.logger.debug( | ||
f"Async HTTP {response.status_code} response with headers: {response.headers}" | ||
f"and body: {response_body} from URL: {request_data.url}" | ||
) | ||
|
||
return await self.handle_response( | ||
endpoint=endpoint, | ||
http_response=HTTPResponse( | ||
status_code=response.status_code, | ||
body=response_body, | ||
headers=response.headers | ||
) | ||
) | ||
|
||
async def close_session(self): | ||
await self.http_session.aclose() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.