telnyx 3.0.0a0__py3-none-any.whl → 3.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of telnyx might be problematic. Click here for more details.
- telnyx/__init__.py +3 -1
- telnyx/_base_client.py +12 -12
- telnyx/_client.py +68 -762
- telnyx/_compat.py +48 -48
- telnyx/_models.py +51 -45
- telnyx/_qs.py +7 -7
- telnyx/_types.py +53 -12
- telnyx/_utils/__init__.py +9 -2
- telnyx/_utils/_compat.py +45 -0
- telnyx/_utils/_datetime_parse.py +136 -0
- telnyx/_utils/_transform.py +13 -3
- telnyx/_utils/_typing.py +6 -1
- telnyx/_utils/_utils.py +4 -5
- telnyx/_version.py +1 -1
- telnyx/resources/__init__.py +73 -0
- telnyx/resources/access_ip_address.py +15 -15
- telnyx/resources/access_ip_ranges.py +13 -13
- telnyx/resources/actions/purchase.py +13 -14
- telnyx/resources/actions/register.py +11 -12
- telnyx/resources/addresses/actions.py +13 -13
- telnyx/resources/addresses/addresses.py +33 -35
- telnyx/resources/advanced_orders.py +154 -24
- telnyx/resources/ai/ai.py +7 -7
- telnyx/resources/ai/assistants/assistants.py +89 -89
- telnyx/resources/ai/assistants/canary_deploys.py +9 -9
- telnyx/resources/ai/assistants/scheduled_events.py +21 -21
- telnyx/resources/ai/assistants/tests/runs.py +13 -13
- telnyx/resources/ai/assistants/tests/test_suites/runs.py +13 -13
- telnyx/resources/ai/assistants/tests/test_suites/test_suites.py +3 -3
- telnyx/resources/ai/assistants/tests/tests.py +43 -43
- telnyx/resources/ai/assistants/tools.py +7 -7
- telnyx/resources/ai/assistants/versions.py +45 -45
- telnyx/resources/ai/audio.py +11 -11
- telnyx/resources/ai/chat.py +48 -48
- telnyx/resources/ai/clusters.py +27 -29
- telnyx/resources/ai/conversations/conversations.py +179 -45
- telnyx/resources/ai/conversations/insight_groups/insight_groups.py +23 -23
- telnyx/resources/ai/conversations/insight_groups/insights.py +5 -5
- telnyx/resources/ai/conversations/insights.py +25 -25
- telnyx/resources/ai/conversations/messages.py +3 -136
- telnyx/resources/ai/embeddings/buckets.py +7 -7
- telnyx/resources/ai/embeddings/embeddings.py +23 -24
- telnyx/resources/ai/fine_tuning/jobs.py +13 -13
- telnyx/resources/audit_events.py +9 -9
- telnyx/resources/authentication_providers.py +29 -29
- telnyx/resources/available_phone_number_blocks.py +5 -5
- telnyx/resources/available_phone_numbers.py +5 -5
- telnyx/resources/balance.py +3 -3
- telnyx/resources/billing_groups.py +17 -17
- telnyx/resources/brand/brand.py +121 -117
- telnyx/resources/brand/external_vetting.py +9 -9
- telnyx/resources/bulk_sim_card_actions.py +11 -11
- telnyx/resources/bundle_pricing/billing_bundles.py +13 -13
- telnyx/resources/bundle_pricing/user_bundles.py +35 -35
- telnyx/resources/call_control_applications.py +64 -68
- telnyx/resources/call_events.py +7 -7
- telnyx/resources/calls/actions.py +695 -697
- telnyx/resources/calls/calls.py +116 -110
- telnyx/resources/campaign/campaign.py +47 -47
- telnyx/resources/campaign/osr.py +3 -3
- telnyx/resources/campaign/usecase.py +3 -3
- telnyx/resources/campaign_builder/brand.py +3 -3
- telnyx/resources/campaign_builder/campaign_builder.py +68 -68
- telnyx/resources/channel_zones.py +7 -7
- telnyx/resources/charges_breakdown.py +7 -7
- telnyx/resources/charges_summary.py +3 -3
- telnyx/resources/comments.py +17 -17
- telnyx/resources/conferences/actions.py +123 -140
- telnyx/resources/conferences/conferences.py +37 -41
- telnyx/resources/connections.py +15 -15
- telnyx/resources/country_coverage.py +5 -5
- telnyx/resources/credential_connections/actions.py +3 -3
- telnyx/resources/credential_connections/credential_connections.py +96 -96
- telnyx/resources/custom_storage_credentials.py +9 -9
- telnyx/resources/customer_service_records.py +21 -23
- telnyx/resources/detail_records.py +9 -11
- telnyx/resources/dialogflow_connections.py +25 -25
- telnyx/resources/document_links.py +7 -7
- telnyx/resources/documents.py +124 -43
- telnyx/resources/dynamic_emergency_addresses.py +23 -23
- telnyx/resources/dynamic_emergency_endpoints.py +13 -13
- telnyx/resources/enum.py +3 -3
- telnyx/resources/external_connections/civic_addresses.py +7 -7
- telnyx/resources/external_connections/external_connections.py +42 -42
- telnyx/resources/external_connections/log_messages.py +11 -11
- telnyx/resources/external_connections/phone_numbers.py +13 -13
- telnyx/resources/external_connections/releases.py +9 -9
- telnyx/resources/external_connections/uploads.py +27 -29
- telnyx/resources/fax_applications.py +48 -48
- telnyx/resources/faxes/actions.py +5 -5
- telnyx/resources/faxes/faxes.py +35 -35
- telnyx/resources/fqdn_connections.py +94 -94
- telnyx/resources/fqdns.py +25 -25
- telnyx/resources/global_ip_allowed_ports.py +3 -3
- telnyx/resources/global_ip_assignment_health.py +5 -5
- telnyx/resources/global_ip_assignments.py +19 -19
- telnyx/resources/global_ip_assignments_usage.py +5 -5
- telnyx/resources/global_ip_health_check_types.py +3 -3
- telnyx/resources/global_ip_health_checks.py +17 -17
- telnyx/resources/global_ip_latency.py +5 -5
- telnyx/resources/global_ip_protocols.py +3 -3
- telnyx/resources/global_ip_usage.py +5 -5
- telnyx/resources/global_ips.py +17 -17
- telnyx/resources/inbound_channels.py +5 -5
- telnyx/resources/integration_secrets.py +17 -17
- telnyx/resources/inventory_coverage.py +5 -5
- telnyx/resources/invoices.py +11 -11
- telnyx/resources/ip_connections.py +94 -94
- telnyx/resources/ips.py +23 -23
- telnyx/resources/ledger_billing_group_reports.py +9 -9
- telnyx/resources/legacy/__init__.py +33 -0
- telnyx/resources/legacy/legacy.py +102 -0
- telnyx/resources/legacy/reporting/__init__.py +47 -0
- telnyx/resources/legacy/reporting/batch_detail_records/__init__.py +61 -0
- telnyx/resources/legacy/reporting/batch_detail_records/batch_detail_records.py +166 -0
- telnyx/resources/legacy/reporting/batch_detail_records/messaging.py +481 -0
- telnyx/resources/legacy/reporting/batch_detail_records/speech_to_text.py +399 -0
- telnyx/resources/legacy/reporting/batch_detail_records/voice.py +538 -0
- telnyx/resources/legacy/reporting/reporting.py +134 -0
- telnyx/resources/legacy/reporting/usage_reports/__init__.py +61 -0
- telnyx/resources/legacy/reporting/usage_reports/messaging.py +471 -0
- telnyx/resources/legacy/reporting/usage_reports/number_lookup.py +464 -0
- telnyx/resources/legacy/reporting/usage_reports/usage_reports.py +288 -0
- telnyx/resources/legacy/reporting/usage_reports/voice.py +493 -0
- telnyx/resources/list.py +5 -5
- telnyx/resources/managed_accounts/actions.py +7 -7
- telnyx/resources/managed_accounts/managed_accounts.py +33 -33
- telnyx/resources/media.py +23 -23
- telnyx/resources/messages/messages.py +124 -124
- telnyx/resources/messages/rcs.py +7 -7
- telnyx/resources/messaging/rcs/agents.py +15 -15
- telnyx/resources/messaging/rcs/rcs.py +9 -11
- telnyx/resources/messaging_hosted_number_orders/actions.py +7 -7
- telnyx/resources/messaging_hosted_number_orders/messaging_hosted_number_orders.py +26 -26
- telnyx/resources/messaging_hosted_numbers.py +3 -3
- telnyx/resources/messaging_numbers_bulk_updates.py +7 -9
- telnyx/resources/messaging_optouts.py +11 -11
- telnyx/resources/messaging_profiles/autoresp_configs.py +25 -26
- telnyx/resources/messaging_profiles/messaging_profiles.py +76 -76
- telnyx/resources/messaging_tollfree/verification/requests.py +27 -27
- telnyx/resources/messaging_url_domains.py +5 -5
- telnyx/resources/messsages.py +11 -11
- telnyx/resources/mobile_network_operators.py +7 -7
- telnyx/resources/mobile_push_credentials.py +23 -23
- telnyx/resources/network_coverage.py +9 -9
- telnyx/resources/networks/default_gateway.py +9 -9
- telnyx/resources/networks/networks.py +21 -21
- telnyx/resources/notification_channels.py +27 -27
- telnyx/resources/notification_event_conditions.py +7 -7
- telnyx/resources/notification_events.py +5 -5
- telnyx/resources/notification_profiles.py +17 -17
- telnyx/resources/notification_settings.py +21 -21
- telnyx/resources/number_block_orders.py +17 -17
- telnyx/resources/number_lookup.py +5 -5
- telnyx/resources/number_order_phone_numbers.py +13 -13
- telnyx/resources/number_orders.py +27 -27
- telnyx/resources/number_reservations/actions.py +3 -3
- telnyx/resources/number_reservations/number_reservations.py +15 -15
- telnyx/resources/numbers_features.py +5 -7
- telnyx/resources/oauth.py +857 -0
- telnyx/resources/oauth_clients.py +711 -0
- telnyx/resources/oauth_grants.py +349 -0
- telnyx/resources/operator_connect/actions.py +3 -3
- telnyx/resources/ota_updates.py +9 -9
- telnyx/resources/outbound_voice_profiles.py +66 -66
- telnyx/resources/partner_campaigns.py +25 -25
- telnyx/resources/payment/auto_recharge_prefs.py +15 -15
- telnyx/resources/phone_number_assignment_by_profile.py +15 -15
- telnyx/resources/phone_number_blocks/jobs.py +13 -13
- telnyx/resources/phone_number_campaigns.py +19 -19
- telnyx/resources/phone_numbers/actions.py +9 -11
- telnyx/resources/phone_numbers/csv_downloads.py +13 -13
- telnyx/resources/phone_numbers/jobs.py +54 -42
- telnyx/resources/phone_numbers/messaging.py +13 -13
- telnyx/resources/phone_numbers/phone_numbers.py +39 -40
- telnyx/resources/phone_numbers/voice.py +31 -31
- telnyx/resources/phone_numbers/voicemail.py +15 -15
- telnyx/resources/phone_numbers_regulatory_requirements.py +5 -5
- telnyx/resources/portability_checks.py +5 -7
- telnyx/resources/porting/events.py +11 -11
- telnyx/resources/porting/loa_configurations.py +17 -17
- telnyx/resources/porting/porting.py +3 -3
- telnyx/resources/porting/reports.py +11 -11
- telnyx/resources/porting_orders/action_requirements.py +11 -11
- telnyx/resources/porting_orders/actions.py +13 -13
- telnyx/resources/porting_orders/activation_jobs.py +11 -11
- telnyx/resources/porting_orders/additional_documents.py +15 -15
- telnyx/resources/porting_orders/associated_phone_numbers.py +13 -13
- telnyx/resources/porting_orders/comments.py +9 -9
- telnyx/resources/porting_orders/phone_number_blocks.py +13 -13
- telnyx/resources/porting_orders/phone_number_configurations.py +13 -13
- telnyx/resources/porting_orders/phone_number_extensions.py +13 -13
- telnyx/resources/porting_orders/porting_orders.py +82 -70
- telnyx/resources/porting_orders/verification_codes.py +20 -20
- telnyx/resources/porting_phone_numbers.py +7 -7
- telnyx/resources/portouts/comments.py +7 -7
- telnyx/resources/portouts/events.py +11 -11
- telnyx/resources/portouts/portouts.py +25 -23
- telnyx/resources/portouts/reports.py +11 -11
- telnyx/resources/portouts/supporting_documents.py +7 -7
- telnyx/resources/private_wireless_gateways.py +25 -25
- telnyx/resources/public_internet_gateways.py +19 -19
- telnyx/resources/queues/calls.py +7 -7
- telnyx/resources/queues/queues.py +3 -3
- telnyx/resources/recording_transcriptions.py +7 -7
- telnyx/resources/recordings/actions.py +5 -7
- telnyx/resources/recordings/recordings.py +11 -11
- telnyx/resources/regions.py +3 -3
- telnyx/resources/regulatory_requirements.py +5 -5
- telnyx/resources/reports/cdr_usage_reports.py +9 -9
- telnyx/resources/reports/mdr_usage_reports.py +22 -22
- telnyx/resources/reports/reports.py +47 -48
- telnyx/resources/requirement_groups.py +23 -23
- telnyx/resources/requirement_types.py +9 -11
- telnyx/resources/requirements.py +11 -11
- telnyx/resources/room_compositions.py +27 -27
- telnyx/resources/room_participants.py +9 -9
- telnyx/resources/room_recordings.py +17 -17
- telnyx/resources/rooms/actions.py +11 -11
- telnyx/resources/rooms/rooms.py +43 -43
- telnyx/resources/rooms/sessions/actions.py +22 -22
- telnyx/resources/rooms/sessions/sessions.py +27 -27
- telnyx/resources/seti.py +5 -5
- telnyx/resources/short_codes.py +11 -11
- telnyx/resources/sim_card_data_usage_notifications.py +21 -21
- telnyx/resources/sim_card_groups/actions.py +23 -23
- telnyx/resources/sim_card_groups/sim_card_groups.py +29 -29
- telnyx/resources/sim_card_order_preview.py +3 -3
- telnyx/resources/sim_card_orders.py +11 -11
- telnyx/resources/sim_cards/actions.py +29 -31
- telnyx/resources/sim_cards/sim_cards.py +48 -48
- telnyx/resources/siprec_connectors.py +13 -13
- telnyx/resources/storage/buckets/buckets.py +5 -5
- telnyx/resources/storage/buckets/ssl_certificate.py +11 -11
- telnyx/resources/storage/buckets/usage.py +5 -5
- telnyx/resources/storage/migration_sources.py +11 -11
- telnyx/resources/storage/migrations/actions.py +3 -3
- telnyx/resources/storage/migrations/migrations.py +9 -9
- telnyx/resources/storage/storage.py +3 -3
- telnyx/resources/sub_number_orders.py +17 -17
- telnyx/resources/sub_number_orders_report.py +19 -19
- telnyx/resources/telephony_credentials.py +31 -31
- telnyx/resources/texml/accounts/accounts.py +15 -15
- telnyx/resources/texml/accounts/calls/calls.py +145 -145
- telnyx/resources/texml/accounts/calls/recordings.py +5 -5
- telnyx/resources/texml/accounts/calls/recordings_json.py +19 -19
- telnyx/resources/texml/accounts/calls/siprec.py +5 -5
- telnyx/resources/texml/accounts/calls/streams.py +5 -5
- telnyx/resources/texml/accounts/conferences/conferences.py +31 -31
- telnyx/resources/texml/accounts/conferences/participants.py +123 -123
- telnyx/resources/texml/accounts/recordings/json.py +5 -5
- telnyx/resources/texml/accounts/transcriptions/json.py +5 -5
- telnyx/resources/texml/calls.py +79 -79
- telnyx/resources/texml/texml.py +3 -3
- telnyx/resources/texml_applications.py +65 -66
- telnyx/resources/text_to_speech.py +9 -9
- telnyx/resources/usage_reports.py +31 -32
- telnyx/resources/user_addresses.py +29 -31
- telnyx/resources/user_tags.py +5 -5
- telnyx/resources/verifications/actions.py +7 -7
- telnyx/resources/verifications/by_phone_number/actions.py +3 -3
- telnyx/resources/verifications/by_phone_number/by_phone_number.py +3 -3
- telnyx/resources/verifications/verifications.py +29 -19
- telnyx/resources/verified_numbers/actions.py +3 -3
- telnyx/resources/verified_numbers/verified_numbers.py +36 -15
- telnyx/resources/verify_profiles.py +226 -44
- telnyx/resources/virtual_cross_connects.py +45 -45
- telnyx/resources/virtual_cross_connects_coverage.py +9 -9
- telnyx/resources/webhook_deliveries.py +9 -9
- telnyx/resources/webhooks.py +34 -0
- telnyx/resources/well_known.py +198 -0
- telnyx/resources/wireguard_interfaces.py +17 -17
- telnyx/resources/wireguard_peers.py +21 -21
- telnyx/resources/wireless/detail_records_reports.py +17 -17
- telnyx/resources/wireless/wireless.py +3 -3
- telnyx/resources/wireless_blocklist_values.py +3 -3
- telnyx/resources/wireless_blocklists.py +29 -30
- telnyx/types/__init__.py +159 -11
- telnyx/types/actions/purchase_create_params.py +3 -2
- telnyx/types/actions/register_create_params.py +4 -3
- telnyx/types/addresses/action_validate_response.py +6 -1
- telnyx/types/advanced_order_create_params.py +3 -0
- telnyx/types/advanced_order_update_params.py +27 -0
- telnyx/types/ai/__init__.py +1 -0
- telnyx/types/ai/chat_create_completion_params.py +3 -2
- telnyx/types/ai/cluster_compute_params.py +3 -2
- telnyx/types/ai/{conversations/message_create_params.py → conversation_add_message_params.py} +6 -5
- telnyx/types/ai/conversations/__init__.py +0 -1
- telnyx/types/ai/embedding_list_params.py +3 -2
- telnyx/types/ai/inference_embedding_bucket_ids_param.py +3 -2
- telnyx/types/ai/inference_embedding_transfer_tool_params.py +6 -0
- telnyx/types/ai/inference_embedding_transfer_tool_params_param.py +6 -0
- telnyx/types/ai/inference_embedding_webhook_tool_params.py +2 -0
- telnyx/types/ai/inference_embedding_webhook_tool_params_param.py +8 -4
- telnyx/types/ai/voice_settings.py +49 -2
- telnyx/types/ai/voice_settings_param.py +49 -2
- telnyx/types/brand_create_params.py +2 -1
- telnyx/types/brand_update_params.py +2 -1
- telnyx/types/bundle_pricing/billing_bundle_list_params.py +4 -3
- telnyx/types/bundle_pricing/user_bundle_list_params.py +4 -3
- telnyx/types/bundle_pricing/user_bundle_list_unused_params.py +4 -3
- telnyx/types/call_ai_gather_ended_webhook_event.py +78 -0
- telnyx/types/call_ai_gather_message_history_updated_webhook_event.py +69 -0
- telnyx/types/call_ai_gather_partial_results_webhook_event.py +75 -0
- telnyx/types/call_answered_webhook_event.py +75 -0
- telnyx/types/call_bridged_webhook_event.py +58 -0
- telnyx/types/call_control_application_update_params.py +3 -2
- telnyx/types/call_conversation_ended_webhook_event.py +84 -0
- telnyx/types/call_conversation_insights_generated_webhook_event.py +67 -0
- telnyx/types/call_dial_params.py +14 -6
- telnyx/types/call_dtmf_received_webhook_event.py +61 -0
- telnyx/types/call_enqueued_webhook_event.py +59 -0
- telnyx/types/call_fork_started_webhook_event.py +53 -0
- telnyx/types/call_fork_stopped_webhook_event.py +53 -0
- telnyx/types/call_gather_ended_webhook_event.py +64 -0
- telnyx/types/call_hangup_webhook_event.py +150 -0
- telnyx/types/call_initiated_webhook_event.py +96 -0
- telnyx/types/call_left_queue_webhook_event.py +62 -0
- telnyx/types/call_machine_detection_ended_webhook_event.py +61 -0
- telnyx/types/call_machine_greeting_ended_webhook_event.py +61 -0
- telnyx/types/call_machine_premium_detection_ended_webhook_event.py +63 -0
- telnyx/types/call_machine_premium_greeting_ended_webhook_event.py +61 -0
- telnyx/types/call_playback_ended_webhook_event.py +70 -0
- telnyx/types/call_playback_started_webhook_event.py +62 -0
- telnyx/types/call_recording_error_webhook_event.py +60 -0
- telnyx/types/call_recording_saved_webhook_event.py +94 -0
- telnyx/types/call_recording_transcription_saved_webhook_event.py +71 -0
- telnyx/types/call_refer_completed_webhook_event.py +61 -0
- telnyx/types/call_refer_failed_webhook_event.py +61 -0
- telnyx/types/call_refer_started_webhook_event.py +61 -0
- telnyx/types/call_siprec_failed_webhook_event.py +53 -0
- telnyx/types/call_siprec_started_webhook_event.py +50 -0
- telnyx/types/call_siprec_stopped_webhook_event.py +53 -0
- telnyx/types/call_speak_ended_webhook_event.py +53 -0
- telnyx/types/call_speak_started_webhook_event.py +50 -0
- telnyx/types/call_streaming_failed_webhook_event.py +70 -0
- telnyx/types/call_streaming_started_webhook_event.py +53 -0
- telnyx/types/call_streaming_stopped_webhook_event.py +53 -0
- telnyx/types/calls/action_answer_params.py +1 -2
- telnyx/types/calls/action_gather_using_ai_params.py +5 -8
- telnyx/types/calls/action_start_streaming_params.py +4 -2
- telnyx/types/calls/action_transfer_params.py +50 -0
- telnyx/types/calls/transcription_engine_a_config_param.py +4 -3
- telnyx/types/campaign_builder_create_params.py +4 -3
- telnyx/types/campaign_status_update_webhook_event.py +26 -0
- telnyx/types/campaign_submit_appeal_response.py +0 -3
- telnyx/types/conference_created_webhook_event.py +53 -0
- telnyx/types/conference_ended_webhook_event.py +56 -0
- telnyx/types/conference_floor_changed_webhook_event.py +45 -0
- telnyx/types/conference_participant_joined_webhook_event.py +53 -0
- telnyx/types/conference_participant_left_webhook_event.py +53 -0
- telnyx/types/conference_participant_playback_ended_webhook_event.py +65 -0
- telnyx/types/conference_participant_playback_started_webhook_event.py +65 -0
- telnyx/types/conference_participant_speak_ended_webhook_event.py +56 -0
- telnyx/types/conference_participant_speak_started_webhook_event.py +56 -0
- telnyx/types/conference_playback_ended_webhook_event.py +49 -0
- telnyx/types/conference_playback_started_webhook_event.py +49 -0
- telnyx/types/conference_recording_saved_webhook_event.py +103 -0
- telnyx/types/conference_speak_ended_webhook_event.py +40 -0
- telnyx/types/conference_speak_started_webhook_event.py +40 -0
- telnyx/types/conferences/action_hold_params.py +3 -2
- telnyx/types/conferences/action_join_params.py +3 -2
- telnyx/types/conferences/action_mute_params.py +3 -2
- telnyx/types/conferences/action_play_params.py +2 -2
- telnyx/types/conferences/action_speak_params.py +3 -2
- telnyx/types/conferences/action_stop_params.py +3 -2
- telnyx/types/conferences/action_unhold_params.py +3 -2
- telnyx/types/conferences/action_unmute_params.py +3 -2
- telnyx/types/conferences/action_update_params.py +3 -2
- telnyx/types/country_coverage_retrieve_country_response.py +7 -0
- telnyx/types/country_coverage_retrieve_response.py +7 -0
- telnyx/types/credential_connection_create_params.py +3 -2
- telnyx/types/credential_connection_update_params.py +3 -2
- telnyx/types/credential_inbound_param.py +3 -2
- telnyx/types/custom_sip_header.py +13 -0
- telnyx/types/customer_service_record_list_params.py +2 -1
- telnyx/types/customer_service_record_status_changed_webhook_event.py +55 -0
- telnyx/types/customer_service_record_verify_phone_number_coverage_params.py +3 -2
- telnyx/types/delivery_update_webhook_event.py +40 -0
- telnyx/types/detail_record_list_params.py +4 -2
- telnyx/types/document_generate_download_link_response.py +14 -0
- telnyx/types/document_list_params.py +2 -1
- telnyx/types/external_connection_create_params.py +4 -2
- telnyx/types/external_connection_update_params.py +4 -2
- telnyx/types/external_connections/civic_address_list_params.py +3 -2
- telnyx/types/external_connections/upload_create_params.py +3 -1
- telnyx/types/fax_application_create_params.py +3 -2
- telnyx/types/fax_application_update_params.py +3 -2
- telnyx/types/fax_delivered_webhook_event.py +69 -0
- telnyx/types/fax_failed_webhook_event.py +66 -0
- telnyx/types/fax_media_processed_webhook_event.py +63 -0
- telnyx/types/fax_queued_webhook_event.py +63 -0
- telnyx/types/fax_sending_started_webhook_event.py +63 -0
- telnyx/types/fqdn_connection_create_params.py +3 -2
- telnyx/types/fqdn_connection_update_params.py +3 -2
- telnyx/types/global_ip_latency_retrieve_response.py +7 -7
- telnyx/types/inbound_fqdn_param.py +4 -2
- telnyx/types/inbound_ip_param.py +3 -2
- telnyx/types/inbound_message_webhook_event.py +227 -0
- telnyx/types/ip_connection_create_params.py +4 -3
- telnyx/types/ip_connection_update_params.py +3 -2
- telnyx/types/legacy/__init__.py +3 -0
- telnyx/types/legacy/reporting/__init__.py +10 -0
- telnyx/types/legacy/reporting/batch_detail_records/__init__.py +20 -0
- telnyx/types/legacy/reporting/batch_detail_records/messaging_create_params.py +77 -0
- telnyx/types/legacy/reporting/batch_detail_records/messaging_create_response.py +68 -0
- telnyx/types/legacy/reporting/batch_detail_records/messaging_delete_response.py +68 -0
- telnyx/types/legacy/reporting/batch_detail_records/messaging_list_response.py +80 -0
- telnyx/types/legacy/reporting/batch_detail_records/messaging_retrieve_response.py +68 -0
- telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_create_params.py +19 -0
- telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_create_response.py +31 -0
- telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_delete_response.py +31 -0
- telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_list_response.py +31 -0
- telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_retrieve_response.py +31 -0
- telnyx/types/legacy/reporting/batch_detail_records/voice_create_params.py +79 -0
- telnyx/types/legacy/reporting/batch_detail_records/voice_create_response.py +91 -0
- telnyx/types/legacy/reporting/batch_detail_records/voice_delete_response.py +91 -0
- telnyx/types/legacy/reporting/batch_detail_records/voice_list_response.py +102 -0
- telnyx/types/legacy/reporting/batch_detail_records/voice_retrieve_fields_response.py +23 -0
- telnyx/types/legacy/reporting/batch_detail_records/voice_retrieve_response.py +91 -0
- telnyx/types/legacy/reporting/usage_report_retrieve_speech_to_text_params.py +17 -0
- telnyx/types/legacy/reporting/usage_report_retrieve_speech_to_text_response.py +11 -0
- telnyx/types/legacy/reporting/usage_reports/__init__.py +18 -0
- telnyx/types/legacy/reporting/usage_reports/messaging_create_params.py +29 -0
- telnyx/types/legacy/reporting/usage_reports/messaging_create_response.py +43 -0
- telnyx/types/legacy/reporting/usage_reports/messaging_delete_response.py +43 -0
- telnyx/types/legacy/reporting/usage_reports/messaging_list_params.py +15 -0
- telnyx/types/legacy/reporting/usage_reports/messaging_list_response.py +54 -0
- telnyx/types/legacy/reporting/usage_reports/messaging_retrieve_response.py +43 -0
- telnyx/types/legacy/reporting/usage_reports/number_lookup_create_params.py +26 -0
- telnyx/types/legacy/reporting/usage_reports/number_lookup_list_params.py +13 -0
- telnyx/types/legacy/reporting/usage_reports/voice_create_params.py +40 -0
- telnyx/types/legacy/reporting/usage_reports/voice_create_response.py +48 -0
- telnyx/types/legacy/reporting/usage_reports/voice_delete_response.py +48 -0
- telnyx/types/legacy/reporting/usage_reports/voice_list_params.py +15 -0
- telnyx/types/legacy/reporting/usage_reports/voice_list_response.py +59 -0
- telnyx/types/legacy/reporting/usage_reports/voice_retrieve_response.py +48 -0
- telnyx/types/media_list_params.py +3 -2
- telnyx/types/message_schedule_params.py +3 -2
- telnyx/types/message_send_group_mms_params.py +3 -3
- telnyx/types/message_send_long_code_params.py +2 -2
- telnyx/types/message_send_number_pool_params.py +3 -2
- telnyx/types/message_send_params.py +3 -2
- telnyx/types/message_send_short_code_params.py +2 -2
- telnyx/types/messaging/rc_list_bulk_capabilities_params.py +3 -2
- telnyx/types/messaging_hosted_number_order_check_eligibility_params.py +3 -2
- telnyx/types/messaging_hosted_number_order_create_params.py +3 -2
- telnyx/types/messaging_hosted_number_order_create_verification_codes_params.py +3 -2
- telnyx/types/messaging_numbers_bulk_update_create_params.py +3 -2
- telnyx/types/messaging_profile_create_params.py +3 -2
- telnyx/types/messaging_profile_update_params.py +3 -2
- telnyx/types/messaging_profiles/autoresp_config_create_params.py +3 -2
- telnyx/types/messaging_profiles/autoresp_config_update_params.py +3 -2
- telnyx/types/messsage_rcs_params.py +2 -2
- telnyx/types/number_order_status_update_webhook_event.py +38 -0
- telnyx/types/numbers_feature_create_params.py +3 -2
- telnyx/types/oauth_authorize_params.py +30 -0
- telnyx/types/oauth_client_create_params.py +39 -0
- telnyx/types/oauth_client_create_response.py +63 -0
- telnyx/types/oauth_client_list_params.py +38 -0
- telnyx/types/oauth_client_list_response.py +79 -0
- telnyx/types/oauth_client_retrieve_response.py +63 -0
- telnyx/types/oauth_client_update_params.py +36 -0
- telnyx/types/oauth_client_update_response.py +63 -0
- telnyx/types/oauth_create_grant_params.py +15 -0
- telnyx/types/oauth_create_grant_response.py +10 -0
- telnyx/types/oauth_exchange_token_params.py +33 -0
- telnyx/types/oauth_exchange_token_response.py +25 -0
- telnyx/types/oauth_grant_list_params.py +17 -0
- telnyx/types/oauth_grant_list_response.py +49 -0
- telnyx/types/oauth_grant_retrieve_response.py +33 -0
- telnyx/types/oauth_grant_revoke_response.py +33 -0
- telnyx/types/oauth_introspect_token_params.py +12 -0
- telnyx/types/oauth_introspect_token_response.py +30 -0
- telnyx/types/oauth_register_client_params.py +39 -0
- telnyx/types/oauth_register_client_response.py +45 -0
- telnyx/types/oauth_retrieve_consent_response.py +47 -0
- telnyx/types/oauth_retrieve_jwks_response.py +25 -0
- telnyx/types/outbound_call_recording_param.py +3 -2
- telnyx/types/outbound_voice_profile_create_params.py +4 -3
- telnyx/types/outbound_voice_profile_update_params.py +4 -3
- telnyx/types/phone_number_delete_response.py +7 -0
- telnyx/types/phone_number_detailed.py +7 -0
- telnyx/types/phone_number_list_params.py +9 -2
- telnyx/types/phone_number_slim_list_params.py +3 -2
- telnyx/types/phone_number_update_params.py +3 -2
- telnyx/types/phone_numbers/action_verify_ownership_params.py +3 -2
- telnyx/types/phone_numbers/job_delete_batch_params.py +3 -2
- telnyx/types/phone_numbers/job_update_batch_params.py +10 -3
- telnyx/types/phone_numbers/job_update_emergency_settings_batch_params.py +4 -2
- telnyx/types/portability_check_run_params.py +3 -2
- telnyx/types/porting/export_porting_orders_csv_report_param.py +2 -1
- telnyx/types/porting_order.py +3 -0
- telnyx/types/porting_order_create_params.py +6 -2
- telnyx/types/porting_order_list_params.py +52 -31
- telnyx/types/porting_order_phone_number_configuration_param.py +3 -2
- telnyx/types/porting_order_update_params.py +2 -0
- telnyx/types/porting_orders/action_requirement_list_params.py +3 -2
- telnyx/types/porting_orders/phone_number_block_list_params.py +5 -3
- telnyx/types/porting_orders/phone_number_configuration_list_params.py +22 -21
- telnyx/types/porting_orders/verification_code_send_params.py +3 -2
- telnyx/types/portout_list_params.py +11 -3
- telnyx/types/portouts/export_portouts_csv_report_param.py +3 -2
- telnyx/types/recordings/action_delete_params.py +3 -2
- telnyx/types/replaced_link_click_webhook_event.py +32 -0
- telnyx/types/report_list_wdrs_params.py +3 -2
- telnyx/types/reports/mdr_usage_report_fetch_sync_params.py +3 -2
- telnyx/types/rooms/sessions/action_kick_params.py +5 -3
- telnyx/types/rooms/sessions/action_mute_params.py +5 -3
- telnyx/types/rooms/sessions/action_unmute_params.py +5 -3
- telnyx/types/shared/simple_sim_card.py +15 -0
- telnyx/types/sim_card.py +12 -0
- telnyx/types/sim_card_list_params.py +2 -1
- telnyx/types/sim_card_update_params.py +4 -3
- telnyx/types/sim_cards/action_bulk_set_public_ips_params.py +3 -2
- telnyx/types/sim_cards/action_validate_registration_codes_params.py +3 -2
- telnyx/types/sip_header.py +15 -0
- telnyx/types/stream_bidirectional_codec.py +1 -1
- telnyx/types/stream_codec.py +1 -1
- telnyx/types/streaming_failed_webhook_event.py +70 -0
- telnyx/types/streaming_started_webhook_event.py +53 -0
- telnyx/types/streaming_stopped_webhook_event.py +53 -0
- telnyx/types/texml_application_create_params.py +2 -2
- telnyx/types/texml_application_update_params.py +2 -2
- telnyx/types/transcription_webhook_event.py +72 -0
- telnyx/types/unwrap_webhook_event.py +138 -0
- telnyx/types/usage_report_list_params.py +5 -4
- telnyx/types/verification_trigger_call_params.py +7 -0
- telnyx/types/verified_number_create_params.py +10 -0
- telnyx/types/verify_profile.py +18 -3
- telnyx/types/verify_profile_create_params.py +6 -4
- telnyx/types/verify_profile_create_template_params.py +12 -0
- telnyx/types/verify_profile_create_template_response.py +17 -0
- telnyx/types/verify_profile_update_params.py +6 -4
- telnyx/types/verify_profile_update_template_params.py +12 -0
- telnyx/types/verify_profile_update_template_response.py +17 -0
- telnyx/types/video_region_param.py +4 -2
- telnyx/types/well_known_retrieve_authorization_server_metadata_response.py +42 -0
- telnyx/types/well_known_retrieve_protected_resource_metadata_response.py +15 -0
- telnyx/types/wireless_blocklist_create_params.py +3 -2
- telnyx/types/wireless_blocklist_update_params.py +3 -2
- {telnyx-3.0.0a0.dist-info → telnyx-3.1.0.dist-info}/METADATA +60 -19
- {telnyx-3.0.0a0.dist-info → telnyx-3.1.0.dist-info}/RECORD +545 -398
- telnyx/types/client_create_bucket_params.py +0 -13
- telnyx/types/client_delete_objects_params.py +0 -20
- telnyx/types/client_get_object_params.py +0 -15
- telnyx/types/client_list_objects_params.py +0 -13
- telnyx/types/client_put_object_params.py +0 -20
- telnyx/types/list_buckets_response.py +0 -20
- telnyx/types/list_objects_response.py +0 -24
- {telnyx-3.0.0a0.dist-info → telnyx-3.1.0.dist-info}/WHEEL +0 -0
- {telnyx-3.0.0a0.dist-info → telnyx-3.1.0.dist-info}/licenses/LICENSE +0 -0
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
|
-
|
|
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
|
-
|
|
48
|
-
|
|
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.
|
|
55
|
+
from pydantic.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime
|
|
56
56
|
else:
|
|
57
|
-
from
|
|
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
|
|
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
|
|
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
|
|
88
|
-
return field.
|
|
89
|
-
return field.
|
|
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
|
|
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
|
|
105
|
-
return field.
|
|
106
|
-
return field.
|
|
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
|
|
111
|
-
return model.
|
|
112
|
-
return model.
|
|
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
|
|
117
|
-
return model.
|
|
118
|
-
return model.
|
|
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
|
|
123
|
-
return model.
|
|
124
|
-
return model.
|
|
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
|
|
129
|
-
return model.
|
|
130
|
-
return model.
|
|
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
|
|
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=
|
|
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
|
|
163
|
-
return model.
|
|
164
|
-
return model.
|
|
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
|
|
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:
|
telnyx/_models.py
CHANGED
|
@@ -50,7 +50,7 @@ from ._utils import (
|
|
|
50
50
|
strip_annotated_type,
|
|
51
51
|
)
|
|
52
52
|
from ._compat import (
|
|
53
|
-
|
|
53
|
+
PYDANTIC_V1,
|
|
54
54
|
ConfigDict,
|
|
55
55
|
GenericModel as BaseGenericModel,
|
|
56
56
|
get_args,
|
|
@@ -81,11 +81,7 @@ class _ConfigProtocol(Protocol):
|
|
|
81
81
|
|
|
82
82
|
|
|
83
83
|
class BaseModel(pydantic.BaseModel):
|
|
84
|
-
if
|
|
85
|
-
model_config: ClassVar[ConfigDict] = ConfigDict(
|
|
86
|
-
extra="allow", defer_build=coerce_boolean(os.environ.get("DEFER_PYDANTIC_BUILD", "true"))
|
|
87
|
-
)
|
|
88
|
-
else:
|
|
84
|
+
if PYDANTIC_V1:
|
|
89
85
|
|
|
90
86
|
@property
|
|
91
87
|
@override
|
|
@@ -95,6 +91,10 @@ class BaseModel(pydantic.BaseModel):
|
|
|
95
91
|
|
|
96
92
|
class Config(pydantic.BaseConfig): # pyright: ignore[reportDeprecated]
|
|
97
93
|
extra: Any = pydantic.Extra.allow # type: ignore
|
|
94
|
+
else:
|
|
95
|
+
model_config: ClassVar[ConfigDict] = ConfigDict(
|
|
96
|
+
extra="allow", defer_build=coerce_boolean(os.environ.get("DEFER_PYDANTIC_BUILD", "true"))
|
|
97
|
+
)
|
|
98
98
|
|
|
99
99
|
def to_dict(
|
|
100
100
|
self,
|
|
@@ -215,25 +215,25 @@ class BaseModel(pydantic.BaseModel):
|
|
|
215
215
|
if key not in model_fields:
|
|
216
216
|
parsed = construct_type(value=value, type_=extra_field_type) if extra_field_type is not None else value
|
|
217
217
|
|
|
218
|
-
if
|
|
219
|
-
_extra[key] = parsed
|
|
220
|
-
else:
|
|
218
|
+
if PYDANTIC_V1:
|
|
221
219
|
_fields_set.add(key)
|
|
222
220
|
fields_values[key] = parsed
|
|
221
|
+
else:
|
|
222
|
+
_extra[key] = parsed
|
|
223
223
|
|
|
224
224
|
object.__setattr__(m, "__dict__", fields_values)
|
|
225
225
|
|
|
226
|
-
if
|
|
227
|
-
# these properties are copied from Pydantic's `model_construct()` method
|
|
228
|
-
object.__setattr__(m, "__pydantic_private__", None)
|
|
229
|
-
object.__setattr__(m, "__pydantic_extra__", _extra)
|
|
230
|
-
object.__setattr__(m, "__pydantic_fields_set__", _fields_set)
|
|
231
|
-
else:
|
|
226
|
+
if PYDANTIC_V1:
|
|
232
227
|
# init_private_attributes() does not exist in v2
|
|
233
228
|
m._init_private_attributes() # type: ignore
|
|
234
229
|
|
|
235
230
|
# copied from Pydantic v1's `construct()` method
|
|
236
231
|
object.__setattr__(m, "__fields_set__", _fields_set)
|
|
232
|
+
else:
|
|
233
|
+
# these properties are copied from Pydantic's `model_construct()` method
|
|
234
|
+
object.__setattr__(m, "__pydantic_private__", None)
|
|
235
|
+
object.__setattr__(m, "__pydantic_extra__", _extra)
|
|
236
|
+
object.__setattr__(m, "__pydantic_fields_set__", _fields_set)
|
|
237
237
|
|
|
238
238
|
return m
|
|
239
239
|
|
|
@@ -243,7 +243,7 @@ class BaseModel(pydantic.BaseModel):
|
|
|
243
243
|
# although not in practice
|
|
244
244
|
model_construct = construct
|
|
245
245
|
|
|
246
|
-
if
|
|
246
|
+
if PYDANTIC_V1:
|
|
247
247
|
# we define aliases for some of the new pydantic v2 methods so
|
|
248
248
|
# that we can just document these methods without having to specify
|
|
249
249
|
# a specific pydantic version as some users may not know which
|
|
@@ -256,7 +256,7 @@ class BaseModel(pydantic.BaseModel):
|
|
|
256
256
|
mode: Literal["json", "python"] | str = "python",
|
|
257
257
|
include: IncEx | None = None,
|
|
258
258
|
exclude: IncEx | None = None,
|
|
259
|
-
by_alias: bool =
|
|
259
|
+
by_alias: bool | None = None,
|
|
260
260
|
exclude_unset: bool = False,
|
|
261
261
|
exclude_defaults: bool = False,
|
|
262
262
|
exclude_none: bool = False,
|
|
@@ -264,6 +264,7 @@ class BaseModel(pydantic.BaseModel):
|
|
|
264
264
|
warnings: bool | Literal["none", "warn", "error"] = True,
|
|
265
265
|
context: dict[str, Any] | None = None,
|
|
266
266
|
serialize_as_any: bool = False,
|
|
267
|
+
fallback: Callable[[Any], Any] | None = None,
|
|
267
268
|
) -> dict[str, Any]:
|
|
268
269
|
"""Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump
|
|
269
270
|
|
|
@@ -295,16 +296,18 @@ class BaseModel(pydantic.BaseModel):
|
|
|
295
296
|
raise ValueError("context is only supported in Pydantic v2")
|
|
296
297
|
if serialize_as_any != False:
|
|
297
298
|
raise ValueError("serialize_as_any is only supported in Pydantic v2")
|
|
299
|
+
if fallback is not None:
|
|
300
|
+
raise ValueError("fallback is only supported in Pydantic v2")
|
|
298
301
|
dumped = super().dict( # pyright: ignore[reportDeprecated]
|
|
299
302
|
include=include,
|
|
300
303
|
exclude=exclude,
|
|
301
|
-
by_alias=by_alias,
|
|
304
|
+
by_alias=by_alias if by_alias is not None else False,
|
|
302
305
|
exclude_unset=exclude_unset,
|
|
303
306
|
exclude_defaults=exclude_defaults,
|
|
304
307
|
exclude_none=exclude_none,
|
|
305
308
|
)
|
|
306
309
|
|
|
307
|
-
return cast(dict[str, Any], json_safe(dumped)) if mode == "json" else dumped
|
|
310
|
+
return cast("dict[str, Any]", json_safe(dumped)) if mode == "json" else dumped
|
|
308
311
|
|
|
309
312
|
@override
|
|
310
313
|
def model_dump_json(
|
|
@@ -313,13 +316,14 @@ class BaseModel(pydantic.BaseModel):
|
|
|
313
316
|
indent: int | None = None,
|
|
314
317
|
include: IncEx | None = None,
|
|
315
318
|
exclude: IncEx | None = None,
|
|
316
|
-
by_alias: bool =
|
|
319
|
+
by_alias: bool | None = None,
|
|
317
320
|
exclude_unset: bool = False,
|
|
318
321
|
exclude_defaults: bool = False,
|
|
319
322
|
exclude_none: bool = False,
|
|
320
323
|
round_trip: bool = False,
|
|
321
324
|
warnings: bool | Literal["none", "warn", "error"] = True,
|
|
322
325
|
context: dict[str, Any] | None = None,
|
|
326
|
+
fallback: Callable[[Any], Any] | None = None,
|
|
323
327
|
serialize_as_any: bool = False,
|
|
324
328
|
) -> str:
|
|
325
329
|
"""Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump_json
|
|
@@ -348,11 +352,13 @@ class BaseModel(pydantic.BaseModel):
|
|
|
348
352
|
raise ValueError("context is only supported in Pydantic v2")
|
|
349
353
|
if serialize_as_any != False:
|
|
350
354
|
raise ValueError("serialize_as_any is only supported in Pydantic v2")
|
|
355
|
+
if fallback is not None:
|
|
356
|
+
raise ValueError("fallback is only supported in Pydantic v2")
|
|
351
357
|
return super().json( # type: ignore[reportDeprecated]
|
|
352
358
|
indent=indent,
|
|
353
359
|
include=include,
|
|
354
360
|
exclude=exclude,
|
|
355
|
-
by_alias=by_alias,
|
|
361
|
+
by_alias=by_alias if by_alias is not None else False,
|
|
356
362
|
exclude_unset=exclude_unset,
|
|
357
363
|
exclude_defaults=exclude_defaults,
|
|
358
364
|
exclude_none=exclude_none,
|
|
@@ -363,10 +369,10 @@ def _construct_field(value: object, field: FieldInfo, key: str) -> object:
|
|
|
363
369
|
if value is None:
|
|
364
370
|
return field_get_default(field)
|
|
365
371
|
|
|
366
|
-
if
|
|
367
|
-
type_ = field.annotation
|
|
368
|
-
else:
|
|
372
|
+
if PYDANTIC_V1:
|
|
369
373
|
type_ = cast(type, field.outer_type_) # type: ignore
|
|
374
|
+
else:
|
|
375
|
+
type_ = field.annotation # type: ignore
|
|
370
376
|
|
|
371
377
|
if type_ is None:
|
|
372
378
|
raise RuntimeError(f"Unexpected field type is None for {key}")
|
|
@@ -375,7 +381,7 @@ def _construct_field(value: object, field: FieldInfo, key: str) -> object:
|
|
|
375
381
|
|
|
376
382
|
|
|
377
383
|
def _get_extra_fields_type(cls: type[pydantic.BaseModel]) -> type | None:
|
|
378
|
-
if
|
|
384
|
+
if PYDANTIC_V1:
|
|
379
385
|
# TODO
|
|
380
386
|
return None
|
|
381
387
|
|
|
@@ -628,30 +634,30 @@ def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any,
|
|
|
628
634
|
for variant in get_args(union):
|
|
629
635
|
variant = strip_annotated_type(variant)
|
|
630
636
|
if is_basemodel_type(variant):
|
|
631
|
-
if
|
|
632
|
-
|
|
633
|
-
if not
|
|
637
|
+
if PYDANTIC_V1:
|
|
638
|
+
field_info = cast("dict[str, FieldInfo]", variant.__fields__).get(discriminator_field_name) # pyright: ignore[reportDeprecated, reportUnnecessaryCast]
|
|
639
|
+
if not field_info:
|
|
634
640
|
continue
|
|
635
641
|
|
|
636
642
|
# Note: if one variant defines an alias then they all should
|
|
637
|
-
discriminator_alias =
|
|
638
|
-
|
|
639
|
-
field_schema = field["schema"]
|
|
643
|
+
discriminator_alias = field_info.alias
|
|
640
644
|
|
|
641
|
-
if
|
|
642
|
-
for entry in
|
|
645
|
+
if (annotation := getattr(field_info, "annotation", None)) and is_literal_type(annotation):
|
|
646
|
+
for entry in get_args(annotation):
|
|
643
647
|
if isinstance(entry, str):
|
|
644
648
|
mapping[entry] = variant
|
|
645
649
|
else:
|
|
646
|
-
|
|
647
|
-
if not
|
|
650
|
+
field = _extract_field_schema_pv2(variant, discriminator_field_name)
|
|
651
|
+
if not field:
|
|
648
652
|
continue
|
|
649
653
|
|
|
650
654
|
# Note: if one variant defines an alias then they all should
|
|
651
|
-
discriminator_alias =
|
|
655
|
+
discriminator_alias = field.get("serialization_alias")
|
|
652
656
|
|
|
653
|
-
|
|
654
|
-
|
|
657
|
+
field_schema = field["schema"]
|
|
658
|
+
|
|
659
|
+
if field_schema["type"] == "literal":
|
|
660
|
+
for entry in cast("LiteralSchema", field_schema)["expected"]:
|
|
655
661
|
if isinstance(entry, str):
|
|
656
662
|
mapping[entry] = variant
|
|
657
663
|
|
|
@@ -714,7 +720,7 @@ else:
|
|
|
714
720
|
pass
|
|
715
721
|
|
|
716
722
|
|
|
717
|
-
if
|
|
723
|
+
if not PYDANTIC_V1:
|
|
718
724
|
from pydantic import TypeAdapter as _TypeAdapter
|
|
719
725
|
|
|
720
726
|
_CachedTypeAdapter = cast("TypeAdapter[object]", lru_cache(maxsize=None)(_TypeAdapter))
|
|
@@ -782,12 +788,12 @@ class FinalRequestOptions(pydantic.BaseModel):
|
|
|
782
788
|
json_data: Union[Body, None] = None
|
|
783
789
|
extra_json: Union[AnyMapping, None] = None
|
|
784
790
|
|
|
785
|
-
if
|
|
786
|
-
model_config: ClassVar[ConfigDict] = ConfigDict(arbitrary_types_allowed=True)
|
|
787
|
-
else:
|
|
791
|
+
if PYDANTIC_V1:
|
|
788
792
|
|
|
789
793
|
class Config(pydantic.BaseConfig): # pyright: ignore[reportDeprecated]
|
|
790
794
|
arbitrary_types_allowed: bool = True
|
|
795
|
+
else:
|
|
796
|
+
model_config: ClassVar[ConfigDict] = ConfigDict(arbitrary_types_allowed=True)
|
|
791
797
|
|
|
792
798
|
def get_max_retries(self, max_retries: int) -> int:
|
|
793
799
|
if isinstance(self.max_retries, NotGiven):
|
|
@@ -820,9 +826,9 @@ class FinalRequestOptions(pydantic.BaseModel):
|
|
|
820
826
|
key: strip_not_given(value)
|
|
821
827
|
for key, value in values.items()
|
|
822
828
|
}
|
|
823
|
-
if
|
|
824
|
-
return super().
|
|
825
|
-
return
|
|
829
|
+
if PYDANTIC_V1:
|
|
830
|
+
return cast(FinalRequestOptions, super().construct(_fields_set, **kwargs)) # pyright: ignore[reportDeprecated]
|
|
831
|
+
return super().model_construct(_fields_set, **kwargs)
|
|
826
832
|
|
|
827
833
|
if not TYPE_CHECKING:
|
|
828
834
|
# type checkers incorrectly complain about this assignment
|
telnyx/_qs.py
CHANGED
|
@@ -4,7 +4,7 @@ from typing import Any, List, Tuple, Union, Mapping, TypeVar
|
|
|
4
4
|
from urllib.parse import parse_qs, urlencode
|
|
5
5
|
from typing_extensions import Literal, get_args
|
|
6
6
|
|
|
7
|
-
from ._types import
|
|
7
|
+
from ._types import NotGiven, not_given
|
|
8
8
|
from ._utils import flatten
|
|
9
9
|
|
|
10
10
|
_T = TypeVar("_T")
|
|
@@ -41,8 +41,8 @@ class Querystring:
|
|
|
41
41
|
self,
|
|
42
42
|
params: Params,
|
|
43
43
|
*,
|
|
44
|
-
array_format:
|
|
45
|
-
nested_format:
|
|
44
|
+
array_format: ArrayFormat | NotGiven = not_given,
|
|
45
|
+
nested_format: NestedFormat | NotGiven = not_given,
|
|
46
46
|
) -> str:
|
|
47
47
|
return urlencode(
|
|
48
48
|
self.stringify_items(
|
|
@@ -56,8 +56,8 @@ class Querystring:
|
|
|
56
56
|
self,
|
|
57
57
|
params: Params,
|
|
58
58
|
*,
|
|
59
|
-
array_format:
|
|
60
|
-
nested_format:
|
|
59
|
+
array_format: ArrayFormat | NotGiven = not_given,
|
|
60
|
+
nested_format: NestedFormat | NotGiven = not_given,
|
|
61
61
|
) -> list[tuple[str, str]]:
|
|
62
62
|
opts = Options(
|
|
63
63
|
qs=self,
|
|
@@ -143,8 +143,8 @@ class Options:
|
|
|
143
143
|
self,
|
|
144
144
|
qs: Querystring = _qs,
|
|
145
145
|
*,
|
|
146
|
-
array_format:
|
|
147
|
-
nested_format:
|
|
146
|
+
array_format: ArrayFormat | NotGiven = not_given,
|
|
147
|
+
nested_format: NestedFormat | NotGiven = not_given,
|
|
148
148
|
) -> None:
|
|
149
149
|
self.array_format = qs.array_format if isinstance(array_format, NotGiven) else array_format
|
|
150
150
|
self.nested_format = qs.nested_format if isinstance(nested_format, NotGiven) else nested_format
|
telnyx/_types.py
CHANGED
|
@@ -13,10 +13,21 @@ from typing import (
|
|
|
13
13
|
Mapping,
|
|
14
14
|
TypeVar,
|
|
15
15
|
Callable,
|
|
16
|
+
Iterator,
|
|
16
17
|
Optional,
|
|
17
18
|
Sequence,
|
|
18
19
|
)
|
|
19
|
-
from typing_extensions import
|
|
20
|
+
from typing_extensions import (
|
|
21
|
+
Set,
|
|
22
|
+
Literal,
|
|
23
|
+
Protocol,
|
|
24
|
+
TypeAlias,
|
|
25
|
+
TypedDict,
|
|
26
|
+
SupportsIndex,
|
|
27
|
+
overload,
|
|
28
|
+
override,
|
|
29
|
+
runtime_checkable,
|
|
30
|
+
)
|
|
20
31
|
|
|
21
32
|
import httpx
|
|
22
33
|
import pydantic
|
|
@@ -106,18 +117,21 @@ class RequestOptions(TypedDict, total=False):
|
|
|
106
117
|
# Sentinel class used until PEP 0661 is accepted
|
|
107
118
|
class NotGiven:
|
|
108
119
|
"""
|
|
109
|
-
|
|
110
|
-
|
|
120
|
+
For parameters with a meaningful None value, we need to distinguish between
|
|
121
|
+
the user explicitly passing None, and the user not passing the parameter at
|
|
122
|
+
all.
|
|
123
|
+
|
|
124
|
+
User code shouldn't need to use not_given directly.
|
|
111
125
|
|
|
112
126
|
For example:
|
|
113
127
|
|
|
114
128
|
```py
|
|
115
|
-
def
|
|
129
|
+
def create(timeout: Timeout | None | NotGiven = not_given): ...
|
|
116
130
|
|
|
117
131
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
132
|
+
create(timeout=1) # 1s timeout
|
|
133
|
+
create(timeout=None) # No timeout
|
|
134
|
+
create() # Default timeout behavior
|
|
121
135
|
```
|
|
122
136
|
"""
|
|
123
137
|
|
|
@@ -129,13 +143,14 @@ class NotGiven:
|
|
|
129
143
|
return "NOT_GIVEN"
|
|
130
144
|
|
|
131
145
|
|
|
132
|
-
|
|
146
|
+
not_given = NotGiven()
|
|
147
|
+
# for backwards compatibility:
|
|
133
148
|
NOT_GIVEN = NotGiven()
|
|
134
149
|
|
|
135
150
|
|
|
136
151
|
class Omit:
|
|
137
|
-
"""
|
|
138
|
-
|
|
152
|
+
"""
|
|
153
|
+
To explicitly omit something from being sent in a request, use `omit`.
|
|
139
154
|
|
|
140
155
|
```py
|
|
141
156
|
# as the default `Content-Type` header is `application/json` that will be sent
|
|
@@ -145,8 +160,8 @@ class Omit:
|
|
|
145
160
|
# to look something like: 'multipart/form-data; boundary=0d8382fcf5f8c3be01ca2e11002d2983'
|
|
146
161
|
client.post(..., headers={"Content-Type": "multipart/form-data"})
|
|
147
162
|
|
|
148
|
-
# instead you can remove the default `application/json` header by passing
|
|
149
|
-
client.post(..., headers={"Content-Type":
|
|
163
|
+
# instead you can remove the default `application/json` header by passing omit
|
|
164
|
+
client.post(..., headers={"Content-Type": omit})
|
|
150
165
|
```
|
|
151
166
|
"""
|
|
152
167
|
|
|
@@ -154,6 +169,9 @@ class Omit:
|
|
|
154
169
|
return False
|
|
155
170
|
|
|
156
171
|
|
|
172
|
+
omit = Omit()
|
|
173
|
+
|
|
174
|
+
|
|
157
175
|
@runtime_checkable
|
|
158
176
|
class ModelBuilderProtocol(Protocol):
|
|
159
177
|
@classmethod
|
|
@@ -217,3 +235,26 @@ class _GenericAlias(Protocol):
|
|
|
217
235
|
class HttpxSendArgs(TypedDict, total=False):
|
|
218
236
|
auth: httpx.Auth
|
|
219
237
|
follow_redirects: bool
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
_T_co = TypeVar("_T_co", covariant=True)
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
if TYPE_CHECKING:
|
|
244
|
+
# This works because str.__contains__ does not accept object (either in typeshed or at runtime)
|
|
245
|
+
# https://github.com/hauntsaninja/useful_types/blob/5e9710f3875107d068e7679fd7fec9cfab0eff3b/useful_types/__init__.py#L285
|
|
246
|
+
class SequenceNotStr(Protocol[_T_co]):
|
|
247
|
+
@overload
|
|
248
|
+
def __getitem__(self, index: SupportsIndex, /) -> _T_co: ...
|
|
249
|
+
@overload
|
|
250
|
+
def __getitem__(self, index: slice, /) -> Sequence[_T_co]: ...
|
|
251
|
+
def __contains__(self, value: object, /) -> bool: ...
|
|
252
|
+
def __len__(self) -> int: ...
|
|
253
|
+
def __iter__(self) -> Iterator[_T_co]: ...
|
|
254
|
+
def index(self, value: Any, start: int = 0, stop: int = ..., /) -> int: ...
|
|
255
|
+
def count(self, value: Any, /) -> int: ...
|
|
256
|
+
def __reversed__(self) -> Iterator[_T_co]: ...
|
|
257
|
+
else:
|
|
258
|
+
# just point this to a normal `Sequence` at runtime to avoid having to special case
|
|
259
|
+
# deserializing our custom sequence type
|
|
260
|
+
SequenceNotStr = Sequence
|
telnyx/_utils/__init__.py
CHANGED
|
@@ -10,7 +10,6 @@ from ._utils import (
|
|
|
10
10
|
lru_cache as lru_cache,
|
|
11
11
|
is_mapping as is_mapping,
|
|
12
12
|
is_tuple_t as is_tuple_t,
|
|
13
|
-
parse_date as parse_date,
|
|
14
13
|
is_iterable as is_iterable,
|
|
15
14
|
is_sequence as is_sequence,
|
|
16
15
|
coerce_float as coerce_float,
|
|
@@ -23,7 +22,6 @@ from ._utils import (
|
|
|
23
22
|
coerce_boolean as coerce_boolean,
|
|
24
23
|
coerce_integer as coerce_integer,
|
|
25
24
|
file_from_path as file_from_path,
|
|
26
|
-
parse_datetime as parse_datetime,
|
|
27
25
|
strip_not_given as strip_not_given,
|
|
28
26
|
deepcopy_minimal as deepcopy_minimal,
|
|
29
27
|
get_async_library as get_async_library,
|
|
@@ -32,12 +30,20 @@ from ._utils import (
|
|
|
32
30
|
maybe_coerce_boolean as maybe_coerce_boolean,
|
|
33
31
|
maybe_coerce_integer as maybe_coerce_integer,
|
|
34
32
|
)
|
|
33
|
+
from ._compat import (
|
|
34
|
+
get_args as get_args,
|
|
35
|
+
is_union as is_union,
|
|
36
|
+
get_origin as get_origin,
|
|
37
|
+
is_typeddict as is_typeddict,
|
|
38
|
+
is_literal_type as is_literal_type,
|
|
39
|
+
)
|
|
35
40
|
from ._typing import (
|
|
36
41
|
is_list_type as is_list_type,
|
|
37
42
|
is_union_type as is_union_type,
|
|
38
43
|
extract_type_arg as extract_type_arg,
|
|
39
44
|
is_iterable_type as is_iterable_type,
|
|
40
45
|
is_required_type as is_required_type,
|
|
46
|
+
is_sequence_type as is_sequence_type,
|
|
41
47
|
is_annotated_type as is_annotated_type,
|
|
42
48
|
is_type_alias_type as is_type_alias_type,
|
|
43
49
|
strip_annotated_type as strip_annotated_type,
|
|
@@ -55,3 +61,4 @@ from ._reflection import (
|
|
|
55
61
|
function_has_argument as function_has_argument,
|
|
56
62
|
assert_signatures_in_sync as assert_signatures_in_sync,
|
|
57
63
|
)
|
|
64
|
+
from ._datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime
|