telnyx 3.5.0a0__py3-none-any.whl → 3.6.0a0__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.

Files changed (128) hide show
  1. telnyx/_client.py +53 -2
  2. telnyx/_version.py +1 -1
  3. telnyx/resources/__init__.py +70 -0
  4. telnyx/resources/ai/conversations/conversations.py +137 -3
  5. telnyx/resources/ai/conversations/messages.py +1 -134
  6. telnyx/resources/calls/actions.py +146 -146
  7. telnyx/resources/calls/calls.py +4 -10
  8. telnyx/resources/conferences/actions.py +8 -24
  9. telnyx/resources/conferences/conferences.py +2 -6
  10. telnyx/resources/legacy/__init__.py +33 -0
  11. telnyx/resources/legacy/legacy.py +102 -0
  12. telnyx/resources/legacy/reporting/__init__.py +47 -0
  13. telnyx/resources/legacy/reporting/batch_detail_records/__init__.py +61 -0
  14. telnyx/resources/legacy/reporting/batch_detail_records/batch_detail_records.py +166 -0
  15. telnyx/resources/legacy/reporting/batch_detail_records/messaging.py +481 -0
  16. telnyx/resources/legacy/reporting/batch_detail_records/speech_to_text.py +399 -0
  17. telnyx/resources/legacy/reporting/batch_detail_records/voice.py +538 -0
  18. telnyx/resources/legacy/reporting/reporting.py +134 -0
  19. telnyx/resources/legacy/reporting/usage_reports/__init__.py +61 -0
  20. telnyx/resources/legacy/reporting/usage_reports/messaging.py +471 -0
  21. telnyx/resources/legacy/reporting/usage_reports/number_lookup.py +464 -0
  22. telnyx/resources/legacy/reporting/usage_reports/usage_reports.py +288 -0
  23. telnyx/resources/legacy/reporting/usage_reports/voice.py +493 -0
  24. telnyx/resources/oauth.py +855 -0
  25. telnyx/resources/oauth_clients.py +711 -0
  26. telnyx/resources/oauth_grants.py +349 -0
  27. telnyx/resources/phone_numbers/jobs.py +12 -0
  28. telnyx/resources/porting_orders/porting_orders.py +20 -8
  29. telnyx/resources/sim_cards/sim_cards.py +3 -2
  30. telnyx/resources/verifications/verifications.py +10 -0
  31. telnyx/resources/verify_profiles.py +183 -1
  32. telnyx/resources/well_known.py +198 -0
  33. telnyx/types/__init__.py +40 -0
  34. telnyx/types/ai/__init__.py +1 -0
  35. telnyx/types/ai/{conversations/message_create_params.py → conversation_add_message_params.py} +4 -4
  36. telnyx/types/ai/conversations/__init__.py +0 -1
  37. telnyx/types/ai/inference_embedding_webhook_tool_params.py +2 -0
  38. telnyx/types/ai/inference_embedding_webhook_tool_params_param.py +2 -0
  39. telnyx/types/call_dial_params.py +2 -3
  40. telnyx/types/calls/action_answer_params.py +1 -2
  41. telnyx/types/calls/action_gather_using_ai_params.py +5 -8
  42. telnyx/types/calls/action_start_streaming_params.py +4 -2
  43. telnyx/types/calls/action_transfer_params.py +50 -0
  44. telnyx/types/campaign_submit_appeal_response.py +0 -3
  45. telnyx/types/legacy/__init__.py +3 -0
  46. telnyx/types/legacy/reporting/__init__.py +10 -0
  47. telnyx/types/legacy/reporting/batch_detail_records/__init__.py +20 -0
  48. telnyx/types/legacy/reporting/batch_detail_records/messaging_create_params.py +77 -0
  49. telnyx/types/legacy/reporting/batch_detail_records/messaging_create_response.py +68 -0
  50. telnyx/types/legacy/reporting/batch_detail_records/messaging_delete_response.py +68 -0
  51. telnyx/types/legacy/reporting/batch_detail_records/messaging_list_response.py +80 -0
  52. telnyx/types/legacy/reporting/batch_detail_records/messaging_retrieve_response.py +68 -0
  53. telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_create_params.py +19 -0
  54. telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_create_response.py +31 -0
  55. telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_delete_response.py +31 -0
  56. telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_list_response.py +31 -0
  57. telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_retrieve_response.py +31 -0
  58. telnyx/types/legacy/reporting/batch_detail_records/voice_create_params.py +79 -0
  59. telnyx/types/legacy/reporting/batch_detail_records/voice_create_response.py +91 -0
  60. telnyx/types/legacy/reporting/batch_detail_records/voice_delete_response.py +91 -0
  61. telnyx/types/legacy/reporting/batch_detail_records/voice_list_response.py +102 -0
  62. telnyx/types/legacy/reporting/batch_detail_records/voice_retrieve_fields_response.py +23 -0
  63. telnyx/types/legacy/reporting/batch_detail_records/voice_retrieve_response.py +91 -0
  64. telnyx/types/legacy/reporting/usage_report_retrieve_speech_to_text_params.py +17 -0
  65. telnyx/types/legacy/reporting/usage_report_retrieve_speech_to_text_response.py +11 -0
  66. telnyx/types/legacy/reporting/usage_reports/__init__.py +18 -0
  67. telnyx/types/legacy/reporting/usage_reports/messaging_create_params.py +29 -0
  68. telnyx/types/legacy/reporting/usage_reports/messaging_create_response.py +43 -0
  69. telnyx/types/legacy/reporting/usage_reports/messaging_delete_response.py +43 -0
  70. telnyx/types/legacy/reporting/usage_reports/messaging_list_params.py +15 -0
  71. telnyx/types/legacy/reporting/usage_reports/messaging_list_response.py +54 -0
  72. telnyx/types/legacy/reporting/usage_reports/messaging_retrieve_response.py +43 -0
  73. telnyx/types/legacy/reporting/usage_reports/number_lookup_create_params.py +26 -0
  74. telnyx/types/legacy/reporting/usage_reports/number_lookup_list_params.py +13 -0
  75. telnyx/types/legacy/reporting/usage_reports/voice_create_params.py +40 -0
  76. telnyx/types/legacy/reporting/usage_reports/voice_create_response.py +48 -0
  77. telnyx/types/legacy/reporting/usage_reports/voice_delete_response.py +48 -0
  78. telnyx/types/legacy/reporting/usage_reports/voice_list_params.py +15 -0
  79. telnyx/types/legacy/reporting/usage_reports/voice_list_response.py +59 -0
  80. telnyx/types/legacy/reporting/usage_reports/voice_retrieve_response.py +48 -0
  81. telnyx/types/number_order_status_update_webhook_event.py +30 -4
  82. telnyx/types/oauth_client_create_params.py +39 -0
  83. telnyx/types/oauth_client_create_response.py +63 -0
  84. telnyx/types/oauth_client_list_params.py +38 -0
  85. telnyx/types/oauth_client_list_response.py +79 -0
  86. telnyx/types/oauth_client_retrieve_response.py +63 -0
  87. telnyx/types/oauth_client_update_params.py +36 -0
  88. telnyx/types/oauth_client_update_response.py +63 -0
  89. telnyx/types/oauth_grant_delete_response.py +33 -0
  90. telnyx/types/oauth_grant_list_params.py +17 -0
  91. telnyx/types/oauth_grant_list_response.py +49 -0
  92. telnyx/types/oauth_grant_retrieve_response.py +33 -0
  93. telnyx/types/oauth_grants_params.py +15 -0
  94. telnyx/types/oauth_grants_response.py +10 -0
  95. telnyx/types/oauth_introspect_params.py +12 -0
  96. telnyx/types/oauth_introspect_response.py +30 -0
  97. telnyx/types/oauth_register_params.py +39 -0
  98. telnyx/types/oauth_register_response.py +45 -0
  99. telnyx/types/oauth_retrieve_authorize_params.py +30 -0
  100. telnyx/types/oauth_retrieve_jwks_response.py +25 -0
  101. telnyx/types/oauth_retrieve_response.py +47 -0
  102. telnyx/types/oauth_token_params.py +33 -0
  103. telnyx/types/oauth_token_response.py +25 -0
  104. telnyx/types/phone_number_delete_response.py +7 -0
  105. telnyx/types/phone_number_detailed.py +7 -0
  106. telnyx/types/phone_number_list_params.py +6 -0
  107. telnyx/types/phone_numbers/job_update_batch_params.py +7 -0
  108. telnyx/types/porting_order.py +3 -0
  109. telnyx/types/porting_order_create_params.py +3 -0
  110. telnyx/types/porting_order_list_params.py +52 -31
  111. telnyx/types/porting_order_update_params.py +2 -0
  112. telnyx/types/porting_orders/phone_number_configuration_list_params.py +19 -19
  113. telnyx/types/shared/simple_sim_card.py +15 -0
  114. telnyx/types/sim_card.py +12 -0
  115. telnyx/types/sim_card_update_params.py +2 -1
  116. telnyx/types/stream_bidirectional_codec.py +1 -1
  117. telnyx/types/stream_codec.py +1 -1
  118. telnyx/types/verification_trigger_call_params.py +7 -0
  119. telnyx/types/verify_profile_create_template_params.py +12 -0
  120. telnyx/types/verify_profile_create_template_response.py +17 -0
  121. telnyx/types/verify_profile_update_template_params.py +12 -0
  122. telnyx/types/verify_profile_update_template_response.py +17 -0
  123. telnyx/types/well_known_retrieve_authorization_server_metadata_response.py +42 -0
  124. telnyx/types/well_known_retrieve_protected_resource_metadata_response.py +15 -0
  125. {telnyx-3.5.0a0.dist-info → telnyx-3.6.0a0.dist-info}/METADATA +1 -1
  126. {telnyx-3.5.0a0.dist-info → telnyx-3.6.0a0.dist-info}/RECORD +128 -46
  127. {telnyx-3.5.0a0.dist-info → telnyx-3.6.0a0.dist-info}/WHEEL +0 -0
  128. {telnyx-3.5.0a0.dist-info → telnyx-3.6.0a0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,855 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import List
6
+ from typing_extensions import Literal
7
+
8
+ import httpx
9
+
10
+ from ..types import (
11
+ oauth_token_params,
12
+ oauth_grants_params,
13
+ oauth_register_params,
14
+ oauth_introspect_params,
15
+ oauth_retrieve_authorize_params,
16
+ )
17
+ from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, SequenceNotStr, omit, not_given
18
+ from .._utils import maybe_transform, async_maybe_transform
19
+ from .._compat import cached_property
20
+ from .._resource import SyncAPIResource, AsyncAPIResource
21
+ from .._response import (
22
+ to_raw_response_wrapper,
23
+ to_streamed_response_wrapper,
24
+ async_to_raw_response_wrapper,
25
+ async_to_streamed_response_wrapper,
26
+ )
27
+ from .._base_client import make_request_options
28
+ from ..types.oauth_token_response import OAuthTokenResponse
29
+ from ..types.oauth_grants_response import OAuthGrantsResponse
30
+ from ..types.oauth_register_response import OAuthRegisterResponse
31
+ from ..types.oauth_retrieve_response import OAuthRetrieveResponse
32
+ from ..types.oauth_introspect_response import OAuthIntrospectResponse
33
+ from ..types.oauth_retrieve_jwks_response import OAuthRetrieveJwksResponse
34
+
35
+ __all__ = ["OAuthResource", "AsyncOAuthResource"]
36
+
37
+
38
+ class OAuthResource(SyncAPIResource):
39
+ @cached_property
40
+ def with_raw_response(self) -> OAuthResourceWithRawResponse:
41
+ """
42
+ This property can be used as a prefix for any HTTP method call to return
43
+ the raw response object instead of the parsed content.
44
+
45
+ For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers
46
+ """
47
+ return OAuthResourceWithRawResponse(self)
48
+
49
+ @cached_property
50
+ def with_streaming_response(self) -> OAuthResourceWithStreamingResponse:
51
+ """
52
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
53
+
54
+ For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response
55
+ """
56
+ return OAuthResourceWithStreamingResponse(self)
57
+
58
+ def retrieve(
59
+ self,
60
+ consent_token: str,
61
+ *,
62
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
63
+ # The extra values given here take precedence over values defined on the client or passed to this method.
64
+ extra_headers: Headers | None = None,
65
+ extra_query: Query | None = None,
66
+ extra_body: Body | None = None,
67
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
68
+ ) -> OAuthRetrieveResponse:
69
+ """
70
+ Retrieve details about an OAuth consent token
71
+
72
+ Args:
73
+ extra_headers: Send extra headers
74
+
75
+ extra_query: Add additional query parameters to the request
76
+
77
+ extra_body: Add additional JSON properties to the request
78
+
79
+ timeout: Override the client-level default timeout for this request, in seconds
80
+ """
81
+ if not consent_token:
82
+ raise ValueError(f"Expected a non-empty value for `consent_token` but received {consent_token!r}")
83
+ return self._get(
84
+ f"/oauth/consent/{consent_token}",
85
+ options=make_request_options(
86
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
87
+ ),
88
+ cast_to=OAuthRetrieveResponse,
89
+ )
90
+
91
+ def grants(
92
+ self,
93
+ *,
94
+ allowed: bool,
95
+ consent_token: str,
96
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
97
+ # The extra values given here take precedence over values defined on the client or passed to this method.
98
+ extra_headers: Headers | None = None,
99
+ extra_query: Query | None = None,
100
+ extra_body: Body | None = None,
101
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
102
+ ) -> OAuthGrantsResponse:
103
+ """
104
+ Create an OAuth authorization grant
105
+
106
+ Args:
107
+ allowed: Whether the grant is allowed
108
+
109
+ consent_token: Consent token
110
+
111
+ extra_headers: Send extra headers
112
+
113
+ extra_query: Add additional query parameters to the request
114
+
115
+ extra_body: Add additional JSON properties to the request
116
+
117
+ timeout: Override the client-level default timeout for this request, in seconds
118
+ """
119
+ return self._post(
120
+ "/oauth/grants",
121
+ body=maybe_transform(
122
+ {
123
+ "allowed": allowed,
124
+ "consent_token": consent_token,
125
+ },
126
+ oauth_grants_params.OAuthGrantsParams,
127
+ ),
128
+ options=make_request_options(
129
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
130
+ ),
131
+ cast_to=OAuthGrantsResponse,
132
+ )
133
+
134
+ def introspect(
135
+ self,
136
+ *,
137
+ token: str,
138
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
139
+ # The extra values given here take precedence over values defined on the client or passed to this method.
140
+ extra_headers: Headers | None = None,
141
+ extra_query: Query | None = None,
142
+ extra_body: Body | None = None,
143
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
144
+ ) -> OAuthIntrospectResponse:
145
+ """
146
+ Introspect an OAuth access token to check its validity and metadata
147
+
148
+ Args:
149
+ token: The token to introspect
150
+
151
+ extra_headers: Send extra headers
152
+
153
+ extra_query: Add additional query parameters to the request
154
+
155
+ extra_body: Add additional JSON properties to the request
156
+
157
+ timeout: Override the client-level default timeout for this request, in seconds
158
+ """
159
+ return self._post(
160
+ "/oauth/introspect",
161
+ body=maybe_transform({"token": token}, oauth_introspect_params.OAuthIntrospectParams),
162
+ options=make_request_options(
163
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
164
+ ),
165
+ cast_to=OAuthIntrospectResponse,
166
+ )
167
+
168
+ def register(
169
+ self,
170
+ *,
171
+ client_name: str | Omit = omit,
172
+ grant_types: List[Literal["authorization_code", "client_credentials", "refresh_token"]] | Omit = omit,
173
+ logo_uri: str | Omit = omit,
174
+ policy_uri: str | Omit = omit,
175
+ redirect_uris: SequenceNotStr[str] | Omit = omit,
176
+ response_types: SequenceNotStr[str] | Omit = omit,
177
+ scope: str | Omit = omit,
178
+ token_endpoint_auth_method: Literal["none", "client_secret_basic", "client_secret_post"] | Omit = omit,
179
+ tos_uri: str | Omit = omit,
180
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
181
+ # The extra values given here take precedence over values defined on the client or passed to this method.
182
+ extra_headers: Headers | None = None,
183
+ extra_query: Query | None = None,
184
+ extra_body: Body | None = None,
185
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
186
+ ) -> OAuthRegisterResponse:
187
+ """
188
+ Register a new OAuth client dynamically (RFC 7591)
189
+
190
+ Args:
191
+ client_name: Human-readable string name of the client to be presented to the end-user
192
+
193
+ grant_types: Array of OAuth 2.0 grant type strings that the client may use
194
+
195
+ logo_uri: URL of the client logo
196
+
197
+ policy_uri: URL of the client's privacy policy
198
+
199
+ redirect_uris: Array of redirection URI strings for use in redirect-based flows
200
+
201
+ response_types: Array of the OAuth 2.0 response type strings that the client may use
202
+
203
+ scope: Space-separated string of scope values that the client may use
204
+
205
+ token_endpoint_auth_method: Authentication method for the token endpoint
206
+
207
+ tos_uri: URL of the client's terms of service
208
+
209
+ extra_headers: Send extra headers
210
+
211
+ extra_query: Add additional query parameters to the request
212
+
213
+ extra_body: Add additional JSON properties to the request
214
+
215
+ timeout: Override the client-level default timeout for this request, in seconds
216
+ """
217
+ return self._post(
218
+ "/oauth/register",
219
+ body=maybe_transform(
220
+ {
221
+ "client_name": client_name,
222
+ "grant_types": grant_types,
223
+ "logo_uri": logo_uri,
224
+ "policy_uri": policy_uri,
225
+ "redirect_uris": redirect_uris,
226
+ "response_types": response_types,
227
+ "scope": scope,
228
+ "token_endpoint_auth_method": token_endpoint_auth_method,
229
+ "tos_uri": tos_uri,
230
+ },
231
+ oauth_register_params.OAuthRegisterParams,
232
+ ),
233
+ options=make_request_options(
234
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
235
+ ),
236
+ cast_to=OAuthRegisterResponse,
237
+ )
238
+
239
+ def retrieve_authorize(
240
+ self,
241
+ *,
242
+ client_id: str,
243
+ redirect_uri: str,
244
+ response_type: Literal["code"],
245
+ code_challenge: str | Omit = omit,
246
+ code_challenge_method: Literal["plain", "S256"] | Omit = omit,
247
+ scope: str | Omit = omit,
248
+ state: str | Omit = omit,
249
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
250
+ # The extra values given here take precedence over values defined on the client or passed to this method.
251
+ extra_headers: Headers | None = None,
252
+ extra_query: Query | None = None,
253
+ extra_body: Body | None = None,
254
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
255
+ ) -> None:
256
+ """
257
+ OAuth 2.0 authorization endpoint for the authorization code flow
258
+
259
+ Args:
260
+ client_id: OAuth client identifier
261
+
262
+ redirect_uri: Redirect URI
263
+
264
+ response_type: OAuth response type
265
+
266
+ code_challenge: PKCE code challenge
267
+
268
+ code_challenge_method: PKCE code challenge method
269
+
270
+ scope: Space-separated list of requested scopes
271
+
272
+ state: State parameter for CSRF protection
273
+
274
+ extra_headers: Send extra headers
275
+
276
+ extra_query: Add additional query parameters to the request
277
+
278
+ extra_body: Add additional JSON properties to the request
279
+
280
+ timeout: Override the client-level default timeout for this request, in seconds
281
+ """
282
+ extra_headers = {"Accept": "*/*", **(extra_headers or {})}
283
+ return self._get(
284
+ "/oauth/authorize",
285
+ options=make_request_options(
286
+ extra_headers=extra_headers,
287
+ extra_query=extra_query,
288
+ extra_body=extra_body,
289
+ timeout=timeout,
290
+ query=maybe_transform(
291
+ {
292
+ "client_id": client_id,
293
+ "redirect_uri": redirect_uri,
294
+ "response_type": response_type,
295
+ "code_challenge": code_challenge,
296
+ "code_challenge_method": code_challenge_method,
297
+ "scope": scope,
298
+ "state": state,
299
+ },
300
+ oauth_retrieve_authorize_params.OAuthRetrieveAuthorizeParams,
301
+ ),
302
+ ),
303
+ cast_to=NoneType,
304
+ )
305
+
306
+ def retrieve_jwks(
307
+ self,
308
+ *,
309
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
310
+ # The extra values given here take precedence over values defined on the client or passed to this method.
311
+ extra_headers: Headers | None = None,
312
+ extra_query: Query | None = None,
313
+ extra_body: Body | None = None,
314
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
315
+ ) -> OAuthRetrieveJwksResponse:
316
+ """Retrieve the JSON Web Key Set for token verification"""
317
+ return self._get(
318
+ "/oauth/jwks",
319
+ options=make_request_options(
320
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
321
+ ),
322
+ cast_to=OAuthRetrieveJwksResponse,
323
+ )
324
+
325
+ def token(
326
+ self,
327
+ *,
328
+ grant_type: Literal["client_credentials", "authorization_code", "refresh_token"],
329
+ client_id: str | Omit = omit,
330
+ client_secret: str | Omit = omit,
331
+ code: str | Omit = omit,
332
+ code_verifier: str | Omit = omit,
333
+ redirect_uri: str | Omit = omit,
334
+ refresh_token: str | Omit = omit,
335
+ scope: str | Omit = omit,
336
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
337
+ # The extra values given here take precedence over values defined on the client or passed to this method.
338
+ extra_headers: Headers | None = None,
339
+ extra_query: Query | None = None,
340
+ extra_body: Body | None = None,
341
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
342
+ ) -> OAuthTokenResponse:
343
+ """
344
+ Exchange authorization code, client credentials, or refresh token for access
345
+ token
346
+
347
+ Args:
348
+ grant_type: OAuth 2.0 grant type
349
+
350
+ client_id: OAuth client ID (if not using HTTP Basic auth)
351
+
352
+ client_secret: OAuth client secret (if not using HTTP Basic auth)
353
+
354
+ code: Authorization code (for authorization_code flow)
355
+
356
+ code_verifier: PKCE code verifier (for authorization_code flow)
357
+
358
+ redirect_uri: Redirect URI (for authorization_code flow)
359
+
360
+ refresh_token: Refresh token (for refresh_token flow)
361
+
362
+ scope: Space-separated list of requested scopes (for client_credentials)
363
+
364
+ extra_headers: Send extra headers
365
+
366
+ extra_query: Add additional query parameters to the request
367
+
368
+ extra_body: Add additional JSON properties to the request
369
+
370
+ timeout: Override the client-level default timeout for this request, in seconds
371
+ """
372
+ return self._post(
373
+ "/oauth/token",
374
+ body=maybe_transform(
375
+ {
376
+ "grant_type": grant_type,
377
+ "client_id": client_id,
378
+ "client_secret": client_secret,
379
+ "code": code,
380
+ "code_verifier": code_verifier,
381
+ "redirect_uri": redirect_uri,
382
+ "refresh_token": refresh_token,
383
+ "scope": scope,
384
+ },
385
+ oauth_token_params.OAuthTokenParams,
386
+ ),
387
+ options=make_request_options(
388
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
389
+ ),
390
+ cast_to=OAuthTokenResponse,
391
+ )
392
+
393
+
394
+ class AsyncOAuthResource(AsyncAPIResource):
395
+ @cached_property
396
+ def with_raw_response(self) -> AsyncOAuthResourceWithRawResponse:
397
+ """
398
+ This property can be used as a prefix for any HTTP method call to return
399
+ the raw response object instead of the parsed content.
400
+
401
+ For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers
402
+ """
403
+ return AsyncOAuthResourceWithRawResponse(self)
404
+
405
+ @cached_property
406
+ def with_streaming_response(self) -> AsyncOAuthResourceWithStreamingResponse:
407
+ """
408
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
409
+
410
+ For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response
411
+ """
412
+ return AsyncOAuthResourceWithStreamingResponse(self)
413
+
414
+ async def retrieve(
415
+ self,
416
+ consent_token: str,
417
+ *,
418
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
419
+ # The extra values given here take precedence over values defined on the client or passed to this method.
420
+ extra_headers: Headers | None = None,
421
+ extra_query: Query | None = None,
422
+ extra_body: Body | None = None,
423
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
424
+ ) -> OAuthRetrieveResponse:
425
+ """
426
+ Retrieve details about an OAuth consent token
427
+
428
+ Args:
429
+ extra_headers: Send extra headers
430
+
431
+ extra_query: Add additional query parameters to the request
432
+
433
+ extra_body: Add additional JSON properties to the request
434
+
435
+ timeout: Override the client-level default timeout for this request, in seconds
436
+ """
437
+ if not consent_token:
438
+ raise ValueError(f"Expected a non-empty value for `consent_token` but received {consent_token!r}")
439
+ return await self._get(
440
+ f"/oauth/consent/{consent_token}",
441
+ options=make_request_options(
442
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
443
+ ),
444
+ cast_to=OAuthRetrieveResponse,
445
+ )
446
+
447
+ async def grants(
448
+ self,
449
+ *,
450
+ allowed: bool,
451
+ consent_token: str,
452
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
453
+ # The extra values given here take precedence over values defined on the client or passed to this method.
454
+ extra_headers: Headers | None = None,
455
+ extra_query: Query | None = None,
456
+ extra_body: Body | None = None,
457
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
458
+ ) -> OAuthGrantsResponse:
459
+ """
460
+ Create an OAuth authorization grant
461
+
462
+ Args:
463
+ allowed: Whether the grant is allowed
464
+
465
+ consent_token: Consent token
466
+
467
+ extra_headers: Send extra headers
468
+
469
+ extra_query: Add additional query parameters to the request
470
+
471
+ extra_body: Add additional JSON properties to the request
472
+
473
+ timeout: Override the client-level default timeout for this request, in seconds
474
+ """
475
+ return await self._post(
476
+ "/oauth/grants",
477
+ body=await async_maybe_transform(
478
+ {
479
+ "allowed": allowed,
480
+ "consent_token": consent_token,
481
+ },
482
+ oauth_grants_params.OAuthGrantsParams,
483
+ ),
484
+ options=make_request_options(
485
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
486
+ ),
487
+ cast_to=OAuthGrantsResponse,
488
+ )
489
+
490
+ async def introspect(
491
+ self,
492
+ *,
493
+ token: str,
494
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
495
+ # The extra values given here take precedence over values defined on the client or passed to this method.
496
+ extra_headers: Headers | None = None,
497
+ extra_query: Query | None = None,
498
+ extra_body: Body | None = None,
499
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
500
+ ) -> OAuthIntrospectResponse:
501
+ """
502
+ Introspect an OAuth access token to check its validity and metadata
503
+
504
+ Args:
505
+ token: The token to introspect
506
+
507
+ extra_headers: Send extra headers
508
+
509
+ extra_query: Add additional query parameters to the request
510
+
511
+ extra_body: Add additional JSON properties to the request
512
+
513
+ timeout: Override the client-level default timeout for this request, in seconds
514
+ """
515
+ return await self._post(
516
+ "/oauth/introspect",
517
+ body=await async_maybe_transform({"token": token}, oauth_introspect_params.OAuthIntrospectParams),
518
+ options=make_request_options(
519
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
520
+ ),
521
+ cast_to=OAuthIntrospectResponse,
522
+ )
523
+
524
+ async def register(
525
+ self,
526
+ *,
527
+ client_name: str | Omit = omit,
528
+ grant_types: List[Literal["authorization_code", "client_credentials", "refresh_token"]] | Omit = omit,
529
+ logo_uri: str | Omit = omit,
530
+ policy_uri: str | Omit = omit,
531
+ redirect_uris: SequenceNotStr[str] | Omit = omit,
532
+ response_types: SequenceNotStr[str] | Omit = omit,
533
+ scope: str | Omit = omit,
534
+ token_endpoint_auth_method: Literal["none", "client_secret_basic", "client_secret_post"] | Omit = omit,
535
+ tos_uri: str | Omit = omit,
536
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
537
+ # The extra values given here take precedence over values defined on the client or passed to this method.
538
+ extra_headers: Headers | None = None,
539
+ extra_query: Query | None = None,
540
+ extra_body: Body | None = None,
541
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
542
+ ) -> OAuthRegisterResponse:
543
+ """
544
+ Register a new OAuth client dynamically (RFC 7591)
545
+
546
+ Args:
547
+ client_name: Human-readable string name of the client to be presented to the end-user
548
+
549
+ grant_types: Array of OAuth 2.0 grant type strings that the client may use
550
+
551
+ logo_uri: URL of the client logo
552
+
553
+ policy_uri: URL of the client's privacy policy
554
+
555
+ redirect_uris: Array of redirection URI strings for use in redirect-based flows
556
+
557
+ response_types: Array of the OAuth 2.0 response type strings that the client may use
558
+
559
+ scope: Space-separated string of scope values that the client may use
560
+
561
+ token_endpoint_auth_method: Authentication method for the token endpoint
562
+
563
+ tos_uri: URL of the client's terms of service
564
+
565
+ extra_headers: Send extra headers
566
+
567
+ extra_query: Add additional query parameters to the request
568
+
569
+ extra_body: Add additional JSON properties to the request
570
+
571
+ timeout: Override the client-level default timeout for this request, in seconds
572
+ """
573
+ return await self._post(
574
+ "/oauth/register",
575
+ body=await async_maybe_transform(
576
+ {
577
+ "client_name": client_name,
578
+ "grant_types": grant_types,
579
+ "logo_uri": logo_uri,
580
+ "policy_uri": policy_uri,
581
+ "redirect_uris": redirect_uris,
582
+ "response_types": response_types,
583
+ "scope": scope,
584
+ "token_endpoint_auth_method": token_endpoint_auth_method,
585
+ "tos_uri": tos_uri,
586
+ },
587
+ oauth_register_params.OAuthRegisterParams,
588
+ ),
589
+ options=make_request_options(
590
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
591
+ ),
592
+ cast_to=OAuthRegisterResponse,
593
+ )
594
+
595
+ async def retrieve_authorize(
596
+ self,
597
+ *,
598
+ client_id: str,
599
+ redirect_uri: str,
600
+ response_type: Literal["code"],
601
+ code_challenge: str | Omit = omit,
602
+ code_challenge_method: Literal["plain", "S256"] | Omit = omit,
603
+ scope: str | Omit = omit,
604
+ state: str | Omit = omit,
605
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
606
+ # The extra values given here take precedence over values defined on the client or passed to this method.
607
+ extra_headers: Headers | None = None,
608
+ extra_query: Query | None = None,
609
+ extra_body: Body | None = None,
610
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
611
+ ) -> None:
612
+ """
613
+ OAuth 2.0 authorization endpoint for the authorization code flow
614
+
615
+ Args:
616
+ client_id: OAuth client identifier
617
+
618
+ redirect_uri: Redirect URI
619
+
620
+ response_type: OAuth response type
621
+
622
+ code_challenge: PKCE code challenge
623
+
624
+ code_challenge_method: PKCE code challenge method
625
+
626
+ scope: Space-separated list of requested scopes
627
+
628
+ state: State parameter for CSRF protection
629
+
630
+ extra_headers: Send extra headers
631
+
632
+ extra_query: Add additional query parameters to the request
633
+
634
+ extra_body: Add additional JSON properties to the request
635
+
636
+ timeout: Override the client-level default timeout for this request, in seconds
637
+ """
638
+ extra_headers = {"Accept": "*/*", **(extra_headers or {})}
639
+ return await self._get(
640
+ "/oauth/authorize",
641
+ options=make_request_options(
642
+ extra_headers=extra_headers,
643
+ extra_query=extra_query,
644
+ extra_body=extra_body,
645
+ timeout=timeout,
646
+ query=await async_maybe_transform(
647
+ {
648
+ "client_id": client_id,
649
+ "redirect_uri": redirect_uri,
650
+ "response_type": response_type,
651
+ "code_challenge": code_challenge,
652
+ "code_challenge_method": code_challenge_method,
653
+ "scope": scope,
654
+ "state": state,
655
+ },
656
+ oauth_retrieve_authorize_params.OAuthRetrieveAuthorizeParams,
657
+ ),
658
+ ),
659
+ cast_to=NoneType,
660
+ )
661
+
662
+ async def retrieve_jwks(
663
+ self,
664
+ *,
665
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
666
+ # The extra values given here take precedence over values defined on the client or passed to this method.
667
+ extra_headers: Headers | None = None,
668
+ extra_query: Query | None = None,
669
+ extra_body: Body | None = None,
670
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
671
+ ) -> OAuthRetrieveJwksResponse:
672
+ """Retrieve the JSON Web Key Set for token verification"""
673
+ return await self._get(
674
+ "/oauth/jwks",
675
+ options=make_request_options(
676
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
677
+ ),
678
+ cast_to=OAuthRetrieveJwksResponse,
679
+ )
680
+
681
+ async def token(
682
+ self,
683
+ *,
684
+ grant_type: Literal["client_credentials", "authorization_code", "refresh_token"],
685
+ client_id: str | Omit = omit,
686
+ client_secret: str | Omit = omit,
687
+ code: str | Omit = omit,
688
+ code_verifier: str | Omit = omit,
689
+ redirect_uri: str | Omit = omit,
690
+ refresh_token: str | Omit = omit,
691
+ scope: str | Omit = omit,
692
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
693
+ # The extra values given here take precedence over values defined on the client or passed to this method.
694
+ extra_headers: Headers | None = None,
695
+ extra_query: Query | None = None,
696
+ extra_body: Body | None = None,
697
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
698
+ ) -> OAuthTokenResponse:
699
+ """
700
+ Exchange authorization code, client credentials, or refresh token for access
701
+ token
702
+
703
+ Args:
704
+ grant_type: OAuth 2.0 grant type
705
+
706
+ client_id: OAuth client ID (if not using HTTP Basic auth)
707
+
708
+ client_secret: OAuth client secret (if not using HTTP Basic auth)
709
+
710
+ code: Authorization code (for authorization_code flow)
711
+
712
+ code_verifier: PKCE code verifier (for authorization_code flow)
713
+
714
+ redirect_uri: Redirect URI (for authorization_code flow)
715
+
716
+ refresh_token: Refresh token (for refresh_token flow)
717
+
718
+ scope: Space-separated list of requested scopes (for client_credentials)
719
+
720
+ extra_headers: Send extra headers
721
+
722
+ extra_query: Add additional query parameters to the request
723
+
724
+ extra_body: Add additional JSON properties to the request
725
+
726
+ timeout: Override the client-level default timeout for this request, in seconds
727
+ """
728
+ return await self._post(
729
+ "/oauth/token",
730
+ body=await async_maybe_transform(
731
+ {
732
+ "grant_type": grant_type,
733
+ "client_id": client_id,
734
+ "client_secret": client_secret,
735
+ "code": code,
736
+ "code_verifier": code_verifier,
737
+ "redirect_uri": redirect_uri,
738
+ "refresh_token": refresh_token,
739
+ "scope": scope,
740
+ },
741
+ oauth_token_params.OAuthTokenParams,
742
+ ),
743
+ options=make_request_options(
744
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
745
+ ),
746
+ cast_to=OAuthTokenResponse,
747
+ )
748
+
749
+
750
+ class OAuthResourceWithRawResponse:
751
+ def __init__(self, oauth: OAuthResource) -> None:
752
+ self._oauth = oauth
753
+
754
+ self.retrieve = to_raw_response_wrapper(
755
+ oauth.retrieve,
756
+ )
757
+ self.grants = to_raw_response_wrapper(
758
+ oauth.grants,
759
+ )
760
+ self.introspect = to_raw_response_wrapper(
761
+ oauth.introspect,
762
+ )
763
+ self.register = to_raw_response_wrapper(
764
+ oauth.register,
765
+ )
766
+ self.retrieve_authorize = to_raw_response_wrapper(
767
+ oauth.retrieve_authorize,
768
+ )
769
+ self.retrieve_jwks = to_raw_response_wrapper(
770
+ oauth.retrieve_jwks,
771
+ )
772
+ self.token = to_raw_response_wrapper(
773
+ oauth.token,
774
+ )
775
+
776
+
777
+ class AsyncOAuthResourceWithRawResponse:
778
+ def __init__(self, oauth: AsyncOAuthResource) -> None:
779
+ self._oauth = oauth
780
+
781
+ self.retrieve = async_to_raw_response_wrapper(
782
+ oauth.retrieve,
783
+ )
784
+ self.grants = async_to_raw_response_wrapper(
785
+ oauth.grants,
786
+ )
787
+ self.introspect = async_to_raw_response_wrapper(
788
+ oauth.introspect,
789
+ )
790
+ self.register = async_to_raw_response_wrapper(
791
+ oauth.register,
792
+ )
793
+ self.retrieve_authorize = async_to_raw_response_wrapper(
794
+ oauth.retrieve_authorize,
795
+ )
796
+ self.retrieve_jwks = async_to_raw_response_wrapper(
797
+ oauth.retrieve_jwks,
798
+ )
799
+ self.token = async_to_raw_response_wrapper(
800
+ oauth.token,
801
+ )
802
+
803
+
804
+ class OAuthResourceWithStreamingResponse:
805
+ def __init__(self, oauth: OAuthResource) -> None:
806
+ self._oauth = oauth
807
+
808
+ self.retrieve = to_streamed_response_wrapper(
809
+ oauth.retrieve,
810
+ )
811
+ self.grants = to_streamed_response_wrapper(
812
+ oauth.grants,
813
+ )
814
+ self.introspect = to_streamed_response_wrapper(
815
+ oauth.introspect,
816
+ )
817
+ self.register = to_streamed_response_wrapper(
818
+ oauth.register,
819
+ )
820
+ self.retrieve_authorize = to_streamed_response_wrapper(
821
+ oauth.retrieve_authorize,
822
+ )
823
+ self.retrieve_jwks = to_streamed_response_wrapper(
824
+ oauth.retrieve_jwks,
825
+ )
826
+ self.token = to_streamed_response_wrapper(
827
+ oauth.token,
828
+ )
829
+
830
+
831
+ class AsyncOAuthResourceWithStreamingResponse:
832
+ def __init__(self, oauth: AsyncOAuthResource) -> None:
833
+ self._oauth = oauth
834
+
835
+ self.retrieve = async_to_streamed_response_wrapper(
836
+ oauth.retrieve,
837
+ )
838
+ self.grants = async_to_streamed_response_wrapper(
839
+ oauth.grants,
840
+ )
841
+ self.introspect = async_to_streamed_response_wrapper(
842
+ oauth.introspect,
843
+ )
844
+ self.register = async_to_streamed_response_wrapper(
845
+ oauth.register,
846
+ )
847
+ self.retrieve_authorize = async_to_streamed_response_wrapper(
848
+ oauth.retrieve_authorize,
849
+ )
850
+ self.retrieve_jwks = async_to_streamed_response_wrapper(
851
+ oauth.retrieve_jwks,
852
+ )
853
+ self.token = async_to_streamed_response_wrapper(
854
+ oauth.token,
855
+ )