telnyx 3.7.0__py3-none-any.whl → 3.8.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of telnyx might be problematic. Click here for more details.
- telnyx/__init__.py +2 -0
- telnyx/_client.py +22 -2
- telnyx/_exceptions.py +4 -0
- telnyx/_version.py +1 -1
- telnyx/resources/webhooks.py +38 -3
- {telnyx-3.7.0.dist-info → telnyx-3.8.0.dist-info}/METADATA +3 -1
- {telnyx-3.7.0.dist-info → telnyx-3.8.0.dist-info}/RECORD +9 -9
- {telnyx-3.7.0.dist-info → telnyx-3.8.0.dist-info}/WHEEL +0 -0
- {telnyx-3.7.0.dist-info → telnyx-3.8.0.dist-info}/licenses/LICENSE +0 -0
telnyx/__init__.py
CHANGED
|
@@ -24,6 +24,7 @@ from ._exceptions import (
|
|
|
24
24
|
InternalServerError,
|
|
25
25
|
PermissionDeniedError,
|
|
26
26
|
UnprocessableEntityError,
|
|
27
|
+
APIWebhookValidationError,
|
|
27
28
|
APIResponseValidationError,
|
|
28
29
|
)
|
|
29
30
|
from ._base_client import DefaultHttpxClient, DefaultAioHttpClient, DefaultAsyncHttpxClient
|
|
@@ -47,6 +48,7 @@ __all__ = [
|
|
|
47
48
|
"APITimeoutError",
|
|
48
49
|
"APIConnectionError",
|
|
49
50
|
"APIResponseValidationError",
|
|
51
|
+
"APIWebhookValidationError",
|
|
50
52
|
"BadRequestError",
|
|
51
53
|
"AuthenticationError",
|
|
52
54
|
"PermissionDeniedError",
|
telnyx/_client.py
CHANGED
|
@@ -346,11 +346,13 @@ class Telnyx(SyncAPIClient):
|
|
|
346
346
|
|
|
347
347
|
# client options
|
|
348
348
|
api_key: str
|
|
349
|
+
public_key: str | None
|
|
349
350
|
|
|
350
351
|
def __init__(
|
|
351
352
|
self,
|
|
352
353
|
*,
|
|
353
354
|
api_key: str | None = None,
|
|
355
|
+
public_key: str | None = None,
|
|
354
356
|
base_url: str | httpx.URL | None = None,
|
|
355
357
|
timeout: float | Timeout | None | NotGiven = not_given,
|
|
356
358
|
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
@@ -372,7 +374,9 @@ class Telnyx(SyncAPIClient):
|
|
|
372
374
|
) -> None:
|
|
373
375
|
"""Construct a new synchronous Telnyx client instance.
|
|
374
376
|
|
|
375
|
-
This automatically infers the
|
|
377
|
+
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
|
|
378
|
+
- `api_key` from `TELNYX_API_KEY`
|
|
379
|
+
- `public_key` from `TELNYX_PUBLIC_KEY`
|
|
376
380
|
"""
|
|
377
381
|
if api_key is None:
|
|
378
382
|
api_key = os.environ.get("TELNYX_API_KEY")
|
|
@@ -382,6 +386,10 @@ class Telnyx(SyncAPIClient):
|
|
|
382
386
|
)
|
|
383
387
|
self.api_key = api_key
|
|
384
388
|
|
|
389
|
+
if public_key is None:
|
|
390
|
+
public_key = os.environ.get("TELNYX_PUBLIC_KEY")
|
|
391
|
+
self.public_key = public_key
|
|
392
|
+
|
|
385
393
|
if base_url is None:
|
|
386
394
|
base_url = os.environ.get("TELNYX_BASE_URL")
|
|
387
395
|
self._base_url_overridden = base_url is not None
|
|
@@ -586,6 +594,7 @@ class Telnyx(SyncAPIClient):
|
|
|
586
594
|
self,
|
|
587
595
|
*,
|
|
588
596
|
api_key: str | None = None,
|
|
597
|
+
public_key: str | None = None,
|
|
589
598
|
base_url: str | httpx.URL | None = None,
|
|
590
599
|
timeout: float | Timeout | None | NotGiven = not_given,
|
|
591
600
|
http_client: httpx.Client | None = None,
|
|
@@ -620,6 +629,7 @@ class Telnyx(SyncAPIClient):
|
|
|
620
629
|
http_client = http_client or self._client
|
|
621
630
|
client = self.__class__(
|
|
622
631
|
api_key=api_key or self.api_key,
|
|
632
|
+
public_key=public_key or self.public_key,
|
|
623
633
|
base_url=base_url or self.base_url,
|
|
624
634
|
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
|
|
625
635
|
http_client=http_client,
|
|
@@ -829,11 +839,13 @@ class AsyncTelnyx(AsyncAPIClient):
|
|
|
829
839
|
|
|
830
840
|
# client options
|
|
831
841
|
api_key: str
|
|
842
|
+
public_key: str | None
|
|
832
843
|
|
|
833
844
|
def __init__(
|
|
834
845
|
self,
|
|
835
846
|
*,
|
|
836
847
|
api_key: str | None = None,
|
|
848
|
+
public_key: str | None = None,
|
|
837
849
|
base_url: str | httpx.URL | None = None,
|
|
838
850
|
timeout: float | Timeout | None | NotGiven = not_given,
|
|
839
851
|
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
@@ -855,7 +867,9 @@ class AsyncTelnyx(AsyncAPIClient):
|
|
|
855
867
|
) -> None:
|
|
856
868
|
"""Construct a new async AsyncTelnyx client instance.
|
|
857
869
|
|
|
858
|
-
This automatically infers the
|
|
870
|
+
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
|
|
871
|
+
- `api_key` from `TELNYX_API_KEY`
|
|
872
|
+
- `public_key` from `TELNYX_PUBLIC_KEY`
|
|
859
873
|
"""
|
|
860
874
|
if api_key is None:
|
|
861
875
|
api_key = os.environ.get("TELNYX_API_KEY")
|
|
@@ -865,6 +879,10 @@ class AsyncTelnyx(AsyncAPIClient):
|
|
|
865
879
|
)
|
|
866
880
|
self.api_key = api_key
|
|
867
881
|
|
|
882
|
+
if public_key is None:
|
|
883
|
+
public_key = os.environ.get("TELNYX_PUBLIC_KEY")
|
|
884
|
+
self.public_key = public_key
|
|
885
|
+
|
|
868
886
|
if base_url is None:
|
|
869
887
|
base_url = os.environ.get("TELNYX_BASE_URL")
|
|
870
888
|
self._base_url_overridden = base_url is not None
|
|
@@ -1075,6 +1093,7 @@ class AsyncTelnyx(AsyncAPIClient):
|
|
|
1075
1093
|
self,
|
|
1076
1094
|
*,
|
|
1077
1095
|
api_key: str | None = None,
|
|
1096
|
+
public_key: str | None = None,
|
|
1078
1097
|
base_url: str | httpx.URL | None = None,
|
|
1079
1098
|
timeout: float | Timeout | None | NotGiven = not_given,
|
|
1080
1099
|
http_client: httpx.AsyncClient | None = None,
|
|
@@ -1109,6 +1128,7 @@ class AsyncTelnyx(AsyncAPIClient):
|
|
|
1109
1128
|
http_client = http_client or self._client
|
|
1110
1129
|
client = self.__class__(
|
|
1111
1130
|
api_key=api_key or self.api_key,
|
|
1131
|
+
public_key=public_key or self.public_key,
|
|
1112
1132
|
base_url=base_url or self.base_url,
|
|
1113
1133
|
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
|
|
1114
1134
|
http_client=http_client,
|
telnyx/_exceptions.py
CHANGED
|
@@ -54,6 +54,10 @@ class APIResponseValidationError(APIError):
|
|
|
54
54
|
self.status_code = response.status_code
|
|
55
55
|
|
|
56
56
|
|
|
57
|
+
class APIWebhookValidationError(APIError):
|
|
58
|
+
pass
|
|
59
|
+
|
|
60
|
+
|
|
57
61
|
class APIStatusError(APIError):
|
|
58
62
|
"""Raised when an API response has a status code of 4xx or 5xx."""
|
|
59
63
|
|
telnyx/_version.py
CHANGED
telnyx/resources/webhooks.py
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import json
|
|
6
|
-
from typing import cast
|
|
6
|
+
from typing import Mapping, cast
|
|
7
7
|
|
|
8
8
|
from .._models import construct_type
|
|
9
9
|
from .._resource import SyncAPIResource, AsyncAPIResource
|
|
10
|
+
from .._exceptions import TelnyxError
|
|
10
11
|
from ..types.unwrap_webhook_event import UnwrapWebhookEvent
|
|
11
12
|
from ..types.unsafe_unwrap_webhook_event import UnsafeUnwrapWebhookEvent
|
|
12
13
|
|
|
@@ -23,7 +24,24 @@ class WebhooksResource(SyncAPIResource):
|
|
|
23
24
|
),
|
|
24
25
|
)
|
|
25
26
|
|
|
26
|
-
def unwrap(self, payload: str) -> UnwrapWebhookEvent:
|
|
27
|
+
def unwrap(self, payload: str, *, headers: Mapping[str, str], key: str | bytes | None = None) -> UnwrapWebhookEvent:
|
|
28
|
+
try:
|
|
29
|
+
from standardwebhooks import Webhook
|
|
30
|
+
except ImportError as exc:
|
|
31
|
+
raise TelnyxError("You need to install `telnyx[webhooks]` to use this method") from exc
|
|
32
|
+
|
|
33
|
+
if key is None:
|
|
34
|
+
key = self._client.public_key
|
|
35
|
+
if key is None:
|
|
36
|
+
raise ValueError(
|
|
37
|
+
"Cannot verify a webhook without a key on either the client's public_key or passed in as an argument"
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
if not isinstance(headers, dict):
|
|
41
|
+
headers = dict(headers)
|
|
42
|
+
|
|
43
|
+
Webhook(key).verify(payload, headers)
|
|
44
|
+
|
|
27
45
|
return cast(
|
|
28
46
|
UnwrapWebhookEvent,
|
|
29
47
|
construct_type(
|
|
@@ -43,7 +61,24 @@ class AsyncWebhooksResource(AsyncAPIResource):
|
|
|
43
61
|
),
|
|
44
62
|
)
|
|
45
63
|
|
|
46
|
-
def unwrap(self, payload: str) -> UnwrapWebhookEvent:
|
|
64
|
+
def unwrap(self, payload: str, *, headers: Mapping[str, str], key: str | bytes | None = None) -> UnwrapWebhookEvent:
|
|
65
|
+
try:
|
|
66
|
+
from standardwebhooks import Webhook
|
|
67
|
+
except ImportError as exc:
|
|
68
|
+
raise TelnyxError("You need to install `telnyx[webhooks]` to use this method") from exc
|
|
69
|
+
|
|
70
|
+
if key is None:
|
|
71
|
+
key = self._client.public_key
|
|
72
|
+
if key is None:
|
|
73
|
+
raise ValueError(
|
|
74
|
+
"Cannot verify a webhook without a key on either the client's public_key or passed in as an argument"
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
if not isinstance(headers, dict):
|
|
78
|
+
headers = dict(headers)
|
|
79
|
+
|
|
80
|
+
Webhook(key).verify(payload, headers)
|
|
81
|
+
|
|
47
82
|
return cast(
|
|
48
83
|
UnwrapWebhookEvent,
|
|
49
84
|
construct_type(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: telnyx
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.8.0
|
|
4
4
|
Summary: The official Python library for the telnyx API
|
|
5
5
|
Project-URL: Homepage, https://github.com/team-telnyx/telnyx-python
|
|
6
6
|
Project-URL: Repository, https://github.com/team-telnyx/telnyx-python
|
|
@@ -31,6 +31,8 @@ Requires-Dist: typing-extensions<5,>=4.10
|
|
|
31
31
|
Provides-Extra: aiohttp
|
|
32
32
|
Requires-Dist: aiohttp; extra == 'aiohttp'
|
|
33
33
|
Requires-Dist: httpx-aiohttp>=0.1.9; extra == 'aiohttp'
|
|
34
|
+
Provides-Extra: webhooks
|
|
35
|
+
Requires-Dist: standardwebhooks; extra == 'webhooks'
|
|
34
36
|
Description-Content-Type: text/markdown
|
|
35
37
|
|
|
36
38
|
# Telnyx Python API library
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
telnyx/__init__.py,sha256=
|
|
1
|
+
telnyx/__init__.py,sha256=8Oaoo-GIP7ZrRHTmGXjXOzx75x18QdsuDdeLrueG4C4,2688
|
|
2
2
|
telnyx/_base_client.py,sha256=NudksDGruga_s-IhQR4dYAEz7mc3QDOJfZPLjFdOghI,67047
|
|
3
|
-
telnyx/_client.py,sha256=
|
|
3
|
+
telnyx/_client.py,sha256=hHoAlmLBsyYgAmo27xXYySwlmjBn_R5d_jZFt14LA9Q,145306
|
|
4
4
|
telnyx/_compat.py,sha256=DQBVORjFb33zch24jzkhM14msvnzY7mmSmgDLaVFUM8,6562
|
|
5
5
|
telnyx/_constants.py,sha256=S14PFzyN9-I31wiV7SmIlL5Ga0MLHxdvegInGdXH7tM,462
|
|
6
|
-
telnyx/_exceptions.py,sha256=
|
|
6
|
+
telnyx/_exceptions.py,sha256=SbhO_R6Bai0lSqs0McbW7wl1iAyoBX1uYNjvX77hwKk,3274
|
|
7
7
|
telnyx/_files.py,sha256=sDy00jrSguKZf-dx9WnJzRyQplNz_b-_zMIVL31CjIo,3619
|
|
8
8
|
telnyx/_models.py,sha256=lKnskYPONAWDvWo8tmbbVk7HmG7UOsI0Nve0vSMmkRc,30452
|
|
9
9
|
telnyx/_qs.py,sha256=craIKyvPktJ94cvf9zn8j8ekG9dWJzhWv0ob34lIOv4,4828
|
|
@@ -11,7 +11,7 @@ telnyx/_resource.py,sha256=B4Qg-uO2a34FQHHZskn89eVURqMuSvv1TdeBJH1z1rU,1100
|
|
|
11
11
|
telnyx/_response.py,sha256=4X24wr7uQn2hnM_b0xqQ92zSgxRFFfWG2lTg93-KzNo,28788
|
|
12
12
|
telnyx/_streaming.py,sha256=OfSFcMQJ_mnvfkbIdOG7Ajp0SMbXnOJSga4xXHjNAJk,10100
|
|
13
13
|
telnyx/_types.py,sha256=Du3G2vdqeLhhdJZ4Jtck4vOqEvAKI9rB1FnrwB1b_k8,7236
|
|
14
|
-
telnyx/_version.py,sha256=
|
|
14
|
+
telnyx/_version.py,sha256=lwpU2hAJbxRw1J5zKphT95CVY5KhP9FxxxnGrX2ydns,158
|
|
15
15
|
telnyx/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
16
|
telnyx/_utils/__init__.py,sha256=7fch0GT9zpNnErbciSpUNa-SjTxxjY6kxHxKMOM4AGs,2305
|
|
17
17
|
telnyx/_utils/_compat.py,sha256=D8gtAvjJQrDWt9upS0XaG9Rr5l1QhiAx_I_1utT_tt0,1195
|
|
@@ -134,7 +134,7 @@ telnyx/resources/verify_profiles.py,sha256=p04zuJk1_we5Ez6OyRVq-KE1EALdgVjzmXukG
|
|
|
134
134
|
telnyx/resources/virtual_cross_connects.py,sha256=JDAXB9dhVNn-qAiTyNDAgYELHdFwGoqS6yM5l4NrDZA,34715
|
|
135
135
|
telnyx/resources/virtual_cross_connects_coverage.py,sha256=LE0l4hJJCO8jsaanpA85fa_wGNHgsZO4yPpf1RoNRCQ,9320
|
|
136
136
|
telnyx/resources/webhook_deliveries.py,sha256=PKo-2i1Ndhe3i7zozog3d0Ko5dznDshsOqLeogdXah0,11174
|
|
137
|
-
telnyx/resources/webhooks.py,sha256=
|
|
137
|
+
telnyx/resources/webhooks.py,sha256=Z25U-Umbj3DlGMsoSozv_ULe_dwmoL9oZ2FuuuQNkbA,2944
|
|
138
138
|
telnyx/resources/well_known.py,sha256=3Nm9gDqj9nDawaMoSj-yy3z_3dhDdBjK0NqOR0NJg4I,8881
|
|
139
139
|
telnyx/resources/wireguard_interfaces.py,sha256=wxfoFKlIQ4We6Zi9huXfN2Y_xAYZN5_IK6ziEGggM4I,18414
|
|
140
140
|
telnyx/resources/wireguard_peers.py,sha256=FefL6ivnxn6uq2vJY6hvzCzTm1wlqWiifc4D81QYSSE,24615
|
|
@@ -2096,7 +2096,7 @@ telnyx/types/wireless/detail_records_report_list_params.py,sha256=cfjsh4L_8mpDkg
|
|
|
2096
2096
|
telnyx/types/wireless/detail_records_report_list_response.py,sha256=S_6nD0fm5EseRIZHnML-UN0-g8Q_0J1cXfg_eLNUev8,331
|
|
2097
2097
|
telnyx/types/wireless/detail_records_report_retrieve_response.py,sha256=f0C8z8uo_QeCyi3nSDME4f4F3vqcy7o0MpinwDIqe_s,327
|
|
2098
2098
|
telnyx/types/wireless/wdr_report.py,sha256=bxRr-dc_IW6D0E3i_PUHK-bbu9w114Qql1uoJ_znxEE,1068
|
|
2099
|
-
telnyx-3.
|
|
2100
|
-
telnyx-3.
|
|
2101
|
-
telnyx-3.
|
|
2102
|
-
telnyx-3.
|
|
2099
|
+
telnyx-3.8.0.dist-info/METADATA,sha256=ODFtLiKVlZYhyzYvN7SI5CyEl3lra5IFqZK2W8rr2pM,15608
|
|
2100
|
+
telnyx-3.8.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
2101
|
+
telnyx-3.8.0.dist-info/licenses/LICENSE,sha256=PprdXvskBJR41_t2uhgs5rHYGME_Ek-lh2PAxKtdZs8,1046
|
|
2102
|
+
telnyx-3.8.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|