telnyx 3.3.0a0__py3-none-any.whl → 3.5.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 (362) hide show
  1. telnyx/__init__.py +3 -1
  2. telnyx/_base_client.py +12 -12
  3. telnyx/_client.py +35 -34
  4. telnyx/_compat.py +48 -48
  5. telnyx/_models.py +50 -44
  6. telnyx/_qs.py +7 -7
  7. telnyx/_types.py +53 -12
  8. telnyx/_utils/__init__.py +9 -2
  9. telnyx/_utils/_compat.py +45 -0
  10. telnyx/_utils/_datetime_parse.py +136 -0
  11. telnyx/_utils/_transform.py +13 -3
  12. telnyx/_utils/_typing.py +6 -1
  13. telnyx/_utils/_utils.py +4 -5
  14. telnyx/_version.py +1 -1
  15. telnyx/resources/access_ip_address.py +15 -15
  16. telnyx/resources/access_ip_ranges.py +13 -13
  17. telnyx/resources/actions/purchase.py +13 -14
  18. telnyx/resources/actions/register.py +11 -12
  19. telnyx/resources/addresses/actions.py +13 -13
  20. telnyx/resources/addresses/addresses.py +33 -35
  21. telnyx/resources/advanced_orders.py +41 -45
  22. telnyx/resources/ai/ai.py +7 -7
  23. telnyx/resources/ai/assistants/assistants.py +89 -89
  24. telnyx/resources/ai/assistants/canary_deploys.py +9 -9
  25. telnyx/resources/ai/assistants/scheduled_events.py +21 -21
  26. telnyx/resources/ai/assistants/tests/runs.py +13 -13
  27. telnyx/resources/ai/assistants/tests/test_suites/runs.py +13 -13
  28. telnyx/resources/ai/assistants/tests/test_suites/test_suites.py +3 -3
  29. telnyx/resources/ai/assistants/tests/tests.py +43 -43
  30. telnyx/resources/ai/assistants/tools.py +7 -7
  31. telnyx/resources/ai/assistants/versions.py +45 -45
  32. telnyx/resources/ai/audio.py +11 -11
  33. telnyx/resources/ai/chat.py +48 -48
  34. telnyx/resources/ai/clusters.py +27 -29
  35. telnyx/resources/ai/conversations/conversations.py +43 -43
  36. telnyx/resources/ai/conversations/insight_groups/insight_groups.py +23 -23
  37. telnyx/resources/ai/conversations/insight_groups/insights.py +5 -5
  38. telnyx/resources/ai/conversations/insights.py +25 -25
  39. telnyx/resources/ai/conversations/messages.py +20 -20
  40. telnyx/resources/ai/embeddings/buckets.py +7 -7
  41. telnyx/resources/ai/embeddings/embeddings.py +23 -24
  42. telnyx/resources/ai/fine_tuning/jobs.py +13 -13
  43. telnyx/resources/audit_events.py +9 -9
  44. telnyx/resources/authentication_providers.py +29 -29
  45. telnyx/resources/available_phone_number_blocks.py +5 -5
  46. telnyx/resources/available_phone_numbers.py +5 -5
  47. telnyx/resources/balance.py +3 -3
  48. telnyx/resources/billing_groups.py +17 -17
  49. telnyx/resources/brand/brand.py +113 -113
  50. telnyx/resources/brand/external_vetting.py +9 -9
  51. telnyx/resources/bulk_sim_card_actions.py +11 -11
  52. telnyx/resources/bundle_pricing/billing_bundles.py +13 -13
  53. telnyx/resources/bundle_pricing/user_bundles.py +35 -35
  54. telnyx/resources/call_control_applications.py +64 -68
  55. telnyx/resources/call_events.py +7 -7
  56. telnyx/resources/calls/actions.py +549 -551
  57. telnyx/resources/calls/calls.py +102 -102
  58. telnyx/resources/campaign/campaign.py +47 -47
  59. telnyx/resources/campaign/osr.py +3 -3
  60. telnyx/resources/campaign/usecase.py +3 -3
  61. telnyx/resources/campaign_builder/brand.py +3 -3
  62. telnyx/resources/campaign_builder/campaign_builder.py +68 -68
  63. telnyx/resources/channel_zones.py +7 -7
  64. telnyx/resources/charges_breakdown.py +7 -7
  65. telnyx/resources/charges_summary.py +3 -3
  66. telnyx/resources/comments.py +17 -17
  67. telnyx/resources/conferences/actions.py +115 -116
  68. telnyx/resources/conferences/conferences.py +35 -35
  69. telnyx/resources/connections.py +15 -15
  70. telnyx/resources/country_coverage.py +5 -5
  71. telnyx/resources/credential_connections/actions.py +3 -3
  72. telnyx/resources/credential_connections/credential_connections.py +96 -96
  73. telnyx/resources/custom_storage_credentials.py +9 -9
  74. telnyx/resources/customer_service_records.py +21 -23
  75. telnyx/resources/detail_records.py +9 -11
  76. telnyx/resources/dialogflow_connections.py +25 -25
  77. telnyx/resources/document_links.py +7 -7
  78. telnyx/resources/documents.py +45 -45
  79. telnyx/resources/dynamic_emergency_addresses.py +23 -23
  80. telnyx/resources/dynamic_emergency_endpoints.py +13 -13
  81. telnyx/resources/enum.py +3 -3
  82. telnyx/resources/external_connections/civic_addresses.py +7 -7
  83. telnyx/resources/external_connections/external_connections.py +42 -42
  84. telnyx/resources/external_connections/log_messages.py +11 -11
  85. telnyx/resources/external_connections/phone_numbers.py +13 -13
  86. telnyx/resources/external_connections/releases.py +9 -9
  87. telnyx/resources/external_connections/uploads.py +27 -29
  88. telnyx/resources/fax_applications.py +48 -48
  89. telnyx/resources/faxes/actions.py +5 -5
  90. telnyx/resources/faxes/faxes.py +35 -35
  91. telnyx/resources/fqdn_connections.py +94 -94
  92. telnyx/resources/fqdns.py +25 -25
  93. telnyx/resources/global_ip_allowed_ports.py +3 -3
  94. telnyx/resources/global_ip_assignment_health.py +5 -5
  95. telnyx/resources/global_ip_assignments.py +19 -19
  96. telnyx/resources/global_ip_assignments_usage.py +5 -5
  97. telnyx/resources/global_ip_health_check_types.py +3 -3
  98. telnyx/resources/global_ip_health_checks.py +17 -17
  99. telnyx/resources/global_ip_latency.py +5 -5
  100. telnyx/resources/global_ip_protocols.py +3 -3
  101. telnyx/resources/global_ip_usage.py +5 -5
  102. telnyx/resources/global_ips.py +17 -17
  103. telnyx/resources/inbound_channels.py +5 -5
  104. telnyx/resources/integration_secrets.py +17 -17
  105. telnyx/resources/inventory_coverage.py +5 -5
  106. telnyx/resources/invoices.py +11 -11
  107. telnyx/resources/ip_connections.py +94 -94
  108. telnyx/resources/ips.py +23 -23
  109. telnyx/resources/ledger_billing_group_reports.py +9 -9
  110. telnyx/resources/list.py +5 -5
  111. telnyx/resources/managed_accounts/actions.py +7 -7
  112. telnyx/resources/managed_accounts/managed_accounts.py +33 -33
  113. telnyx/resources/media.py +23 -23
  114. telnyx/resources/messages/messages.py +124 -124
  115. telnyx/resources/messages/rcs.py +7 -7
  116. telnyx/resources/messaging/rcs/agents.py +15 -15
  117. telnyx/resources/messaging/rcs/rcs.py +9 -11
  118. telnyx/resources/messaging_hosted_number_orders/actions.py +7 -7
  119. telnyx/resources/messaging_hosted_number_orders/messaging_hosted_number_orders.py +26 -26
  120. telnyx/resources/messaging_hosted_numbers.py +3 -3
  121. telnyx/resources/messaging_numbers_bulk_updates.py +7 -9
  122. telnyx/resources/messaging_optouts.py +11 -11
  123. telnyx/resources/messaging_profiles/autoresp_configs.py +25 -26
  124. telnyx/resources/messaging_profiles/messaging_profiles.py +76 -76
  125. telnyx/resources/messaging_tollfree/verification/requests.py +27 -27
  126. telnyx/resources/messaging_url_domains.py +5 -5
  127. telnyx/resources/messsages.py +11 -11
  128. telnyx/resources/mobile_network_operators.py +7 -7
  129. telnyx/resources/mobile_push_credentials.py +23 -23
  130. telnyx/resources/network_coverage.py +9 -9
  131. telnyx/resources/networks/default_gateway.py +9 -9
  132. telnyx/resources/networks/networks.py +21 -21
  133. telnyx/resources/notification_channels.py +27 -27
  134. telnyx/resources/notification_event_conditions.py +7 -7
  135. telnyx/resources/notification_events.py +5 -5
  136. telnyx/resources/notification_profiles.py +17 -17
  137. telnyx/resources/notification_settings.py +21 -21
  138. telnyx/resources/number_block_orders.py +17 -17
  139. telnyx/resources/number_lookup.py +5 -5
  140. telnyx/resources/number_order_phone_numbers.py +13 -13
  141. telnyx/resources/number_orders.py +27 -27
  142. telnyx/resources/number_reservations/actions.py +3 -3
  143. telnyx/resources/number_reservations/number_reservations.py +15 -15
  144. telnyx/resources/numbers_features.py +5 -7
  145. telnyx/resources/operator_connect/actions.py +3 -3
  146. telnyx/resources/ota_updates.py +9 -9
  147. telnyx/resources/outbound_voice_profiles.py +66 -66
  148. telnyx/resources/partner_campaigns.py +25 -25
  149. telnyx/resources/payment/auto_recharge_prefs.py +15 -15
  150. telnyx/resources/phone_number_assignment_by_profile.py +15 -15
  151. telnyx/resources/phone_number_blocks/jobs.py +13 -13
  152. telnyx/resources/phone_number_campaigns.py +19 -19
  153. telnyx/resources/phone_numbers/actions.py +9 -11
  154. telnyx/resources/phone_numbers/csv_downloads.py +13 -13
  155. telnyx/resources/phone_numbers/jobs.py +42 -42
  156. telnyx/resources/phone_numbers/messaging.py +13 -13
  157. telnyx/resources/phone_numbers/phone_numbers.py +39 -40
  158. telnyx/resources/phone_numbers/voice.py +31 -31
  159. telnyx/resources/phone_numbers/voicemail.py +15 -15
  160. telnyx/resources/phone_numbers_regulatory_requirements.py +5 -5
  161. telnyx/resources/portability_checks.py +5 -7
  162. telnyx/resources/porting/events.py +11 -11
  163. telnyx/resources/porting/loa_configurations.py +17 -17
  164. telnyx/resources/porting/porting.py +3 -3
  165. telnyx/resources/porting/reports.py +11 -11
  166. telnyx/resources/porting_orders/action_requirements.py +11 -11
  167. telnyx/resources/porting_orders/actions.py +13 -13
  168. telnyx/resources/porting_orders/activation_jobs.py +11 -11
  169. telnyx/resources/porting_orders/additional_documents.py +15 -15
  170. telnyx/resources/porting_orders/associated_phone_numbers.py +13 -13
  171. telnyx/resources/porting_orders/comments.py +9 -9
  172. telnyx/resources/porting_orders/phone_number_blocks.py +13 -13
  173. telnyx/resources/porting_orders/phone_number_configurations.py +13 -13
  174. telnyx/resources/porting_orders/phone_number_extensions.py +13 -13
  175. telnyx/resources/porting_orders/porting_orders.py +62 -62
  176. telnyx/resources/porting_orders/verification_codes.py +20 -20
  177. telnyx/resources/porting_phone_numbers.py +7 -7
  178. telnyx/resources/portouts/comments.py +7 -7
  179. telnyx/resources/portouts/events.py +11 -11
  180. telnyx/resources/portouts/portouts.py +17 -17
  181. telnyx/resources/portouts/reports.py +11 -11
  182. telnyx/resources/portouts/supporting_documents.py +7 -7
  183. telnyx/resources/private_wireless_gateways.py +25 -25
  184. telnyx/resources/public_internet_gateways.py +19 -19
  185. telnyx/resources/queues/calls.py +7 -7
  186. telnyx/resources/queues/queues.py +3 -3
  187. telnyx/resources/recording_transcriptions.py +7 -7
  188. telnyx/resources/recordings/actions.py +5 -7
  189. telnyx/resources/recordings/recordings.py +11 -11
  190. telnyx/resources/regions.py +3 -3
  191. telnyx/resources/regulatory_requirements.py +5 -5
  192. telnyx/resources/reports/cdr_usage_reports.py +9 -9
  193. telnyx/resources/reports/mdr_usage_reports.py +22 -22
  194. telnyx/resources/reports/reports.py +47 -48
  195. telnyx/resources/requirement_groups.py +23 -23
  196. telnyx/resources/requirement_types.py +9 -11
  197. telnyx/resources/requirements.py +11 -11
  198. telnyx/resources/room_compositions.py +27 -27
  199. telnyx/resources/room_participants.py +9 -9
  200. telnyx/resources/room_recordings.py +17 -17
  201. telnyx/resources/rooms/actions.py +11 -11
  202. telnyx/resources/rooms/rooms.py +43 -43
  203. telnyx/resources/rooms/sessions/actions.py +22 -22
  204. telnyx/resources/rooms/sessions/sessions.py +27 -27
  205. telnyx/resources/seti.py +5 -5
  206. telnyx/resources/short_codes.py +11 -11
  207. telnyx/resources/sim_card_data_usage_notifications.py +21 -21
  208. telnyx/resources/sim_card_groups/actions.py +23 -23
  209. telnyx/resources/sim_card_groups/sim_card_groups.py +29 -29
  210. telnyx/resources/sim_card_order_preview.py +3 -3
  211. telnyx/resources/sim_card_orders.py +11 -11
  212. telnyx/resources/sim_cards/actions.py +29 -31
  213. telnyx/resources/sim_cards/sim_cards.py +47 -48
  214. telnyx/resources/siprec_connectors.py +13 -13
  215. telnyx/resources/storage/buckets/buckets.py +5 -5
  216. telnyx/resources/storage/buckets/ssl_certificate.py +11 -11
  217. telnyx/resources/storage/buckets/usage.py +5 -5
  218. telnyx/resources/storage/migration_sources.py +11 -11
  219. telnyx/resources/storage/migrations/actions.py +3 -3
  220. telnyx/resources/storage/migrations/migrations.py +9 -9
  221. telnyx/resources/storage/storage.py +3 -3
  222. telnyx/resources/sub_number_orders.py +17 -17
  223. telnyx/resources/sub_number_orders_report.py +19 -19
  224. telnyx/resources/telephony_credentials.py +31 -31
  225. telnyx/resources/texml/accounts/accounts.py +15 -15
  226. telnyx/resources/texml/accounts/calls/calls.py +145 -145
  227. telnyx/resources/texml/accounts/calls/recordings.py +5 -5
  228. telnyx/resources/texml/accounts/calls/recordings_json.py +19 -19
  229. telnyx/resources/texml/accounts/calls/siprec.py +5 -5
  230. telnyx/resources/texml/accounts/calls/streams.py +5 -5
  231. telnyx/resources/texml/accounts/conferences/conferences.py +31 -31
  232. telnyx/resources/texml/accounts/conferences/participants.py +123 -123
  233. telnyx/resources/texml/accounts/recordings/json.py +5 -5
  234. telnyx/resources/texml/accounts/transcriptions/json.py +5 -5
  235. telnyx/resources/texml/calls.py +79 -79
  236. telnyx/resources/texml/texml.py +3 -3
  237. telnyx/resources/texml_applications.py +65 -66
  238. telnyx/resources/text_to_speech.py +9 -9
  239. telnyx/resources/usage_reports.py +31 -32
  240. telnyx/resources/user_addresses.py +29 -31
  241. telnyx/resources/user_tags.py +5 -5
  242. telnyx/resources/verifications/actions.py +7 -7
  243. telnyx/resources/verifications/by_phone_number/actions.py +3 -3
  244. telnyx/resources/verifications/by_phone_number/by_phone_number.py +3 -3
  245. telnyx/resources/verifications/verifications.py +19 -19
  246. telnyx/resources/verified_numbers/actions.py +3 -3
  247. telnyx/resources/verified_numbers/verified_numbers.py +11 -11
  248. telnyx/resources/verify_profiles.py +43 -43
  249. telnyx/resources/virtual_cross_connects.py +45 -45
  250. telnyx/resources/virtual_cross_connects_coverage.py +9 -9
  251. telnyx/resources/webhook_deliveries.py +9 -9
  252. telnyx/resources/wireguard_interfaces.py +17 -17
  253. telnyx/resources/wireguard_peers.py +21 -21
  254. telnyx/resources/wireless/detail_records_reports.py +17 -17
  255. telnyx/resources/wireless/wireless.py +3 -3
  256. telnyx/resources/wireless_blocklist_values.py +3 -3
  257. telnyx/resources/wireless_blocklists.py +29 -30
  258. telnyx/types/__init__.py +4 -4
  259. telnyx/types/actions/purchase_create_params.py +3 -2
  260. telnyx/types/actions/register_create_params.py +4 -3
  261. telnyx/types/ai/chat_create_completion_params.py +3 -2
  262. telnyx/types/ai/cluster_compute_params.py +3 -2
  263. telnyx/types/ai/conversations/message_create_params.py +3 -2
  264. telnyx/types/ai/embedding_list_params.py +3 -2
  265. telnyx/types/ai/inference_embedding_bucket_ids_param.py +3 -2
  266. telnyx/types/ai/inference_embedding_webhook_tool_params_param.py +6 -4
  267. telnyx/types/bundle_pricing/billing_bundle_list_params.py +4 -3
  268. telnyx/types/bundle_pricing/user_bundle_list_params.py +4 -3
  269. telnyx/types/bundle_pricing/user_bundle_list_unused_params.py +4 -3
  270. telnyx/types/call_control_application_update_params.py +3 -2
  271. telnyx/types/call_dial_params.py +4 -3
  272. telnyx/types/calls/transcription_engine_a_config_param.py +4 -3
  273. telnyx/types/campaign_builder_create_params.py +4 -3
  274. telnyx/types/conferences/action_hold_params.py +3 -2
  275. telnyx/types/conferences/action_join_params.py +3 -2
  276. telnyx/types/conferences/action_mute_params.py +3 -2
  277. telnyx/types/conferences/action_play_params.py +2 -2
  278. telnyx/types/conferences/action_speak_params.py +3 -2
  279. telnyx/types/conferences/action_stop_params.py +3 -2
  280. telnyx/types/conferences/action_unhold_params.py +3 -2
  281. telnyx/types/conferences/action_unmute_params.py +3 -2
  282. telnyx/types/conferences/action_update_params.py +3 -2
  283. telnyx/types/credential_connection_create_params.py +3 -2
  284. telnyx/types/credential_connection_update_params.py +3 -2
  285. telnyx/types/credential_inbound_param.py +3 -2
  286. telnyx/types/customer_service_record_list_params.py +2 -1
  287. telnyx/types/customer_service_record_verify_phone_number_coverage_params.py +3 -2
  288. telnyx/types/detail_record_list_params.py +4 -2
  289. telnyx/types/document_list_params.py +2 -1
  290. telnyx/types/external_connection_create_params.py +4 -2
  291. telnyx/types/external_connection_update_params.py +4 -2
  292. telnyx/types/external_connections/civic_address_list_params.py +3 -2
  293. telnyx/types/external_connections/upload_create_params.py +3 -1
  294. telnyx/types/fax_application_create_params.py +3 -2
  295. telnyx/types/fax_application_update_params.py +3 -2
  296. telnyx/types/fqdn_connection_create_params.py +3 -2
  297. telnyx/types/fqdn_connection_update_params.py +3 -2
  298. telnyx/types/global_ip_latency_retrieve_response.py +7 -7
  299. telnyx/types/inbound_fqdn_param.py +4 -2
  300. telnyx/types/inbound_ip_param.py +3 -2
  301. telnyx/types/ip_connection_create_params.py +4 -3
  302. telnyx/types/ip_connection_update_params.py +3 -2
  303. telnyx/types/media_list_params.py +3 -2
  304. telnyx/types/message_schedule_params.py +3 -2
  305. telnyx/types/message_send_group_mms_params.py +3 -3
  306. telnyx/types/message_send_long_code_params.py +2 -2
  307. telnyx/types/message_send_number_pool_params.py +3 -2
  308. telnyx/types/message_send_params.py +3 -2
  309. telnyx/types/message_send_short_code_params.py +2 -2
  310. telnyx/types/messaging/rc_list_bulk_capabilities_params.py +3 -2
  311. telnyx/types/messaging_hosted_number_order_check_eligibility_params.py +3 -2
  312. telnyx/types/messaging_hosted_number_order_create_params.py +3 -2
  313. telnyx/types/messaging_hosted_number_order_create_verification_codes_params.py +3 -2
  314. telnyx/types/messaging_numbers_bulk_update_create_params.py +3 -2
  315. telnyx/types/messaging_profile_create_params.py +3 -2
  316. telnyx/types/messaging_profile_update_params.py +3 -2
  317. telnyx/types/messaging_profiles/autoresp_config_create_params.py +3 -2
  318. telnyx/types/messaging_profiles/autoresp_config_update_params.py +3 -2
  319. telnyx/types/messsage_rcs_params.py +2 -2
  320. telnyx/types/numbers_feature_create_params.py +3 -2
  321. telnyx/types/outbound_call_recording_param.py +3 -2
  322. telnyx/types/outbound_voice_profile_create_params.py +4 -3
  323. telnyx/types/outbound_voice_profile_update_params.py +4 -3
  324. telnyx/types/phone_number_list_params.py +3 -2
  325. telnyx/types/phone_number_slim_list_params.py +3 -2
  326. telnyx/types/phone_number_update_params.py +3 -2
  327. telnyx/types/phone_numbers/action_verify_ownership_params.py +3 -2
  328. telnyx/types/phone_numbers/job_delete_batch_params.py +3 -2
  329. telnyx/types/phone_numbers/job_update_batch_params.py +3 -3
  330. telnyx/types/phone_numbers/job_update_emergency_settings_batch_params.py +4 -2
  331. telnyx/types/portability_check_run_params.py +3 -2
  332. telnyx/types/porting/export_porting_orders_csv_report_param.py +2 -1
  333. telnyx/types/porting_order_create_params.py +3 -2
  334. telnyx/types/porting_order_phone_number_configuration_param.py +3 -2
  335. telnyx/types/porting_orders/action_requirement_list_params.py +3 -2
  336. telnyx/types/porting_orders/phone_number_block_list_params.py +5 -3
  337. telnyx/types/porting_orders/phone_number_configuration_list_params.py +3 -2
  338. telnyx/types/porting_orders/verification_code_send_params.py +3 -2
  339. telnyx/types/portout_list_params.py +2 -1
  340. telnyx/types/portouts/export_portouts_csv_report_param.py +3 -2
  341. telnyx/types/recordings/action_delete_params.py +3 -2
  342. telnyx/types/report_list_wdrs_params.py +3 -2
  343. telnyx/types/reports/mdr_usage_report_fetch_sync_params.py +3 -2
  344. telnyx/types/rooms/sessions/action_kick_params.py +5 -3
  345. telnyx/types/rooms/sessions/action_mute_params.py +5 -3
  346. telnyx/types/rooms/sessions/action_unmute_params.py +5 -3
  347. telnyx/types/sim_card_list_params.py +2 -1
  348. telnyx/types/sim_card_update_params.py +3 -3
  349. telnyx/types/sim_cards/action_bulk_set_public_ips_params.py +3 -2
  350. telnyx/types/sim_cards/action_validate_registration_codes_params.py +3 -2
  351. telnyx/types/texml_application_create_params.py +2 -2
  352. telnyx/types/texml_application_update_params.py +2 -2
  353. telnyx/types/usage_report_list_params.py +5 -4
  354. telnyx/types/verify_profile_create_params.py +6 -4
  355. telnyx/types/verify_profile_update_params.py +6 -4
  356. telnyx/types/video_region_param.py +4 -2
  357. telnyx/types/wireless_blocklist_create_params.py +3 -2
  358. telnyx/types/wireless_blocklist_update_params.py +3 -2
  359. {telnyx-3.3.0a0.dist-info → telnyx-3.5.0a0.dist-info}/METADATA +58 -17
  360. {telnyx-3.3.0a0.dist-info → telnyx-3.5.0a0.dist-info}/RECORD +362 -360
  361. {telnyx-3.3.0a0.dist-info → telnyx-3.5.0a0.dist-info}/WHEEL +0 -0
  362. {telnyx-3.3.0a0.dist-info → telnyx-3.5.0a0.dist-info}/licenses/LICENSE +0 -0
