telnyx 3.2.0a0__py3-none-any.whl → 3.4.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 (226) hide show
  1. telnyx/_base_client.py +3 -3
  2. telnyx/_client.py +5 -0
  3. telnyx/_compat.py +48 -48
  4. telnyx/_models.py +40 -40
  5. telnyx/_types.py +35 -1
  6. telnyx/_utils/__init__.py +9 -2
  7. telnyx/_utils/_compat.py +45 -0
  8. telnyx/_utils/_datetime_parse.py +136 -0
  9. telnyx/_utils/_transform.py +11 -1
  10. telnyx/_utils/_typing.py +6 -1
  11. telnyx/_utils/_utils.py +0 -1
  12. telnyx/_version.py +1 -1
  13. telnyx/resources/__init__.py +3 -0
  14. telnyx/resources/actions/purchase.py +3 -4
  15. telnyx/resources/actions/register.py +5 -6
  16. telnyx/resources/ai/chat.py +4 -4
  17. telnyx/resources/ai/clusters.py +3 -5
  18. telnyx/resources/ai/conversations/messages.py +4 -4
  19. telnyx/resources/ai/embeddings/embeddings.py +3 -4
  20. telnyx/resources/call_control_applications.py +4 -4
  21. telnyx/resources/calls/calls.py +4 -4
  22. telnyx/resources/campaign_builder/campaign_builder.py +6 -6
  23. telnyx/resources/conferences/actions.py +19 -20
  24. telnyx/resources/credential_connections/credential_connections.py +6 -6
  25. telnyx/resources/customer_service_records.py +3 -5
  26. telnyx/resources/detail_records.py +3 -5
  27. telnyx/resources/external_connections/external_connections.py +6 -6
  28. telnyx/resources/external_connections/uploads.py +3 -3
  29. telnyx/resources/fax_applications.py +6 -6
  30. telnyx/resources/fqdn_connections.py +6 -6
  31. telnyx/resources/ip_connections.py +6 -6
  32. telnyx/resources/messages/messages.py +16 -16
  33. telnyx/resources/messaging/rcs/rcs.py +3 -5
  34. telnyx/resources/messaging_hosted_number_orders/messaging_hosted_number_orders.py +8 -8
  35. telnyx/resources/messaging_numbers_bulk_updates.py +3 -5
  36. telnyx/resources/messaging_profiles/autoresp_configs.py +5 -6
  37. telnyx/resources/messaging_profiles/messaging_profiles.py +6 -6
  38. telnyx/resources/numbers_features.py +3 -5
  39. telnyx/resources/outbound_voice_profiles.py +10 -10
  40. telnyx/resources/phone_numbers/actions.py +3 -5
  41. telnyx/resources/phone_numbers/jobs.py +10 -10
  42. telnyx/resources/phone_numbers/phone_numbers.py +3 -4
  43. telnyx/resources/portability_checks.py +3 -5
  44. telnyx/resources/porting_orders/porting_orders.py +4 -4
  45. telnyx/resources/porting_orders/verification_codes.py +4 -4
  46. telnyx/resources/recordings/actions.py +3 -5
  47. telnyx/resources/reports/mdr_usage_reports.py +4 -4
  48. telnyx/resources/reports/reports.py +3 -4
  49. telnyx/resources/rooms/sessions/actions.py +14 -14
  50. telnyx/resources/sim_cards/actions.py +5 -7
  51. telnyx/resources/sim_cards/sim_cards.py +5 -6
  52. telnyx/resources/texml_applications.py +5 -6
  53. telnyx/resources/usage_reports.py +7 -8
  54. telnyx/resources/webhooks.py +34 -0
  55. telnyx/resources/wireless_blocklists.py +5 -6
  56. telnyx/types/__init__.py +115 -4
  57. telnyx/types/actions/purchase_create_params.py +3 -2
  58. telnyx/types/actions/register_create_params.py +4 -3
  59. telnyx/types/ai/chat_create_completion_params.py +3 -2
  60. telnyx/types/ai/cluster_compute_params.py +3 -2
  61. telnyx/types/ai/conversations/message_create_params.py +3 -2
  62. telnyx/types/ai/embedding_list_params.py +3 -2
  63. telnyx/types/ai/inference_embedding_bucket_ids_param.py +3 -2
  64. telnyx/types/ai/inference_embedding_webhook_tool_params_param.py +6 -4
  65. telnyx/types/bundle_pricing/billing_bundle_list_params.py +4 -3
  66. telnyx/types/bundle_pricing/user_bundle_list_params.py +4 -3
  67. telnyx/types/bundle_pricing/user_bundle_list_unused_params.py +4 -3
  68. telnyx/types/call_ai_gather_ended_webhook_event.py +78 -0
  69. telnyx/types/call_ai_gather_message_history_updated_webhook_event.py +69 -0
  70. telnyx/types/call_ai_gather_partial_results_webhook_event.py +75 -0
  71. telnyx/types/call_answered_webhook_event.py +75 -0
  72. telnyx/types/call_bridged_webhook_event.py +58 -0
  73. telnyx/types/call_control_application_update_params.py +3 -2
  74. telnyx/types/call_conversation_ended_webhook_event.py +84 -0
  75. telnyx/types/call_conversation_insights_generated_webhook_event.py +67 -0
  76. telnyx/types/call_dial_params.py +4 -3
  77. telnyx/types/call_dtmf_received_webhook_event.py +61 -0
  78. telnyx/types/call_enqueued_webhook_event.py +59 -0
  79. telnyx/types/call_fork_started_webhook_event.py +53 -0
  80. telnyx/types/call_fork_stopped_webhook_event.py +53 -0
  81. telnyx/types/call_gather_ended_webhook_event.py +64 -0
  82. telnyx/types/call_hangup_webhook_event.py +150 -0
  83. telnyx/types/call_initiated_webhook_event.py +96 -0
  84. telnyx/types/call_left_queue_webhook_event.py +62 -0
  85. telnyx/types/call_machine_detection_ended_webhook_event.py +61 -0
  86. telnyx/types/call_machine_greeting_ended_webhook_event.py +61 -0
  87. telnyx/types/call_machine_premium_detection_ended_webhook_event.py +63 -0
  88. telnyx/types/call_machine_premium_greeting_ended_webhook_event.py +61 -0
  89. telnyx/types/call_playback_ended_webhook_event.py +70 -0
  90. telnyx/types/call_playback_started_webhook_event.py +62 -0
  91. telnyx/types/call_recording_error_webhook_event.py +60 -0
  92. telnyx/types/call_recording_saved_webhook_event.py +94 -0
  93. telnyx/types/call_recording_transcription_saved_webhook_event.py +71 -0
  94. telnyx/types/call_refer_completed_webhook_event.py +61 -0
  95. telnyx/types/call_refer_failed_webhook_event.py +61 -0
  96. telnyx/types/call_refer_started_webhook_event.py +61 -0
  97. telnyx/types/call_siprec_failed_webhook_event.py +53 -0
  98. telnyx/types/call_siprec_started_webhook_event.py +50 -0
  99. telnyx/types/call_siprec_stopped_webhook_event.py +53 -0
  100. telnyx/types/call_speak_ended_webhook_event.py +53 -0
  101. telnyx/types/call_speak_started_webhook_event.py +50 -0
  102. telnyx/types/call_streaming_failed_webhook_event.py +70 -0
  103. telnyx/types/call_streaming_started_webhook_event.py +53 -0
  104. telnyx/types/call_streaming_stopped_webhook_event.py +53 -0
  105. telnyx/types/calls/transcription_engine_a_config_param.py +4 -3
  106. telnyx/types/campaign_builder_create_params.py +4 -3
  107. telnyx/types/campaign_status_update_webhook_event.py +26 -0
  108. telnyx/types/conference_created_webhook_event.py +53 -0
  109. telnyx/types/conference_ended_webhook_event.py +56 -0
  110. telnyx/types/conference_floor_changed_webhook_event.py +45 -0
  111. telnyx/types/conference_participant_joined_webhook_event.py +53 -0
  112. telnyx/types/conference_participant_left_webhook_event.py +53 -0
  113. telnyx/types/conference_participant_playback_ended_webhook_event.py +65 -0
  114. telnyx/types/conference_participant_playback_started_webhook_event.py +65 -0
  115. telnyx/types/conference_participant_speak_ended_webhook_event.py +56 -0
  116. telnyx/types/conference_participant_speak_started_webhook_event.py +56 -0
  117. telnyx/types/conference_playback_ended_webhook_event.py +49 -0
  118. telnyx/types/conference_playback_started_webhook_event.py +49 -0
  119. telnyx/types/conference_recording_saved_webhook_event.py +103 -0
  120. telnyx/types/conference_speak_ended_webhook_event.py +40 -0
  121. telnyx/types/conference_speak_started_webhook_event.py +40 -0
  122. telnyx/types/conferences/action_hold_params.py +3 -2
  123. telnyx/types/conferences/action_join_params.py +3 -2
  124. telnyx/types/conferences/action_mute_params.py +3 -2
  125. telnyx/types/conferences/action_play_params.py +2 -2
  126. telnyx/types/conferences/action_speak_params.py +3 -2
  127. telnyx/types/conferences/action_stop_params.py +3 -2
  128. telnyx/types/conferences/action_unhold_params.py +3 -2
  129. telnyx/types/conferences/action_unmute_params.py +3 -2
  130. telnyx/types/conferences/action_update_params.py +3 -2
  131. telnyx/types/credential_connection_create_params.py +3 -2
  132. telnyx/types/credential_connection_update_params.py +3 -2
  133. telnyx/types/credential_inbound_param.py +3 -2
  134. telnyx/types/custom_sip_header.py +13 -0
  135. telnyx/types/customer_service_record_list_params.py +2 -1
  136. telnyx/types/customer_service_record_status_changed_webhook_event.py +55 -0
  137. telnyx/types/customer_service_record_verify_phone_number_coverage_params.py +3 -2
  138. telnyx/types/delivery_update_webhook_event.py +40 -0
  139. telnyx/types/detail_record_list_params.py +4 -2
  140. telnyx/types/document_list_params.py +2 -1
  141. telnyx/types/external_connection_create_params.py +4 -2
  142. telnyx/types/external_connection_update_params.py +4 -2
  143. telnyx/types/external_connections/civic_address_list_params.py +3 -2
  144. telnyx/types/external_connections/upload_create_params.py +3 -1
  145. telnyx/types/fax_application_create_params.py +3 -2
  146. telnyx/types/fax_application_update_params.py +3 -2
  147. telnyx/types/fax_delivered_webhook_event.py +69 -0
  148. telnyx/types/fax_failed_webhook_event.py +66 -0
  149. telnyx/types/fax_media_processed_webhook_event.py +63 -0
  150. telnyx/types/fax_queued_webhook_event.py +63 -0
  151. telnyx/types/fax_sending_started_webhook_event.py +63 -0
  152. telnyx/types/fqdn_connection_create_params.py +3 -2
  153. telnyx/types/fqdn_connection_update_params.py +3 -2
  154. telnyx/types/inbound_fqdn_param.py +4 -2
  155. telnyx/types/inbound_ip_param.py +3 -2
  156. telnyx/types/inbound_message_webhook_event.py +227 -0
  157. telnyx/types/ip_connection_create_params.py +4 -3
  158. telnyx/types/ip_connection_update_params.py +3 -2
  159. telnyx/types/media_list_params.py +3 -2
  160. telnyx/types/message_schedule_params.py +3 -2
  161. telnyx/types/message_send_group_mms_params.py +3 -3
  162. telnyx/types/message_send_long_code_params.py +2 -2
  163. telnyx/types/message_send_number_pool_params.py +3 -2
  164. telnyx/types/message_send_params.py +3 -2
  165. telnyx/types/message_send_short_code_params.py +2 -2
  166. telnyx/types/messaging/rc_list_bulk_capabilities_params.py +3 -2
  167. telnyx/types/messaging_hosted_number_order_check_eligibility_params.py +3 -2
  168. telnyx/types/messaging_hosted_number_order_create_params.py +3 -2
  169. telnyx/types/messaging_hosted_number_order_create_verification_codes_params.py +3 -2
  170. telnyx/types/messaging_numbers_bulk_update_create_params.py +3 -2
  171. telnyx/types/messaging_profile_create_params.py +3 -2
  172. telnyx/types/messaging_profile_update_params.py +3 -2
  173. telnyx/types/messaging_profiles/autoresp_config_create_params.py +3 -2
  174. telnyx/types/messaging_profiles/autoresp_config_update_params.py +3 -2
  175. telnyx/types/messsage_rcs_params.py +2 -2
  176. telnyx/types/number_order_status_update_webhook_event.py +12 -0
  177. telnyx/types/numbers_feature_create_params.py +3 -2
  178. telnyx/types/outbound_call_recording_param.py +3 -2
  179. telnyx/types/outbound_voice_profile_create_params.py +4 -3
  180. telnyx/types/outbound_voice_profile_update_params.py +4 -3
  181. telnyx/types/phone_number_list_params.py +3 -2
  182. telnyx/types/phone_number_slim_list_params.py +3 -2
  183. telnyx/types/phone_number_update_params.py +3 -2
  184. telnyx/types/phone_numbers/action_verify_ownership_params.py +3 -2
  185. telnyx/types/phone_numbers/job_delete_batch_params.py +3 -2
  186. telnyx/types/phone_numbers/job_update_batch_params.py +3 -3
  187. telnyx/types/phone_numbers/job_update_emergency_settings_batch_params.py +4 -2
  188. telnyx/types/portability_check_run_params.py +3 -2
  189. telnyx/types/porting/export_porting_orders_csv_report_param.py +2 -1
  190. telnyx/types/porting_order_create_params.py +3 -2
  191. telnyx/types/porting_order_phone_number_configuration_param.py +3 -2
  192. telnyx/types/porting_orders/action_requirement_list_params.py +3 -2
  193. telnyx/types/porting_orders/phone_number_block_list_params.py +5 -3
  194. telnyx/types/porting_orders/phone_number_configuration_list_params.py +3 -2
  195. telnyx/types/porting_orders/verification_code_send_params.py +3 -2
  196. telnyx/types/portout_list_params.py +2 -1
  197. telnyx/types/portouts/export_portouts_csv_report_param.py +3 -2
  198. telnyx/types/recordings/action_delete_params.py +3 -2
  199. telnyx/types/replaced_link_click_webhook_event.py +32 -0
  200. telnyx/types/report_list_wdrs_params.py +3 -2
  201. telnyx/types/reports/mdr_usage_report_fetch_sync_params.py +3 -2
  202. telnyx/types/rooms/sessions/action_kick_params.py +5 -3
  203. telnyx/types/rooms/sessions/action_mute_params.py +5 -3
  204. telnyx/types/rooms/sessions/action_unmute_params.py +5 -3
  205. telnyx/types/sim_card_list_params.py +2 -1
  206. telnyx/types/sim_card_update_params.py +3 -3
  207. telnyx/types/sim_cards/action_bulk_set_public_ips_params.py +3 -2
  208. telnyx/types/sim_cards/action_validate_registration_codes_params.py +3 -2
  209. telnyx/types/sip_header.py +15 -0
  210. telnyx/types/streaming_failed_webhook_event.py +70 -0
  211. telnyx/types/streaming_started_webhook_event.py +53 -0
  212. telnyx/types/streaming_stopped_webhook_event.py +53 -0
  213. telnyx/types/texml_application_create_params.py +2 -2
  214. telnyx/types/texml_application_update_params.py +2 -2
  215. telnyx/types/transcription_webhook_event.py +72 -0
  216. telnyx/types/unwrap_webhook_event.py +138 -0
  217. telnyx/types/usage_report_list_params.py +5 -4
  218. telnyx/types/verify_profile_create_params.py +6 -4
  219. telnyx/types/verify_profile_update_params.py +6 -4
  220. telnyx/types/video_region_param.py +4 -2
  221. telnyx/types/wireless_blocklist_create_params.py +3 -2
  222. telnyx/types/wireless_blocklist_update_params.py +3 -2
  223. {telnyx-3.2.0a0.dist-info → telnyx-3.4.0a0.dist-info}/METADATA +1 -1
  224. {telnyx-3.2.0a0.dist-info → telnyx-3.4.0a0.dist-info}/RECORD +226 -156
  225. {telnyx-3.2.0a0.dist-info → telnyx-3.4.0a0.dist-info}/WHEEL +0 -0
  226. {telnyx-3.2.0a0.dist-info → telnyx-3.4.0a0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,136 @@
1
+ """
2
+ This file contains code from https://github.com/pydantic/pydantic/blob/main/pydantic/v1/datetime_parse.py
3
+ without the Pydantic v1 specific errors.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ import re
9
+ from typing import Dict, Union, Optional
10
+ from datetime import date, datetime, timezone, timedelta
11
+
12
+ from .._types import StrBytesIntFloat
13
+
14
+ date_expr = r"(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2})"
15
+ time_expr = (
16
+ r"(?P<hour>\d{1,2}):(?P<minute>\d{1,2})"
17
+ r"(?::(?P<second>\d{1,2})(?:\.(?P<microsecond>\d{1,6})\d{0,6})?)?"
18
+ r"(?P<tzinfo>Z|[+-]\d{2}(?::?\d{2})?)?$"
19
+ )
20
+
21
+ date_re = re.compile(f"{date_expr}$")
22
+ datetime_re = re.compile(f"{date_expr}[T ]{time_expr}")
23
+
24
+
25
+ EPOCH = datetime(1970, 1, 1)
26
+ # if greater than this, the number is in ms, if less than or equal it's in seconds
27
+ # (in seconds this is 11th October 2603, in ms it's 20th August 1970)
28
+ MS_WATERSHED = int(2e10)
29
+ # slightly more than datetime.max in ns - (datetime.max - EPOCH).total_seconds() * 1e9
30
+ MAX_NUMBER = int(3e20)
31
+
32
+
33
+ def _get_numeric(value: StrBytesIntFloat, native_expected_type: str) -> Union[None, int, float]:
34
+ if isinstance(value, (int, float)):
35
+ return value
36
+ try:
37
+ return float(value)
38
+ except ValueError:
39
+ return None
40
+ except TypeError:
41
+ raise TypeError(f"invalid type; expected {native_expected_type}, string, bytes, int or float") from None
42
+
43
+
44
+ def _from_unix_seconds(seconds: Union[int, float]) -> datetime:
45
+ if seconds > MAX_NUMBER:
46
+ return datetime.max
47
+ elif seconds < -MAX_NUMBER:
48
+ return datetime.min
49
+
50
+ while abs(seconds) > MS_WATERSHED:
51
+ seconds /= 1000
52
+ dt = EPOCH + timedelta(seconds=seconds)
53
+ return dt.replace(tzinfo=timezone.utc)
54
+
55
+
56
+ def _parse_timezone(value: Optional[str]) -> Union[None, int, timezone]:
57
+ if value == "Z":
58
+ return timezone.utc
59
+ elif value is not None:
60
+ offset_mins = int(value[-2:]) if len(value) > 3 else 0
61
+ offset = 60 * int(value[1:3]) + offset_mins
62
+ if value[0] == "-":
63
+ offset = -offset
64
+ return timezone(timedelta(minutes=offset))
65
+ else:
66
+ return None
67
+
68
+
69
+ def parse_datetime(value: Union[datetime, StrBytesIntFloat]) -> datetime:
70
+ """
71
+ Parse a datetime/int/float/string and return a datetime.datetime.
72
+
73
+ This function supports time zone offsets. When the input contains one,
74
+ the output uses a timezone with a fixed offset from UTC.
75
+
76
+ Raise ValueError if the input is well formatted but not a valid datetime.
77
+ Raise ValueError if the input isn't well formatted.
78
+ """
79
+ if isinstance(value, datetime):
80
+ return value
81
+
82
+ number = _get_numeric(value, "datetime")
83
+ if number is not None:
84
+ return _from_unix_seconds(number)
85
+
86
+ if isinstance(value, bytes):
87
+ value = value.decode()
88
+
89
+ assert not isinstance(value, (float, int))
90
+
91
+ match = datetime_re.match(value)
92
+ if match is None:
93
+ raise ValueError("invalid datetime format")
94
+
95
+ kw = match.groupdict()
96
+ if kw["microsecond"]:
97
+ kw["microsecond"] = kw["microsecond"].ljust(6, "0")
98
+
99
+ tzinfo = _parse_timezone(kw.pop("tzinfo"))
100
+ kw_: Dict[str, Union[None, int, timezone]] = {k: int(v) for k, v in kw.items() if v is not None}
101
+ kw_["tzinfo"] = tzinfo
102
+
103
+ return datetime(**kw_) # type: ignore
104
+
105
+
106
+ def parse_date(value: Union[date, StrBytesIntFloat]) -> date:
107
+ """
108
+ Parse a date/int/float/string and return a datetime.date.
109
+
110
+ Raise ValueError if the input is well formatted but not a valid date.
111
+ Raise ValueError if the input isn't well formatted.
112
+ """
113
+ if isinstance(value, date):
114
+ if isinstance(value, datetime):
115
+ return value.date()
116
+ else:
117
+ return value
118
+
119
+ number = _get_numeric(value, "date")
120
+ if number is not None:
121
+ return _from_unix_seconds(number).date()
122
+
123
+ if isinstance(value, bytes):
124
+ value = value.decode()
125
+
126
+ assert not isinstance(value, (float, int))
127
+ match = date_re.match(value)
128
+ if match is None:
129
+ raise ValueError("invalid date format")
130
+
131
+ kw = {k: int(v) for k, v in match.groupdict().items()}
132
+
133
+ try:
134
+ return date(**kw)
135
+ except ValueError:
136
+ raise ValueError("invalid date format") from None
@@ -16,18 +16,20 @@ from ._utils import (
16
16
  lru_cache,
17
17
  is_mapping,
18
18
  is_iterable,
19
+ is_sequence,
19
20
  )
20
21
  from .._files import is_base64_file_input
22
+ from ._compat import get_origin, is_typeddict
21
23
  from ._typing import (
22
24
  is_list_type,
23
25
  is_union_type,
24
26
  extract_type_arg,
25
27
  is_iterable_type,
26
28
  is_required_type,
29
+ is_sequence_type,
27
30
  is_annotated_type,
28
31
  strip_annotated_type,
29
32
  )
30
- from .._compat import get_origin, model_dump, is_typeddict
31
33
 
32
34
  _T = TypeVar("_T")
33
35
 
@@ -167,6 +169,8 @@ def _transform_recursive(
167
169
 
168
170
  Defaults to the same value as the `annotation` argument.
169
171
  """
172
+ from .._compat import model_dump
173
+
170
174
  if inner_type is None:
171
175
  inner_type = annotation
172
176
 
@@ -184,6 +188,8 @@ def _transform_recursive(
184
188
  (is_list_type(stripped_type) and is_list(data))
185
189
  # Iterable[T]
186
190
  or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
191
+ # Sequence[T]
192
+ or (is_sequence_type(stripped_type) and is_sequence(data) and not isinstance(data, str))
187
193
  ):
188
194
  # dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
189
195
  # intended as an iterable, so we don't transform it.
@@ -329,6 +335,8 @@ async def _async_transform_recursive(
329
335
 
330
336
  Defaults to the same value as the `annotation` argument.
331
337
  """
338
+ from .._compat import model_dump
339
+
332
340
  if inner_type is None:
333
341
  inner_type = annotation
334
342
 
@@ -346,6 +354,8 @@ async def _async_transform_recursive(
346
354
  (is_list_type(stripped_type) and is_list(data))
347
355
  # Iterable[T]
348
356
  or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
357
+ # Sequence[T]
358
+ or (is_sequence_type(stripped_type) and is_sequence(data) and not isinstance(data, str))
349
359
  ):
350
360
  # dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
351
361
  # intended as an iterable, so we don't transform it.
telnyx/_utils/_typing.py CHANGED
@@ -15,7 +15,7 @@ from typing_extensions import (
15
15
 
16
16
  from ._utils import lru_cache
17
17
  from .._types import InheritsGeneric
18
- from .._compat import is_union as _is_union
18
+ from ._compat import is_union as _is_union
19
19
 
20
20
 
21
21
  def is_annotated_type(typ: type) -> bool:
@@ -26,6 +26,11 @@ def is_list_type(typ: type) -> bool:
26
26
  return (get_origin(typ) or typ) == list
27
27
 
28
28
 
29
+ def is_sequence_type(typ: type) -> bool:
30
+ origin = get_origin(typ) or typ
31
+ return origin == typing_extensions.Sequence or origin == typing.Sequence or origin == _c_abc.Sequence
32
+
33
+
29
34
  def is_iterable_type(typ: type) -> bool:
30
35
  """If the given type is `typing.Iterable[T]`"""
31
36
  origin = get_origin(typ) or typ
telnyx/_utils/_utils.py CHANGED
@@ -22,7 +22,6 @@ from typing_extensions import TypeGuard
22
22
  import sniffio
23
23
 
24
24
  from .._types import NotGiven, FileTypes, NotGivenOr, HeadersLike
25
- from .._compat import parse_date as parse_date, parse_datetime as parse_datetime
26
25
 
27
26
  _T = TypeVar("_T")
28
27
  _TupleT = TypeVar("_TupleT", bound=Tuple[object, ...])
telnyx/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "telnyx"
4
- __version__ = "3.2.0-alpha" # x-release-please-version
4
+ __version__ = "3.4.0-alpha" # x-release-please-version
@@ -208,6 +208,7 @@ from .portouts import (
208
208
  PortoutsResourceWithStreamingResponse,
209
209
  AsyncPortoutsResourceWithStreamingResponse,
210
210
  )
211
+ from .webhooks import WebhooksResource, AsyncWebhooksResource
211
212
  from .wireless import (
212
213
  WirelessResource,
213
214
  AsyncWirelessResource,
@@ -1170,6 +1171,8 @@ from .phone_numbers_regulatory_requirements import (
1170
1171
  )
1171
1172
 
1172
1173
  __all__ = [
1174
+ "WebhooksResource",
1175
+ "AsyncWebhooksResource",
1173
1176
  "AccessIPAddressResource",
1174
1177
  "AsyncAccessIPAddressResource",
1175
1178
  "AccessIPAddressResourceWithRawResponse",
@@ -2,12 +2,11 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import List
6
5
  from typing_extensions import Literal
7
6
 
8
7
  import httpx
9
8
 
10
- from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
9
+ from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
11
10
  from ..._utils import maybe_transform, async_maybe_transform
12
11
  from ..._compat import cached_property
13
12
  from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -51,7 +50,7 @@ class PurchaseResource(SyncAPIResource):
51
50
  product: str | NotGiven = NOT_GIVEN,
52
51
  sim_card_group_id: str | NotGiven = NOT_GIVEN,
53
52
  status: Literal["enabled", "disabled", "standby"] | NotGiven = NOT_GIVEN,
54
- tags: List[str] | NotGiven = NOT_GIVEN,
53
+ tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
55
54
  whitelabel_name: str | NotGiven = NOT_GIVEN,
56
55
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
57
56
  # The extra values given here take precedence over values defined on the client or passed to this method.
@@ -137,7 +136,7 @@ class AsyncPurchaseResource(AsyncAPIResource):
137
136
  product: str | NotGiven = NOT_GIVEN,
138
137
  sim_card_group_id: str | NotGiven = NOT_GIVEN,
139
138
  status: Literal["enabled", "disabled", "standby"] | NotGiven = NOT_GIVEN,
140
- tags: List[str] | NotGiven = NOT_GIVEN,
139
+ tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
141
140
  whitelabel_name: str | NotGiven = NOT_GIVEN,
142
141
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
143
142
  # The extra values given here take precedence over values defined on the client or passed to this method.
@@ -2,12 +2,11 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import List
6
5
  from typing_extensions import Literal
7
6
 
8
7
  import httpx
9
8
 
10
- from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
9
+ from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
11
10
  from ..._utils import maybe_transform, async_maybe_transform
12
11
  from ..._compat import cached_property
13
12
  from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -47,10 +46,10 @@ class RegisterResource(SyncAPIResource):
47
46
  def create(
48
47
  self,
49
48
  *,
50
- registration_codes: List[str],
49
+ registration_codes: SequenceNotStr[str],
51
50
  sim_card_group_id: str | NotGiven = NOT_GIVEN,
52
51
  status: Literal["enabled", "disabled", "standby"] | NotGiven = NOT_GIVEN,
53
- tags: List[str] | NotGiven = NOT_GIVEN,
52
+ tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
54
53
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
55
54
  # The extra values given here take precedence over values defined on the client or passed to this method.
56
55
  extra_headers: Headers | None = None,
@@ -121,10 +120,10 @@ class AsyncRegisterResource(AsyncAPIResource):
121
120
  async def create(
122
121
  self,
123
122
  *,
124
- registration_codes: List[str],
123
+ registration_codes: SequenceNotStr[str],
125
124
  sim_card_group_id: str | NotGiven = NOT_GIVEN,
126
125
  status: Literal["enabled", "disabled", "standby"] | NotGiven = NOT_GIVEN,
127
- tags: List[str] | NotGiven = NOT_GIVEN,
126
+ tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
128
127
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
129
128
  # The extra values given here take precedence over values defined on the client or passed to this method.
130
129
  extra_headers: Headers | None = None,
@@ -2,12 +2,12 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import Dict, List, Iterable
5
+ from typing import Dict, Iterable
6
6
  from typing_extensions import Literal
7
7
 
8
8
  import httpx
9
9
 
10
- from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
10
+ from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
11
11
  from ..._utils import maybe_transform, async_maybe_transform
12
12
  from ..._compat import cached_property
13
13
  from ...types.ai import chat_create_completion_params
@@ -51,7 +51,7 @@ class ChatResource(SyncAPIResource):
51
51
  best_of: int | NotGiven = NOT_GIVEN,
52
52
  early_stopping: bool | NotGiven = NOT_GIVEN,
53
53
  frequency_penalty: float | NotGiven = NOT_GIVEN,
54
- guided_choice: List[str] | NotGiven = NOT_GIVEN,
54
+ guided_choice: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
55
55
  guided_json: Dict[str, object] | NotGiven = NOT_GIVEN,
56
56
  guided_regex: str | NotGiven = NOT_GIVEN,
57
57
  length_penalty: float | NotGiven = NOT_GIVEN,
@@ -226,7 +226,7 @@ class AsyncChatResource(AsyncAPIResource):
226
226
  best_of: int | NotGiven = NOT_GIVEN,
227
227
  early_stopping: bool | NotGiven = NOT_GIVEN,
228
228
  frequency_penalty: float | NotGiven = NOT_GIVEN,
229
- guided_choice: List[str] | NotGiven = NOT_GIVEN,
229
+ guided_choice: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
230
230
  guided_json: Dict[str, object] | NotGiven = NOT_GIVEN,
231
231
  guided_regex: str | NotGiven = NOT_GIVEN,
232
232
  length_penalty: float | NotGiven = NOT_GIVEN,
@@ -2,11 +2,9 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import List
6
-
7
5
  import httpx
8
6
 
9
- from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
7
+ from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven, SequenceNotStr
10
8
  from ..._utils import maybe_transform, async_maybe_transform
11
9
  from ..._compat import cached_property
12
10
  from ...types.ai import cluster_list_params, cluster_compute_params, cluster_retrieve_params, cluster_fetch_graph_params
@@ -172,7 +170,7 @@ class ClustersResource(SyncAPIResource):
172
170
  self,
173
171
  *,
174
172
  bucket: str,
175
- files: List[str] | NotGiven = NOT_GIVEN,
173
+ files: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
176
174
  min_cluster_size: int | NotGiven = NOT_GIVEN,
177
175
  min_subcluster_size: int | NotGiven = NOT_GIVEN,
178
176
  prefix: str | NotGiven = NOT_GIVEN,
@@ -415,7 +413,7 @@ class AsyncClustersResource(AsyncAPIResource):
415
413
  self,
416
414
  *,
417
415
  bucket: str,
418
- files: List[str] | NotGiven = NOT_GIVEN,
416
+ files: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
419
417
  min_cluster_size: int | NotGiven = NOT_GIVEN,
420
418
  min_subcluster_size: int | NotGiven = NOT_GIVEN,
421
419
  prefix: str | NotGiven = NOT_GIVEN,
@@ -2,12 +2,12 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import Dict, List, Union, Iterable
5
+ from typing import Dict, Union, Iterable
6
6
  from datetime import datetime
7
7
 
8
8
  import httpx
9
9
 
10
- from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
10
+ from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
11
11
  from ...._utils import maybe_transform, async_maybe_transform
12
12
  from ...._compat import cached_property
13
13
  from ...._resource import SyncAPIResource, AsyncAPIResource
@@ -50,7 +50,7 @@ class MessagesResource(SyncAPIResource):
50
50
  *,
51
51
  role: str,
52
52
  content: str | NotGiven = NOT_GIVEN,
53
- metadata: Dict[str, Union[str, int, bool, List[Union[str, int, bool]]]] | NotGiven = NOT_GIVEN,
53
+ metadata: Dict[str, Union[str, int, bool, SequenceNotStr[Union[str, int, bool]]]] | NotGiven = NOT_GIVEN,
54
54
  name: str | NotGiven = NOT_GIVEN,
55
55
  sent_at: Union[str, datetime] | NotGiven = NOT_GIVEN,
56
56
  tool_call_id: str | NotGiven = NOT_GIVEN,
@@ -163,7 +163,7 @@ class AsyncMessagesResource(AsyncAPIResource):
163
163
  *,
164
164
  role: str,
165
165
  content: str | NotGiven = NOT_GIVEN,
166
- metadata: Dict[str, Union[str, int, bool, List[Union[str, int, bool]]]] | NotGiven = NOT_GIVEN,
166
+ metadata: Dict[str, Union[str, int, bool, SequenceNotStr[Union[str, int, bool]]]] | NotGiven = NOT_GIVEN,
167
167
  name: str | NotGiven = NOT_GIVEN,
168
168
  sent_at: Union[str, datetime] | NotGiven = NOT_GIVEN,
169
169
  tool_call_id: str | NotGiven = NOT_GIVEN,
@@ -2,7 +2,6 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import List
6
5
  from typing_extensions import Literal
7
6
 
8
7
  import httpx
@@ -15,7 +14,7 @@ from .buckets import (
15
14
  BucketsResourceWithStreamingResponse,
16
15
  AsyncBucketsResourceWithStreamingResponse,
17
16
  )
18
- from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
17
+ from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
19
18
  from ...._utils import maybe_transform, async_maybe_transform
20
19
  from ...._compat import cached_property
21
20
  from ....types.ai import (
@@ -186,7 +185,7 @@ class EmbeddingsResource(SyncAPIResource):
186
185
  def list(
187
186
  self,
188
187
  *,
189
- status: List[str] | NotGiven = NOT_GIVEN,
188
+ status: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
190
189
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
191
190
  # The extra values given here take precedence over values defined on the client or passed to this method.
192
191
  extra_headers: Headers | None = None,
@@ -471,7 +470,7 @@ class AsyncEmbeddingsResource(AsyncAPIResource):
471
470
  async def list(
472
471
  self,
473
472
  *,
474
- status: List[str] | NotGiven = NOT_GIVEN,
473
+ status: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
475
474
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
476
475
  # The extra values given here take precedence over values defined on the client or passed to this method.
477
476
  extra_headers: Headers | None = None,
@@ -2,7 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import List, Optional
5
+ from typing import Optional
6
6
  from typing_extensions import Literal
7
7
 
8
8
  import httpx
@@ -12,7 +12,7 @@ from ..types import (
12
12
  call_control_application_create_params,
13
13
  call_control_application_update_params,
14
14
  )
15
- from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
15
+ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
16
16
  from .._utils import maybe_transform, async_maybe_transform
17
17
  from .._compat import cached_property
18
18
  from .._resource import SyncAPIResource, AsyncAPIResource
@@ -194,7 +194,7 @@ class CallControlApplicationsResource(SyncAPIResource):
194
194
  inbound: CallControlApplicationInboundParam | NotGiven = NOT_GIVEN,
195
195
  outbound: CallControlApplicationOutboundParam | NotGiven = NOT_GIVEN,
196
196
  redact_dtmf_debug_logging: bool | NotGiven = NOT_GIVEN,
197
- tags: List[str] | NotGiven = NOT_GIVEN,
197
+ tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
198
198
  webhook_api_version: Literal["1", "2"] | NotGiven = NOT_GIVEN,
199
199
  webhook_event_failover_url: Optional[str] | NotGiven = NOT_GIVEN,
200
200
  webhook_timeout_secs: Optional[int] | NotGiven = NOT_GIVEN,
@@ -541,7 +541,7 @@ class AsyncCallControlApplicationsResource(AsyncAPIResource):
541
541
  inbound: CallControlApplicationInboundParam | NotGiven = NOT_GIVEN,
542
542
  outbound: CallControlApplicationOutboundParam | NotGiven = NOT_GIVEN,
543
543
  redact_dtmf_debug_logging: bool | NotGiven = NOT_GIVEN,
544
- tags: List[str] | NotGiven = NOT_GIVEN,
544
+ tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
545
545
  webhook_api_version: Literal["1", "2"] | NotGiven = NOT_GIVEN,
546
546
  webhook_event_failover_url: Optional[str] | NotGiven = NOT_GIVEN,
547
547
  webhook_timeout_secs: Optional[int] | NotGiven = NOT_GIVEN,
@@ -2,7 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import List, Union, Iterable
5
+ from typing import Union, Iterable
6
6
  from typing_extensions import Literal
7
7
 
8
8
  import httpx
@@ -22,7 +22,7 @@ from .actions import (
22
22
  ActionsResourceWithStreamingResponse,
23
23
  AsyncActionsResourceWithStreamingResponse,
24
24
  )
25
- from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
25
+ from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
26
26
  from ..._utils import maybe_transform, async_maybe_transform
27
27
  from ..._compat import cached_property
28
28
  from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -77,7 +77,7 @@ class CallsResource(SyncAPIResource):
77
77
  *,
78
78
  connection_id: str,
79
79
  from_: str,
80
- to: Union[str, List[str]],
80
+ to: Union[str, SequenceNotStr[str]],
81
81
  answering_machine_detection: Literal[
82
82
  "premium", "detect", "detect_beep", "detect_words", "greeting_end", "disabled"
83
83
  ]
@@ -457,7 +457,7 @@ class AsyncCallsResource(AsyncAPIResource):
457
457
  *,
458
458
  connection_id: str,
459
459
  from_: str,
460
- to: Union[str, List[str]],
460
+ to: Union[str, SequenceNotStr[str]],
461
461
  answering_machine_detection: Literal[
462
462
  "premium", "detect", "detect_beep", "detect_words", "greeting_end", "disabled"
463
463
  ]
@@ -2,7 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import Any, List, Iterable, cast
5
+ from typing import Any, Iterable, cast
6
6
 
7
7
  import httpx
8
8
 
@@ -15,7 +15,7 @@ from .brand import (
15
15
  AsyncBrandResourceWithStreamingResponse,
16
16
  )
17
17
  from ...types import campaign_builder_create_params
18
- from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
18
+ from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
19
19
  from ..._utils import maybe_transform, async_maybe_transform
20
20
  from ..._compat import cached_property
21
21
  from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -87,8 +87,8 @@ class CampaignBuilderResource(SyncAPIResource):
87
87
  subscriber_help: bool | NotGiven = NOT_GIVEN,
88
88
  subscriber_optin: bool | NotGiven = NOT_GIVEN,
89
89
  subscriber_optout: bool | NotGiven = NOT_GIVEN,
90
- sub_usecases: List[str] | NotGiven = NOT_GIVEN,
91
- tag: List[str] | NotGiven = NOT_GIVEN,
90
+ sub_usecases: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
91
+ tag: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
92
92
  terms_and_conditions: bool | NotGiven = NOT_GIVEN,
93
93
  terms_and_conditions_link: str | NotGiven = NOT_GIVEN,
94
94
  webhook_failover_url: str | NotGiven = NOT_GIVEN,
@@ -307,8 +307,8 @@ class AsyncCampaignBuilderResource(AsyncAPIResource):
307
307
  subscriber_help: bool | NotGiven = NOT_GIVEN,
308
308
  subscriber_optin: bool | NotGiven = NOT_GIVEN,
309
309
  subscriber_optout: bool | NotGiven = NOT_GIVEN,
310
- sub_usecases: List[str] | NotGiven = NOT_GIVEN,
311
- tag: List[str] | NotGiven = NOT_GIVEN,
310
+ sub_usecases: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
311
+ tag: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
312
312
  terms_and_conditions: bool | NotGiven = NOT_GIVEN,
313
313
  terms_and_conditions_link: str | NotGiven = NOT_GIVEN,
314
314
  webhook_failover_url: str | NotGiven = NOT_GIVEN,