telnyx/__init__.py CHANGED
@@ -3,7 +3,7 @@
3
3
  import typing as _t
4
4
 
5
5
  from . import types
6
- from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes
6
+ from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes, omit, not_given
7
7
  from ._utils import file_from_path
8
8
  from ._client import Client, Stream, Telnyx, Timeout, Transport, AsyncClient, AsyncStream, AsyncTelnyx, RequestOptions
9
9
  from ._models import BaseModel
@@ -38,7 +38,9 @@ __all__ = [
38
38
  "ProxiesTypes",
39
39
  "NotGiven",
40
40
  "NOT_GIVEN",
41
+ "not_given",
41
42
  "Omit",
43
+ "omit",
42
44
  "TelnyxError",
43
45
  "APIError",
44
46
  "APIStatusError",
telnyx/_base_client.py CHANGED
@@ -42,7 +42,6 @@ from . import _exceptions
42
42
  from ._qs import Querystring
43
43
  from ._files import to_httpx_files, async_to_httpx_files
44
44
  from ._types import (
45
- NOT_GIVEN,
46
45
  Body,
47
46
  Omit,
48
47
  Query,
@@ -57,9 +56,10 @@ from ._types import (
57
56
  RequestOptions,
58
57
  HttpxRequestFiles,
59
58
  ModelBuilderProtocol,
59
+ not_given,
60
60
  )
61
61
  from ._utils import is_dict, is_list, asyncify, is_given, lru_cache, is_mapping
62
- from ._compat import PYDANTIC_V2, model_copy, model_dump
62
+ from ._compat import PYDANTIC_V1, model_copy, model_dump
63
63
  from ._models import GenericModel, FinalRequestOptions, validate_type, construct_type
64
64
  from ._response import (
65
65
  APIResponse,
@@ -145,9 +145,9 @@ class PageInfo:
145
145
  def __init__(
146
146
  self,
147
147
  *,
148
- url: URL | NotGiven = NOT_GIVEN,
149
- json: Body | NotGiven = NOT_GIVEN,
150
- params: Query | NotGiven = NOT_GIVEN,
148
+ url: URL | NotGiven = not_given,
149
+ json: Body | NotGiven = not_given,
150
+ params: Query | NotGiven = not_given,
151
151
  ) -> None:
152
152
  self.url = url
153
153
  self.json = json
@@ -232,7 +232,7 @@ class BaseSyncPage(BasePage[_T], Generic[_T]):
232
232
  model: Type[_T],
233
233
  options: FinalRequestOptions,
234
234
  ) -> None:
235
- if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None:
235
+ if (not PYDANTIC_V1) and getattr(self, "__pydantic_private__", None) is None:
236
236
  self.__pydantic_private__ = {}
237
237
 
238
238
  self._model = model
@@ -320,7 +320,7 @@ class BaseAsyncPage(BasePage[_T], Generic[_T]):
320
320
  client: AsyncAPIClient,
321
321
  options: FinalRequestOptions,
322
322
  ) -> None:
323
- if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None:
323
+ if (not PYDANTIC_V1) and getattr(self, "__pydantic_private__", None) is None:
324
324
  self.__pydantic_private__ = {}
325
325
 
326
326
  self._model = model
@@ -595,7 +595,7 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
595
595
  # we internally support defining a temporary header to override the
596
596
  # default `cast_to` type for use with `.with_raw_response` and `.with_streaming_response`
597
597
  # see _response.py for implementation details
598
- override_cast_to = headers.pop(OVERRIDE_CAST_TO_HEADER, NOT_GIVEN)
598
+ override_cast_to = headers.pop(OVERRIDE_CAST_TO_HEADER, not_given)
599
599
  if is_given(override_cast_to):
600
600
  options.headers = headers
601
601
  return cast(Type[ResponseT], override_cast_to)
@@ -825,7 +825,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
825
825
  version: str,
826
826
  base_url: str | URL,
827
827
  max_retries: int = DEFAULT_MAX_RETRIES,
828
- timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
828
+ timeout: float | Timeout | None | NotGiven = not_given,
829
829
  http_client: httpx.Client | None = None,
830
830
  custom_headers: Mapping[str, str] | None = None,
831
831
  custom_query: Mapping[str, object] | None = None,
@@ -1356,7 +1356,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1356
1356
  base_url: str | URL,
1357
1357
  _strict_response_validation: bool,
1358
1358
  max_retries: int = DEFAULT_MAX_RETRIES,
1359
- timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
1359
+ timeout: float | Timeout | None | NotGiven = not_given,
1360
1360
  http_client: httpx.AsyncClient | None = None,
1361
1361
  custom_headers: Mapping[str, str] | None = None,
1362
1362
  custom_query: Mapping[str, object] | None = None,
@@ -1818,8 +1818,8 @@ def make_request_options(
1818
1818
  extra_query: Query | None = None,
1819
1819
  extra_body: Body | None = None,
1820
1820
  idempotency_key: str | None = None,
1821
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1822
- post_parser: PostParser | NotGiven = NOT_GIVEN,
1821
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1822
+ post_parser: PostParser | NotGiven = not_given,
1823
1823
  ) -> RequestOptions:
1824
1824
  """Create a dict of type RequestOptions without keys of NotGiven values."""
1825
1825
  options: RequestOptions = {}
telnyx/_client.py CHANGED
@@ -3,7 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import os
6
- from typing import Any, Union, Mapping, Iterable
6
+ from typing import Any, Mapping, Iterable
7
7
  from typing_extensions import Self, Literal, override
8
8
 
9
9
  import httpx
@@ -18,7 +18,6 @@ from .types import (
18
18
  client_delete_objects_params,
19
19
  )
20
20
  from ._types import (
21
- NOT_GIVEN,
22
21
  Body,
23
22
  Omit,
24
23
  Query,
@@ -30,6 +29,8 @@ from ._types import (
30
29
  Transport,
31
30
  ProxiesTypes,
32
31
  RequestOptions,
32
+ omit,
33
+ not_given,
33
34
  )
34
35
  from ._utils import (
35
36
  is_given,
@@ -376,7 +377,7 @@ class Telnyx(SyncAPIClient):
376
377
  *,
377
378
  api_key: str | None = None,
378
379
  base_url: str | httpx.URL | None = None,
379
- timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
380
+ timeout: float | Timeout | None | NotGiven = not_given,
380
381
  max_retries: int = DEFAULT_MAX_RETRIES,
381
382
  default_headers: Mapping[str, str] | None = None,
382
383
  default_query: Mapping[str, object] | None = None,
@@ -605,9 +606,9 @@ class Telnyx(SyncAPIClient):
605
606
  *,
606
607
  api_key: str | None = None,
607
608
  base_url: str | httpx.URL | None = None,
608
- timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
609
+ timeout: float | Timeout | None | NotGiven = not_given,
609
610
  http_client: httpx.Client | None = None,
610
- max_retries: int | NotGiven = NOT_GIVEN,
611
+ max_retries: int | NotGiven = not_given,
611
612
  default_headers: Mapping[str, str] | None = None,
612
613
  set_default_headers: Mapping[str, str] | None = None,
613
614
  default_query: Mapping[str, object] | None = None,
@@ -655,13 +656,13 @@ class Telnyx(SyncAPIClient):
655
656
  self,
656
657
  bucket_name: str,
657
658
  *,
658
- location_constraint: str | NotGiven = NOT_GIVEN,
659
+ location_constraint: str | Omit = omit,
659
660
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
660
661
  # The extra values given here take precedence over values defined on the client or passed to this method.
661
662
  extra_headers: Headers | None = None,
662
663
  extra_query: Query | None = None,
663
664
  extra_body: Body | None = None,
664
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
665
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
665
666
  ) -> None:
666
667
  """
667
668
  Create a bucket.
@@ -698,7 +699,7 @@ class Telnyx(SyncAPIClient):
698
699
  extra_headers: Headers | None = None,
699
700
  extra_query: Query | None = None,
700
701
  extra_body: Body | None = None,
701
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
702
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
702
703
  ) -> None:
703
704
  """Deletes a bucket.
704
705
 
@@ -734,7 +735,7 @@ class Telnyx(SyncAPIClient):
734
735
  extra_headers: Headers | None = None,
735
736
  extra_query: Query | None = None,
736
737
  extra_body: Body | None = None,
737
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
738
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
738
739
  ) -> None:
739
740
  """
740
741
  Delete an object from a given bucket.
@@ -772,7 +773,7 @@ class Telnyx(SyncAPIClient):
772
773
  extra_headers: Headers | None = None,
773
774
  extra_query: Query | None = None,
774
775
  extra_body: Body | None = None,
775
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
776
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
776
777
  ) -> object:
777
778
  """
778
779
  Deletes one or multiple objects from a given bucket.
@@ -807,13 +808,13 @@ class Telnyx(SyncAPIClient):
807
808
  object_name: str,
808
809
  *,
809
810
  bucket_name: str,
810
- upload_id: str | NotGiven = NOT_GIVEN,
811
+ upload_id: str | Omit = omit,
811
812
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
812
813
  # The extra values given here take precedence over values defined on the client or passed to this method.
813
814
  extra_headers: Headers | None = None,
814
815
  extra_query: Query | None = None,
815
816
  extra_body: Body | None = None,
816
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
817
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
817
818
  ) -> BinaryAPIResponse:
818
819
  """
819
820
  Retrieves an object from a given bucket.
@@ -852,7 +853,7 @@ class Telnyx(SyncAPIClient):
852
853
  extra_headers: Headers | None = None,
853
854
  extra_query: Query | None = None,
854
855
  extra_body: Body | None = None,
855
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
856
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
856
857
  ) -> ListBucketsResponse:
857
858
  """List all Buckets."""
858
859
  extra_headers = {"Accept": "application/xml", **(extra_headers or {})}
@@ -868,13 +869,13 @@ class Telnyx(SyncAPIClient):
868
869
  self,
869
870
  bucket_name: str,
870
871
  *,
871
- list_type: Literal[2] | NotGiven = NOT_GIVEN,
872
+ list_type: Literal[2] | Omit = omit,
872
873
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
873
874
  # The extra values given here take precedence over values defined on the client or passed to this method.
874
875
  extra_headers: Headers | None = None,
875
876
  extra_query: Query | None = None,
876
877
  extra_body: Body | None = None,
877
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
878
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
878
879
  ) -> ListObjectsResponse:
879
880
  """
880
881
  List all objects contained in a given bucket.
@@ -909,14 +910,14 @@ class Telnyx(SyncAPIClient):
909
910
  *,
910
911
  bucket_name: str,
911
912
  body: FileTypes,
912
- part_number: str | NotGiven = NOT_GIVEN,
913
- upload_id: str | NotGiven = NOT_GIVEN,
913
+ part_number: str | Omit = omit,
914
+ upload_id: str | Omit = omit,
914
915
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
915
916
  # The extra values given here take precedence over values defined on the client or passed to this method.
916
917
  extra_headers: Headers | None = None,
917
918
  extra_query: Query | None = None,
918
919
  extra_body: Body | None = None,
919
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
920
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
920
921
  ) -> None:
921
922
  """
922
923
  Add an object to a bucket.
@@ -1149,7 +1150,7 @@ class AsyncTelnyx(AsyncAPIClient):
1149
1150
  *,
1150
1151
  api_key: str | None = None,
1151
1152
  base_url: str | httpx.URL | None = None,
1152
- timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
1153
+ timeout: float | Timeout | None | NotGiven = not_given,
1153
1154
  max_retries: int = DEFAULT_MAX_RETRIES,
1154
1155
  default_headers: Mapping[str, str] | None = None,
1155
1156
  default_query: Mapping[str, object] | None = None,
@@ -1384,9 +1385,9 @@ class AsyncTelnyx(AsyncAPIClient):
1384
1385
  *,
1385
1386
  api_key: str | None = None,
1386
1387
  base_url: str | httpx.URL | None = None,
1387
- timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
1388
+ timeout: float | Timeout | None | NotGiven = not_given,
1388
1389
  http_client: httpx.AsyncClient | None = None,
1389
- max_retries: int | NotGiven = NOT_GIVEN,
1390
+ max_retries: int | NotGiven = not_given,
1390
1391
  default_headers: Mapping[str, str] | None = None,
1391
1392
  set_default_headers: Mapping[str, str] | None = None,
1392
1393
  default_query: Mapping[str, object] | None = None,
@@ -1434,13 +1435,13 @@ class AsyncTelnyx(AsyncAPIClient):
1434
1435
  self,
1435
1436
  bucket_name: str,
1436
1437
  *,
1437
- location_constraint: str | NotGiven = NOT_GIVEN,
1438
+ location_constraint: str | Omit = omit,
1438
1439
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1439
1440
  # The extra values given here take precedence over values defined on the client or passed to this method.
1440
1441
  extra_headers: Headers | None = None,
1441
1442
  extra_query: Query | None = None,
1442
1443
  extra_body: Body | None = None,
1443
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1444
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1444
1445
  ) -> None:
1445
1446
  """
1446
1447
  Create a bucket.
@@ -1477,7 +1478,7 @@ class AsyncTelnyx(AsyncAPIClient):
1477
1478
  extra_headers: Headers | None = None,
1478
1479
  extra_query: Query | None = None,
1479
1480
  extra_body: Body | None = None,
1480
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1481
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1481
1482
  ) -> None:
1482
1483
  """Deletes a bucket.
1483
1484
 
@@ -1513,7 +1514,7 @@ class AsyncTelnyx(AsyncAPIClient):
1513
1514
  extra_headers: Headers | None = None,
1514
1515
  extra_query: Query | None = None,
1515
1516
  extra_body: Body | None = None,
1516
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1517
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1517
1518
  ) -> None:
1518
1519
  """
1519
1520
  Delete an object from a given bucket.
@@ -1551,7 +1552,7 @@ class AsyncTelnyx(AsyncAPIClient):
1551
1552
  extra_headers: Headers | None = None,
1552
1553
  extra_query: Query | None = None,
1553
1554
  extra_body: Body | None = None,
1554
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1555
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1555
1556
  ) -> object:
1556
1557
  """
1557
1558
  Deletes one or multiple objects from a given bucket.
@@ -1588,13 +1589,13 @@ class AsyncTelnyx(AsyncAPIClient):
1588
1589
  object_name: str,
1589
1590
  *,
1590
1591
  bucket_name: str,
1591
- upload_id: str | NotGiven = NOT_GIVEN,
1592
+ upload_id: str | Omit = omit,
1592
1593
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1593
1594
  # The extra values given here take precedence over values defined on the client or passed to this method.
1594
1595
  extra_headers: Headers | None = None,
1595
1596
  extra_query: Query | None = None,
1596
1597
  extra_body: Body | None = None,
1597
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1598
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1598
1599
  ) -> AsyncBinaryAPIResponse:
1599
1600
  """
1600
1601
  Retrieves an object from a given bucket.
@@ -1635,7 +1636,7 @@ class AsyncTelnyx(AsyncAPIClient):
1635
1636
  extra_headers: Headers | None = None,
1636
1637
  extra_query: Query | None = None,
1637
1638
  extra_body: Body | None = None,
1638
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1639
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1639
1640
  ) -> ListBucketsResponse:
1640
1641
  """List all Buckets."""
1641
1642
  extra_headers = {"Accept": "application/xml", **(extra_headers or {})}
@@ -1651,13 +1652,13 @@ class AsyncTelnyx(AsyncAPIClient):
1651
1652
  self,
1652
1653
  bucket_name: str,
1653
1654
  *,
1654
- list_type: Literal[2] | NotGiven = NOT_GIVEN,
1655
+ list_type: Literal[2] | Omit = omit,
1655
1656
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1656
1657
  # The extra values given here take precedence over values defined on the client or passed to this method.
1657
1658
  extra_headers: Headers | None = None,
1658
1659
  extra_query: Query | None = None,
1659
1660
  extra_body: Body | None = None,
1660
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1661
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1661
1662
  ) -> ListObjectsResponse:
1662
1663
  """
1663
1664
  List all objects contained in a given bucket.
@@ -1694,14 +1695,14 @@ class AsyncTelnyx(AsyncAPIClient):
1694
1695
  *,
1695
1696
  bucket_name: str,
1696
1697
  body: FileTypes,
1697
- part_number: str | NotGiven = NOT_GIVEN,
1698
- upload_id: str | NotGiven = NOT_GIVEN,
1698
+ part_number: str | Omit = omit,
1699
+ upload_id: str | Omit = omit,
1699
1700
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1700
1701
  # The extra values given here take precedence over values defined on the client or passed to this method.
1701
1702
  extra_headers: Headers | None = None,
1702
1703
  extra_query: Query | None = None,
1703
1704
  extra_body: Body | None = None,
1704
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1705
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1705
1706
  ) -> None:
1706
1707
  """
1707
1708
  Add an object to a bucket.
telnyx/_compat.py CHANGED
@@ -12,14 +12,13 @@ from ._types import IncEx, StrBytesIntFloat
12
12
  _T = TypeVar("_T")
13
13
  _ModelT = TypeVar("_ModelT", bound=pydantic.BaseModel)
14
14
 
15
- # --------------- Pydantic v2 compatibility ---------------
15
+ # --------------- Pydantic v2, v3 compatibility ---------------
16
16
 
17
17
  # Pyright incorrectly reports some of our functions as overriding a method when they don't
18
18
  # pyright: reportIncompatibleMethodOverride=false
19
19
 
20
- PYDANTIC_V2 = pydantic.VERSION.startswith("2.")
20
+ PYDANTIC_V1 = pydantic.VERSION.startswith("1.")
21
21
 
22
- # v1 re-exports
23
22
  if TYPE_CHECKING:
24
23
 
25
24
  def parse_date(value: date | StrBytesIntFloat) -> date: # noqa: ARG001
@@ -44,90 +43,92 @@ if TYPE_CHECKING:
44
43
  ...
45
44
 
46
45
  else:
47
- if PYDANTIC_V2:
48
- from pydantic.v1.typing import (
46
+ # v1 re-exports
47
+ if PYDANTIC_V1:
48
+ from pydantic.typing import (
49
49
  get_args as get_args,
50
50
  is_union as is_union,
51
51
  get_origin as get_origin,
52
52
  is_typeddict as is_typeddict,
53
53
  is_literal_type as is_literal_type,
54
54
  )
55
- from pydantic.v1.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime
55
+ from pydantic.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime
56
56
  else:
57
- from pydantic.typing import (
57
+ from ._utils import (
58
58
  get_args as get_args,
59
59
  is_union as is_union,
60
60
  get_origin as get_origin,
61
+ parse_date as parse_date,
61
62
  is_typeddict as is_typeddict,
63
+ parse_datetime as parse_datetime,
62
64
  is_literal_type as is_literal_type,
63
65
  )
64
- from pydantic.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime
65
66
 
66
67
 
67
68
  # refactored config
68
69
  if TYPE_CHECKING:
69
70
  from pydantic import ConfigDict as ConfigDict
70
71
  else:
71
- if PYDANTIC_V2:
72
- from pydantic import ConfigDict
73
- else:
72
+ if PYDANTIC_V1:
74
73
  # TODO: provide an error message here?
75
74
  ConfigDict = None
75
+ else:
76
+ from pydantic import ConfigDict as ConfigDict
76
77
 
77
78
 
78
79
  # renamed methods / properties
79
80
  def parse_obj(model: type[_ModelT], value: object) -> _ModelT:
80
- if PYDANTIC_V2:
81
- return model.model_validate(value)
82
- else:
81
+ if PYDANTIC_V1:
83
82
  return cast(_ModelT, model.parse_obj(value)) # pyright: ignore[reportDeprecated, reportUnnecessaryCast]
83
+ else:
84
+ return model.model_validate(value)
84
85
 
85
86
 
86
87
  def field_is_required(field: FieldInfo) -> bool:
87
- if PYDANTIC_V2:
88
- return field.is_required()
89
- return field.required # type: ignore
88
+ if PYDANTIC_V1:
89
+ return field.required # type: ignore
90
+ return field.is_required()
90
91
 
91
92
 
92
93
  def field_get_default(field: FieldInfo) -> Any:
93
94
  value = field.get_default()
94
- if PYDANTIC_V2:
95
- from pydantic_core import PydanticUndefined
96
-
97
- if value == PydanticUndefined:
98
- return None
95
+ if PYDANTIC_V1:
99
96
  return value
97
+ from pydantic_core import PydanticUndefined
98
+
99
+ if value == PydanticUndefined:
100
+ return None
100
101
  return value
101
102
 
102
103
 
103
104
  def field_outer_type(field: FieldInfo) -> Any:
104
- if PYDANTIC_V2:
105
- return field.annotation
106
- return field.outer_type_ # type: ignore
105
+ if PYDANTIC_V1:
106
+ return field.outer_type_ # type: ignore
107
+ return field.annotation
107
108
 
108
109
 
109
110
  def get_model_config(model: type[pydantic.BaseModel]) -> Any:
110
- if PYDANTIC_V2:
111
- return model.model_config
112
- return model.__config__ # type: ignore
111
+ if PYDANTIC_V1:
112
+ return model.__config__ # type: ignore
113
+ return model.model_config
113
114
 
114
115
 
115
116
  def get_model_fields(model: type[pydantic.BaseModel]) -> dict[str, FieldInfo]:
116
- if PYDANTIC_V2:
117
- return model.model_fields
118
- return model.__fields__ # type: ignore
117
+ if PYDANTIC_V1:
118
+ return model.__fields__ # type: ignore
119
+ return model.model_fields
119
120
 
120
121
 
121
122
  def model_copy(model: _ModelT, *, deep: bool = False) -> _ModelT:
122
- if PYDANTIC_V2:
123
- return model.model_copy(deep=deep)
124
- return model.copy(deep=deep) # type: ignore
123
+ if PYDANTIC_V1:
124
+ return model.copy(deep=deep) # type: ignore
125
+ return model.model_copy(deep=deep)
125
126
 
126
127
 
127
128
  def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str:
128
- if PYDANTIC_V2:
129
- return model.model_dump_json(indent=indent)
130
- return model.json(indent=indent) # type: ignore
129
+ if PYDANTIC_V1:
130
+ return model.json(indent=indent) # type: ignore
131
+ return model.model_dump_json(indent=indent)
131
132
 
132
133
 
133
134
  def model_dump(
@@ -139,14 +140,14 @@ def model_dump(
139
140
  warnings: bool = True,
140
141
  mode: Literal["json", "python"] = "python",
141
142
  ) -> dict[str, Any]:
142
- if PYDANTIC_V2 or hasattr(model, "model_dump"):
143
+ if (not PYDANTIC_V1) or hasattr(model, "model_dump"):
143
144
  return model.model_dump(
144
145
  mode=mode,
145
146
  exclude=exclude,
146
147
  exclude_unset=exclude_unset,
147
148
  exclude_defaults=exclude_defaults,
148
149
  # warnings are not supported in Pydantic v1
149
- warnings=warnings if PYDANTIC_V2 else True,
150
+ warnings=True if PYDANTIC_V1 else warnings,
150
151
  )
151
152
  return cast(
152
153
  "dict[str, Any]",
@@ -159,9 +160,9 @@ def model_dump(
159
160
 
160
161
 
161
162
  def model_parse(model: type[_ModelT], data: Any) -> _ModelT:
162
- if PYDANTIC_V2:
163
- return model.model_validate(data)
164
- return model.parse_obj(data) # pyright: ignore[reportDeprecated]
163
+ if PYDANTIC_V1:
164
+ return model.parse_obj(data) # pyright: ignore[reportDeprecated]
165
+ return model.model_validate(data)
165
166
 
166
167
 
167
168
  # generic models
@@ -170,17 +171,16 @@ if TYPE_CHECKING:
170
171
  class GenericModel(pydantic.BaseModel): ...
171
172
 
172
173
  else:
173
- if PYDANTIC_V2:
174
+ if PYDANTIC_V1:
175
+ import pydantic.generics
176
+
177
+ class GenericModel(pydantic.generics.GenericModel, pydantic.BaseModel): ...
178
+ else:
174
179
  # there no longer needs to be a distinction in v2 but
175
180
  # we still have to create our own subclass to avoid
176
181
  # inconsistent MRO ordering errors
177
182
  class GenericModel(pydantic.BaseModel): ...
178
183
 
179
- else:
180
- import pydantic.generics
181
-
182
- class GenericModel(pydantic.generics.GenericModel, pydantic.BaseModel): ...
183
-
184
184
 
185
185
  # cached properties
186
186
  if TYPE_CHECKING: