telnyx 3.0.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.
- telnyx/__init__.py +90 -0
- telnyx/_base_client.py +1995 -0
- telnyx/_client.py +3163 -0
- telnyx/_compat.py +219 -0
- telnyx/_constants.py +14 -0
- telnyx/_exceptions.py +108 -0
- telnyx/_files.py +123 -0
- telnyx/_models.py +829 -0
- telnyx/_qs.py +150 -0
- telnyx/_resource.py +43 -0
- telnyx/_response.py +830 -0
- telnyx/_streaming.py +333 -0
- telnyx/_types.py +219 -0
- telnyx/_utils/__init__.py +57 -0
- telnyx/_utils/_logs.py +25 -0
- telnyx/_utils/_proxy.py +65 -0
- telnyx/_utils/_reflection.py +42 -0
- telnyx/_utils/_resources_proxy.py +24 -0
- telnyx/_utils/_streams.py +12 -0
- telnyx/_utils/_sync.py +86 -0
- telnyx/_utils/_transform.py +447 -0
- telnyx/_utils/_typing.py +151 -0
- telnyx/_utils/_utils.py +422 -0
- telnyx/_version.py +4 -0
- telnyx/lib/.keep +4 -0
- telnyx/py.typed +0 -0
- telnyx/resources/__init__.py +2049 -0
- telnyx/resources/access_ip_address.py +452 -0
- telnyx/resources/access_ip_ranges.py +370 -0
- telnyx/resources/actions/__init__.py +47 -0
- telnyx/resources/actions/actions.py +134 -0
- telnyx/resources/actions/purchase.py +232 -0
- telnyx/resources/actions/register.py +208 -0
- telnyx/resources/addresses/__init__.py +33 -0
- telnyx/resources/addresses/actions.py +314 -0
- telnyx/resources/addresses/addresses.py +660 -0
- telnyx/resources/advanced_orders.py +329 -0
- telnyx/resources/ai/__init__.py +117 -0
- telnyx/resources/ai/ai.py +500 -0
- telnyx/resources/ai/assistants/__init__.py +89 -0
- telnyx/resources/ai/assistants/assistants.py +1313 -0
- telnyx/resources/ai/assistants/canary_deploys.py +448 -0
- telnyx/resources/ai/assistants/scheduled_events.py +534 -0
- telnyx/resources/ai/assistants/tests/__init__.py +47 -0
- telnyx/resources/ai/assistants/tests/runs.py +380 -0
- telnyx/resources/ai/assistants/tests/test_suites/__init__.py +33 -0
- telnyx/resources/ai/assistants/tests/test_suites/runs.py +304 -0
- telnyx/resources/ai/assistants/tests/test_suites/test_suites.py +173 -0
- telnyx/resources/ai/assistants/tests/tests.py +759 -0
- telnyx/resources/ai/assistants/tools.py +199 -0
- telnyx/resources/ai/assistants/versions.py +672 -0
- telnyx/resources/ai/audio.py +248 -0
- telnyx/resources/ai/chat.py +409 -0
- telnyx/resources/ai/clusters.py +597 -0
- telnyx/resources/ai/conversations/__init__.py +61 -0
- telnyx/resources/ai/conversations/conversations.py +813 -0
- telnyx/resources/ai/conversations/insight_groups/__init__.py +33 -0
- telnyx/resources/ai/conversations/insight_groups/insight_groups.py +580 -0
- telnyx/resources/ai/conversations/insight_groups/insights.py +268 -0
- telnyx/resources/ai/conversations/insights.py +554 -0
- telnyx/resources/ai/conversations/messages.py +298 -0
- telnyx/resources/ai/embeddings/__init__.py +33 -0
- telnyx/resources/ai/embeddings/buckets.py +298 -0
- telnyx/resources/ai/embeddings/embeddings.py +710 -0
- telnyx/resources/ai/fine_tuning/__init__.py +33 -0
- telnyx/resources/ai/fine_tuning/fine_tuning.py +102 -0
- telnyx/resources/ai/fine_tuning/jobs.py +408 -0
- telnyx/resources/audit_events.py +211 -0
- telnyx/resources/authentication_providers.py +666 -0
- telnyx/resources/available_phone_number_blocks.py +181 -0
- telnyx/resources/available_phone_numbers.py +187 -0
- telnyx/resources/balance.py +135 -0
- telnyx/resources/billing_groups.py +501 -0
- telnyx/resources/brand/__init__.py +33 -0
- telnyx/resources/brand/brand.py +1316 -0
- telnyx/resources/brand/external_vetting.py +389 -0
- telnyx/resources/bulk_sim_card_actions.py +288 -0
- telnyx/resources/bundle_pricing/__init__.py +47 -0
- telnyx/resources/bundle_pricing/billing_bundles.py +296 -0
- telnyx/resources/bundle_pricing/bundle_pricing.py +134 -0
- telnyx/resources/bundle_pricing/user_bundles.py +686 -0
- telnyx/resources/call_control_applications.py +812 -0
- telnyx/resources/call_events.py +213 -0
- telnyx/resources/calls/__init__.py +33 -0
- telnyx/resources/calls/actions.py +7061 -0
- telnyx/resources/calls/calls.py +872 -0
- telnyx/resources/campaign/__init__.py +47 -0
- telnyx/resources/campaign/campaign.py +1064 -0
- telnyx/resources/campaign/osr.py +162 -0
- telnyx/resources/campaign/usecase.py +169 -0
- telnyx/resources/campaign_builder/__init__.py +33 -0
- telnyx/resources/campaign_builder/brand.py +171 -0
- telnyx/resources/campaign_builder/campaign_builder.py +523 -0
- telnyx/resources/channel_zones.py +282 -0
- telnyx/resources/charges_breakdown.py +211 -0
- telnyx/resources/charges_summary.py +202 -0
- telnyx/resources/comments.py +432 -0
- telnyx/resources/conferences/__init__.py +33 -0
- telnyx/resources/conferences/actions.py +2029 -0
- telnyx/resources/conferences/conferences.py +670 -0
- telnyx/resources/connections.py +423 -0
- telnyx/resources/country_coverage.py +214 -0
- telnyx/resources/credential_connections/__init__.py +33 -0
- telnyx/resources/credential_connections/actions.py +169 -0
- telnyx/resources/credential_connections/credential_connections.py +995 -0
- telnyx/resources/custom_storage_credentials.py +441 -0
- telnyx/resources/customer_service_records.py +488 -0
- telnyx/resources/detail_records.py +207 -0
- telnyx/resources/dialogflow_connections.py +514 -0
- telnyx/resources/document_links.py +197 -0
- telnyx/resources/documents.py +804 -0
- telnyx/resources/dynamic_emergency_addresses.py +482 -0
- telnyx/resources/dynamic_emergency_endpoints.py +452 -0
- telnyx/resources/enum.py +210 -0
- telnyx/resources/external_connections/__init__.py +89 -0
- telnyx/resources/external_connections/civic_addresses.py +268 -0
- telnyx/resources/external_connections/external_connections.py +928 -0
- telnyx/resources/external_connections/log_messages.py +355 -0
- telnyx/resources/external_connections/phone_numbers.py +387 -0
- telnyx/resources/external_connections/releases.py +292 -0
- telnyx/resources/external_connections/uploads.py +671 -0
- telnyx/resources/fax_applications.py +744 -0
- telnyx/resources/faxes/__init__.py +33 -0
- telnyx/resources/faxes/actions.py +244 -0
- telnyx/resources/faxes/faxes.py +648 -0
- telnyx/resources/fqdn_connections.py +921 -0
- telnyx/resources/fqdns.py +605 -0
- telnyx/resources/global_ip_allowed_ports.py +135 -0
- telnyx/resources/global_ip_assignment_health.py +183 -0
- telnyx/resources/global_ip_assignments.py +529 -0
- telnyx/resources/global_ip_assignments_usage.py +183 -0
- telnyx/resources/global_ip_health_check_types.py +135 -0
- telnyx/resources/global_ip_health_checks.py +444 -0
- telnyx/resources/global_ip_latency.py +181 -0
- telnyx/resources/global_ip_protocols.py +135 -0
- telnyx/resources/global_ip_usage.py +179 -0
- telnyx/resources/global_ips.py +442 -0
- telnyx/resources/inbound_channels.py +240 -0
- telnyx/resources/integration_secrets.py +400 -0
- telnyx/resources/inventory_coverage.py +185 -0
- telnyx/resources/invoices.py +288 -0
- telnyx/resources/ip_connections.py +899 -0
- telnyx/resources/ips.py +575 -0
- telnyx/resources/ledger_billing_group_reports.py +264 -0
- telnyx/resources/list.py +214 -0
- telnyx/resources/managed_accounts/__init__.py +33 -0
- telnyx/resources/managed_accounts/actions.py +266 -0
- telnyx/resources/managed_accounts/managed_accounts.py +773 -0
- telnyx/resources/media.py +678 -0
- telnyx/resources/messages/__init__.py +33 -0
- telnyx/resources/messages/messages.py +1425 -0
- telnyx/resources/messages/rcs.py +199 -0
- telnyx/resources/messaging/__init__.py +33 -0
- telnyx/resources/messaging/messaging.py +102 -0
- telnyx/resources/messaging/rcs/__init__.py +33 -0
- telnyx/resources/messaging/rcs/agents.py +368 -0
- telnyx/resources/messaging/rcs/rcs.py +389 -0
- telnyx/resources/messaging_hosted_number_orders/__init__.py +33 -0
- telnyx/resources/messaging_hosted_number_orders/actions.py +207 -0
- telnyx/resources/messaging_hosted_number_orders/messaging_hosted_number_orders.py +766 -0
- telnyx/resources/messaging_hosted_numbers.py +163 -0
- telnyx/resources/messaging_numbers_bulk_updates.py +278 -0
- telnyx/resources/messaging_optouts.py +217 -0
- telnyx/resources/messaging_profiles/__init__.py +33 -0
- telnyx/resources/messaging_profiles/autoresp_configs.py +599 -0
- telnyx/resources/messaging_profiles/messaging_profiles.py +1048 -0
- telnyx/resources/messaging_tollfree/__init__.py +33 -0
- telnyx/resources/messaging_tollfree/messaging_tollfree.py +102 -0
- telnyx/resources/messaging_tollfree/verification/__init__.py +33 -0
- telnyx/resources/messaging_tollfree/verification/requests.py +922 -0
- telnyx/resources/messaging_tollfree/verification/verification.py +102 -0
- telnyx/resources/messaging_url_domains.py +177 -0
- telnyx/resources/messsages.py +224 -0
- telnyx/resources/mobile_network_operators.py +207 -0
- telnyx/resources/mobile_push_credentials.py +579 -0
- telnyx/resources/network_coverage.py +211 -0
- telnyx/resources/networks/__init__.py +33 -0
- telnyx/resources/networks/default_gateway.py +335 -0
- telnyx/resources/networks/networks.py +666 -0
- telnyx/resources/notification_channels.py +585 -0
- telnyx/resources/notification_event_conditions.py +201 -0
- telnyx/resources/notification_events.py +177 -0
- telnyx/resources/notification_profiles.py +511 -0
- telnyx/resources/notification_settings.py +472 -0
- telnyx/resources/number_block_orders.py +401 -0
- telnyx/resources/number_lookup.py +183 -0
- telnyx/resources/number_order_phone_numbers.py +461 -0
- telnyx/resources/number_orders.py +499 -0
- telnyx/resources/number_reservations/__init__.py +33 -0
- telnyx/resources/number_reservations/actions.py +167 -0
- telnyx/resources/number_reservations/number_reservations.py +410 -0
- telnyx/resources/numbers_features.py +169 -0
- telnyx/resources/operator_connect/__init__.py +33 -0
- telnyx/resources/operator_connect/actions.py +147 -0
- telnyx/resources/operator_connect/operator_connect.py +102 -0
- telnyx/resources/ota_updates.py +276 -0
- telnyx/resources/outbound_voice_profiles.py +821 -0
- telnyx/resources/partner_campaigns.py +630 -0
- telnyx/resources/payment/__init__.py +33 -0
- telnyx/resources/payment/auto_recharge_prefs.py +260 -0
- telnyx/resources/payment/payment.py +102 -0
- telnyx/resources/phone_number_assignment_by_profile.py +416 -0
- telnyx/resources/phone_number_blocks/__init__.py +33 -0
- telnyx/resources/phone_number_blocks/jobs.py +377 -0
- telnyx/resources/phone_number_blocks/phone_number_blocks.py +102 -0
- telnyx/resources/phone_number_campaigns.py +576 -0
- telnyx/resources/phone_numbers/__init__.py +103 -0
- telnyx/resources/phone_numbers/actions.py +385 -0
- telnyx/resources/phone_numbers/csv_downloads.py +375 -0
- telnyx/resources/phone_numbers/jobs.py +686 -0
- telnyx/resources/phone_numbers/messaging.py +379 -0
- telnyx/resources/phone_numbers/phone_numbers.py +854 -0
- telnyx/resources/phone_numbers/voice.py +468 -0
- telnyx/resources/phone_numbers/voicemail.py +375 -0
- telnyx/resources/phone_numbers_regulatory_requirements.py +185 -0
- telnyx/resources/portability_checks.py +173 -0
- telnyx/resources/porting/__init__.py +61 -0
- telnyx/resources/porting/events.py +354 -0
- telnyx/resources/porting/loa_configurations.py +815 -0
- telnyx/resources/porting/porting.py +231 -0
- telnyx/resources/porting/reports.py +378 -0
- telnyx/resources/porting_orders/__init__.py +159 -0
- telnyx/resources/porting_orders/action_requirements.py +308 -0
- telnyx/resources/porting_orders/actions.py +438 -0
- telnyx/resources/porting_orders/activation_jobs.py +366 -0
- telnyx/resources/porting_orders/additional_documents.py +392 -0
- telnyx/resources/porting_orders/associated_phone_numbers.py +411 -0
- telnyx/resources/porting_orders/comments.py +264 -0
- telnyx/resources/porting_orders/phone_number_blocks.py +405 -0
- telnyx/resources/porting_orders/phone_number_configurations.py +294 -0
- telnyx/resources/porting_orders/phone_number_extensions.py +413 -0
- telnyx/resources/porting_orders/porting_orders.py +1438 -0
- telnyx/resources/porting_orders/verification_codes.py +399 -0
- telnyx/resources/porting_phone_numbers.py +197 -0
- telnyx/resources/portouts/__init__.py +75 -0
- telnyx/resources/portouts/comments.py +252 -0
- telnyx/resources/portouts/events.py +356 -0
- telnyx/resources/portouts/portouts.py +622 -0
- telnyx/resources/portouts/reports.py +378 -0
- telnyx/resources/portouts/supporting_documents.py +258 -0
- telnyx/resources/private_wireless_gateways.py +502 -0
- telnyx/resources/public_internet_gateways.py +458 -0
- telnyx/resources/queues/__init__.py +33 -0
- telnyx/resources/queues/calls.py +266 -0
- telnyx/resources/queues/queues.py +195 -0
- telnyx/resources/recording_transcriptions.py +301 -0
- telnyx/resources/recordings/__init__.py +33 -0
- telnyx/resources/recordings/actions.py +170 -0
- telnyx/resources/recordings/recordings.py +391 -0
- telnyx/resources/regions.py +135 -0
- telnyx/resources/regulatory_requirements.py +183 -0
- telnyx/resources/reports/__init__.py +47 -0
- telnyx/resources/reports/cdr_usage_reports.py +205 -0
- telnyx/resources/reports/mdr_usage_reports.py +561 -0
- telnyx/resources/reports/reports.py +505 -0
- telnyx/resources/requirement_groups.py +625 -0
- telnyx/resources/requirement_types.py +279 -0
- telnyx/resources/requirements.py +315 -0
- telnyx/resources/room_compositions.py +516 -0
- telnyx/resources/room_participants.py +288 -0
- telnyx/resources/room_recordings.py +483 -0
- telnyx/resources/rooms/__init__.py +47 -0
- telnyx/resources/rooms/actions.py +310 -0
- telnyx/resources/rooms/rooms.py +736 -0
- telnyx/resources/rooms/sessions/__init__.py +33 -0
- telnyx/resources/rooms/sessions/actions.py +489 -0
- telnyx/resources/rooms/sessions/sessions.py +605 -0
- telnyx/resources/seti.py +179 -0
- telnyx/resources/short_codes.py +371 -0
- telnyx/resources/sim_card_data_usage_notifications.py +569 -0
- telnyx/resources/sim_card_groups/__init__.py +33 -0
- telnyx/resources/sim_card_groups/actions.py +690 -0
- telnyx/resources/sim_card_groups/sim_card_groups.py +632 -0
- telnyx/resources/sim_card_order_preview.py +187 -0
- telnyx/resources/sim_card_orders.py +381 -0
- telnyx/resources/sim_cards/__init__.py +33 -0
- telnyx/resources/sim_cards/actions.py +934 -0
- telnyx/resources/sim_cards/sim_cards.py +970 -0
- telnyx/resources/siprec_connectors.py +481 -0
- telnyx/resources/storage/__init__.py +61 -0
- telnyx/resources/storage/buckets/__init__.py +47 -0
- telnyx/resources/storage/buckets/buckets.py +257 -0
- telnyx/resources/storage/buckets/ssl_certificate.py +365 -0
- telnyx/resources/storage/buckets/usage.py +266 -0
- telnyx/resources/storage/migration_sources.py +412 -0
- telnyx/resources/storage/migrations/__init__.py +33 -0
- telnyx/resources/storage/migrations/actions.py +163 -0
- telnyx/resources/storage/migrations/migrations.py +371 -0
- telnyx/resources/storage/storage.py +231 -0
- telnyx/resources/sub_number_orders.py +561 -0
- telnyx/resources/sub_number_orders_report.py +388 -0
- telnyx/resources/telephony_credentials.py +665 -0
- telnyx/resources/texml/__init__.py +47 -0
- telnyx/resources/texml/accounts/__init__.py +75 -0
- telnyx/resources/texml/accounts/accounts.py +453 -0
- telnyx/resources/texml/accounts/calls/__init__.py +75 -0
- telnyx/resources/texml/accounts/calls/calls.py +1412 -0
- telnyx/resources/texml/accounts/calls/recordings.py +187 -0
- telnyx/resources/texml/accounts/calls/recordings_json.py +334 -0
- telnyx/resources/texml/accounts/calls/siprec.py +191 -0
- telnyx/resources/texml/accounts/calls/streams.py +189 -0
- telnyx/resources/texml/accounts/conferences/__init__.py +33 -0
- telnyx/resources/texml/accounts/conferences/conferences.py +659 -0
- telnyx/resources/texml/accounts/conferences/participants.py +1106 -0
- telnyx/resources/texml/accounts/recordings/__init__.py +33 -0
- telnyx/resources/texml/accounts/recordings/json.py +255 -0
- telnyx/resources/texml/accounts/recordings/recordings.py +102 -0
- telnyx/resources/texml/accounts/transcriptions/__init__.py +33 -0
- telnyx/resources/texml/accounts/transcriptions/json.py +265 -0
- telnyx/resources/texml/accounts/transcriptions/transcriptions.py +102 -0
- telnyx/resources/texml/calls.py +632 -0
- telnyx/resources/texml/texml.py +259 -0
- telnyx/resources/texml_applications.py +808 -0
- telnyx/resources/text_to_speech.py +327 -0
- telnyx/resources/usage_reports.py +389 -0
- telnyx/resources/user_addresses.py +541 -0
- telnyx/resources/user_tags.py +177 -0
- telnyx/resources/verifications/__init__.py +47 -0
- telnyx/resources/verifications/actions.py +195 -0
- telnyx/resources/verifications/by_phone_number/__init__.py +33 -0
- telnyx/resources/verifications/by_phone_number/actions.py +195 -0
- telnyx/resources/verifications/by_phone_number/by_phone_number.py +199 -0
- telnyx/resources/verifications/verifications.py +570 -0
- telnyx/resources/verified_numbers/__init__.py +33 -0
- telnyx/resources/verified_numbers/actions.py +179 -0
- telnyx/resources/verified_numbers/verified_numbers.py +469 -0
- telnyx/resources/verify_profiles.py +627 -0
- telnyx/resources/virtual_cross_connects.py +773 -0
- telnyx/resources/virtual_cross_connects_coverage.py +215 -0
- telnyx/resources/webhook_deliveries.py +282 -0
- telnyx/resources/wireguard_interfaces.py +470 -0
- telnyx/resources/wireguard_peers.py +631 -0
- telnyx/resources/wireless/__init__.py +33 -0
- telnyx/resources/wireless/detail_records_reports.py +450 -0
- telnyx/resources/wireless/wireless.py +211 -0
- telnyx/resources/wireless_blocklist_values.py +181 -0
- telnyx/resources/wireless_blocklists.py +590 -0
- telnyx/types/__init__.py +1223 -0
- telnyx/types/access_ip_address_create_params.py +13 -0
- telnyx/types/access_ip_address_list_params.py +63 -0
- telnyx/types/access_ip_address_list_response.py +24 -0
- telnyx/types/access_ip_address_response.py +28 -0
- telnyx/types/access_ip_range.py +26 -0
- telnyx/types/access_ip_range_create_params.py +13 -0
- telnyx/types/access_ip_range_list_params.py +83 -0
- telnyx/types/access_ip_range_list_response.py +24 -0
- telnyx/types/actions/__init__.py +8 -0
- telnyx/types/actions/purchase_create_params.py +36 -0
- telnyx/types/actions/purchase_create_response.py +35 -0
- telnyx/types/actions/register_create_params.py +25 -0
- telnyx/types/actions/register_create_response.py +35 -0
- telnyx/types/address.py +102 -0
- telnyx/types/address_create_params.py +90 -0
- telnyx/types/address_create_response.py +12 -0
- telnyx/types/address_delete_response.py +12 -0
- telnyx/types/address_list_params.py +106 -0
- telnyx/types/address_list_response.py +15 -0
- telnyx/types/address_retrieve_response.py +12 -0
- telnyx/types/addresses/__init__.py +8 -0
- telnyx/types/addresses/action_accept_suggestions_params.py +14 -0
- telnyx/types/addresses/action_accept_suggestions_response.py +22 -0
- telnyx/types/addresses/action_validate_params.py +36 -0
- telnyx/types/addresses/action_validate_response.py +64 -0
- telnyx/types/advanced_order_create_params.py +24 -0
- telnyx/types/ai/__init__.py +87 -0
- telnyx/types/ai/assistant_chat_params.py +18 -0
- telnyx/types/ai/assistant_chat_response.py +10 -0
- telnyx/types/ai/assistant_clone_response.py +92 -0
- telnyx/types/ai/assistant_create_params.py +86 -0
- telnyx/types/ai/assistant_create_response.py +92 -0
- telnyx/types/ai/assistant_delete_response.py +13 -0
- telnyx/types/ai/assistant_get_texml_response.py +7 -0
- telnyx/types/ai/assistant_import_params.py +19 -0
- telnyx/types/ai/assistant_param.py +108 -0
- telnyx/types/ai/assistant_retrieve_params.py +19 -0
- telnyx/types/ai/assistant_retrieve_response.py +92 -0
- telnyx/types/ai/assistant_tool.py +122 -0
- telnyx/types/ai/assistant_tool_param.py +123 -0
- telnyx/types/ai/assistant_update_params.py +92 -0
- telnyx/types/ai/assistants/__init__.py +30 -0
- telnyx/types/ai/assistants/assistant_test.py +52 -0
- telnyx/types/ai/assistants/canary_deploy_create_params.py +15 -0
- telnyx/types/ai/assistants/canary_deploy_response.py +19 -0
- telnyx/types/ai/assistants/canary_deploy_update_params.py +15 -0
- telnyx/types/ai/assistants/conversation_channel_type.py +7 -0
- telnyx/types/ai/assistants/event_status.py +7 -0
- telnyx/types/ai/assistants/scheduled_event_create_params.py +35 -0
- telnyx/types/ai/assistants/scheduled_event_list_params.py +32 -0
- telnyx/types/ai/assistants/scheduled_event_list_response.py +19 -0
- telnyx/types/ai/assistants/scheduled_event_response.py +11 -0
- telnyx/types/ai/assistants/scheduled_phone_call_event_response.py +38 -0
- telnyx/types/ai/assistants/scheduled_sms_event_response.py +38 -0
- telnyx/types/ai/assistants/telnyx_conversation_channel.py +7 -0
- telnyx/types/ai/assistants/test_create_params.py +72 -0
- telnyx/types/ai/assistants/test_list_params.py +32 -0
- telnyx/types/ai/assistants/test_list_response.py +18 -0
- telnyx/types/ai/assistants/test_update_params.py +47 -0
- telnyx/types/ai/assistants/tests/__init__.py +9 -0
- telnyx/types/ai/assistants/tests/run_list_params.py +26 -0
- telnyx/types/ai/assistants/tests/run_trigger_params.py +16 -0
- telnyx/types/ai/assistants/tests/test_run_response.py +76 -0
- telnyx/types/ai/assistants/tests/test_status.py +7 -0
- telnyx/types/ai/assistants/tests/test_suite_list_response.py +13 -0
- telnyx/types/ai/assistants/tests/test_suites/__init__.py +9 -0
- telnyx/types/ai/assistants/tests/test_suites/meta.py +15 -0
- telnyx/types/ai/assistants/tests/test_suites/paginated_test_run_list.py +17 -0
- telnyx/types/ai/assistants/tests/test_suites/run_list_params.py +29 -0
- telnyx/types/ai/assistants/tests/test_suites/run_trigger_params.py +16 -0
- telnyx/types/ai/assistants/tests/test_suites/run_trigger_response.py +10 -0
- telnyx/types/ai/assistants/tool_test_params.py +18 -0
- telnyx/types/ai/assistants/tool_test_response.py +24 -0
- telnyx/types/ai/assistants/version_config.py +13 -0
- telnyx/types/ai/assistants/version_config_param.py +15 -0
- telnyx/types/ai/assistants/version_promote_response.py +92 -0
- telnyx/types/ai/assistants/version_retrieve_params.py +13 -0
- telnyx/types/ai/assistants/version_retrieve_response.py +92 -0
- telnyx/types/ai/assistants/version_update_params.py +88 -0
- telnyx/types/ai/assistants/version_update_response.py +92 -0
- telnyx/types/ai/assistants_list.py +96 -0
- telnyx/types/ai/audio_transcribe_params.py +46 -0
- telnyx/types/ai/audio_transcribe_response.py +38 -0
- telnyx/types/ai/background_task_status.py +7 -0
- telnyx/types/ai/chat_create_completion_params.py +184 -0
- telnyx/types/ai/cluster_compute_params.py +37 -0
- telnyx/types/ai/cluster_compute_response.py +13 -0
- telnyx/types/ai/cluster_fetch_graph_params.py +11 -0
- telnyx/types/ai/cluster_list_params.py +21 -0
- telnyx/types/ai/cluster_list_response.py +32 -0
- telnyx/types/ai/cluster_retrieve_params.py +18 -0
- telnyx/types/ai/cluster_retrieve_response.py +25 -0
- telnyx/types/ai/conversation.py +27 -0
- telnyx/types/ai/conversation_create_params.py +15 -0
- telnyx/types/ai/conversation_list_params.py +62 -0
- telnyx/types/ai/conversation_list_response.py +12 -0
- telnyx/types/ai/conversation_retrieve_conversations_insights_response.py +41 -0
- telnyx/types/ai/conversation_retrieve_response.py +12 -0
- telnyx/types/ai/conversation_update_params.py +13 -0
- telnyx/types/ai/conversation_update_response.py +12 -0
- telnyx/types/ai/conversations/__init__.py +22 -0
- telnyx/types/ai/conversations/insight_create_params.py +19 -0
- telnyx/types/ai/conversations/insight_group_insight_groups_params.py +15 -0
- telnyx/types/ai/conversations/insight_group_retrieve_insight_groups_params.py +23 -0
- telnyx/types/ai/conversations/insight_group_retrieve_insight_groups_response.py +15 -0
- telnyx/types/ai/conversations/insight_group_update_params.py +15 -0
- telnyx/types/ai/conversations/insight_groups/__init__.py +3 -0
- telnyx/types/ai/conversations/insight_list_params.py +23 -0
- telnyx/types/ai/conversations/insight_list_response.py +15 -0
- telnyx/types/ai/conversations/insight_template.py +26 -0
- telnyx/types/ai/conversations/insight_template_detail.py +10 -0
- telnyx/types/ai/conversations/insight_template_group.py +23 -0
- telnyx/types/ai/conversations/insight_template_group_detail.py +10 -0
- telnyx/types/ai/conversations/insight_update_params.py +18 -0
- telnyx/types/ai/conversations/message_create_params.py +29 -0
- telnyx/types/ai/conversations/message_list_response.py +56 -0
- telnyx/types/ai/embedding_create_params.py +21 -0
- telnyx/types/ai/embedding_list_params.py +13 -0
- telnyx/types/ai/embedding_list_response.py +30 -0
- telnyx/types/ai/embedding_response.py +25 -0
- telnyx/types/ai/embedding_retrieve_response.py +25 -0
- telnyx/types/ai/embedding_similarity_search_params.py +15 -0
- telnyx/types/ai/embedding_similarity_search_response.py +33 -0
- telnyx/types/ai/embedding_url_params.py +15 -0
- telnyx/types/ai/embeddings/__init__.py +6 -0
- telnyx/types/ai/embeddings/bucket_list_response.py +15 -0
- telnyx/types/ai/embeddings/bucket_retrieve_response.py +26 -0
- telnyx/types/ai/enabled_features.py +7 -0
- telnyx/types/ai/fine_tuning/__init__.py +7 -0
- telnyx/types/ai/fine_tuning/fine_tuning_job.py +51 -0
- telnyx/types/ai/fine_tuning/job_create_params.py +31 -0
- telnyx/types/ai/fine_tuning/job_list_response.py +12 -0
- telnyx/types/ai/hangup_tool.py +14 -0
- telnyx/types/ai/hangup_tool_param.py +15 -0
- telnyx/types/ai/hangup_tool_params.py +12 -0
- telnyx/types/ai/hangup_tool_params_param.py +12 -0
- telnyx/types/ai/import_metadata.py +16 -0
- telnyx/types/ai/inference_embedding_bucket_ids.py +19 -0
- telnyx/types/ai/inference_embedding_bucket_ids_param.py +20 -0
- telnyx/types/ai/inference_embedding_transfer_tool_params.py +43 -0
- telnyx/types/ai/inference_embedding_transfer_tool_params_param.py +50 -0
- telnyx/types/ai/inference_embedding_webhook_tool_params.py +99 -0
- telnyx/types/ai/inference_embedding_webhook_tool_params_param.py +99 -0
- telnyx/types/ai/insight_settings.py +16 -0
- telnyx/types/ai/insight_settings_param.py +16 -0
- telnyx/types/ai/messaging_settings.py +21 -0
- telnyx/types/ai/messaging_settings_param.py +21 -0
- telnyx/types/ai/privacy_settings.py +19 -0
- telnyx/types/ai/privacy_settings_param.py +19 -0
- telnyx/types/ai/recursive_cluster.py +34 -0
- telnyx/types/ai/retrieval_tool.py +14 -0
- telnyx/types/ai/retrieval_tool_param.py +15 -0
- telnyx/types/ai/telephony_settings.py +22 -0
- telnyx/types/ai/telephony_settings_param.py +22 -0
- telnyx/types/ai/transcription_settings.py +26 -0
- telnyx/types/ai/transcription_settings_param.py +26 -0
- telnyx/types/ai/transfer_tool.py +14 -0
- telnyx/types/ai/transfer_tool_param.py +15 -0
- telnyx/types/ai/voice_settings.py +36 -0
- telnyx/types/ai/voice_settings_param.py +36 -0
- telnyx/types/ai/webhook_tool.py +14 -0
- telnyx/types/ai/webhook_tool_param.py +15 -0
- telnyx/types/ai_retrieve_models_response.py +23 -0
- telnyx/types/ai_summarize_params.py +18 -0
- telnyx/types/ai_summarize_response.py +13 -0
- telnyx/types/alt_business_id_type.py +7 -0
- telnyx/types/anchorsite_override.py +18 -0
- telnyx/types/audit_event_list_params.py +44 -0
- telnyx/types/audit_event_list_response.py +82 -0
- telnyx/types/authentication_provider.py +71 -0
- telnyx/types/authentication_provider_create_params.py +32 -0
- telnyx/types/authentication_provider_create_response.py +12 -0
- telnyx/types/authentication_provider_delete_response.py +12 -0
- telnyx/types/authentication_provider_list_params.py +51 -0
- telnyx/types/authentication_provider_list_response.py +15 -0
- telnyx/types/authentication_provider_retrieve_response.py +12 -0
- telnyx/types/authentication_provider_update_params.py +32 -0
- telnyx/types/authentication_provider_update_response.py +12 -0
- telnyx/types/available_phone_number_block_list_params.py +30 -0
- telnyx/types/available_phone_number_block_list_response.py +60 -0
- telnyx/types/available_phone_number_list_params.py +92 -0
- telnyx/types/available_phone_number_list_response.py +75 -0
- telnyx/types/available_service.py +7 -0
- telnyx/types/azure_configuration_data.py +18 -0
- telnyx/types/azure_configuration_data_param.py +18 -0
- telnyx/types/balance_retrieve_response.py +32 -0
- telnyx/types/billing_group.py +32 -0
- telnyx/types/billing_group_create_params.py +12 -0
- telnyx/types/billing_group_create_response.py +12 -0
- telnyx/types/billing_group_delete_response.py +12 -0
- telnyx/types/billing_group_list_params.py +23 -0
- telnyx/types/billing_group_list_response.py +15 -0
- telnyx/types/billing_group_retrieve_response.py +12 -0
- telnyx/types/billing_group_update_params.py +12 -0
- telnyx/types/billing_group_update_response.py +12 -0
- telnyx/types/brand/__init__.py +7 -0
- telnyx/types/brand/external_vetting_import_params.py +23 -0
- telnyx/types/brand/external_vetting_import_response.py +43 -0
- telnyx/types/brand/external_vetting_order_params.py +17 -0
- telnyx/types/brand_create_params.py +91 -0
- telnyx/types/brand_get_feedback_response.py +31 -0
- telnyx/types/brand_identity_status.py +7 -0
- telnyx/types/brand_list_params.py +51 -0
- telnyx/types/brand_list_response.py +61 -0
- telnyx/types/brand_retrieve_response.py +14 -0
- telnyx/types/brand_update_params.py +96 -0
- telnyx/types/bulk_sim_card_action_list_params.py +20 -0
- telnyx/types/bulk_sim_card_action_list_response.py +47 -0
- telnyx/types/bulk_sim_card_action_retrieve_response.py +44 -0
- telnyx/types/bundle_pricing/__init__.py +20 -0
- telnyx/types/bundle_pricing/billing_bundle_list_params.py +42 -0
- telnyx/types/bundle_pricing/billing_bundle_list_response.py +15 -0
- telnyx/types/bundle_pricing/billing_bundle_retrieve_response.py +68 -0
- telnyx/types/bundle_pricing/billing_bundle_summary.py +36 -0
- telnyx/types/bundle_pricing/pagination_response.py +19 -0
- telnyx/types/bundle_pricing/user_bundle.py +31 -0
- telnyx/types/bundle_pricing/user_bundle_create_params.py +29 -0
- telnyx/types/bundle_pricing/user_bundle_create_response.py +12 -0
- telnyx/types/bundle_pricing/user_bundle_deactivate_response.py +10 -0
- telnyx/types/bundle_pricing/user_bundle_list_params.py +42 -0
- telnyx/types/bundle_pricing/user_bundle_list_resources_response.py +12 -0
- telnyx/types/bundle_pricing/user_bundle_list_response.py +15 -0
- telnyx/types/bundle_pricing/user_bundle_list_unused_params.py +28 -0
- telnyx/types/bundle_pricing/user_bundle_list_unused_response.py +19 -0
- telnyx/types/bundle_pricing/user_bundle_resource.py +25 -0
- telnyx/types/bundle_pricing/user_bundle_retrieve_response.py +10 -0
- telnyx/types/call_control_application.py +80 -0
- telnyx/types/call_control_application_create_params.py +70 -0
- telnyx/types/call_control_application_create_response.py +12 -0
- telnyx/types/call_control_application_delete_response.py +12 -0
- telnyx/types/call_control_application_inbound.py +39 -0
- telnyx/types/call_control_application_inbound_param.py +38 -0
- telnyx/types/call_control_application_list_params.py +141 -0
- telnyx/types/call_control_application_list_response.py +15 -0
- telnyx/types/call_control_application_outbound.py +18 -0
- telnyx/types/call_control_application_outbound_param.py +18 -0
- telnyx/types/call_control_application_retrieve_response.py +12 -0
- telnyx/types/call_control_application_update_params.py +73 -0
- telnyx/types/call_control_application_update_response.py +12 -0
- telnyx/types/call_dial_params.py +435 -0
- telnyx/types/call_dial_response.py +56 -0
- telnyx/types/call_event_list_params.py +123 -0
- telnyx/types/call_event_list_response.py +43 -0
- telnyx/types/call_retrieve_status_response.py +50 -0
- telnyx/types/calls/__init__.py +95 -0
- telnyx/types/calls/action_answer_params.py +149 -0
- telnyx/types/calls/action_answer_response.py +21 -0
- telnyx/types/calls/action_bridge_params.py +170 -0
- telnyx/types/calls/action_bridge_response.py +12 -0
- telnyx/types/calls/action_enqueue_params.py +37 -0
- telnyx/types/calls/action_enqueue_response.py +12 -0
- telnyx/types/calls/action_gather_params.py +55 -0
- telnyx/types/calls/action_gather_response.py +12 -0
- telnyx/types/calls/action_gather_using_ai_params.py +138 -0
- telnyx/types/calls/action_gather_using_ai_response.py +18 -0
- telnyx/types/calls/action_gather_using_audio_params.py +87 -0
- telnyx/types/calls/action_gather_using_audio_response.py +12 -0
- telnyx/types/calls/action_gather_using_speak_params.py +157 -0
- telnyx/types/calls/action_gather_using_speak_response.py +12 -0
- telnyx/types/calls/action_hangup_params.py +22 -0
- telnyx/types/calls/action_hangup_response.py +12 -0
- telnyx/types/calls/action_leave_queue_params.py +22 -0
- telnyx/types/calls/action_leave_queue_response.py +12 -0
- telnyx/types/calls/action_pause_recording_params.py +25 -0
- telnyx/types/calls/action_pause_recording_response.py +12 -0
- telnyx/types/calls/action_refer_params.py +44 -0
- telnyx/types/calls/action_refer_response.py +12 -0
- telnyx/types/calls/action_reject_params.py +25 -0
- telnyx/types/calls/action_reject_response.py +12 -0
- telnyx/types/calls/action_resume_recording_params.py +25 -0
- telnyx/types/calls/action_resume_recording_response.py +12 -0
- telnyx/types/calls/action_send_dtmf_params.py +35 -0
- telnyx/types/calls/action_send_dtmf_response.py +12 -0
- telnyx/types/calls/action_send_sip_info_params.py +31 -0
- telnyx/types/calls/action_send_sip_info_response.py +12 -0
- telnyx/types/calls/action_speak_params.py +125 -0
- telnyx/types/calls/action_speak_response.py +12 -0
- telnyx/types/calls/action_start_ai_assistant_params.py +97 -0
- telnyx/types/calls/action_start_ai_assistant_response.py +18 -0
- telnyx/types/calls/action_start_forking_params.py +41 -0
- telnyx/types/calls/action_start_forking_response.py +12 -0
- telnyx/types/calls/action_start_noise_suppression_params.py +31 -0
- telnyx/types/calls/action_start_noise_suppression_response.py +12 -0
- telnyx/types/calls/action_start_playback_params.py +83 -0
- telnyx/types/calls/action_start_playback_response.py +12 -0
- telnyx/types/calls/action_start_recording_params.py +245 -0
- telnyx/types/calls/action_start_recording_response.py +12 -0
- telnyx/types/calls/action_start_siprec_params.py +44 -0
- telnyx/types/calls/action_start_siprec_response.py +12 -0
- telnyx/types/calls/action_start_streaming_params.py +59 -0
- telnyx/types/calls/action_start_streaming_response.py +12 -0
- telnyx/types/calls/action_start_transcription_params.py +41 -0
- telnyx/types/calls/action_start_transcription_response.py +12 -0
- telnyx/types/calls/action_stop_ai_assistant_params.py +22 -0
- telnyx/types/calls/action_stop_ai_assistant_response.py +12 -0
- telnyx/types/calls/action_stop_forking_params.py +29 -0
- telnyx/types/calls/action_stop_forking_response.py +12 -0
- telnyx/types/calls/action_stop_gather_params.py +22 -0
- telnyx/types/calls/action_stop_gather_response.py +12 -0
- telnyx/types/calls/action_stop_noise_suppression_params.py +22 -0
- telnyx/types/calls/action_stop_noise_suppression_response.py +12 -0
- telnyx/types/calls/action_stop_playback_params.py +32 -0
- telnyx/types/calls/action_stop_playback_response.py +12 -0
- telnyx/types/calls/action_stop_recording_params.py +25 -0
- telnyx/types/calls/action_stop_recording_response.py +12 -0
- telnyx/types/calls/action_stop_siprec_params.py +22 -0
- telnyx/types/calls/action_stop_siprec_response.py +12 -0
- telnyx/types/calls/action_stop_streaming_params.py +29 -0
- telnyx/types/calls/action_stop_streaming_response.py +12 -0
- telnyx/types/calls/action_stop_transcription_params.py +22 -0
- telnyx/types/calls/action_stop_transcription_response.py +12 -0
- telnyx/types/calls/action_switch_supervisor_role_params.py +16 -0
- telnyx/types/calls/action_switch_supervisor_role_response.py +12 -0
- telnyx/types/calls/action_transfer_params.py +199 -0
- telnyx/types/calls/action_transfer_response.py +12 -0
- telnyx/types/calls/action_update_client_state_params.py +15 -0
- telnyx/types/calls/action_update_client_state_response.py +12 -0
- telnyx/types/calls/aws_voice_settings_param.py +9 -0
- telnyx/types/calls/call_control_command_result.py +11 -0
- telnyx/types/calls/eleven_labs_voice_settings_param.py +17 -0
- telnyx/types/calls/google_transcription_language.py +88 -0
- telnyx/types/calls/interruption_settings_param.py +12 -0
- telnyx/types/calls/loopcount_param.py +10 -0
- telnyx/types/calls/telnyx_voice_settings_param.py +15 -0
- telnyx/types/calls/transcription_config_param.py +19 -0
- telnyx/types/calls/transcription_engine_a_config_param.py +64 -0
- telnyx/types/calls/transcription_engine_b_config_param.py +119 -0
- telnyx/types/calls/transcription_start_request_param.py +40 -0
- telnyx/types/campaign/__init__.py +6 -0
- telnyx/types/campaign/usecase_get_cost_params.py +11 -0
- telnyx/types/campaign/usecase_get_cost_response.py +17 -0
- telnyx/types/campaign_builder/__init__.py +5 -0
- telnyx/types/campaign_builder/brand_qualify_by_usecase_response.py +36 -0
- telnyx/types/campaign_builder_create_params.py +145 -0
- telnyx/types/campaign_builder_create_response.py +10 -0
- telnyx/types/campaign_deactivate_response.py +15 -0
- telnyx/types/campaign_get_mno_metadata_response.py +35 -0
- telnyx/types/campaign_get_sharing_status_response.py +16 -0
- telnyx/types/campaign_list_params.py +39 -0
- telnyx/types/campaign_list_response.py +225 -0
- telnyx/types/campaign_sharing_status.py +21 -0
- telnyx/types/campaign_submit_appeal_params.py +15 -0
- telnyx/types/campaign_submit_appeal_response.py +16 -0
- telnyx/types/campaign_update_params.py +47 -0
- telnyx/types/channel_zone_list_params.py +23 -0
- telnyx/types/channel_zone_list_response.py +37 -0
- telnyx/types/channel_zone_update_params.py +12 -0
- telnyx/types/channel_zone_update_response.py +30 -0
- telnyx/types/charges_breakdown_retrieve_params.py +27 -0
- telnyx/types/charges_breakdown_retrieve_response.py +60 -0
- telnyx/types/charges_summary_retrieve_params.py +23 -0
- telnyx/types/charges_summary_retrieve_response.py +122 -0
- telnyx/types/client_create_bucket_params.py +13 -0
- telnyx/types/client_delete_objects_params.py +20 -0
- telnyx/types/client_get_object_params.py +15 -0
- telnyx/types/client_list_objects_params.py +13 -0
- telnyx/types/client_put_object_params.py +20 -0
- telnyx/types/cloudflare_sync_status.py +7 -0
- telnyx/types/comment_create_params.py +15 -0
- telnyx/types/comment_create_response.py +36 -0
- telnyx/types/comment_list_params.py +23 -0
- telnyx/types/comment_list_response.py +39 -0
- telnyx/types/comment_mark_as_read_response.py +36 -0
- telnyx/types/comment_retrieve_response.py +36 -0
- telnyx/types/conference.py +53 -0
- telnyx/types/conference_create_params.py +72 -0
- telnyx/types/conference_create_response.py +12 -0
- telnyx/types/conference_list_params.py +123 -0
- telnyx/types/conference_list_participants_params.py +51 -0
- telnyx/types/conference_list_participants_response.py +69 -0
- telnyx/types/conference_list_response.py +15 -0
- telnyx/types/conference_retrieve_response.py +12 -0
- telnyx/types/conferences/__init__.py +33 -0
- telnyx/types/conferences/action_hold_params.py +30 -0
- telnyx/types/conferences/action_hold_response.py +12 -0
- telnyx/types/conferences/action_join_params.py +100 -0
- telnyx/types/conferences/action_join_response.py +12 -0
- telnyx/types/conferences/action_leave_params.py +26 -0
- telnyx/types/conferences/action_leave_response.py +12 -0
- telnyx/types/conferences/action_mute_params.py +16 -0
- telnyx/types/conferences/action_mute_response.py +12 -0
- telnyx/types/conferences/action_play_params.py +39 -0
- telnyx/types/conferences/action_play_response.py +12 -0
- telnyx/types/conferences/action_record_pause_params.py +19 -0
- telnyx/types/conferences/action_record_pause_response.py +12 -0
- telnyx/types/conferences/action_record_resume_params.py +19 -0
- telnyx/types/conferences/action_record_resume_response.py +12 -0
- telnyx/types/conferences/action_record_start_params.py +37 -0
- telnyx/types/conferences/action_record_start_response.py +12 -0
- telnyx/types/conferences/action_record_stop_params.py +25 -0
- telnyx/types/conferences/action_record_stop_response.py +12 -0
- telnyx/types/conferences/action_speak_params.py +110 -0
- telnyx/types/conferences/action_speak_response.py +12 -0
- telnyx/types/conferences/action_stop_params.py +16 -0
- telnyx/types/conferences/action_stop_response.py +12 -0
- telnyx/types/conferences/action_unhold_params.py +16 -0
- telnyx/types/conferences/action_unhold_response.py +12 -0
- telnyx/types/conferences/action_unmute_params.py +17 -0
- telnyx/types/conferences/action_unmute_response.py +12 -0
- telnyx/types/conferences/action_update_params.py +37 -0
- telnyx/types/conferences/action_update_response.py +12 -0
- telnyx/types/conferences/conference_command_result.py +9 -0
- telnyx/types/connection_list_active_calls_params.py +32 -0
- telnyx/types/connection_list_active_calls_response.py +57 -0
- telnyx/types/connection_list_params.py +71 -0
- telnyx/types/connection_list_response.py +60 -0
- telnyx/types/connection_retrieve_response.py +57 -0
- telnyx/types/connection_rtcp_settings.py +25 -0
- telnyx/types/connection_rtcp_settings_param.py +24 -0
- telnyx/types/consumed_data.py +13 -0
- telnyx/types/country_coverage_retrieve_country_response.py +71 -0
- telnyx/types/country_coverage_retrieve_response.py +71 -0
- telnyx/types/create_verification_response.py +10 -0
- telnyx/types/credential_connection.py +122 -0
- telnyx/types/credential_connection_create_params.py +122 -0
- telnyx/types/credential_connection_create_response.py +12 -0
- telnyx/types/credential_connection_delete_response.py +12 -0
- telnyx/types/credential_connection_list_params.py +71 -0
- telnyx/types/credential_connection_list_response.py +15 -0
- telnyx/types/credential_connection_retrieve_response.py +12 -0
- telnyx/types/credential_connection_update_params.py +118 -0
- telnyx/types/credential_connection_update_response.py +12 -0
- telnyx/types/credential_connections/__init__.py +7 -0
- telnyx/types/credential_connections/action_check_registration_status_response.py +40 -0
- telnyx/types/credential_inbound.py +60 -0
- telnyx/types/credential_inbound_param.py +60 -0
- telnyx/types/credential_outbound.py +66 -0
- telnyx/types/credential_outbound_param.py +64 -0
- telnyx/types/custom_sip_header_param.py +15 -0
- telnyx/types/custom_storage_configuration.py +19 -0
- telnyx/types/custom_storage_credential_create_params.py +21 -0
- telnyx/types/custom_storage_credential_create_response.py +21 -0
- telnyx/types/custom_storage_credential_retrieve_response.py +21 -0
- telnyx/types/custom_storage_credential_update_params.py +21 -0
- telnyx/types/custom_storage_credential_update_response.py +21 -0
- telnyx/types/customer_service_record.py +86 -0
- telnyx/types/customer_service_record_create_params.py +49 -0
- telnyx/types/customer_service_record_create_response.py +12 -0
- telnyx/types/customer_service_record_list_params.py +98 -0
- telnyx/types/customer_service_record_list_response.py +15 -0
- telnyx/types/customer_service_record_retrieve_response.py +12 -0
- telnyx/types/customer_service_record_verify_phone_number_coverage_params.py +13 -0
- telnyx/types/customer_service_record_verify_phone_number_coverage_response.py +50 -0
- telnyx/types/detail_record_list_params.py +83 -0
- telnyx/types/detail_record_list_response.py +493 -0
- telnyx/types/dialogflow_config_param.py +15 -0
- telnyx/types/dialogflow_connection_create_params.py +28 -0
- telnyx/types/dialogflow_connection_create_response.py +30 -0
- telnyx/types/dialogflow_connection_retrieve_response.py +30 -0
- telnyx/types/dialogflow_connection_update_params.py +28 -0
- telnyx/types/dialogflow_connection_update_response.py +30 -0
- telnyx/types/doc_service_document.py +48 -0
- telnyx/types/document_delete_response.py +12 -0
- telnyx/types/document_link_list_params.py +37 -0
- telnyx/types/document_link_list_response.py +37 -0
- telnyx/types/document_list_params.py +75 -0
- telnyx/types/document_list_response.py +15 -0
- telnyx/types/document_retrieve_response.py +12 -0
- telnyx/types/document_update_params.py +15 -0
- telnyx/types/document_update_response.py +12 -0
- telnyx/types/document_upload_params.py +39 -0
- telnyx/types/document_upload_response.py +12 -0
- telnyx/types/dtmf_type.py +7 -0
- telnyx/types/dynamic_emergency_address.py +52 -0
- telnyx/types/dynamic_emergency_address_create_params.py +31 -0
- telnyx/types/dynamic_emergency_address_create_response.py +12 -0
- telnyx/types/dynamic_emergency_address_delete_response.py +12 -0
- telnyx/types/dynamic_emergency_address_list_params.py +37 -0
- telnyx/types/dynamic_emergency_address_list_response.py +15 -0
- telnyx/types/dynamic_emergency_address_retrieve_response.py +12 -0
- telnyx/types/dynamic_emergency_endpoint.py +33 -0
- telnyx/types/dynamic_emergency_endpoint_create_params.py +16 -0
- telnyx/types/dynamic_emergency_endpoint_create_response.py +12 -0
- telnyx/types/dynamic_emergency_endpoint_delete_response.py +12 -0
- telnyx/types/dynamic_emergency_endpoint_list_params.py +37 -0
- telnyx/types/dynamic_emergency_endpoint_list_response.py +15 -0
- telnyx/types/dynamic_emergency_endpoint_retrieve_response.py +12 -0
- telnyx/types/encrypted_media.py +8 -0
- telnyx/types/entity_type.py +7 -0
- telnyx/types/enum_retrieve_response.py +8 -0
- telnyx/types/error.py +27 -0
- telnyx/types/external_connection.py +75 -0
- telnyx/types/external_connection_create_params.py +57 -0
- telnyx/types/external_connection_create_response.py +12 -0
- telnyx/types/external_connection_delete_response.py +12 -0
- telnyx/types/external_connection_list_params.py +76 -0
- telnyx/types/external_connection_list_response.py +15 -0
- telnyx/types/external_connection_retrieve_response.py +12 -0
- telnyx/types/external_connection_update_location_params.py +14 -0
- telnyx/types/external_connection_update_location_response.py +19 -0
- telnyx/types/external_connection_update_params.py +54 -0
- telnyx/types/external_connection_update_response.py +12 -0
- telnyx/types/external_connections/__init__.py +30 -0
- telnyx/types/external_connections/civic_address_list_params.py +21 -0
- telnyx/types/external_connections/civic_address_list_response.py +60 -0
- telnyx/types/external_connections/civic_address_retrieve_response.py +60 -0
- telnyx/types/external_connections/external_connection_phone_number.py +35 -0
- telnyx/types/external_connections/log_message_dismiss_response.py +12 -0
- telnyx/types/external_connections/log_message_list_params.py +55 -0
- telnyx/types/external_connections/log_message_list_response.py +42 -0
- telnyx/types/external_connections/log_message_retrieve_response.py +39 -0
- telnyx/types/external_connections/phone_number_list_params.py +56 -0
- telnyx/types/external_connections/phone_number_list_response.py +15 -0
- telnyx/types/external_connections/phone_number_retrieve_response.py +12 -0
- telnyx/types/external_connections/phone_number_update_params.py +14 -0
- telnyx/types/external_connections/phone_number_update_response.py +12 -0
- telnyx/types/external_connections/release_list_params.py +76 -0
- telnyx/types/external_connections/release_list_response.py +43 -0
- telnyx/types/external_connections/release_retrieve_response.py +40 -0
- telnyx/types/external_connections/tn_upload_entry.py +58 -0
- telnyx/types/external_connections/upload.py +33 -0
- telnyx/types/external_connections/upload_create_params.py +26 -0
- telnyx/types/external_connections/upload_create_response.py +15 -0
- telnyx/types/external_connections/upload_list_params.py +72 -0
- telnyx/types/external_connections/upload_list_response.py +15 -0
- telnyx/types/external_connections/upload_pending_count_response.py +22 -0
- telnyx/types/external_connections/upload_refresh_status_response.py +12 -0
- telnyx/types/external_connections/upload_retrieve_response.py +12 -0
- telnyx/types/external_connections/upload_retry_response.py +12 -0
- telnyx/types/external_voice_integrations_pagination_meta.py +17 -0
- telnyx/types/fax.py +108 -0
- telnyx/types/fax_application.py +94 -0
- telnyx/types/fax_application_create_params.py +83 -0
- telnyx/types/fax_application_create_response.py +12 -0
- telnyx/types/fax_application_delete_response.py +12 -0
- telnyx/types/fax_application_list_params.py +65 -0
- telnyx/types/fax_application_list_response.py +15 -0
- telnyx/types/fax_application_retrieve_response.py +12 -0
- telnyx/types/fax_application_update_params.py +89 -0
- telnyx/types/fax_application_update_response.py +12 -0
- telnyx/types/fax_create_params.py +81 -0
- telnyx/types/fax_create_response.py +12 -0
- telnyx/types/fax_list_params.py +84 -0
- telnyx/types/fax_list_response.py +14 -0
- telnyx/types/fax_retrieve_response.py +12 -0
- telnyx/types/faxes/__init__.py +6 -0
- telnyx/types/faxes/action_cancel_response.py +11 -0
- telnyx/types/faxes/action_refresh_response.py +11 -0
- telnyx/types/fqdn.py +38 -0
- telnyx/types/fqdn_connection.py +150 -0
- telnyx/types/fqdn_connection_create_params.py +110 -0
- telnyx/types/fqdn_connection_create_response.py +12 -0
- telnyx/types/fqdn_connection_delete_response.py +12 -0
- telnyx/types/fqdn_connection_list_params.py +71 -0
- telnyx/types/fqdn_connection_list_response.py +15 -0
- telnyx/types/fqdn_connection_retrieve_response.py +12 -0
- telnyx/types/fqdn_connection_update_params.py +104 -0
- telnyx/types/fqdn_connection_update_response.py +12 -0
- telnyx/types/fqdn_create_params.py +27 -0
- telnyx/types/fqdn_create_response.py +12 -0
- telnyx/types/fqdn_delete_response.py +12 -0
- telnyx/types/fqdn_list_params.py +44 -0
- telnyx/types/fqdn_list_response.py +15 -0
- telnyx/types/fqdn_retrieve_response.py +12 -0
- telnyx/types/fqdn_update_params.py +27 -0
- telnyx/types/fqdn_update_response.py +12 -0
- telnyx/types/gcs_configuration_data.py +18 -0
- telnyx/types/gcs_configuration_data_param.py +18 -0
- telnyx/types/global_ip_allowed_port_list_response.py +31 -0
- telnyx/types/global_ip_assignment.py +31 -0
- telnyx/types/global_ip_assignment_create_params.py +18 -0
- telnyx/types/global_ip_assignment_create_response.py +12 -0
- telnyx/types/global_ip_assignment_delete_response.py +12 -0
- telnyx/types/global_ip_assignment_health_retrieve_params.py +62 -0
- telnyx/types/global_ip_assignment_health_retrieve_response.py +66 -0
- telnyx/types/global_ip_assignment_list_params.py +23 -0
- telnyx/types/global_ip_assignment_list_response.py +15 -0
- telnyx/types/global_ip_assignment_param.py +18 -0
- telnyx/types/global_ip_assignment_retrieve_response.py +12 -0
- telnyx/types/global_ip_assignment_update_params.py +17 -0
- telnyx/types/global_ip_assignment_update_response.py +12 -0
- telnyx/types/global_ip_assignments_usage_retrieve_params.py +62 -0
- telnyx/types/global_ip_assignments_usage_retrieve_response.py +75 -0
- telnyx/types/global_ip_create_params.py +19 -0
- telnyx/types/global_ip_create_response.py +29 -0
- telnyx/types/global_ip_delete_response.py +29 -0
- telnyx/types/global_ip_health_check_create_params.py +19 -0
- telnyx/types/global_ip_health_check_create_response.py +26 -0
- telnyx/types/global_ip_health_check_delete_response.py +26 -0
- telnyx/types/global_ip_health_check_list_params.py +23 -0
- telnyx/types/global_ip_health_check_list_response.py +29 -0
- telnyx/types/global_ip_health_check_retrieve_response.py +26 -0
- telnyx/types/global_ip_health_check_type_list_response.py +22 -0
- telnyx/types/global_ip_latency_retrieve_params.py +37 -0
- telnyx/types/global_ip_latency_retrieve_response.py +143 -0
- telnyx/types/global_ip_list_params.py +23 -0
- telnyx/types/global_ip_list_response.py +32 -0
- telnyx/types/global_ip_protocol_list_response.py +22 -0
- telnyx/types/global_ip_retrieve_response.py +29 -0
- telnyx/types/global_ip_usage_retrieve_params.py +37 -0
- telnyx/types/global_ip_usage_retrieve_response.py +47 -0
- telnyx/types/inbound_channel_list_response.py +19 -0
- telnyx/types/inbound_channel_update_params.py +12 -0
- telnyx/types/inbound_channel_update_response.py +19 -0
- telnyx/types/inbound_fqdn.py +111 -0
- telnyx/types/inbound_fqdn_param.py +111 -0
- telnyx/types/inbound_ip.py +111 -0
- telnyx/types/inbound_ip_param.py +111 -0
- telnyx/types/integration_secret.py +20 -0
- telnyx/types/integration_secret_create_params.py +30 -0
- telnyx/types/integration_secret_create_response.py +10 -0
- telnyx/types/integration_secret_list_params.py +28 -0
- telnyx/types/integration_secret_list_response.py +24 -0
- telnyx/types/interface.py +19 -0
- telnyx/types/interface_status.py +7 -0
- telnyx/types/inventory_coverage_list_params.py +86 -0
- telnyx/types/inventory_coverage_list_response.py +41 -0
- telnyx/types/invoice_list_params.py +26 -0
- telnyx/types/invoice_list_response.py +38 -0
- telnyx/types/invoice_retrieve_params.py +12 -0
- telnyx/types/invoice_retrieve_response.py +29 -0
- telnyx/types/ip.py +30 -0
- telnyx/types/ip_connection.py +106 -0
- telnyx/types/ip_connection_create_params.py +182 -0
- telnyx/types/ip_connection_create_response.py +12 -0
- telnyx/types/ip_connection_delete_response.py +12 -0
- telnyx/types/ip_connection_list_params.py +71 -0
- telnyx/types/ip_connection_list_response.py +15 -0
- telnyx/types/ip_connection_retrieve_response.py +12 -0
- telnyx/types/ip_connection_update_params.py +101 -0
- telnyx/types/ip_connection_update_response.py +12 -0
- telnyx/types/ip_create_params.py +18 -0
- telnyx/types/ip_create_response.py +12 -0
- telnyx/types/ip_delete_response.py +12 -0
- telnyx/types/ip_list_params.py +40 -0
- telnyx/types/ip_list_response.py +12 -0
- telnyx/types/ip_retrieve_response.py +12 -0
- telnyx/types/ip_update_params.py +18 -0
- telnyx/types/ip_update_response.py +12 -0
- telnyx/types/ledger_billing_group_report.py +32 -0
- telnyx/types/ledger_billing_group_report_create_params.py +15 -0
- telnyx/types/ledger_billing_group_report_create_response.py +12 -0
- telnyx/types/ledger_billing_group_report_retrieve_response.py +12 -0
- telnyx/types/list_buckets_response.py +20 -0
- telnyx/types/list_objects_response.py +24 -0
- telnyx/types/list_retrieve_all_response.py +30 -0
- telnyx/types/list_retrieve_by_zone_response.py +30 -0
- telnyx/types/managed_account.py +61 -0
- telnyx/types/managed_account_balance.py +25 -0
- telnyx/types/managed_account_create_params.py +48 -0
- telnyx/types/managed_account_create_response.py +12 -0
- telnyx/types/managed_account_get_allocatable_global_outbound_channels_response.py +39 -0
- telnyx/types/managed_account_list_params.py +86 -0
- telnyx/types/managed_account_list_response.py +59 -0
- telnyx/types/managed_account_retrieve_response.py +12 -0
- telnyx/types/managed_account_update_global_channel_limit_params.py +17 -0
- telnyx/types/managed_account_update_global_channel_limit_response.py +32 -0
- telnyx/types/managed_account_update_params.py +17 -0
- telnyx/types/managed_account_update_response.py +12 -0
- telnyx/types/managed_accounts/__init__.py +7 -0
- telnyx/types/managed_accounts/action_disable_response.py +12 -0
- telnyx/types/managed_accounts/action_enable_params.py +16 -0
- telnyx/types/managed_accounts/action_enable_response.py +12 -0
- telnyx/types/media_list_params.py +21 -0
- telnyx/types/media_list_response.py +15 -0
- telnyx/types/media_resource.py +24 -0
- telnyx/types/media_retrieve_response.py +12 -0
- telnyx/types/media_update_params.py +21 -0
- telnyx/types/media_update_response.py +12 -0
- telnyx/types/media_upload_params.py +24 -0
- telnyx/types/media_upload_response.py +12 -0
- telnyx/types/message_cancel_scheduled_response.py +198 -0
- telnyx/types/message_retrieve_response.py +215 -0
- telnyx/types/message_schedule_params.py +77 -0
- telnyx/types/message_schedule_response.py +12 -0
- telnyx/types/message_send_group_mms_params.py +43 -0
- telnyx/types/message_send_group_mms_response.py +12 -0
- telnyx/types/message_send_long_code_params.py +58 -0
- telnyx/types/message_send_long_code_response.py +12 -0
- telnyx/types/message_send_number_pool_params.py +56 -0
- telnyx/types/message_send_number_pool_response.py +12 -0
- telnyx/types/message_send_params.py +77 -0
- telnyx/types/message_send_response.py +12 -0
- telnyx/types/message_send_short_code_params.py +58 -0
- telnyx/types/message_send_short_code_response.py +12 -0
- telnyx/types/messages/__init__.py +6 -0
- telnyx/types/messages/rc_generate_deeplink_params.py +15 -0
- telnyx/types/messages/rc_generate_deeplink_response.py +14 -0
- telnyx/types/messaging/__init__.py +9 -0
- telnyx/types/messaging/rc_invite_test_number_response.py +26 -0
- telnyx/types/messaging/rc_list_bulk_capabilities_params.py +16 -0
- telnyx/types/messaging/rc_list_bulk_capabilities_response.py +12 -0
- telnyx/types/messaging/rc_retrieve_capabilities_response.py +12 -0
- telnyx/types/messaging/rcs/__init__.py +7 -0
- telnyx/types/messaging/rcs/agent_list_params.py +23 -0
- telnyx/types/messaging/rcs/agent_list_response.py +15 -0
- telnyx/types/messaging/rcs/agent_update_params.py +19 -0
- telnyx/types/messaging/rcs_capabilities.py +25 -0
- telnyx/types/messaging_error.py +27 -0
- telnyx/types/messaging_hosted_number_delete_response.py +12 -0
- telnyx/types/messaging_hosted_number_order_check_eligibility_params.py +13 -0
- telnyx/types/messaging_hosted_number_order_check_eligibility_response.py +42 -0
- telnyx/types/messaging_hosted_number_order_create_params.py +19 -0
- telnyx/types/messaging_hosted_number_order_create_response.py +12 -0
- telnyx/types/messaging_hosted_number_order_create_verification_codes_params.py +14 -0
- telnyx/types/messaging_hosted_number_order_create_verification_codes_response.py +39 -0
- telnyx/types/messaging_hosted_number_order_delete_response.py +12 -0
- telnyx/types/messaging_hosted_number_order_list_params.py +23 -0
- telnyx/types/messaging_hosted_number_order_list_response.py +15 -0
- telnyx/types/messaging_hosted_number_order_retrieve_response.py +12 -0
- telnyx/types/messaging_hosted_number_order_validate_codes_params.py +18 -0
- telnyx/types/messaging_hosted_number_order_validate_codes_response.py +24 -0
- telnyx/types/messaging_hosted_number_orders/__init__.py +6 -0
- telnyx/types/messaging_hosted_number_orders/action_upload_file_params.py +20 -0
- telnyx/types/messaging_hosted_number_orders/action_upload_file_response.py +12 -0
- telnyx/types/messaging_numbers_bulk_update_create_params.py +22 -0
- telnyx/types/messaging_numbers_bulk_update_create_response.py +29 -0
- telnyx/types/messaging_numbers_bulk_update_retrieve_response.py +29 -0
- telnyx/types/messaging_optout_list_params.py +64 -0
- telnyx/types/messaging_optout_list_response.py +37 -0
- telnyx/types/messaging_profile.py +97 -0
- telnyx/types/messaging_profile_create_params.py +82 -0
- telnyx/types/messaging_profile_create_response.py +12 -0
- telnyx/types/messaging_profile_delete_response.py +12 -0
- telnyx/types/messaging_profile_list_params.py +31 -0
- telnyx/types/messaging_profile_list_phone_numbers_params.py +23 -0
- telnyx/types/messaging_profile_list_phone_numbers_response.py +15 -0
- telnyx/types/messaging_profile_list_response.py +15 -0
- telnyx/types/messaging_profile_list_short_codes_params.py +23 -0
- telnyx/types/messaging_profile_list_short_codes_response.py +15 -0
- telnyx/types/messaging_profile_retrieve_response.py +12 -0
- telnyx/types/messaging_profile_update_params.py +87 -0
- telnyx/types/messaging_profile_update_response.py +12 -0
- telnyx/types/messaging_profiles/__init__.py +10 -0
- telnyx/types/messaging_profiles/auto_resp_config.py +25 -0
- telnyx/types/messaging_profiles/auto_resp_config_response.py +10 -0
- telnyx/types/messaging_profiles/autoresp_config_create_params.py +18 -0
- telnyx/types/messaging_profiles/autoresp_config_list_params.py +35 -0
- telnyx/types/messaging_profiles/autoresp_config_list_response.py +15 -0
- telnyx/types/messaging_profiles/autoresp_config_update_params.py +20 -0
- telnyx/types/messaging_tollfree/__init__.py +3 -0
- telnyx/types/messaging_tollfree/verification/__init__.py +17 -0
- telnyx/types/messaging_tollfree/verification/request_create_params.py +91 -0
- telnyx/types/messaging_tollfree/verification/request_list_params.py +31 -0
- telnyx/types/messaging_tollfree/verification/request_list_response.py +16 -0
- telnyx/types/messaging_tollfree/verification/request_update_params.py +91 -0
- telnyx/types/messaging_tollfree/verification/tf_phone_number.py +11 -0
- telnyx/types/messaging_tollfree/verification/tf_phone_number_param.py +13 -0
- telnyx/types/messaging_tollfree/verification/tf_verification_status.py +9 -0
- telnyx/types/messaging_tollfree/verification/url.py +9 -0
- telnyx/types/messaging_tollfree/verification/url_param.py +11 -0
- telnyx/types/messaging_tollfree/verification/use_case_categories.py +51 -0
- telnyx/types/messaging_tollfree/verification/verification_request_egress.py +67 -0
- telnyx/types/messaging_tollfree/verification/verification_request_status.py +72 -0
- telnyx/types/messaging_tollfree/verification/volume.py +9 -0
- telnyx/types/messaging_url_domain_list_params.py +23 -0
- telnyx/types/messaging_url_domain_list_response.py +24 -0
- telnyx/types/messsage_rcs_params.py +67 -0
- telnyx/types/messsage_rcs_response.py +59 -0
- telnyx/types/mobile_network_operator_list_params.py +62 -0
- telnyx/types/mobile_network_operator_list_response.py +57 -0
- telnyx/types/mobile_push_credential_create_params.py +36 -0
- telnyx/types/mobile_push_credential_list_params.py +37 -0
- telnyx/types/mobile_push_credential_list_response.py +15 -0
- telnyx/types/month_detail.py +18 -0
- telnyx/types/network_coverage_list_params.py +74 -0
- telnyx/types/network_coverage_list_response.py +42 -0
- telnyx/types/network_create_params.py +12 -0
- telnyx/types/network_create_response.py +20 -0
- telnyx/types/network_delete_response.py +20 -0
- telnyx/types/network_list_interfaces_params.py +37 -0
- telnyx/types/network_list_interfaces_response.py +40 -0
- telnyx/types/network_list_params.py +31 -0
- telnyx/types/network_list_response.py +23 -0
- telnyx/types/network_retrieve_response.py +20 -0
- telnyx/types/network_update_params.py +12 -0
- telnyx/types/network_update_response.py +20 -0
- telnyx/types/networks/__init__.py +8 -0
- telnyx/types/networks/default_gateway_create_params.py +12 -0
- telnyx/types/networks/default_gateway_create_response.py +30 -0
- telnyx/types/networks/default_gateway_delete_response.py +30 -0
- telnyx/types/networks/default_gateway_retrieve_response.py +30 -0
- telnyx/types/notification_channel.py +29 -0
- telnyx/types/notification_channel_create_params.py +18 -0
- telnyx/types/notification_channel_create_response.py +13 -0
- telnyx/types/notification_channel_delete_response.py +13 -0
- telnyx/types/notification_channel_list_params.py +94 -0
- telnyx/types/notification_channel_list_response.py +15 -0
- telnyx/types/notification_channel_retrieve_response.py +13 -0
- telnyx/types/notification_channel_update_params.py +18 -0
- telnyx/types/notification_channel_update_response.py +13 -0
- telnyx/types/notification_event_condition_list_params.py +94 -0
- telnyx/types/notification_event_condition_list_response.py +59 -0
- telnyx/types/notification_event_list_params.py +23 -0
- telnyx/types/notification_event_list_response.py +33 -0
- telnyx/types/notification_profile.py +22 -0
- telnyx/types/notification_profile_create_params.py +12 -0
- telnyx/types/notification_profile_create_response.py +13 -0
- telnyx/types/notification_profile_delete_response.py +13 -0
- telnyx/types/notification_profile_list_params.py +23 -0
- telnyx/types/notification_profile_list_response.py +15 -0
- telnyx/types/notification_profile_retrieve_response.py +13 -0
- telnyx/types/notification_profile_update_params.py +12 -0
- telnyx/types/notification_profile_update_response.py +13 -0
- telnyx/types/notification_setting.py +55 -0
- telnyx/types/notification_setting_create_params.py +27 -0
- telnyx/types/notification_setting_create_response.py +12 -0
- telnyx/types/notification_setting_delete_response.py +12 -0
- telnyx/types/notification_setting_list_params.py +94 -0
- telnyx/types/notification_setting_list_response.py +15 -0
- telnyx/types/notification_setting_retrieve_response.py +12 -0
- telnyx/types/number_block_order.py +48 -0
- telnyx/types/number_block_order_create_params.py +24 -0
- telnyx/types/number_block_order_create_response.py +12 -0
- telnyx/types/number_block_order_list_params.py +51 -0
- telnyx/types/number_block_order_list_response.py +15 -0
- telnyx/types/number_block_order_retrieve_response.py +12 -0
- telnyx/types/number_lookup_retrieve_params.py +12 -0
- telnyx/types/number_lookup_retrieve_response.py +145 -0
- telnyx/types/number_order_create_params.py +35 -0
- telnyx/types/number_order_create_response.py +12 -0
- telnyx/types/number_order_list_params.py +55 -0
- telnyx/types/number_order_list_response.py +61 -0
- telnyx/types/number_order_phone_number.py +55 -0
- telnyx/types/number_order_phone_number_list_params.py +20 -0
- telnyx/types/number_order_phone_number_list_response.py +15 -0
- telnyx/types/number_order_phone_number_retrieve_response.py +12 -0
- telnyx/types/number_order_phone_number_update_requirement_group_params.py +12 -0
- telnyx/types/number_order_phone_number_update_requirement_group_response.py +54 -0
- telnyx/types/number_order_phone_number_update_requirements_params.py +14 -0
- telnyx/types/number_order_phone_number_update_requirements_response.py +12 -0
- telnyx/types/number_order_retrieve_response.py +12 -0
- telnyx/types/number_order_update_params.py +17 -0
- telnyx/types/number_order_update_response.py +12 -0
- telnyx/types/number_order_with_phone_numbers.py +47 -0
- telnyx/types/number_pool_settings.py +51 -0
- telnyx/types/number_pool_settings_param.py +51 -0
- telnyx/types/number_reservation.py +30 -0
- telnyx/types/number_reservation_create_params.py +17 -0
- telnyx/types/number_reservation_create_response.py +12 -0
- telnyx/types/number_reservation_list_params.py +54 -0
- telnyx/types/number_reservation_list_response.py +15 -0
- telnyx/types/number_reservation_retrieve_response.py +12 -0
- telnyx/types/number_reservations/__init__.py +5 -0
- telnyx/types/number_reservations/action_extend_response.py +12 -0
- telnyx/types/numbers_feature_create_params.py +12 -0
- telnyx/types/numbers_feature_create_response.py +17 -0
- telnyx/types/operator_connect/__init__.py +5 -0
- telnyx/types/operator_connect/action_refresh_response.py +15 -0
- telnyx/types/ota_update_list_params.py +40 -0
- telnyx/types/ota_update_list_response.py +39 -0
- telnyx/types/ota_update_retrieve_response.py +71 -0
- telnyx/types/outbound_call_recording.py +28 -0
- telnyx/types/outbound_call_recording_param.py +28 -0
- telnyx/types/outbound_fqdn.py +86 -0
- telnyx/types/outbound_fqdn_param.py +85 -0
- telnyx/types/outbound_ip.py +73 -0
- telnyx/types/outbound_ip_param.py +71 -0
- telnyx/types/outbound_message_payload.py +196 -0
- telnyx/types/outbound_voice_profile.py +84 -0
- telnyx/types/outbound_voice_profile_create_params.py +71 -0
- telnyx/types/outbound_voice_profile_create_response.py +12 -0
- telnyx/types/outbound_voice_profile_delete_response.py +12 -0
- telnyx/types/outbound_voice_profile_list_params.py +70 -0
- telnyx/types/outbound_voice_profile_list_response.py +15 -0
- telnyx/types/outbound_voice_profile_retrieve_response.py +12 -0
- telnyx/types/outbound_voice_profile_update_params.py +71 -0
- telnyx/types/outbound_voice_profile_update_response.py +12 -0
- telnyx/types/pagination_meta.py +17 -0
- telnyx/types/partner_campaign_list_params.py +39 -0
- telnyx/types/partner_campaign_list_response.py +18 -0
- telnyx/types/partner_campaign_list_shared_by_me_params.py +20 -0
- telnyx/types/partner_campaign_list_shared_by_me_response.py +45 -0
- telnyx/types/partner_campaign_retrieve_sharing_status_response.py +10 -0
- telnyx/types/partner_campaign_update_params.py +17 -0
- telnyx/types/payment/__init__.py +7 -0
- telnyx/types/payment/auto_recharge_pref_list_response.py +37 -0
- telnyx/types/payment/auto_recharge_pref_update_params.py +26 -0
- telnyx/types/payment/auto_recharge_pref_update_response.py +37 -0
- telnyx/types/phone_number.py +49 -0
- telnyx/types/phone_number_assignment_by_profile_assign_params.py +29 -0
- telnyx/types/phone_number_assignment_by_profile_assign_response.py +46 -0
- telnyx/types/phone_number_assignment_by_profile_retrieve_phone_number_status_params.py +15 -0
- telnyx/types/phone_number_assignment_by_profile_retrieve_phone_number_status_response.py +24 -0
- telnyx/types/phone_number_assignment_by_profile_retrieve_status_response.py +22 -0
- telnyx/types/phone_number_blocks/__init__.py +12 -0
- telnyx/types/phone_number_blocks/job.py +89 -0
- telnyx/types/phone_number_blocks/job_delete_phone_number_block_params.py +11 -0
- telnyx/types/phone_number_blocks/job_delete_phone_number_block_response.py +12 -0
- telnyx/types/phone_number_blocks/job_list_params.py +43 -0
- telnyx/types/phone_number_blocks/job_list_response.py +15 -0
- telnyx/types/phone_number_blocks/job_retrieve_response.py +12 -0
- telnyx/types/phone_number_campaign.py +48 -0
- telnyx/types/phone_number_campaign_create_params.py +17 -0
- telnyx/types/phone_number_campaign_list_params.py +42 -0
- telnyx/types/phone_number_campaign_list_response.py +18 -0
- telnyx/types/phone_number_campaign_update_params.py +17 -0
- telnyx/types/phone_number_delete_response.py +113 -0
- telnyx/types/phone_number_detailed.py +139 -0
- telnyx/types/phone_number_list_params.py +130 -0
- telnyx/types/phone_number_list_response.py +15 -0
- telnyx/types/phone_number_retrieve_response.py +12 -0
- telnyx/types/phone_number_slim_list_params.py +148 -0
- telnyx/types/phone_number_slim_list_response.py +125 -0
- telnyx/types/phone_number_update_params.py +33 -0
- telnyx/types/phone_number_update_response.py +12 -0
- telnyx/types/phone_numbers/__init__.py +56 -0
- telnyx/types/phone_numbers/action_change_bundle_status_params.py +18 -0
- telnyx/types/phone_numbers/action_change_bundle_status_response.py +12 -0
- telnyx/types/phone_numbers/action_enable_emergency_params.py +15 -0
- telnyx/types/phone_numbers/action_enable_emergency_response.py +12 -0
- telnyx/types/phone_numbers/action_verify_ownership_params.py +13 -0
- telnyx/types/phone_numbers/action_verify_ownership_response.py +30 -0
- telnyx/types/phone_numbers/call_forwarding.py +27 -0
- telnyx/types/phone_numbers/call_forwarding_param.py +26 -0
- telnyx/types/phone_numbers/call_recording.py +22 -0
- telnyx/types/phone_numbers/call_recording_param.py +21 -0
- telnyx/types/phone_numbers/cnam_listing.py +22 -0
- telnyx/types/phone_numbers/cnam_listing_param.py +22 -0
- telnyx/types/phone_numbers/csv_download.py +25 -0
- telnyx/types/phone_numbers/csv_download_create_params.py +96 -0
- telnyx/types/phone_numbers/csv_download_create_response.py +12 -0
- telnyx/types/phone_numbers/csv_download_list_params.py +23 -0
- telnyx/types/phone_numbers/csv_download_list_response.py +15 -0
- telnyx/types/phone_numbers/csv_download_retrieve_response.py +12 -0
- telnyx/types/phone_numbers/job_delete_batch_params.py +12 -0
- telnyx/types/phone_numbers/job_delete_batch_response.py +12 -0
- telnyx/types/phone_numbers/job_list_params.py +37 -0
- telnyx/types/phone_numbers/job_list_response.py +15 -0
- telnyx/types/phone_numbers/job_retrieve_response.py +12 -0
- telnyx/types/phone_numbers/job_update_batch_params.py +130 -0
- telnyx/types/phone_numbers/job_update_batch_response.py +12 -0
- telnyx/types/phone_numbers/job_update_emergency_settings_batch_params.py +22 -0
- telnyx/types/phone_numbers/job_update_emergency_settings_batch_response.py +12 -0
- telnyx/types/phone_numbers/media_features.py +28 -0
- telnyx/types/phone_numbers/media_features_param.py +28 -0
- telnyx/types/phone_numbers/messaging_list_params.py +23 -0
- telnyx/types/phone_numbers/messaging_list_response.py +15 -0
- telnyx/types/phone_numbers/messaging_retrieve_response.py +12 -0
- telnyx/types/phone_numbers/messaging_update_params.py +25 -0
- telnyx/types/phone_numbers/messaging_update_response.py +12 -0
- telnyx/types/phone_numbers/phone_number_with_voice_settings.py +84 -0
- telnyx/types/phone_numbers/phone_numbers_job.py +111 -0
- telnyx/types/phone_numbers/update_voice_settings_param.py +52 -0
- telnyx/types/phone_numbers/voice_list_params.py +63 -0
- telnyx/types/phone_numbers/voice_list_response.py +15 -0
- telnyx/types/phone_numbers/voice_retrieve_response.py +12 -0
- telnyx/types/phone_numbers/voice_update_params.py +52 -0
- telnyx/types/phone_numbers/voice_update_response.py +12 -0
- telnyx/types/phone_numbers/voicemail_create_params.py +15 -0
- telnyx/types/phone_numbers/voicemail_create_response.py +12 -0
- telnyx/types/phone_numbers/voicemail_pref_response.py +15 -0
- telnyx/types/phone_numbers/voicemail_retrieve_response.py +12 -0
- telnyx/types/phone_numbers/voicemail_update_params.py +15 -0
- telnyx/types/phone_numbers/voicemail_update_response.py +12 -0
- telnyx/types/phone_numbers_regulatory_requirement_retrieve_params.py +20 -0
- telnyx/types/phone_numbers_regulatory_requirement_retrieve_response.py +62 -0
- telnyx/types/portability_check_run_params.py +13 -0
- telnyx/types/portability_check_run_response.py +31 -0
- telnyx/types/porting/__init__.py +26 -0
- telnyx/types/porting/event_list_params.py +61 -0
- telnyx/types/porting/event_list_response.py +200 -0
- telnyx/types/porting/event_retrieve_response.py +197 -0
- telnyx/types/porting/export_porting_orders_csv_report.py +43 -0
- telnyx/types/porting/export_porting_orders_csv_report_param.py +44 -0
- telnyx/types/porting/loa_configuration_create_params.py +57 -0
- telnyx/types/porting/loa_configuration_create_response.py +12 -0
- telnyx/types/porting/loa_configuration_list_params.py +23 -0
- telnyx/types/porting/loa_configuration_list_response.py +15 -0
- telnyx/types/porting/loa_configuration_preview_0_params.py +57 -0
- telnyx/types/porting/loa_configuration_retrieve_response.py +12 -0
- telnyx/types/porting/loa_configuration_update_params.py +57 -0
- telnyx/types/porting/loa_configuration_update_response.py +12 -0
- telnyx/types/porting/porting_loa_configuration.py +77 -0
- telnyx/types/porting/porting_report.py +39 -0
- telnyx/types/porting/report_create_params.py +17 -0
- telnyx/types/porting/report_create_response.py +12 -0
- telnyx/types/porting/report_list_params.py +37 -0
- telnyx/types/porting/report_list_response.py +15 -0
- telnyx/types/porting/report_retrieve_response.py +12 -0
- telnyx/types/porting_list_uk_carriers_response.py +38 -0
- telnyx/types/porting_order.py +98 -0
- telnyx/types/porting_order_activation_settings.py +39 -0
- telnyx/types/porting_order_create_params.py +16 -0
- telnyx/types/porting_order_create_response.py +12 -0
- telnyx/types/porting_order_documents.py +15 -0
- telnyx/types/porting_order_documents_param.py +15 -0
- telnyx/types/porting_order_end_user.py +15 -0
- telnyx/types/porting_order_end_user_admin.py +33 -0
- telnyx/types/porting_order_end_user_admin_param.py +33 -0
- telnyx/types/porting_order_end_user_location.py +27 -0
- telnyx/types/porting_order_end_user_location_param.py +27 -0
- telnyx/types/porting_order_end_user_param.py +16 -0
- telnyx/types/porting_order_list_params.py +116 -0
- telnyx/types/porting_order_list_response.py +15 -0
- telnyx/types/porting_order_messaging.py +28 -0
- telnyx/types/porting_order_misc.py +32 -0
- telnyx/types/porting_order_misc_param.py +32 -0
- telnyx/types/porting_order_phone_number_configuration.py +23 -0
- telnyx/types/porting_order_phone_number_configuration_param.py +24 -0
- telnyx/types/porting_order_requirement.py +22 -0
- telnyx/types/porting_order_retrieve_allowed_foc_windows_response.py +26 -0
- telnyx/types/porting_order_retrieve_exception_types_response.py +12 -0
- telnyx/types/porting_order_retrieve_loa_template_params.py +15 -0
- telnyx/types/porting_order_retrieve_params.py +12 -0
- telnyx/types/porting_order_retrieve_requirements_params.py +23 -0
- telnyx/types/porting_order_retrieve_requirements_response.py +52 -0
- telnyx/types/porting_order_retrieve_response.py +19 -0
- telnyx/types/porting_order_retrieve_sub_request_response.py +19 -0
- telnyx/types/porting_order_type.py +7 -0
- telnyx/types/porting_order_update_params.py +74 -0
- telnyx/types/porting_order_update_response.py +19 -0
- telnyx/types/porting_order_user_feedback.py +18 -0
- telnyx/types/porting_order_user_feedback_param.py +18 -0
- telnyx/types/porting_orders/__init__.py +73 -0
- telnyx/types/porting_orders/action_activate_response.py +12 -0
- telnyx/types/porting_orders/action_cancel_response.py +19 -0
- telnyx/types/porting_orders/action_confirm_response.py +19 -0
- telnyx/types/porting_orders/action_requirement_initiate_params.py +25 -0
- telnyx/types/porting_orders/action_requirement_initiate_response.py +45 -0
- telnyx/types/porting_orders/action_requirement_list_params.py +56 -0
- telnyx/types/porting_orders/action_requirement_list_response.py +48 -0
- telnyx/types/porting_orders/action_share_params.py +15 -0
- telnyx/types/porting_orders/action_share_response.py +39 -0
- telnyx/types/porting_orders/activation_job_list_params.py +23 -0
- telnyx/types/porting_orders/activation_job_list_response.py +15 -0
- telnyx/types/porting_orders/activation_job_retrieve_response.py +12 -0
- telnyx/types/porting_orders/activation_job_update_params.py +21 -0
- telnyx/types/porting_orders/activation_job_update_response.py +12 -0
- telnyx/types/porting_orders/additional_document_create_params.py +20 -0
- telnyx/types/porting_orders/additional_document_create_response.py +42 -0
- telnyx/types/porting_orders/additional_document_list_params.py +46 -0
- telnyx/types/porting_orders/additional_document_list_response.py +45 -0
- telnyx/types/porting_orders/associated_phone_number_create_params.py +22 -0
- telnyx/types/porting_orders/associated_phone_number_create_response.py +12 -0
- telnyx/types/porting_orders/associated_phone_number_delete_response.py +12 -0
- telnyx/types/porting_orders/associated_phone_number_list_params.py +48 -0
- telnyx/types/porting_orders/associated_phone_number_list_response.py +15 -0
- telnyx/types/porting_orders/comment_create_params.py +11 -0
- telnyx/types/porting_orders/comment_create_response.py +31 -0
- telnyx/types/porting_orders/comment_list_params.py +23 -0
- telnyx/types/porting_orders/comment_list_response.py +34 -0
- telnyx/types/porting_orders/phone_number_block_create_params.py +46 -0
- telnyx/types/porting_orders/phone_number_block_create_response.py +12 -0
- telnyx/types/porting_orders/phone_number_block_delete_response.py +12 -0
- telnyx/types/porting_orders/phone_number_block_list_params.py +105 -0
- telnyx/types/porting_orders/phone_number_block_list_response.py +15 -0
- telnyx/types/porting_orders/phone_number_configuration_create_params.py +20 -0
- telnyx/types/porting_orders/phone_number_configuration_create_response.py +32 -0
- telnyx/types/porting_orders/phone_number_configuration_list_params.py +70 -0
- telnyx/types/porting_orders/phone_number_configuration_list_response.py +35 -0
- telnyx/types/porting_orders/phone_number_extension_create_params.py +53 -0
- telnyx/types/porting_orders/phone_number_extension_create_response.py +12 -0
- telnyx/types/porting_orders/phone_number_extension_delete_response.py +12 -0
- telnyx/types/porting_orders/phone_number_extension_list_params.py +45 -0
- telnyx/types/porting_orders/phone_number_extension_list_response.py +15 -0
- telnyx/types/porting_orders/porting_associated_phone_number.py +49 -0
- telnyx/types/porting_orders/porting_phone_number_block.py +69 -0
- telnyx/types/porting_orders/porting_phone_number_extension.py +66 -0
- telnyx/types/porting_orders/verification_code_list_params.py +42 -0
- telnyx/types/porting_orders/verification_code_list_response.py +38 -0
- telnyx/types/porting_orders/verification_code_send_params.py +14 -0
- telnyx/types/porting_orders/verification_code_verify_params.py +18 -0
- telnyx/types/porting_orders/verification_code_verify_response.py +35 -0
- telnyx/types/porting_orders_activation_job.py +46 -0
- telnyx/types/porting_phone_number_list_params.py +36 -0
- telnyx/types/porting_phone_number_list_response.py +76 -0
- telnyx/types/portout_details.py +98 -0
- telnyx/types/portout_list_params.py +86 -0
- telnyx/types/portout_list_rejection_codes_params.py +21 -0
- telnyx/types/portout_list_rejection_codes_response.py +19 -0
- telnyx/types/portout_list_response.py +15 -0
- telnyx/types/portout_retrieve_response.py +12 -0
- telnyx/types/portout_update_status_params.py +20 -0
- telnyx/types/portout_update_status_response.py +12 -0
- telnyx/types/portouts/__init__.py +21 -0
- telnyx/types/portouts/comment_create_params.py +12 -0
- telnyx/types/portouts/comment_create_response.py +33 -0
- telnyx/types/portouts/comment_list_response.py +36 -0
- telnyx/types/portouts/event_list_params.py +52 -0
- telnyx/types/portouts/event_list_response.py +116 -0
- telnyx/types/portouts/event_retrieve_response.py +113 -0
- telnyx/types/portouts/export_portouts_csv_report.py +38 -0
- telnyx/types/portouts/export_portouts_csv_report_param.py +39 -0
- telnyx/types/portouts/portout_report.py +39 -0
- telnyx/types/portouts/report_create_params.py +17 -0
- telnyx/types/portouts/report_create_response.py +12 -0
- telnyx/types/portouts/report_list_params.py +37 -0
- telnyx/types/portouts/report_list_response.py +15 -0
- telnyx/types/portouts/report_retrieve_response.py +12 -0
- telnyx/types/portouts/supporting_document_create_params.py +21 -0
- telnyx/types/portouts/supporting_document_create_response.py +34 -0
- telnyx/types/portouts/supporting_document_list_response.py +34 -0
- telnyx/types/private_wireless_gateway.py +42 -0
- telnyx/types/private_wireless_gateway_create_params.py +21 -0
- telnyx/types/private_wireless_gateway_create_response.py +12 -0
- telnyx/types/private_wireless_gateway_delete_response.py +12 -0
- telnyx/types/private_wireless_gateway_list_params.py +32 -0
- telnyx/types/private_wireless_gateway_list_response.py +15 -0
- telnyx/types/private_wireless_gateway_retrieve_response.py +12 -0
- telnyx/types/private_wireless_gateway_status.py +30 -0
- telnyx/types/public_internet_gateway_create_params.py +18 -0
- telnyx/types/public_internet_gateway_create_response.py +37 -0
- telnyx/types/public_internet_gateway_delete_response.py +37 -0
- telnyx/types/public_internet_gateway_list_params.py +34 -0
- telnyx/types/public_internet_gateway_list_response.py +40 -0
- telnyx/types/public_internet_gateway_retrieve_response.py +37 -0
- telnyx/types/push_credential.py +39 -0
- telnyx/types/push_credential_response.py +12 -0
- telnyx/types/pwg_assigned_resources_summary.py +15 -0
- telnyx/types/queue_retrieve_response.py +40 -0
- telnyx/types/queues/__init__.py +7 -0
- telnyx/types/queues/call_list_params.py +32 -0
- telnyx/types/queues/call_list_response.py +55 -0
- telnyx/types/queues/call_retrieve_response.py +52 -0
- telnyx/types/rcs_agent.py +37 -0
- telnyx/types/rcs_agent_message.py +77 -0
- telnyx/types/rcs_agent_message_param.py +79 -0
- telnyx/types/rcs_agent_response.py +12 -0
- telnyx/types/rcs_card_content.py +35 -0
- telnyx/types/rcs_card_content_param.py +36 -0
- telnyx/types/rcs_content_info.py +18 -0
- telnyx/types/rcs_content_info_param.py +18 -0
- telnyx/types/rcs_suggestion.py +124 -0
- telnyx/types/rcs_suggestion_param.py +126 -0
- telnyx/types/record.py +21 -0
- telnyx/types/record_param.py +11 -0
- telnyx/types/recording_delete_response.py +12 -0
- telnyx/types/recording_list_params.py +76 -0
- telnyx/types/recording_list_response.py +15 -0
- telnyx/types/recording_response_data.py +72 -0
- telnyx/types/recording_retrieve_response.py +12 -0
- telnyx/types/recording_transcription.py +36 -0
- telnyx/types/recording_transcription_delete_response.py +12 -0
- telnyx/types/recording_transcription_list_response.py +32 -0
- telnyx/types/recording_transcription_retrieve_response.py +12 -0
- telnyx/types/recordings/__init__.py +5 -0
- telnyx/types/recordings/action_delete_params.py +13 -0
- telnyx/types/region_in.py +12 -0
- telnyx/types/region_list_response.py +31 -0
- telnyx/types/regulatory_requirement_retrieve_params.py +33 -0
- telnyx/types/regulatory_requirement_retrieve_response.py +58 -0
- telnyx/types/report_list_mdrs_params.py +36 -0
- telnyx/types/report_list_mdrs_response.py +74 -0
- telnyx/types/report_list_wdrs_params.py +60 -0
- telnyx/types/report_list_wdrs_response.py +99 -0
- telnyx/types/reports/__init__.py +15 -0
- telnyx/types/reports/cdr_usage_report_fetch_sync_params.py +23 -0
- telnyx/types/reports/cdr_usage_report_fetch_sync_response.py +42 -0
- telnyx/types/reports/mdr_usage_report.py +66 -0
- telnyx/types/reports/mdr_usage_report_create_params.py +21 -0
- telnyx/types/reports/mdr_usage_report_create_response.py +12 -0
- telnyx/types/reports/mdr_usage_report_delete_response.py +12 -0
- telnyx/types/reports/mdr_usage_report_fetch_sync_params.py +21 -0
- telnyx/types/reports/mdr_usage_report_fetch_sync_response.py +12 -0
- telnyx/types/reports/mdr_usage_report_list_params.py +23 -0
- telnyx/types/reports/mdr_usage_report_list_response.py +24 -0
- telnyx/types/reports/mdr_usage_report_retrieve_response.py +12 -0
- telnyx/types/requirement_group.py +47 -0
- telnyx/types/requirement_group_create_params.py +27 -0
- telnyx/types/requirement_group_list_params.py +33 -0
- telnyx/types/requirement_group_list_response.py +10 -0
- telnyx/types/requirement_group_update_params.py +23 -0
- telnyx/types/requirement_list_params.py +61 -0
- telnyx/types/requirement_list_response.py +53 -0
- telnyx/types/requirement_retrieve_response.py +50 -0
- telnyx/types/requirement_type_list_params.py +31 -0
- telnyx/types/requirement_type_list_response.py +15 -0
- telnyx/types/requirement_type_retrieve_response.py +12 -0
- telnyx/types/reserved_phone_number.py +38 -0
- telnyx/types/reserved_phone_number_param.py +11 -0
- telnyx/types/room.py +51 -0
- telnyx/types/room_composition.py +77 -0
- telnyx/types/room_composition_create_params.py +43 -0
- telnyx/types/room_composition_create_response.py +12 -0
- telnyx/types/room_composition_list_params.py +55 -0
- telnyx/types/room_composition_list_response.py +15 -0
- telnyx/types/room_composition_retrieve_response.py +12 -0
- telnyx/types/room_create_params.py +38 -0
- telnyx/types/room_create_response.py +12 -0
- telnyx/types/room_list_params.py +69 -0
- telnyx/types/room_list_response.py +15 -0
- telnyx/types/room_participant_list_params.py +96 -0
- telnyx/types/room_participant_list_response.py +15 -0
- telnyx/types/room_participant_retrieve_response.py +12 -0
- telnyx/types/room_recording_delete_bulk_params.py +83 -0
- telnyx/types/room_recording_delete_bulk_response.py +16 -0
- telnyx/types/room_recording_list_params.py +83 -0
- telnyx/types/room_recording_list_response.py +65 -0
- telnyx/types/room_recording_retrieve_response.py +62 -0
- telnyx/types/room_retrieve_params.py +12 -0
- telnyx/types/room_retrieve_response.py +12 -0
- telnyx/types/room_session.py +33 -0
- telnyx/types/room_update_params.py +38 -0
- telnyx/types/room_update_response.py +12 -0
- telnyx/types/rooms/__init__.py +22 -0
- telnyx/types/rooms/action_generate_join_client_token_params.py +21 -0
- telnyx/types/rooms/action_generate_join_client_token_response.py +24 -0
- telnyx/types/rooms/action_refresh_client_token_params.py +17 -0
- telnyx/types/rooms/action_refresh_client_token_response.py +19 -0
- telnyx/types/rooms/session_list_0_params.py +87 -0
- telnyx/types/rooms/session_list_0_response.py +15 -0
- telnyx/types/rooms/session_list_1_params.py +84 -0
- telnyx/types/rooms/session_list_1_response.py +15 -0
- telnyx/types/rooms/session_retrieve_params.py +12 -0
- telnyx/types/rooms/session_retrieve_participants_params.py +93 -0
- telnyx/types/rooms/session_retrieve_participants_response.py +15 -0
- telnyx/types/rooms/session_retrieve_response.py +12 -0
- telnyx/types/rooms/sessions/__init__.py +11 -0
- telnyx/types/rooms/sessions/action_end_response.py +15 -0
- telnyx/types/rooms/sessions/action_kick_params.py +19 -0
- telnyx/types/rooms/sessions/action_kick_response.py +15 -0
- telnyx/types/rooms/sessions/action_mute_params.py +19 -0
- telnyx/types/rooms/sessions/action_mute_response.py +15 -0
- telnyx/types/rooms/sessions/action_unmute_params.py +19 -0
- telnyx/types/rooms/sessions/action_unmute_response.py +15 -0
- telnyx/types/s3_configuration_data.py +21 -0
- telnyx/types/s3_configuration_data_param.py +21 -0
- telnyx/types/service_plan.py +7 -0
- telnyx/types/seti_retrieve_black_box_test_results_params.py +17 -0
- telnyx/types/seti_retrieve_black_box_test_results_response.py +30 -0
- telnyx/types/settings_param.py +24 -0
- telnyx/types/shared/__init__.py +19 -0
- telnyx/types/shared/connections_pagination_meta.py +17 -0
- telnyx/types/shared/doc_reqs_requirement_type.py +60 -0
- telnyx/types/shared/hosted_number.py +35 -0
- telnyx/types/shared/messaging_feature_set.py +16 -0
- telnyx/types/shared/messaging_hosted_number_order.py +42 -0
- telnyx/types/shared/metadata.py +24 -0
- telnyx/types/shared/number_health_metrics.py +21 -0
- telnyx/types/shared/phone_number_with_messaging_settings.py +67 -0
- telnyx/types/shared/porting_order_status.py +28 -0
- telnyx/types/shared/porting_orders_exception_type.py +40 -0
- telnyx/types/shared/room_participant.py +30 -0
- telnyx/types/shared/short_code.py +32 -0
- telnyx/types/shared/sim_card_status.py +40 -0
- telnyx/types/shared/simple_sim_card.py +85 -0
- telnyx/types/shared/sub_number_order_regulatory_requirement_with_value.py +23 -0
- telnyx/types/shared_params/__init__.py +3 -0
- telnyx/types/shared_params/sim_card_status.py +11 -0
- telnyx/types/short_code_list_params.py +39 -0
- telnyx/types/short_code_list_response.py +15 -0
- telnyx/types/short_code_retrieve_response.py +12 -0
- telnyx/types/short_code_update_params.py +12 -0
- telnyx/types/short_code_update_response.py +12 -0
- telnyx/types/sim_card.py +177 -0
- telnyx/types/sim_card_data_usage_notification.py +33 -0
- telnyx/types/sim_card_data_usage_notification_create_params.py +21 -0
- telnyx/types/sim_card_data_usage_notification_create_response.py +13 -0
- telnyx/types/sim_card_data_usage_notification_delete_response.py +13 -0
- telnyx/types/sim_card_data_usage_notification_list_params.py +20 -0
- telnyx/types/sim_card_data_usage_notification_list_response.py +15 -0
- telnyx/types/sim_card_data_usage_notification_retrieve_response.py +13 -0
- telnyx/types/sim_card_data_usage_notification_update_params.py +21 -0
- telnyx/types/sim_card_data_usage_notification_update_response.py +13 -0
- telnyx/types/sim_card_delete_params.py +15 -0
- telnyx/types/sim_card_delete_response.py +12 -0
- telnyx/types/sim_card_get_activation_code_response.py +18 -0
- telnyx/types/sim_card_get_device_details_response.py +32 -0
- telnyx/types/sim_card_get_public_ip_response.py +35 -0
- telnyx/types/sim_card_group.py +49 -0
- telnyx/types/sim_card_group_create_params.py +21 -0
- telnyx/types/sim_card_group_create_response.py +12 -0
- telnyx/types/sim_card_group_delete_response.py +12 -0
- telnyx/types/sim_card_group_list_params.py +26 -0
- telnyx/types/sim_card_group_list_response.py +59 -0
- telnyx/types/sim_card_group_retrieve_params.py +12 -0
- telnyx/types/sim_card_group_retrieve_response.py +12 -0
- telnyx/types/sim_card_group_update_params.py +21 -0
- telnyx/types/sim_card_group_update_response.py +12 -0
- telnyx/types/sim_card_groups/__init__.py +24 -0
- telnyx/types/sim_card_groups/action_list_params.py +34 -0
- telnyx/types/sim_card_groups/action_list_response.py +15 -0
- telnyx/types/sim_card_groups/action_remove_private_wireless_gateway_response.py +17 -0
- telnyx/types/sim_card_groups/action_remove_wireless_blocklist_response.py +17 -0
- telnyx/types/sim_card_groups/action_retrieve_response.py +17 -0
- telnyx/types/sim_card_groups/action_set_private_wireless_gateway_params.py +12 -0
- telnyx/types/sim_card_groups/action_set_private_wireless_gateway_response.py +17 -0
- telnyx/types/sim_card_groups/action_set_wireless_blocklist_params.py +12 -0
- telnyx/types/sim_card_groups/action_set_wireless_blocklist_response.py +17 -0
- telnyx/types/sim_card_groups/sim_card_group_action.py +44 -0
- telnyx/types/sim_card_list_params.py +65 -0
- telnyx/types/sim_card_list_response.py +15 -0
- telnyx/types/sim_card_list_wireless_connectivity_logs_params.py +17 -0
- telnyx/types/sim_card_list_wireless_connectivity_logs_response.py +106 -0
- telnyx/types/sim_card_order.py +89 -0
- telnyx/types/sim_card_order_create_params.py +15 -0
- telnyx/types/sim_card_order_create_response.py +12 -0
- telnyx/types/sim_card_order_list_params.py +95 -0
- telnyx/types/sim_card_order_list_response.py +15 -0
- telnyx/types/sim_card_order_preview_preview_params.py +18 -0
- telnyx/types/sim_card_order_preview_preview_response.py +49 -0
- telnyx/types/sim_card_order_retrieve_response.py +12 -0
- telnyx/types/sim_card_retrieve_params.py +19 -0
- telnyx/types/sim_card_retrieve_response.py +12 -0
- telnyx/types/sim_card_update_params.py +36 -0
- telnyx/types/sim_card_update_response.py +12 -0
- telnyx/types/sim_cards/__init__.py +22 -0
- telnyx/types/sim_cards/action_bulk_set_public_ips_params.py +12 -0
- telnyx/types/sim_cards/action_bulk_set_public_ips_response.py +41 -0
- telnyx/types/sim_cards/action_disable_response.py +16 -0
- telnyx/types/sim_cards/action_enable_response.py +16 -0
- telnyx/types/sim_cards/action_list_params.py +46 -0
- telnyx/types/sim_cards/action_list_response.py +15 -0
- telnyx/types/sim_cards/action_remove_public_ip_response.py +16 -0
- telnyx/types/sim_cards/action_retrieve_response.py +16 -0
- telnyx/types/sim_cards/action_set_public_ip_params.py +15 -0
- telnyx/types/sim_cards/action_set_public_ip_response.py +16 -0
- telnyx/types/sim_cards/action_set_standby_response.py +16 -0
- telnyx/types/sim_cards/action_validate_registration_codes_params.py +12 -0
- telnyx/types/sim_cards/action_validate_registration_codes_response.py +24 -0
- telnyx/types/sim_cards/sim_card_action.py +53 -0
- telnyx/types/sip_header_param.py +15 -0
- telnyx/types/siprec_connector_create_params.py +23 -0
- telnyx/types/siprec_connector_create_response.py +33 -0
- telnyx/types/siprec_connector_retrieve_response.py +33 -0
- telnyx/types/siprec_connector_update_params.py +23 -0
- telnyx/types/siprec_connector_update_response.py +33 -0
- telnyx/types/sound_modifications_param.py +24 -0
- telnyx/types/stock_exchange.py +33 -0
- telnyx/types/storage/__init__.py +17 -0
- telnyx/types/storage/bucket_create_presigned_url_params.py +16 -0
- telnyx/types/storage/bucket_create_presigned_url_response.py +23 -0
- telnyx/types/storage/buckets/__init__.py +13 -0
- telnyx/types/storage/buckets/pagination_meta_simple.py +17 -0
- telnyx/types/storage/buckets/ssl_certificate.py +48 -0
- telnyx/types/storage/buckets/ssl_certificate_create_params.py +17 -0
- telnyx/types/storage/buckets/ssl_certificate_create_response.py +12 -0
- telnyx/types/storage/buckets/ssl_certificate_delete_response.py +12 -0
- telnyx/types/storage/buckets/ssl_certificate_retrieve_response.py +12 -0
- telnyx/types/storage/buckets/usage_get_api_usage_params.py +27 -0
- telnyx/types/storage/buckets/usage_get_api_usage_response.py +66 -0
- telnyx/types/storage/buckets/usage_get_bucket_usage_response.py +29 -0
- telnyx/types/storage/migration_create_params.py +27 -0
- telnyx/types/storage/migration_create_response.py +12 -0
- telnyx/types/storage/migration_list_response.py +15 -0
- telnyx/types/storage/migration_params.py +53 -0
- telnyx/types/storage/migration_retrieve_response.py +12 -0
- telnyx/types/storage/migration_source_create_params.py +37 -0
- telnyx/types/storage/migration_source_create_response.py +12 -0
- telnyx/types/storage/migration_source_delete_response.py +12 -0
- telnyx/types/storage/migration_source_list_response.py +15 -0
- telnyx/types/storage/migration_source_params.py +41 -0
- telnyx/types/storage/migration_source_retrieve_response.py +12 -0
- telnyx/types/storage/migrations/__init__.py +5 -0
- telnyx/types/storage/migrations/action_stop_response.py +12 -0
- telnyx/types/storage_list_migration_source_coverage_response.py +23 -0
- telnyx/types/stream_bidirectional_codec.py +7 -0
- telnyx/types/stream_bidirectional_mode.py +7 -0
- telnyx/types/stream_bidirectional_target_legs.py +7 -0
- telnyx/types/stream_codec.py +7 -0
- telnyx/types/sub_number_order.py +47 -0
- telnyx/types/sub_number_order_cancel_response.py +12 -0
- telnyx/types/sub_number_order_list_params.py +33 -0
- telnyx/types/sub_number_order_list_response.py +15 -0
- telnyx/types/sub_number_order_regulatory_requirement.py +17 -0
- telnyx/types/sub_number_order_retrieve_params.py +20 -0
- telnyx/types/sub_number_order_retrieve_response.py +12 -0
- telnyx/types/sub_number_order_update_params.py +14 -0
- telnyx/types/sub_number_order_update_requirement_group_params.py +12 -0
- telnyx/types/sub_number_order_update_requirement_group_response.py +88 -0
- telnyx/types/sub_number_order_update_response.py +12 -0
- telnyx/types/sub_number_orders_report_create_params.py +31 -0
- telnyx/types/sub_number_orders_report_create_response.py +53 -0
- telnyx/types/sub_number_orders_report_download_response.py +7 -0
- telnyx/types/sub_number_orders_report_retrieve_response.py +53 -0
- telnyx/types/task_status.py +7 -0
- telnyx/types/telephony_credential.py +38 -0
- telnyx/types/telephony_credential_create_params.py +20 -0
- telnyx/types/telephony_credential_create_response.py +12 -0
- telnyx/types/telephony_credential_create_token_response.py +7 -0
- telnyx/types/telephony_credential_delete_response.py +12 -0
- telnyx/types/telephony_credential_list_params.py +47 -0
- telnyx/types/telephony_credential_list_response.py +15 -0
- telnyx/types/telephony_credential_retrieve_response.py +12 -0
- telnyx/types/telephony_credential_update_params.py +20 -0
- telnyx/types/telephony_credential_update_response.py +12 -0
- telnyx/types/telnyx_brand.py +142 -0
- telnyx/types/telnyx_campaign_csp.py +214 -0
- telnyx/types/telnyx_downstream_campaign.py +154 -0
- telnyx/types/texml/__init__.py +24 -0
- telnyx/types/texml/account_retrieve_recordings_json_params.py +30 -0
- telnyx/types/texml/account_retrieve_recordings_json_response.py +36 -0
- telnyx/types/texml/account_retrieve_transcriptions_json_params.py +17 -0
- telnyx/types/texml/account_retrieve_transcriptions_json_response.py +71 -0
- telnyx/types/texml/accounts/__init__.py +30 -0
- telnyx/types/texml/accounts/call_calls_params.py +169 -0
- telnyx/types/texml/accounts/call_calls_response.py +17 -0
- telnyx/types/texml/accounts/call_retrieve_calls_params.py +50 -0
- telnyx/types/texml/accounts/call_retrieve_calls_response.py +101 -0
- telnyx/types/texml/accounts/call_retrieve_response.py +72 -0
- telnyx/types/texml/accounts/call_siprec_json_params.py +61 -0
- telnyx/types/texml/accounts/call_siprec_json_response.py +40 -0
- telnyx/types/texml/accounts/call_streams_json_params.py +37 -0
- telnyx/types/texml/accounts/call_streams_json_response.py +29 -0
- telnyx/types/texml/accounts/call_update_params.py +46 -0
- telnyx/types/texml/accounts/call_update_response.py +72 -0
- telnyx/types/texml/accounts/calls/__init__.py +21 -0
- telnyx/types/texml/accounts/calls/recording_recording_sid_json_params.py +17 -0
- telnyx/types/texml/accounts/calls/recording_recording_sid_json_response.py +58 -0
- telnyx/types/texml/accounts/calls/recordings_json_recordings_json_params.py +43 -0
- telnyx/types/texml/accounts/calls/recordings_json_recordings_json_response.py +58 -0
- telnyx/types/texml/accounts/calls/recordings_json_retrieve_recordings_json_response.py +36 -0
- telnyx/types/texml/accounts/calls/siprec_siprec_sid_json_params.py +21 -0
- telnyx/types/texml/accounts/calls/siprec_siprec_sid_json_response.py +31 -0
- telnyx/types/texml/accounts/calls/stream_streaming_sid_json_params.py +18 -0
- telnyx/types/texml/accounts/calls/stream_streaming_sid_json_response.py +26 -0
- telnyx/types/texml/accounts/conference_retrieve_conferences_params.py +43 -0
- telnyx/types/texml/accounts/conference_retrieve_conferences_response.py +85 -0
- telnyx/types/texml/accounts/conference_retrieve_recordings_json_response.py +36 -0
- telnyx/types/texml/accounts/conference_retrieve_recordings_response.py +94 -0
- telnyx/types/texml/accounts/conference_retrieve_response.py +56 -0
- telnyx/types/texml/accounts/conference_update_params.py +29 -0
- telnyx/types/texml/accounts/conference_update_response.py +56 -0
- telnyx/types/texml/accounts/conferences/__init__.py +12 -0
- telnyx/types/texml/accounts/conferences/participant_participants_params.py +251 -0
- telnyx/types/texml/accounts/conferences/participant_participants_response.py +37 -0
- telnyx/types/texml/accounts/conferences/participant_retrieve_participants_response.py +81 -0
- telnyx/types/texml/accounts/conferences/participant_retrieve_response.py +52 -0
- telnyx/types/texml/accounts/conferences/participant_update_params.py +69 -0
- telnyx/types/texml/accounts/conferences/participant_update_response.py +52 -0
- telnyx/types/texml/accounts/recordings/__init__.py +3 -0
- telnyx/types/texml/accounts/transcriptions/__init__.py +7 -0
- telnyx/types/texml/accounts/transcriptions/json_retrieve_recording_transcription_sid_json_response.py +43 -0
- telnyx/types/texml/call_initiate_params.py +163 -0
- telnyx/types/texml/call_initiate_response.py +21 -0
- telnyx/types/texml/call_update_params.py +44 -0
- telnyx/types/texml/call_update_response.py +17 -0
- telnyx/types/texml/texml_get_call_recording_response_body.py +57 -0
- telnyx/types/texml/texml_recording_subresources_uris.py +11 -0
- telnyx/types/texml_application.py +125 -0
- telnyx/types/texml_application_create_params.py +114 -0
- telnyx/types/texml_application_create_response.py +12 -0
- telnyx/types/texml_application_delete_response.py +12 -0
- telnyx/types/texml_application_list_params.py +59 -0
- telnyx/types/texml_application_list_response.py +24 -0
- telnyx/types/texml_application_retrieve_response.py +12 -0
- telnyx/types/texml_application_update_params.py +114 -0
- telnyx/types/texml_application_update_response.py +12 -0
- telnyx/types/texml_secrets_params.py +18 -0
- telnyx/types/texml_secrets_response.py +18 -0
- telnyx/types/text_to_speech_generate_speech_params.py +26 -0
- telnyx/types/text_to_speech_list_voices_params.py +15 -0
- telnyx/types/text_to_speech_list_voices_response.py +29 -0
- telnyx/types/traffic_type.py +7 -0
- telnyx/types/transport_protocol.py +7 -0
- telnyx/types/update_regulatory_requirement_param.py +19 -0
- telnyx/types/url_shortener_settings.py +30 -0
- telnyx/types/url_shortener_settings_param.py +30 -0
- telnyx/types/usage_payment_method.py +7 -0
- telnyx/types/usage_report_get_options_params.py +18 -0
- telnyx/types/usage_report_get_options_response.py +37 -0
- telnyx/types/usage_report_list_params.py +70 -0
- telnyx/types/usage_report_list_response.py +27 -0
- telnyx/types/user_address.py +77 -0
- telnyx/types/user_address_create_params.py +80 -0
- telnyx/types/user_address_create_response.py +12 -0
- telnyx/types/user_address_list_params.py +86 -0
- telnyx/types/user_address_list_response.py +15 -0
- telnyx/types/user_address_retrieve_response.py +12 -0
- telnyx/types/user_tag_list_params.py +20 -0
- telnyx/types/user_tag_list_response.py +31 -0
- telnyx/types/verification.py +42 -0
- telnyx/types/verification_retrieve_response.py +10 -0
- telnyx/types/verification_trigger_call_params.py +22 -0
- telnyx/types/verification_trigger_flashcall_params.py +18 -0
- telnyx/types/verification_trigger_sms_params.py +22 -0
- telnyx/types/verifications/__init__.py +6 -0
- telnyx/types/verifications/action_verify_params.py +18 -0
- telnyx/types/verifications/by_phone_number/__init__.py +6 -0
- telnyx/types/verifications/by_phone_number/action_verify_params.py +15 -0
- telnyx/types/verifications/by_phone_number/verify_verification_code_response.py +19 -0
- telnyx/types/verifications/by_phone_number_list_response.py +24 -0
- telnyx/types/verified_number.py +17 -0
- telnyx/types/verified_number_create_params.py +14 -0
- telnyx/types/verified_number_create_response.py +13 -0
- telnyx/types/verified_number_data_wrapper.py +12 -0
- telnyx/types/verified_number_list_params.py +22 -0
- telnyx/types/verified_number_list_response.py +24 -0
- telnyx/types/verified_numbers/__init__.py +7 -0
- telnyx/types/verified_numbers/action_submit_verification_code_params.py +11 -0
- telnyx/types/verify_profile.py +130 -0
- telnyx/types/verify_profile_create_params.py +114 -0
- telnyx/types/verify_profile_data.py +12 -0
- telnyx/types/verify_profile_list_params.py +29 -0
- telnyx/types/verify_profile_list_response.py +24 -0
- telnyx/types/verify_profile_retrieve_templates_response.py +17 -0
- telnyx/types/verify_profile_update_params.py +114 -0
- telnyx/types/vertical.py +25 -0
- telnyx/types/video_region.py +53 -0
- telnyx/types/video_region_param.py +54 -0
- telnyx/types/virtual_cross_connect_create_params.py +95 -0
- telnyx/types/virtual_cross_connect_create_response.py +129 -0
- telnyx/types/virtual_cross_connect_delete_response.py +129 -0
- telnyx/types/virtual_cross_connect_list_params.py +34 -0
- telnyx/types/virtual_cross_connect_list_response.py +132 -0
- telnyx/types/virtual_cross_connect_retrieve_response.py +129 -0
- telnyx/types/virtual_cross_connect_update_params.py +41 -0
- telnyx/types/virtual_cross_connect_update_response.py +129 -0
- telnyx/types/virtual_cross_connects_coverage_list_params.py +80 -0
- telnyx/types/virtual_cross_connects_coverage_list_response.py +58 -0
- telnyx/types/webhook_api_version.py +7 -0
- telnyx/types/webhook_delivery_list_params.py +106 -0
- telnyx/types/webhook_delivery_list_response.py +120 -0
- telnyx/types/webhook_delivery_retrieve_response.py +108 -0
- telnyx/types/wireguard_interface_create_params.py +21 -0
- telnyx/types/wireguard_interface_create_response.py +43 -0
- telnyx/types/wireguard_interface_delete_response.py +43 -0
- telnyx/types/wireguard_interface_list_params.py +34 -0
- telnyx/types/wireguard_interface_list_response.py +46 -0
- telnyx/types/wireguard_interface_retrieve_response.py +43 -0
- telnyx/types/wireguard_peer_create_params.py +18 -0
- telnyx/types/wireguard_peer_create_response.py +33 -0
- telnyx/types/wireguard_peer_delete_response.py +33 -0
- telnyx/types/wireguard_peer_list_params.py +34 -0
- telnyx/types/wireguard_peer_list_response.py +36 -0
- telnyx/types/wireguard_peer_patch.py +15 -0
- telnyx/types/wireguard_peer_retrieve_config_response.py +7 -0
- telnyx/types/wireguard_peer_retrieve_response.py +33 -0
- telnyx/types/wireguard_peer_update_params.py +15 -0
- telnyx/types/wireguard_peer_update_response.py +33 -0
- telnyx/types/wireless/__init__.py +17 -0
- telnyx/types/wireless/detail_records_report_create_params.py +15 -0
- telnyx/types/wireless/detail_records_report_create_response.py +12 -0
- telnyx/types/wireless/detail_records_report_delete_response.py +12 -0
- telnyx/types/wireless/detail_records_report_list_params.py +17 -0
- telnyx/types/wireless/detail_records_report_list_response.py +12 -0
- telnyx/types/wireless/detail_records_report_retrieve_response.py +12 -0
- telnyx/types/wireless/wdr_report.py +33 -0
- telnyx/types/wireless_blocklist.py +30 -0
- telnyx/types/wireless_blocklist_create_params.py +19 -0
- telnyx/types/wireless_blocklist_create_response.py +12 -0
- telnyx/types/wireless_blocklist_delete_response.py +12 -0
- telnyx/types/wireless_blocklist_list_params.py +26 -0
- telnyx/types/wireless_blocklist_list_response.py +15 -0
- telnyx/types/wireless_blocklist_retrieve_response.py +12 -0
- telnyx/types/wireless_blocklist_update_params.py +19 -0
- telnyx/types/wireless_blocklist_update_response.py +12 -0
- telnyx/types/wireless_blocklist_value_list_params.py +15 -0
- telnyx/types/wireless_blocklist_value_list_response.py +38 -0
- telnyx/types/wireless_retrieve_regions_params.py +15 -0
- telnyx/types/wireless_retrieve_regions_response.py +26 -0
- telnyx-3.0.0a0.dist-info/METADATA +431 -0
- telnyx-3.0.0a0.dist-info/RECORD +1874 -0
- telnyx-3.0.0a0.dist-info/WHEEL +4 -0
- telnyx-3.0.0a0.dist-info/licenses/LICENSE +7 -0
telnyx/_base_client.py
ADDED
|
@@ -0,0 +1,1995 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
import json
|
|
5
|
+
import time
|
|
6
|
+
import uuid
|
|
7
|
+
import email
|
|
8
|
+
import asyncio
|
|
9
|
+
import inspect
|
|
10
|
+
import logging
|
|
11
|
+
import platform
|
|
12
|
+
import email.utils
|
|
13
|
+
from types import TracebackType
|
|
14
|
+
from random import random
|
|
15
|
+
from typing import (
|
|
16
|
+
TYPE_CHECKING,
|
|
17
|
+
Any,
|
|
18
|
+
Dict,
|
|
19
|
+
Type,
|
|
20
|
+
Union,
|
|
21
|
+
Generic,
|
|
22
|
+
Mapping,
|
|
23
|
+
TypeVar,
|
|
24
|
+
Iterable,
|
|
25
|
+
Iterator,
|
|
26
|
+
Optional,
|
|
27
|
+
Generator,
|
|
28
|
+
AsyncIterator,
|
|
29
|
+
cast,
|
|
30
|
+
overload,
|
|
31
|
+
)
|
|
32
|
+
from typing_extensions import Literal, override, get_origin
|
|
33
|
+
|
|
34
|
+
import anyio
|
|
35
|
+
import httpx
|
|
36
|
+
import distro
|
|
37
|
+
import pydantic
|
|
38
|
+
from httpx import URL
|
|
39
|
+
from pydantic import PrivateAttr
|
|
40
|
+
|
|
41
|
+
from . import _exceptions
|
|
42
|
+
from ._qs import Querystring
|
|
43
|
+
from ._files import to_httpx_files, async_to_httpx_files
|
|
44
|
+
from ._types import (
|
|
45
|
+
NOT_GIVEN,
|
|
46
|
+
Body,
|
|
47
|
+
Omit,
|
|
48
|
+
Query,
|
|
49
|
+
Headers,
|
|
50
|
+
Timeout,
|
|
51
|
+
NotGiven,
|
|
52
|
+
ResponseT,
|
|
53
|
+
AnyMapping,
|
|
54
|
+
PostParser,
|
|
55
|
+
RequestFiles,
|
|
56
|
+
HttpxSendArgs,
|
|
57
|
+
RequestOptions,
|
|
58
|
+
HttpxRequestFiles,
|
|
59
|
+
ModelBuilderProtocol,
|
|
60
|
+
)
|
|
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
|
|
63
|
+
from ._models import GenericModel, FinalRequestOptions, validate_type, construct_type
|
|
64
|
+
from ._response import (
|
|
65
|
+
APIResponse,
|
|
66
|
+
BaseAPIResponse,
|
|
67
|
+
AsyncAPIResponse,
|
|
68
|
+
extract_response_type,
|
|
69
|
+
)
|
|
70
|
+
from ._constants import (
|
|
71
|
+
DEFAULT_TIMEOUT,
|
|
72
|
+
MAX_RETRY_DELAY,
|
|
73
|
+
DEFAULT_MAX_RETRIES,
|
|
74
|
+
INITIAL_RETRY_DELAY,
|
|
75
|
+
RAW_RESPONSE_HEADER,
|
|
76
|
+
OVERRIDE_CAST_TO_HEADER,
|
|
77
|
+
DEFAULT_CONNECTION_LIMITS,
|
|
78
|
+
)
|
|
79
|
+
from ._streaming import Stream, SSEDecoder, AsyncStream, SSEBytesDecoder
|
|
80
|
+
from ._exceptions import (
|
|
81
|
+
APIStatusError,
|
|
82
|
+
APITimeoutError,
|
|
83
|
+
APIConnectionError,
|
|
84
|
+
APIResponseValidationError,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
log: logging.Logger = logging.getLogger(__name__)
|
|
88
|
+
|
|
89
|
+
# TODO: make base page type vars covariant
|
|
90
|
+
SyncPageT = TypeVar("SyncPageT", bound="BaseSyncPage[Any]")
|
|
91
|
+
AsyncPageT = TypeVar("AsyncPageT", bound="BaseAsyncPage[Any]")
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
_T = TypeVar("_T")
|
|
95
|
+
_T_co = TypeVar("_T_co", covariant=True)
|
|
96
|
+
|
|
97
|
+
_StreamT = TypeVar("_StreamT", bound=Stream[Any])
|
|
98
|
+
_AsyncStreamT = TypeVar("_AsyncStreamT", bound=AsyncStream[Any])
|
|
99
|
+
|
|
100
|
+
if TYPE_CHECKING:
|
|
101
|
+
from httpx._config import (
|
|
102
|
+
DEFAULT_TIMEOUT_CONFIG, # pyright: ignore[reportPrivateImportUsage]
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
HTTPX_DEFAULT_TIMEOUT = DEFAULT_TIMEOUT_CONFIG
|
|
106
|
+
else:
|
|
107
|
+
try:
|
|
108
|
+
from httpx._config import DEFAULT_TIMEOUT_CONFIG as HTTPX_DEFAULT_TIMEOUT
|
|
109
|
+
except ImportError:
|
|
110
|
+
# taken from https://github.com/encode/httpx/blob/3ba5fe0d7ac70222590e759c31442b1cab263791/httpx/_config.py#L366
|
|
111
|
+
HTTPX_DEFAULT_TIMEOUT = Timeout(5.0)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class PageInfo:
|
|
115
|
+
"""Stores the necessary information to build the request to retrieve the next page.
|
|
116
|
+
|
|
117
|
+
Either `url` or `params` must be set.
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
url: URL | NotGiven
|
|
121
|
+
params: Query | NotGiven
|
|
122
|
+
json: Body | NotGiven
|
|
123
|
+
|
|
124
|
+
@overload
|
|
125
|
+
def __init__(
|
|
126
|
+
self,
|
|
127
|
+
*,
|
|
128
|
+
url: URL,
|
|
129
|
+
) -> None: ...
|
|
130
|
+
|
|
131
|
+
@overload
|
|
132
|
+
def __init__(
|
|
133
|
+
self,
|
|
134
|
+
*,
|
|
135
|
+
params: Query,
|
|
136
|
+
) -> None: ...
|
|
137
|
+
|
|
138
|
+
@overload
|
|
139
|
+
def __init__(
|
|
140
|
+
self,
|
|
141
|
+
*,
|
|
142
|
+
json: Body,
|
|
143
|
+
) -> None: ...
|
|
144
|
+
|
|
145
|
+
def __init__(
|
|
146
|
+
self,
|
|
147
|
+
*,
|
|
148
|
+
url: URL | NotGiven = NOT_GIVEN,
|
|
149
|
+
json: Body | NotGiven = NOT_GIVEN,
|
|
150
|
+
params: Query | NotGiven = NOT_GIVEN,
|
|
151
|
+
) -> None:
|
|
152
|
+
self.url = url
|
|
153
|
+
self.json = json
|
|
154
|
+
self.params = params
|
|
155
|
+
|
|
156
|
+
@override
|
|
157
|
+
def __repr__(self) -> str:
|
|
158
|
+
if self.url:
|
|
159
|
+
return f"{self.__class__.__name__}(url={self.url})"
|
|
160
|
+
if self.json:
|
|
161
|
+
return f"{self.__class__.__name__}(json={self.json})"
|
|
162
|
+
return f"{self.__class__.__name__}(params={self.params})"
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class BasePage(GenericModel, Generic[_T]):
|
|
166
|
+
"""
|
|
167
|
+
Defines the core interface for pagination.
|
|
168
|
+
|
|
169
|
+
Type Args:
|
|
170
|
+
ModelT: The pydantic model that represents an item in the response.
|
|
171
|
+
|
|
172
|
+
Methods:
|
|
173
|
+
has_next_page(): Check if there is another page available
|
|
174
|
+
next_page_info(): Get the necessary information to make a request for the next page
|
|
175
|
+
"""
|
|
176
|
+
|
|
177
|
+
_options: FinalRequestOptions = PrivateAttr()
|
|
178
|
+
_model: Type[_T] = PrivateAttr()
|
|
179
|
+
|
|
180
|
+
def has_next_page(self) -> bool:
|
|
181
|
+
items = self._get_page_items()
|
|
182
|
+
if not items:
|
|
183
|
+
return False
|
|
184
|
+
return self.next_page_info() is not None
|
|
185
|
+
|
|
186
|
+
def next_page_info(self) -> Optional[PageInfo]: ...
|
|
187
|
+
|
|
188
|
+
def _get_page_items(self) -> Iterable[_T]: # type: ignore[empty-body]
|
|
189
|
+
...
|
|
190
|
+
|
|
191
|
+
def _params_from_url(self, url: URL) -> httpx.QueryParams:
|
|
192
|
+
# TODO: do we have to preprocess params here?
|
|
193
|
+
return httpx.QueryParams(cast(Any, self._options.params)).merge(url.params)
|
|
194
|
+
|
|
195
|
+
def _info_to_options(self, info: PageInfo) -> FinalRequestOptions:
|
|
196
|
+
options = model_copy(self._options)
|
|
197
|
+
options._strip_raw_response_header()
|
|
198
|
+
|
|
199
|
+
if not isinstance(info.params, NotGiven):
|
|
200
|
+
options.params = {**options.params, **info.params}
|
|
201
|
+
return options
|
|
202
|
+
|
|
203
|
+
if not isinstance(info.url, NotGiven):
|
|
204
|
+
params = self._params_from_url(info.url)
|
|
205
|
+
url = info.url.copy_with(params=params)
|
|
206
|
+
options.params = dict(url.params)
|
|
207
|
+
options.url = str(url)
|
|
208
|
+
return options
|
|
209
|
+
|
|
210
|
+
if not isinstance(info.json, NotGiven):
|
|
211
|
+
if not is_mapping(info.json):
|
|
212
|
+
raise TypeError("Pagination is only supported with mappings")
|
|
213
|
+
|
|
214
|
+
if not options.json_data:
|
|
215
|
+
options.json_data = {**info.json}
|
|
216
|
+
else:
|
|
217
|
+
if not is_mapping(options.json_data):
|
|
218
|
+
raise TypeError("Pagination is only supported with mappings")
|
|
219
|
+
|
|
220
|
+
options.json_data = {**options.json_data, **info.json}
|
|
221
|
+
return options
|
|
222
|
+
|
|
223
|
+
raise ValueError("Unexpected PageInfo state")
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
class BaseSyncPage(BasePage[_T], Generic[_T]):
|
|
227
|
+
_client: SyncAPIClient = pydantic.PrivateAttr()
|
|
228
|
+
|
|
229
|
+
def _set_private_attributes(
|
|
230
|
+
self,
|
|
231
|
+
client: SyncAPIClient,
|
|
232
|
+
model: Type[_T],
|
|
233
|
+
options: FinalRequestOptions,
|
|
234
|
+
) -> None:
|
|
235
|
+
if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None:
|
|
236
|
+
self.__pydantic_private__ = {}
|
|
237
|
+
|
|
238
|
+
self._model = model
|
|
239
|
+
self._client = client
|
|
240
|
+
self._options = options
|
|
241
|
+
|
|
242
|
+
# Pydantic uses a custom `__iter__` method to support casting BaseModels
|
|
243
|
+
# to dictionaries. e.g. dict(model).
|
|
244
|
+
# As we want to support `for item in page`, this is inherently incompatible
|
|
245
|
+
# with the default pydantic behaviour. It is not possible to support both
|
|
246
|
+
# use cases at once. Fortunately, this is not a big deal as all other pydantic
|
|
247
|
+
# methods should continue to work as expected as there is an alternative method
|
|
248
|
+
# to cast a model to a dictionary, model.dict(), which is used internally
|
|
249
|
+
# by pydantic.
|
|
250
|
+
def __iter__(self) -> Iterator[_T]: # type: ignore
|
|
251
|
+
for page in self.iter_pages():
|
|
252
|
+
for item in page._get_page_items():
|
|
253
|
+
yield item
|
|
254
|
+
|
|
255
|
+
def iter_pages(self: SyncPageT) -> Iterator[SyncPageT]:
|
|
256
|
+
page = self
|
|
257
|
+
while True:
|
|
258
|
+
yield page
|
|
259
|
+
if page.has_next_page():
|
|
260
|
+
page = page.get_next_page()
|
|
261
|
+
else:
|
|
262
|
+
return
|
|
263
|
+
|
|
264
|
+
def get_next_page(self: SyncPageT) -> SyncPageT:
|
|
265
|
+
info = self.next_page_info()
|
|
266
|
+
if not info:
|
|
267
|
+
raise RuntimeError(
|
|
268
|
+
"No next page expected; please check `.has_next_page()` before calling `.get_next_page()`."
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
options = self._info_to_options(info)
|
|
272
|
+
return self._client._request_api_list(self._model, page=self.__class__, options=options)
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
class AsyncPaginator(Generic[_T, AsyncPageT]):
|
|
276
|
+
def __init__(
|
|
277
|
+
self,
|
|
278
|
+
client: AsyncAPIClient,
|
|
279
|
+
options: FinalRequestOptions,
|
|
280
|
+
page_cls: Type[AsyncPageT],
|
|
281
|
+
model: Type[_T],
|
|
282
|
+
) -> None:
|
|
283
|
+
self._model = model
|
|
284
|
+
self._client = client
|
|
285
|
+
self._options = options
|
|
286
|
+
self._page_cls = page_cls
|
|
287
|
+
|
|
288
|
+
def __await__(self) -> Generator[Any, None, AsyncPageT]:
|
|
289
|
+
return self._get_page().__await__()
|
|
290
|
+
|
|
291
|
+
async def _get_page(self) -> AsyncPageT:
|
|
292
|
+
def _parser(resp: AsyncPageT) -> AsyncPageT:
|
|
293
|
+
resp._set_private_attributes(
|
|
294
|
+
model=self._model,
|
|
295
|
+
options=self._options,
|
|
296
|
+
client=self._client,
|
|
297
|
+
)
|
|
298
|
+
return resp
|
|
299
|
+
|
|
300
|
+
self._options.post_parser = _parser
|
|
301
|
+
|
|
302
|
+
return await self._client.request(self._page_cls, self._options)
|
|
303
|
+
|
|
304
|
+
async def __aiter__(self) -> AsyncIterator[_T]:
|
|
305
|
+
# https://github.com/microsoft/pyright/issues/3464
|
|
306
|
+
page = cast(
|
|
307
|
+
AsyncPageT,
|
|
308
|
+
await self, # type: ignore
|
|
309
|
+
)
|
|
310
|
+
async for item in page:
|
|
311
|
+
yield item
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
class BaseAsyncPage(BasePage[_T], Generic[_T]):
|
|
315
|
+
_client: AsyncAPIClient = pydantic.PrivateAttr()
|
|
316
|
+
|
|
317
|
+
def _set_private_attributes(
|
|
318
|
+
self,
|
|
319
|
+
model: Type[_T],
|
|
320
|
+
client: AsyncAPIClient,
|
|
321
|
+
options: FinalRequestOptions,
|
|
322
|
+
) -> None:
|
|
323
|
+
if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None:
|
|
324
|
+
self.__pydantic_private__ = {}
|
|
325
|
+
|
|
326
|
+
self._model = model
|
|
327
|
+
self._client = client
|
|
328
|
+
self._options = options
|
|
329
|
+
|
|
330
|
+
async def __aiter__(self) -> AsyncIterator[_T]:
|
|
331
|
+
async for page in self.iter_pages():
|
|
332
|
+
for item in page._get_page_items():
|
|
333
|
+
yield item
|
|
334
|
+
|
|
335
|
+
async def iter_pages(self: AsyncPageT) -> AsyncIterator[AsyncPageT]:
|
|
336
|
+
page = self
|
|
337
|
+
while True:
|
|
338
|
+
yield page
|
|
339
|
+
if page.has_next_page():
|
|
340
|
+
page = await page.get_next_page()
|
|
341
|
+
else:
|
|
342
|
+
return
|
|
343
|
+
|
|
344
|
+
async def get_next_page(self: AsyncPageT) -> AsyncPageT:
|
|
345
|
+
info = self.next_page_info()
|
|
346
|
+
if not info:
|
|
347
|
+
raise RuntimeError(
|
|
348
|
+
"No next page expected; please check `.has_next_page()` before calling `.get_next_page()`."
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
options = self._info_to_options(info)
|
|
352
|
+
return await self._client._request_api_list(self._model, page=self.__class__, options=options)
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
_HttpxClientT = TypeVar("_HttpxClientT", bound=Union[httpx.Client, httpx.AsyncClient])
|
|
356
|
+
_DefaultStreamT = TypeVar("_DefaultStreamT", bound=Union[Stream[Any], AsyncStream[Any]])
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
|
|
360
|
+
_client: _HttpxClientT
|
|
361
|
+
_version: str
|
|
362
|
+
_base_url: URL
|
|
363
|
+
max_retries: int
|
|
364
|
+
timeout: Union[float, Timeout, None]
|
|
365
|
+
_strict_response_validation: bool
|
|
366
|
+
_idempotency_header: str | None
|
|
367
|
+
_default_stream_cls: type[_DefaultStreamT] | None = None
|
|
368
|
+
|
|
369
|
+
def __init__(
|
|
370
|
+
self,
|
|
371
|
+
*,
|
|
372
|
+
version: str,
|
|
373
|
+
base_url: str | URL,
|
|
374
|
+
_strict_response_validation: bool,
|
|
375
|
+
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
376
|
+
timeout: float | Timeout | None = DEFAULT_TIMEOUT,
|
|
377
|
+
custom_headers: Mapping[str, str] | None = None,
|
|
378
|
+
custom_query: Mapping[str, object] | None = None,
|
|
379
|
+
) -> None:
|
|
380
|
+
self._version = version
|
|
381
|
+
self._base_url = self._enforce_trailing_slash(URL(base_url))
|
|
382
|
+
self.max_retries = max_retries
|
|
383
|
+
self.timeout = timeout
|
|
384
|
+
self._custom_headers = custom_headers or {}
|
|
385
|
+
self._custom_query = custom_query or {}
|
|
386
|
+
self._strict_response_validation = _strict_response_validation
|
|
387
|
+
self._idempotency_header = None
|
|
388
|
+
self._platform: Platform | None = None
|
|
389
|
+
|
|
390
|
+
if max_retries is None: # pyright: ignore[reportUnnecessaryComparison]
|
|
391
|
+
raise TypeError(
|
|
392
|
+
"max_retries cannot be None. If you want to disable retries, pass `0`; if you want unlimited retries, pass `math.inf` or a very high number; if you want the default behavior, pass `telnyx.DEFAULT_MAX_RETRIES`"
|
|
393
|
+
)
|
|
394
|
+
|
|
395
|
+
def _enforce_trailing_slash(self, url: URL) -> URL:
|
|
396
|
+
if url.raw_path.endswith(b"/"):
|
|
397
|
+
return url
|
|
398
|
+
return url.copy_with(raw_path=url.raw_path + b"/")
|
|
399
|
+
|
|
400
|
+
def _make_status_error_from_response(
|
|
401
|
+
self,
|
|
402
|
+
response: httpx.Response,
|
|
403
|
+
) -> APIStatusError:
|
|
404
|
+
if response.is_closed and not response.is_stream_consumed:
|
|
405
|
+
# We can't read the response body as it has been closed
|
|
406
|
+
# before it was read. This can happen if an event hook
|
|
407
|
+
# raises a status error.
|
|
408
|
+
body = None
|
|
409
|
+
err_msg = f"Error code: {response.status_code}"
|
|
410
|
+
else:
|
|
411
|
+
err_text = response.text.strip()
|
|
412
|
+
body = err_text
|
|
413
|
+
|
|
414
|
+
try:
|
|
415
|
+
body = json.loads(err_text)
|
|
416
|
+
err_msg = f"Error code: {response.status_code} - {body}"
|
|
417
|
+
except Exception:
|
|
418
|
+
err_msg = err_text or f"Error code: {response.status_code}"
|
|
419
|
+
|
|
420
|
+
return self._make_status_error(err_msg, body=body, response=response)
|
|
421
|
+
|
|
422
|
+
def _make_status_error(
|
|
423
|
+
self,
|
|
424
|
+
err_msg: str,
|
|
425
|
+
*,
|
|
426
|
+
body: object,
|
|
427
|
+
response: httpx.Response,
|
|
428
|
+
) -> _exceptions.APIStatusError:
|
|
429
|
+
raise NotImplementedError()
|
|
430
|
+
|
|
431
|
+
def _build_headers(self, options: FinalRequestOptions, *, retries_taken: int = 0) -> httpx.Headers:
|
|
432
|
+
custom_headers = options.headers or {}
|
|
433
|
+
headers_dict = _merge_mappings(self.default_headers, custom_headers)
|
|
434
|
+
self._validate_headers(headers_dict, custom_headers)
|
|
435
|
+
|
|
436
|
+
# headers are case-insensitive while dictionaries are not.
|
|
437
|
+
headers = httpx.Headers(headers_dict)
|
|
438
|
+
|
|
439
|
+
idempotency_header = self._idempotency_header
|
|
440
|
+
if idempotency_header and options.idempotency_key and idempotency_header not in headers:
|
|
441
|
+
headers[idempotency_header] = options.idempotency_key
|
|
442
|
+
|
|
443
|
+
# Don't set these headers if they were already set or removed by the caller. We check
|
|
444
|
+
# `custom_headers`, which can contain `Omit()`, instead of `headers` to account for the removal case.
|
|
445
|
+
lower_custom_headers = [header.lower() for header in custom_headers]
|
|
446
|
+
if "x-stainless-retry-count" not in lower_custom_headers:
|
|
447
|
+
headers["x-stainless-retry-count"] = str(retries_taken)
|
|
448
|
+
if "x-stainless-read-timeout" not in lower_custom_headers:
|
|
449
|
+
timeout = self.timeout if isinstance(options.timeout, NotGiven) else options.timeout
|
|
450
|
+
if isinstance(timeout, Timeout):
|
|
451
|
+
timeout = timeout.read
|
|
452
|
+
if timeout is not None:
|
|
453
|
+
headers["x-stainless-read-timeout"] = str(timeout)
|
|
454
|
+
|
|
455
|
+
return headers
|
|
456
|
+
|
|
457
|
+
def _prepare_url(self, url: str) -> URL:
|
|
458
|
+
"""
|
|
459
|
+
Merge a URL argument together with any 'base_url' on the client,
|
|
460
|
+
to create the URL used for the outgoing request.
|
|
461
|
+
"""
|
|
462
|
+
# Copied from httpx's `_merge_url` method.
|
|
463
|
+
merge_url = URL(url)
|
|
464
|
+
if merge_url.is_relative_url:
|
|
465
|
+
merge_raw_path = self.base_url.raw_path + merge_url.raw_path.lstrip(b"/")
|
|
466
|
+
return self.base_url.copy_with(raw_path=merge_raw_path)
|
|
467
|
+
|
|
468
|
+
return merge_url
|
|
469
|
+
|
|
470
|
+
def _make_sse_decoder(self) -> SSEDecoder | SSEBytesDecoder:
|
|
471
|
+
return SSEDecoder()
|
|
472
|
+
|
|
473
|
+
def _build_request(
|
|
474
|
+
self,
|
|
475
|
+
options: FinalRequestOptions,
|
|
476
|
+
*,
|
|
477
|
+
retries_taken: int = 0,
|
|
478
|
+
) -> httpx.Request:
|
|
479
|
+
if log.isEnabledFor(logging.DEBUG):
|
|
480
|
+
log.debug("Request options: %s", model_dump(options, exclude_unset=True))
|
|
481
|
+
|
|
482
|
+
kwargs: dict[str, Any] = {}
|
|
483
|
+
|
|
484
|
+
json_data = options.json_data
|
|
485
|
+
if options.extra_json is not None:
|
|
486
|
+
if json_data is None:
|
|
487
|
+
json_data = cast(Body, options.extra_json)
|
|
488
|
+
elif is_mapping(json_data):
|
|
489
|
+
json_data = _merge_mappings(json_data, options.extra_json)
|
|
490
|
+
else:
|
|
491
|
+
raise RuntimeError(f"Unexpected JSON data type, {type(json_data)}, cannot merge with `extra_body`")
|
|
492
|
+
|
|
493
|
+
headers = self._build_headers(options, retries_taken=retries_taken)
|
|
494
|
+
params = _merge_mappings(self.default_query, options.params)
|
|
495
|
+
content_type = headers.get("Content-Type")
|
|
496
|
+
files = options.files
|
|
497
|
+
|
|
498
|
+
# If the given Content-Type header is multipart/form-data then it
|
|
499
|
+
# has to be removed so that httpx can generate the header with
|
|
500
|
+
# additional information for us as it has to be in this form
|
|
501
|
+
# for the server to be able to correctly parse the request:
|
|
502
|
+
# multipart/form-data; boundary=---abc--
|
|
503
|
+
if content_type is not None and content_type.startswith("multipart/form-data"):
|
|
504
|
+
if "boundary" not in content_type:
|
|
505
|
+
# only remove the header if the boundary hasn't been explicitly set
|
|
506
|
+
# as the caller doesn't want httpx to come up with their own boundary
|
|
507
|
+
headers.pop("Content-Type")
|
|
508
|
+
|
|
509
|
+
# As we are now sending multipart/form-data instead of application/json
|
|
510
|
+
# we need to tell httpx to use it, https://www.python-httpx.org/advanced/clients/#multipart-file-encoding
|
|
511
|
+
if json_data:
|
|
512
|
+
if not is_dict(json_data):
|
|
513
|
+
raise TypeError(
|
|
514
|
+
f"Expected query input to be a dictionary for multipart requests but got {type(json_data)} instead."
|
|
515
|
+
)
|
|
516
|
+
kwargs["data"] = self._serialize_multipartform(json_data)
|
|
517
|
+
|
|
518
|
+
# httpx determines whether or not to send a "multipart/form-data"
|
|
519
|
+
# request based on the truthiness of the "files" argument.
|
|
520
|
+
# This gets around that issue by generating a dict value that
|
|
521
|
+
# evaluates to true.
|
|
522
|
+
#
|
|
523
|
+
# https://github.com/encode/httpx/discussions/2399#discussioncomment-3814186
|
|
524
|
+
if not files:
|
|
525
|
+
files = cast(HttpxRequestFiles, ForceMultipartDict())
|
|
526
|
+
|
|
527
|
+
prepared_url = self._prepare_url(options.url)
|
|
528
|
+
if "_" in prepared_url.host:
|
|
529
|
+
# work around https://github.com/encode/httpx/discussions/2880
|
|
530
|
+
kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")}
|
|
531
|
+
|
|
532
|
+
is_body_allowed = options.method.lower() != "get"
|
|
533
|
+
|
|
534
|
+
if is_body_allowed:
|
|
535
|
+
if isinstance(json_data, bytes):
|
|
536
|
+
kwargs["content"] = json_data
|
|
537
|
+
else:
|
|
538
|
+
kwargs["json"] = json_data if is_given(json_data) else None
|
|
539
|
+
kwargs["files"] = files
|
|
540
|
+
else:
|
|
541
|
+
headers.pop("Content-Type", None)
|
|
542
|
+
kwargs.pop("data", None)
|
|
543
|
+
|
|
544
|
+
# TODO: report this error to httpx
|
|
545
|
+
return self._client.build_request( # pyright: ignore[reportUnknownMemberType]
|
|
546
|
+
headers=headers,
|
|
547
|
+
timeout=self.timeout if isinstance(options.timeout, NotGiven) else options.timeout,
|
|
548
|
+
method=options.method,
|
|
549
|
+
url=prepared_url,
|
|
550
|
+
# the `Query` type that we use is incompatible with qs'
|
|
551
|
+
# `Params` type as it needs to be typed as `Mapping[str, object]`
|
|
552
|
+
# so that passing a `TypedDict` doesn't cause an error.
|
|
553
|
+
# https://github.com/microsoft/pyright/issues/3526#event-6715453066
|
|
554
|
+
params=self.qs.stringify(cast(Mapping[str, Any], params)) if params else None,
|
|
555
|
+
**kwargs,
|
|
556
|
+
)
|
|
557
|
+
|
|
558
|
+
def _serialize_multipartform(self, data: Mapping[object, object]) -> dict[str, object]:
|
|
559
|
+
items = self.qs.stringify_items(
|
|
560
|
+
# TODO: type ignore is required as stringify_items is well typed but we can't be
|
|
561
|
+
# well typed without heavy validation.
|
|
562
|
+
data, # type: ignore
|
|
563
|
+
array_format="brackets",
|
|
564
|
+
)
|
|
565
|
+
serialized: dict[str, object] = {}
|
|
566
|
+
for key, value in items:
|
|
567
|
+
existing = serialized.get(key)
|
|
568
|
+
|
|
569
|
+
if not existing:
|
|
570
|
+
serialized[key] = value
|
|
571
|
+
continue
|
|
572
|
+
|
|
573
|
+
# If a value has already been set for this key then that
|
|
574
|
+
# means we're sending data like `array[]=[1, 2, 3]` and we
|
|
575
|
+
# need to tell httpx that we want to send multiple values with
|
|
576
|
+
# the same key which is done by using a list or a tuple.
|
|
577
|
+
#
|
|
578
|
+
# Note: 2d arrays should never result in the same key at both
|
|
579
|
+
# levels so it's safe to assume that if the value is a list,
|
|
580
|
+
# it was because we changed it to be a list.
|
|
581
|
+
if is_list(existing):
|
|
582
|
+
existing.append(value)
|
|
583
|
+
else:
|
|
584
|
+
serialized[key] = [existing, value]
|
|
585
|
+
|
|
586
|
+
return serialized
|
|
587
|
+
|
|
588
|
+
def _maybe_override_cast_to(self, cast_to: type[ResponseT], options: FinalRequestOptions) -> type[ResponseT]:
|
|
589
|
+
if not is_given(options.headers):
|
|
590
|
+
return cast_to
|
|
591
|
+
|
|
592
|
+
# make a copy of the headers so we don't mutate user-input
|
|
593
|
+
headers = dict(options.headers)
|
|
594
|
+
|
|
595
|
+
# we internally support defining a temporary header to override the
|
|
596
|
+
# default `cast_to` type for use with `.with_raw_response` and `.with_streaming_response`
|
|
597
|
+
# see _response.py for implementation details
|
|
598
|
+
override_cast_to = headers.pop(OVERRIDE_CAST_TO_HEADER, NOT_GIVEN)
|
|
599
|
+
if is_given(override_cast_to):
|
|
600
|
+
options.headers = headers
|
|
601
|
+
return cast(Type[ResponseT], override_cast_to)
|
|
602
|
+
|
|
603
|
+
return cast_to
|
|
604
|
+
|
|
605
|
+
def _should_stream_response_body(self, request: httpx.Request) -> bool:
|
|
606
|
+
return request.headers.get(RAW_RESPONSE_HEADER) == "stream" # type: ignore[no-any-return]
|
|
607
|
+
|
|
608
|
+
def _process_response_data(
|
|
609
|
+
self,
|
|
610
|
+
*,
|
|
611
|
+
data: object,
|
|
612
|
+
cast_to: type[ResponseT],
|
|
613
|
+
response: httpx.Response,
|
|
614
|
+
) -> ResponseT:
|
|
615
|
+
if data is None:
|
|
616
|
+
return cast(ResponseT, None)
|
|
617
|
+
|
|
618
|
+
if cast_to is object:
|
|
619
|
+
return cast(ResponseT, data)
|
|
620
|
+
|
|
621
|
+
try:
|
|
622
|
+
if inspect.isclass(cast_to) and issubclass(cast_to, ModelBuilderProtocol):
|
|
623
|
+
return cast(ResponseT, cast_to.build(response=response, data=data))
|
|
624
|
+
|
|
625
|
+
if self._strict_response_validation:
|
|
626
|
+
return cast(ResponseT, validate_type(type_=cast_to, value=data))
|
|
627
|
+
|
|
628
|
+
return cast(ResponseT, construct_type(type_=cast_to, value=data))
|
|
629
|
+
except pydantic.ValidationError as err:
|
|
630
|
+
raise APIResponseValidationError(response=response, body=data) from err
|
|
631
|
+
|
|
632
|
+
@property
|
|
633
|
+
def qs(self) -> Querystring:
|
|
634
|
+
return Querystring()
|
|
635
|
+
|
|
636
|
+
@property
|
|
637
|
+
def custom_auth(self) -> httpx.Auth | None:
|
|
638
|
+
return None
|
|
639
|
+
|
|
640
|
+
@property
|
|
641
|
+
def auth_headers(self) -> dict[str, str]:
|
|
642
|
+
return {}
|
|
643
|
+
|
|
644
|
+
@property
|
|
645
|
+
def default_headers(self) -> dict[str, str | Omit]:
|
|
646
|
+
return {
|
|
647
|
+
"Accept": "application/json",
|
|
648
|
+
"Content-Type": "application/json",
|
|
649
|
+
"User-Agent": self.user_agent,
|
|
650
|
+
**self.platform_headers(),
|
|
651
|
+
**self.auth_headers,
|
|
652
|
+
**self._custom_headers,
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
@property
|
|
656
|
+
def default_query(self) -> dict[str, object]:
|
|
657
|
+
return {
|
|
658
|
+
**self._custom_query,
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
def _validate_headers(
|
|
662
|
+
self,
|
|
663
|
+
headers: Headers, # noqa: ARG002
|
|
664
|
+
custom_headers: Headers, # noqa: ARG002
|
|
665
|
+
) -> None:
|
|
666
|
+
"""Validate the given default headers and custom headers.
|
|
667
|
+
|
|
668
|
+
Does nothing by default.
|
|
669
|
+
"""
|
|
670
|
+
return
|
|
671
|
+
|
|
672
|
+
@property
|
|
673
|
+
def user_agent(self) -> str:
|
|
674
|
+
return f"{self.__class__.__name__}/Python {self._version}"
|
|
675
|
+
|
|
676
|
+
@property
|
|
677
|
+
def base_url(self) -> URL:
|
|
678
|
+
return self._base_url
|
|
679
|
+
|
|
680
|
+
@base_url.setter
|
|
681
|
+
def base_url(self, url: URL | str) -> None:
|
|
682
|
+
self._base_url = self._enforce_trailing_slash(url if isinstance(url, URL) else URL(url))
|
|
683
|
+
|
|
684
|
+
def platform_headers(self) -> Dict[str, str]:
|
|
685
|
+
# the actual implementation is in a separate `lru_cache` decorated
|
|
686
|
+
# function because adding `lru_cache` to methods will leak memory
|
|
687
|
+
# https://github.com/python/cpython/issues/88476
|
|
688
|
+
return platform_headers(self._version, platform=self._platform)
|
|
689
|
+
|
|
690
|
+
def _parse_retry_after_header(self, response_headers: Optional[httpx.Headers] = None) -> float | None:
|
|
691
|
+
"""Returns a float of the number of seconds (not milliseconds) to wait after retrying, or None if unspecified.
|
|
692
|
+
|
|
693
|
+
About the Retry-After header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
|
|
694
|
+
See also https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After#syntax
|
|
695
|
+
"""
|
|
696
|
+
if response_headers is None:
|
|
697
|
+
return None
|
|
698
|
+
|
|
699
|
+
# First, try the non-standard `retry-after-ms` header for milliseconds,
|
|
700
|
+
# which is more precise than integer-seconds `retry-after`
|
|
701
|
+
try:
|
|
702
|
+
retry_ms_header = response_headers.get("retry-after-ms", None)
|
|
703
|
+
return float(retry_ms_header) / 1000
|
|
704
|
+
except (TypeError, ValueError):
|
|
705
|
+
pass
|
|
706
|
+
|
|
707
|
+
# Next, try parsing `retry-after` header as seconds (allowing nonstandard floats).
|
|
708
|
+
retry_header = response_headers.get("retry-after")
|
|
709
|
+
try:
|
|
710
|
+
# note: the spec indicates that this should only ever be an integer
|
|
711
|
+
# but if someone sends a float there's no reason for us to not respect it
|
|
712
|
+
return float(retry_header)
|
|
713
|
+
except (TypeError, ValueError):
|
|
714
|
+
pass
|
|
715
|
+
|
|
716
|
+
# Last, try parsing `retry-after` as a date.
|
|
717
|
+
retry_date_tuple = email.utils.parsedate_tz(retry_header)
|
|
718
|
+
if retry_date_tuple is None:
|
|
719
|
+
return None
|
|
720
|
+
|
|
721
|
+
retry_date = email.utils.mktime_tz(retry_date_tuple)
|
|
722
|
+
return float(retry_date - time.time())
|
|
723
|
+
|
|
724
|
+
def _calculate_retry_timeout(
|
|
725
|
+
self,
|
|
726
|
+
remaining_retries: int,
|
|
727
|
+
options: FinalRequestOptions,
|
|
728
|
+
response_headers: Optional[httpx.Headers] = None,
|
|
729
|
+
) -> float:
|
|
730
|
+
max_retries = options.get_max_retries(self.max_retries)
|
|
731
|
+
|
|
732
|
+
# If the API asks us to wait a certain amount of time (and it's a reasonable amount), just do what it says.
|
|
733
|
+
retry_after = self._parse_retry_after_header(response_headers)
|
|
734
|
+
if retry_after is not None and 0 < retry_after <= 60:
|
|
735
|
+
return retry_after
|
|
736
|
+
|
|
737
|
+
# Also cap retry count to 1000 to avoid any potential overflows with `pow`
|
|
738
|
+
nb_retries = min(max_retries - remaining_retries, 1000)
|
|
739
|
+
|
|
740
|
+
# Apply exponential backoff, but not more than the max.
|
|
741
|
+
sleep_seconds = min(INITIAL_RETRY_DELAY * pow(2.0, nb_retries), MAX_RETRY_DELAY)
|
|
742
|
+
|
|
743
|
+
# Apply some jitter, plus-or-minus half a second.
|
|
744
|
+
jitter = 1 - 0.25 * random()
|
|
745
|
+
timeout = sleep_seconds * jitter
|
|
746
|
+
return timeout if timeout >= 0 else 0
|
|
747
|
+
|
|
748
|
+
def _should_retry(self, response: httpx.Response) -> bool:
|
|
749
|
+
# Note: this is not a standard header
|
|
750
|
+
should_retry_header = response.headers.get("x-should-retry")
|
|
751
|
+
|
|
752
|
+
# If the server explicitly says whether or not to retry, obey.
|
|
753
|
+
if should_retry_header == "true":
|
|
754
|
+
log.debug("Retrying as header `x-should-retry` is set to `true`")
|
|
755
|
+
return True
|
|
756
|
+
if should_retry_header == "false":
|
|
757
|
+
log.debug("Not retrying as header `x-should-retry` is set to `false`")
|
|
758
|
+
return False
|
|
759
|
+
|
|
760
|
+
# Retry on request timeouts.
|
|
761
|
+
if response.status_code == 408:
|
|
762
|
+
log.debug("Retrying due to status code %i", response.status_code)
|
|
763
|
+
return True
|
|
764
|
+
|
|
765
|
+
# Retry on lock timeouts.
|
|
766
|
+
if response.status_code == 409:
|
|
767
|
+
log.debug("Retrying due to status code %i", response.status_code)
|
|
768
|
+
return True
|
|
769
|
+
|
|
770
|
+
# Retry on rate limits.
|
|
771
|
+
if response.status_code == 429:
|
|
772
|
+
log.debug("Retrying due to status code %i", response.status_code)
|
|
773
|
+
return True
|
|
774
|
+
|
|
775
|
+
# Retry internal errors.
|
|
776
|
+
if response.status_code >= 500:
|
|
777
|
+
log.debug("Retrying due to status code %i", response.status_code)
|
|
778
|
+
return True
|
|
779
|
+
|
|
780
|
+
log.debug("Not retrying")
|
|
781
|
+
return False
|
|
782
|
+
|
|
783
|
+
def _idempotency_key(self) -> str:
|
|
784
|
+
return f"stainless-python-retry-{uuid.uuid4()}"
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
class _DefaultHttpxClient(httpx.Client):
|
|
788
|
+
def __init__(self, **kwargs: Any) -> None:
|
|
789
|
+
kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
|
|
790
|
+
kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
|
|
791
|
+
kwargs.setdefault("follow_redirects", True)
|
|
792
|
+
super().__init__(**kwargs)
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
if TYPE_CHECKING:
|
|
796
|
+
DefaultHttpxClient = httpx.Client
|
|
797
|
+
"""An alias to `httpx.Client` that provides the same defaults that this SDK
|
|
798
|
+
uses internally.
|
|
799
|
+
|
|
800
|
+
This is useful because overriding the `http_client` with your own instance of
|
|
801
|
+
`httpx.Client` will result in httpx's defaults being used, not ours.
|
|
802
|
+
"""
|
|
803
|
+
else:
|
|
804
|
+
DefaultHttpxClient = _DefaultHttpxClient
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
class SyncHttpxClientWrapper(DefaultHttpxClient):
|
|
808
|
+
def __del__(self) -> None:
|
|
809
|
+
if self.is_closed:
|
|
810
|
+
return
|
|
811
|
+
|
|
812
|
+
try:
|
|
813
|
+
self.close()
|
|
814
|
+
except Exception:
|
|
815
|
+
pass
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
|
|
819
|
+
_client: httpx.Client
|
|
820
|
+
_default_stream_cls: type[Stream[Any]] | None = None
|
|
821
|
+
|
|
822
|
+
def __init__(
|
|
823
|
+
self,
|
|
824
|
+
*,
|
|
825
|
+
version: str,
|
|
826
|
+
base_url: str | URL,
|
|
827
|
+
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
828
|
+
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
|
|
829
|
+
http_client: httpx.Client | None = None,
|
|
830
|
+
custom_headers: Mapping[str, str] | None = None,
|
|
831
|
+
custom_query: Mapping[str, object] | None = None,
|
|
832
|
+
_strict_response_validation: bool,
|
|
833
|
+
) -> None:
|
|
834
|
+
if not is_given(timeout):
|
|
835
|
+
# if the user passed in a custom http client with a non-default
|
|
836
|
+
# timeout set then we use that timeout.
|
|
837
|
+
#
|
|
838
|
+
# note: there is an edge case here where the user passes in a client
|
|
839
|
+
# where they've explicitly set the timeout to match the default timeout
|
|
840
|
+
# as this check is structural, meaning that we'll think they didn't
|
|
841
|
+
# pass in a timeout and will ignore it
|
|
842
|
+
if http_client and http_client.timeout != HTTPX_DEFAULT_TIMEOUT:
|
|
843
|
+
timeout = http_client.timeout
|
|
844
|
+
else:
|
|
845
|
+
timeout = DEFAULT_TIMEOUT
|
|
846
|
+
|
|
847
|
+
if http_client is not None and not isinstance(http_client, httpx.Client): # pyright: ignore[reportUnnecessaryIsInstance]
|
|
848
|
+
raise TypeError(
|
|
849
|
+
f"Invalid `http_client` argument; Expected an instance of `httpx.Client` but got {type(http_client)}"
|
|
850
|
+
)
|
|
851
|
+
|
|
852
|
+
super().__init__(
|
|
853
|
+
version=version,
|
|
854
|
+
# cast to a valid type because mypy doesn't understand our type narrowing
|
|
855
|
+
timeout=cast(Timeout, timeout),
|
|
856
|
+
base_url=base_url,
|
|
857
|
+
max_retries=max_retries,
|
|
858
|
+
custom_query=custom_query,
|
|
859
|
+
custom_headers=custom_headers,
|
|
860
|
+
_strict_response_validation=_strict_response_validation,
|
|
861
|
+
)
|
|
862
|
+
self._client = http_client or SyncHttpxClientWrapper(
|
|
863
|
+
base_url=base_url,
|
|
864
|
+
# cast to a valid type because mypy doesn't understand our type narrowing
|
|
865
|
+
timeout=cast(Timeout, timeout),
|
|
866
|
+
)
|
|
867
|
+
|
|
868
|
+
def is_closed(self) -> bool:
|
|
869
|
+
return self._client.is_closed
|
|
870
|
+
|
|
871
|
+
def close(self) -> None:
|
|
872
|
+
"""Close the underlying HTTPX client.
|
|
873
|
+
|
|
874
|
+
The client will *not* be usable after this.
|
|
875
|
+
"""
|
|
876
|
+
# If an error is thrown while constructing a client, self._client
|
|
877
|
+
# may not be present
|
|
878
|
+
if hasattr(self, "_client"):
|
|
879
|
+
self._client.close()
|
|
880
|
+
|
|
881
|
+
def __enter__(self: _T) -> _T:
|
|
882
|
+
return self
|
|
883
|
+
|
|
884
|
+
def __exit__(
|
|
885
|
+
self,
|
|
886
|
+
exc_type: type[BaseException] | None,
|
|
887
|
+
exc: BaseException | None,
|
|
888
|
+
exc_tb: TracebackType | None,
|
|
889
|
+
) -> None:
|
|
890
|
+
self.close()
|
|
891
|
+
|
|
892
|
+
def _prepare_options(
|
|
893
|
+
self,
|
|
894
|
+
options: FinalRequestOptions, # noqa: ARG002
|
|
895
|
+
) -> FinalRequestOptions:
|
|
896
|
+
"""Hook for mutating the given options"""
|
|
897
|
+
return options
|
|
898
|
+
|
|
899
|
+
def _prepare_request(
|
|
900
|
+
self,
|
|
901
|
+
request: httpx.Request, # noqa: ARG002
|
|
902
|
+
) -> None:
|
|
903
|
+
"""This method is used as a callback for mutating the `Request` object
|
|
904
|
+
after it has been constructed.
|
|
905
|
+
This is useful for cases where you want to add certain headers based off of
|
|
906
|
+
the request properties, e.g. `url`, `method` etc.
|
|
907
|
+
"""
|
|
908
|
+
return None
|
|
909
|
+
|
|
910
|
+
@overload
|
|
911
|
+
def request(
|
|
912
|
+
self,
|
|
913
|
+
cast_to: Type[ResponseT],
|
|
914
|
+
options: FinalRequestOptions,
|
|
915
|
+
*,
|
|
916
|
+
stream: Literal[True],
|
|
917
|
+
stream_cls: Type[_StreamT],
|
|
918
|
+
) -> _StreamT: ...
|
|
919
|
+
|
|
920
|
+
@overload
|
|
921
|
+
def request(
|
|
922
|
+
self,
|
|
923
|
+
cast_to: Type[ResponseT],
|
|
924
|
+
options: FinalRequestOptions,
|
|
925
|
+
*,
|
|
926
|
+
stream: Literal[False] = False,
|
|
927
|
+
) -> ResponseT: ...
|
|
928
|
+
|
|
929
|
+
@overload
|
|
930
|
+
def request(
|
|
931
|
+
self,
|
|
932
|
+
cast_to: Type[ResponseT],
|
|
933
|
+
options: FinalRequestOptions,
|
|
934
|
+
*,
|
|
935
|
+
stream: bool = False,
|
|
936
|
+
stream_cls: Type[_StreamT] | None = None,
|
|
937
|
+
) -> ResponseT | _StreamT: ...
|
|
938
|
+
|
|
939
|
+
def request(
|
|
940
|
+
self,
|
|
941
|
+
cast_to: Type[ResponseT],
|
|
942
|
+
options: FinalRequestOptions,
|
|
943
|
+
*,
|
|
944
|
+
stream: bool = False,
|
|
945
|
+
stream_cls: type[_StreamT] | None = None,
|
|
946
|
+
) -> ResponseT | _StreamT:
|
|
947
|
+
cast_to = self._maybe_override_cast_to(cast_to, options)
|
|
948
|
+
|
|
949
|
+
# create a copy of the options we were given so that if the
|
|
950
|
+
# options are mutated later & we then retry, the retries are
|
|
951
|
+
# given the original options
|
|
952
|
+
input_options = model_copy(options)
|
|
953
|
+
if input_options.idempotency_key is None and input_options.method.lower() != "get":
|
|
954
|
+
# ensure the idempotency key is reused between requests
|
|
955
|
+
input_options.idempotency_key = self._idempotency_key()
|
|
956
|
+
|
|
957
|
+
response: httpx.Response | None = None
|
|
958
|
+
max_retries = input_options.get_max_retries(self.max_retries)
|
|
959
|
+
|
|
960
|
+
retries_taken = 0
|
|
961
|
+
for retries_taken in range(max_retries + 1):
|
|
962
|
+
options = model_copy(input_options)
|
|
963
|
+
options = self._prepare_options(options)
|
|
964
|
+
|
|
965
|
+
remaining_retries = max_retries - retries_taken
|
|
966
|
+
request = self._build_request(options, retries_taken=retries_taken)
|
|
967
|
+
self._prepare_request(request)
|
|
968
|
+
|
|
969
|
+
kwargs: HttpxSendArgs = {}
|
|
970
|
+
if self.custom_auth is not None:
|
|
971
|
+
kwargs["auth"] = self.custom_auth
|
|
972
|
+
|
|
973
|
+
if options.follow_redirects is not None:
|
|
974
|
+
kwargs["follow_redirects"] = options.follow_redirects
|
|
975
|
+
|
|
976
|
+
log.debug("Sending HTTP Request: %s %s", request.method, request.url)
|
|
977
|
+
|
|
978
|
+
response = None
|
|
979
|
+
try:
|
|
980
|
+
response = self._client.send(
|
|
981
|
+
request,
|
|
982
|
+
stream=stream or self._should_stream_response_body(request=request),
|
|
983
|
+
**kwargs,
|
|
984
|
+
)
|
|
985
|
+
except httpx.TimeoutException as err:
|
|
986
|
+
log.debug("Encountered httpx.TimeoutException", exc_info=True)
|
|
987
|
+
|
|
988
|
+
if remaining_retries > 0:
|
|
989
|
+
self._sleep_for_retry(
|
|
990
|
+
retries_taken=retries_taken,
|
|
991
|
+
max_retries=max_retries,
|
|
992
|
+
options=input_options,
|
|
993
|
+
response=None,
|
|
994
|
+
)
|
|
995
|
+
continue
|
|
996
|
+
|
|
997
|
+
log.debug("Raising timeout error")
|
|
998
|
+
raise APITimeoutError(request=request) from err
|
|
999
|
+
except Exception as err:
|
|
1000
|
+
log.debug("Encountered Exception", exc_info=True)
|
|
1001
|
+
|
|
1002
|
+
if remaining_retries > 0:
|
|
1003
|
+
self._sleep_for_retry(
|
|
1004
|
+
retries_taken=retries_taken,
|
|
1005
|
+
max_retries=max_retries,
|
|
1006
|
+
options=input_options,
|
|
1007
|
+
response=None,
|
|
1008
|
+
)
|
|
1009
|
+
continue
|
|
1010
|
+
|
|
1011
|
+
log.debug("Raising connection error")
|
|
1012
|
+
raise APIConnectionError(request=request) from err
|
|
1013
|
+
|
|
1014
|
+
log.debug(
|
|
1015
|
+
'HTTP Response: %s %s "%i %s" %s',
|
|
1016
|
+
request.method,
|
|
1017
|
+
request.url,
|
|
1018
|
+
response.status_code,
|
|
1019
|
+
response.reason_phrase,
|
|
1020
|
+
response.headers,
|
|
1021
|
+
)
|
|
1022
|
+
|
|
1023
|
+
try:
|
|
1024
|
+
response.raise_for_status()
|
|
1025
|
+
except httpx.HTTPStatusError as err: # thrown on 4xx and 5xx status code
|
|
1026
|
+
log.debug("Encountered httpx.HTTPStatusError", exc_info=True)
|
|
1027
|
+
|
|
1028
|
+
if remaining_retries > 0 and self._should_retry(err.response):
|
|
1029
|
+
err.response.close()
|
|
1030
|
+
self._sleep_for_retry(
|
|
1031
|
+
retries_taken=retries_taken,
|
|
1032
|
+
max_retries=max_retries,
|
|
1033
|
+
options=input_options,
|
|
1034
|
+
response=response,
|
|
1035
|
+
)
|
|
1036
|
+
continue
|
|
1037
|
+
|
|
1038
|
+
# If the response is streamed then we need to explicitly read the response
|
|
1039
|
+
# to completion before attempting to access the response text.
|
|
1040
|
+
if not err.response.is_closed:
|
|
1041
|
+
err.response.read()
|
|
1042
|
+
|
|
1043
|
+
log.debug("Re-raising status error")
|
|
1044
|
+
raise self._make_status_error_from_response(err.response) from None
|
|
1045
|
+
|
|
1046
|
+
break
|
|
1047
|
+
|
|
1048
|
+
assert response is not None, "could not resolve response (should never happen)"
|
|
1049
|
+
return self._process_response(
|
|
1050
|
+
cast_to=cast_to,
|
|
1051
|
+
options=options,
|
|
1052
|
+
response=response,
|
|
1053
|
+
stream=stream,
|
|
1054
|
+
stream_cls=stream_cls,
|
|
1055
|
+
retries_taken=retries_taken,
|
|
1056
|
+
)
|
|
1057
|
+
|
|
1058
|
+
def _sleep_for_retry(
|
|
1059
|
+
self, *, retries_taken: int, max_retries: int, options: FinalRequestOptions, response: httpx.Response | None
|
|
1060
|
+
) -> None:
|
|
1061
|
+
remaining_retries = max_retries - retries_taken
|
|
1062
|
+
if remaining_retries == 1:
|
|
1063
|
+
log.debug("1 retry left")
|
|
1064
|
+
else:
|
|
1065
|
+
log.debug("%i retries left", remaining_retries)
|
|
1066
|
+
|
|
1067
|
+
timeout = self._calculate_retry_timeout(remaining_retries, options, response.headers if response else None)
|
|
1068
|
+
log.info("Retrying request to %s in %f seconds", options.url, timeout)
|
|
1069
|
+
|
|
1070
|
+
time.sleep(timeout)
|
|
1071
|
+
|
|
1072
|
+
def _process_response(
|
|
1073
|
+
self,
|
|
1074
|
+
*,
|
|
1075
|
+
cast_to: Type[ResponseT],
|
|
1076
|
+
options: FinalRequestOptions,
|
|
1077
|
+
response: httpx.Response,
|
|
1078
|
+
stream: bool,
|
|
1079
|
+
stream_cls: type[Stream[Any]] | type[AsyncStream[Any]] | None,
|
|
1080
|
+
retries_taken: int = 0,
|
|
1081
|
+
) -> ResponseT:
|
|
1082
|
+
origin = get_origin(cast_to) or cast_to
|
|
1083
|
+
|
|
1084
|
+
if (
|
|
1085
|
+
inspect.isclass(origin)
|
|
1086
|
+
and issubclass(origin, BaseAPIResponse)
|
|
1087
|
+
# we only want to actually return the custom BaseAPIResponse class if we're
|
|
1088
|
+
# returning the raw response, or if we're not streaming SSE, as if we're streaming
|
|
1089
|
+
# SSE then `cast_to` doesn't actively reflect the type we need to parse into
|
|
1090
|
+
and (not stream or bool(response.request.headers.get(RAW_RESPONSE_HEADER)))
|
|
1091
|
+
):
|
|
1092
|
+
if not issubclass(origin, APIResponse):
|
|
1093
|
+
raise TypeError(f"API Response types must subclass {APIResponse}; Received {origin}")
|
|
1094
|
+
|
|
1095
|
+
response_cls = cast("type[BaseAPIResponse[Any]]", cast_to)
|
|
1096
|
+
return cast(
|
|
1097
|
+
ResponseT,
|
|
1098
|
+
response_cls(
|
|
1099
|
+
raw=response,
|
|
1100
|
+
client=self,
|
|
1101
|
+
cast_to=extract_response_type(response_cls),
|
|
1102
|
+
stream=stream,
|
|
1103
|
+
stream_cls=stream_cls,
|
|
1104
|
+
options=options,
|
|
1105
|
+
retries_taken=retries_taken,
|
|
1106
|
+
),
|
|
1107
|
+
)
|
|
1108
|
+
|
|
1109
|
+
if cast_to == httpx.Response:
|
|
1110
|
+
return cast(ResponseT, response)
|
|
1111
|
+
|
|
1112
|
+
api_response = APIResponse(
|
|
1113
|
+
raw=response,
|
|
1114
|
+
client=self,
|
|
1115
|
+
cast_to=cast("type[ResponseT]", cast_to), # pyright: ignore[reportUnnecessaryCast]
|
|
1116
|
+
stream=stream,
|
|
1117
|
+
stream_cls=stream_cls,
|
|
1118
|
+
options=options,
|
|
1119
|
+
retries_taken=retries_taken,
|
|
1120
|
+
)
|
|
1121
|
+
if bool(response.request.headers.get(RAW_RESPONSE_HEADER)):
|
|
1122
|
+
return cast(ResponseT, api_response)
|
|
1123
|
+
|
|
1124
|
+
return api_response.parse()
|
|
1125
|
+
|
|
1126
|
+
def _request_api_list(
|
|
1127
|
+
self,
|
|
1128
|
+
model: Type[object],
|
|
1129
|
+
page: Type[SyncPageT],
|
|
1130
|
+
options: FinalRequestOptions,
|
|
1131
|
+
) -> SyncPageT:
|
|
1132
|
+
def _parser(resp: SyncPageT) -> SyncPageT:
|
|
1133
|
+
resp._set_private_attributes(
|
|
1134
|
+
client=self,
|
|
1135
|
+
model=model,
|
|
1136
|
+
options=options,
|
|
1137
|
+
)
|
|
1138
|
+
return resp
|
|
1139
|
+
|
|
1140
|
+
options.post_parser = _parser
|
|
1141
|
+
|
|
1142
|
+
return self.request(page, options, stream=False)
|
|
1143
|
+
|
|
1144
|
+
@overload
|
|
1145
|
+
def get(
|
|
1146
|
+
self,
|
|
1147
|
+
path: str,
|
|
1148
|
+
*,
|
|
1149
|
+
cast_to: Type[ResponseT],
|
|
1150
|
+
options: RequestOptions = {},
|
|
1151
|
+
stream: Literal[False] = False,
|
|
1152
|
+
) -> ResponseT: ...
|
|
1153
|
+
|
|
1154
|
+
@overload
|
|
1155
|
+
def get(
|
|
1156
|
+
self,
|
|
1157
|
+
path: str,
|
|
1158
|
+
*,
|
|
1159
|
+
cast_to: Type[ResponseT],
|
|
1160
|
+
options: RequestOptions = {},
|
|
1161
|
+
stream: Literal[True],
|
|
1162
|
+
stream_cls: type[_StreamT],
|
|
1163
|
+
) -> _StreamT: ...
|
|
1164
|
+
|
|
1165
|
+
@overload
|
|
1166
|
+
def get(
|
|
1167
|
+
self,
|
|
1168
|
+
path: str,
|
|
1169
|
+
*,
|
|
1170
|
+
cast_to: Type[ResponseT],
|
|
1171
|
+
options: RequestOptions = {},
|
|
1172
|
+
stream: bool,
|
|
1173
|
+
stream_cls: type[_StreamT] | None = None,
|
|
1174
|
+
) -> ResponseT | _StreamT: ...
|
|
1175
|
+
|
|
1176
|
+
def get(
|
|
1177
|
+
self,
|
|
1178
|
+
path: str,
|
|
1179
|
+
*,
|
|
1180
|
+
cast_to: Type[ResponseT],
|
|
1181
|
+
options: RequestOptions = {},
|
|
1182
|
+
stream: bool = False,
|
|
1183
|
+
stream_cls: type[_StreamT] | None = None,
|
|
1184
|
+
) -> ResponseT | _StreamT:
|
|
1185
|
+
opts = FinalRequestOptions.construct(method="get", url=path, **options)
|
|
1186
|
+
# cast is required because mypy complains about returning Any even though
|
|
1187
|
+
# it understands the type variables
|
|
1188
|
+
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
|
|
1189
|
+
|
|
1190
|
+
@overload
|
|
1191
|
+
def post(
|
|
1192
|
+
self,
|
|
1193
|
+
path: str,
|
|
1194
|
+
*,
|
|
1195
|
+
cast_to: Type[ResponseT],
|
|
1196
|
+
body: Body | None = None,
|
|
1197
|
+
options: RequestOptions = {},
|
|
1198
|
+
files: RequestFiles | None = None,
|
|
1199
|
+
stream: Literal[False] = False,
|
|
1200
|
+
) -> ResponseT: ...
|
|
1201
|
+
|
|
1202
|
+
@overload
|
|
1203
|
+
def post(
|
|
1204
|
+
self,
|
|
1205
|
+
path: str,
|
|
1206
|
+
*,
|
|
1207
|
+
cast_to: Type[ResponseT],
|
|
1208
|
+
body: Body | None = None,
|
|
1209
|
+
options: RequestOptions = {},
|
|
1210
|
+
files: RequestFiles | None = None,
|
|
1211
|
+
stream: Literal[True],
|
|
1212
|
+
stream_cls: type[_StreamT],
|
|
1213
|
+
) -> _StreamT: ...
|
|
1214
|
+
|
|
1215
|
+
@overload
|
|
1216
|
+
def post(
|
|
1217
|
+
self,
|
|
1218
|
+
path: str,
|
|
1219
|
+
*,
|
|
1220
|
+
cast_to: Type[ResponseT],
|
|
1221
|
+
body: Body | None = None,
|
|
1222
|
+
options: RequestOptions = {},
|
|
1223
|
+
files: RequestFiles | None = None,
|
|
1224
|
+
stream: bool,
|
|
1225
|
+
stream_cls: type[_StreamT] | None = None,
|
|
1226
|
+
) -> ResponseT | _StreamT: ...
|
|
1227
|
+
|
|
1228
|
+
def post(
|
|
1229
|
+
self,
|
|
1230
|
+
path: str,
|
|
1231
|
+
*,
|
|
1232
|
+
cast_to: Type[ResponseT],
|
|
1233
|
+
body: Body | None = None,
|
|
1234
|
+
options: RequestOptions = {},
|
|
1235
|
+
files: RequestFiles | None = None,
|
|
1236
|
+
stream: bool = False,
|
|
1237
|
+
stream_cls: type[_StreamT] | None = None,
|
|
1238
|
+
) -> ResponseT | _StreamT:
|
|
1239
|
+
opts = FinalRequestOptions.construct(
|
|
1240
|
+
method="post", url=path, json_data=body, files=to_httpx_files(files), **options
|
|
1241
|
+
)
|
|
1242
|
+
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
|
|
1243
|
+
|
|
1244
|
+
def patch(
|
|
1245
|
+
self,
|
|
1246
|
+
path: str,
|
|
1247
|
+
*,
|
|
1248
|
+
cast_to: Type[ResponseT],
|
|
1249
|
+
body: Body | None = None,
|
|
1250
|
+
options: RequestOptions = {},
|
|
1251
|
+
) -> ResponseT:
|
|
1252
|
+
opts = FinalRequestOptions.construct(method="patch", url=path, json_data=body, **options)
|
|
1253
|
+
return self.request(cast_to, opts)
|
|
1254
|
+
|
|
1255
|
+
def put(
|
|
1256
|
+
self,
|
|
1257
|
+
path: str,
|
|
1258
|
+
*,
|
|
1259
|
+
cast_to: Type[ResponseT],
|
|
1260
|
+
body: Body | None = None,
|
|
1261
|
+
files: RequestFiles | None = None,
|
|
1262
|
+
options: RequestOptions = {},
|
|
1263
|
+
) -> ResponseT:
|
|
1264
|
+
opts = FinalRequestOptions.construct(
|
|
1265
|
+
method="put", url=path, json_data=body, files=to_httpx_files(files), **options
|
|
1266
|
+
)
|
|
1267
|
+
return self.request(cast_to, opts)
|
|
1268
|
+
|
|
1269
|
+
def delete(
|
|
1270
|
+
self,
|
|
1271
|
+
path: str,
|
|
1272
|
+
*,
|
|
1273
|
+
cast_to: Type[ResponseT],
|
|
1274
|
+
body: Body | None = None,
|
|
1275
|
+
options: RequestOptions = {},
|
|
1276
|
+
) -> ResponseT:
|
|
1277
|
+
opts = FinalRequestOptions.construct(method="delete", url=path, json_data=body, **options)
|
|
1278
|
+
return self.request(cast_to, opts)
|
|
1279
|
+
|
|
1280
|
+
def get_api_list(
|
|
1281
|
+
self,
|
|
1282
|
+
path: str,
|
|
1283
|
+
*,
|
|
1284
|
+
model: Type[object],
|
|
1285
|
+
page: Type[SyncPageT],
|
|
1286
|
+
body: Body | None = None,
|
|
1287
|
+
options: RequestOptions = {},
|
|
1288
|
+
method: str = "get",
|
|
1289
|
+
) -> SyncPageT:
|
|
1290
|
+
opts = FinalRequestOptions.construct(method=method, url=path, json_data=body, **options)
|
|
1291
|
+
return self._request_api_list(model, page, opts)
|
|
1292
|
+
|
|
1293
|
+
|
|
1294
|
+
class _DefaultAsyncHttpxClient(httpx.AsyncClient):
|
|
1295
|
+
def __init__(self, **kwargs: Any) -> None:
|
|
1296
|
+
kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
|
|
1297
|
+
kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
|
|
1298
|
+
kwargs.setdefault("follow_redirects", True)
|
|
1299
|
+
super().__init__(**kwargs)
|
|
1300
|
+
|
|
1301
|
+
|
|
1302
|
+
try:
|
|
1303
|
+
import httpx_aiohttp
|
|
1304
|
+
except ImportError:
|
|
1305
|
+
|
|
1306
|
+
class _DefaultAioHttpClient(httpx.AsyncClient):
|
|
1307
|
+
def __init__(self, **_kwargs: Any) -> None:
|
|
1308
|
+
raise RuntimeError("To use the aiohttp client you must have installed the package with the `aiohttp` extra")
|
|
1309
|
+
else:
|
|
1310
|
+
|
|
1311
|
+
class _DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore
|
|
1312
|
+
def __init__(self, **kwargs: Any) -> None:
|
|
1313
|
+
kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
|
|
1314
|
+
kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
|
|
1315
|
+
kwargs.setdefault("follow_redirects", True)
|
|
1316
|
+
|
|
1317
|
+
super().__init__(**kwargs)
|
|
1318
|
+
|
|
1319
|
+
|
|
1320
|
+
if TYPE_CHECKING:
|
|
1321
|
+
DefaultAsyncHttpxClient = httpx.AsyncClient
|
|
1322
|
+
"""An alias to `httpx.AsyncClient` that provides the same defaults that this SDK
|
|
1323
|
+
uses internally.
|
|
1324
|
+
|
|
1325
|
+
This is useful because overriding the `http_client` with your own instance of
|
|
1326
|
+
`httpx.AsyncClient` will result in httpx's defaults being used, not ours.
|
|
1327
|
+
"""
|
|
1328
|
+
|
|
1329
|
+
DefaultAioHttpClient = httpx.AsyncClient
|
|
1330
|
+
"""An alias to `httpx.AsyncClient` that changes the default HTTP transport to `aiohttp`."""
|
|
1331
|
+
else:
|
|
1332
|
+
DefaultAsyncHttpxClient = _DefaultAsyncHttpxClient
|
|
1333
|
+
DefaultAioHttpClient = _DefaultAioHttpClient
|
|
1334
|
+
|
|
1335
|
+
|
|
1336
|
+
class AsyncHttpxClientWrapper(DefaultAsyncHttpxClient):
|
|
1337
|
+
def __del__(self) -> None:
|
|
1338
|
+
if self.is_closed:
|
|
1339
|
+
return
|
|
1340
|
+
|
|
1341
|
+
try:
|
|
1342
|
+
# TODO(someday): support non asyncio runtimes here
|
|
1343
|
+
asyncio.get_running_loop().create_task(self.aclose())
|
|
1344
|
+
except Exception:
|
|
1345
|
+
pass
|
|
1346
|
+
|
|
1347
|
+
|
|
1348
|
+
class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
|
|
1349
|
+
_client: httpx.AsyncClient
|
|
1350
|
+
_default_stream_cls: type[AsyncStream[Any]] | None = None
|
|
1351
|
+
|
|
1352
|
+
def __init__(
|
|
1353
|
+
self,
|
|
1354
|
+
*,
|
|
1355
|
+
version: str,
|
|
1356
|
+
base_url: str | URL,
|
|
1357
|
+
_strict_response_validation: bool,
|
|
1358
|
+
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
1359
|
+
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
|
|
1360
|
+
http_client: httpx.AsyncClient | None = None,
|
|
1361
|
+
custom_headers: Mapping[str, str] | None = None,
|
|
1362
|
+
custom_query: Mapping[str, object] | None = None,
|
|
1363
|
+
) -> None:
|
|
1364
|
+
if not is_given(timeout):
|
|
1365
|
+
# if the user passed in a custom http client with a non-default
|
|
1366
|
+
# timeout set then we use that timeout.
|
|
1367
|
+
#
|
|
1368
|
+
# note: there is an edge case here where the user passes in a client
|
|
1369
|
+
# where they've explicitly set the timeout to match the default timeout
|
|
1370
|
+
# as this check is structural, meaning that we'll think they didn't
|
|
1371
|
+
# pass in a timeout and will ignore it
|
|
1372
|
+
if http_client and http_client.timeout != HTTPX_DEFAULT_TIMEOUT:
|
|
1373
|
+
timeout = http_client.timeout
|
|
1374
|
+
else:
|
|
1375
|
+
timeout = DEFAULT_TIMEOUT
|
|
1376
|
+
|
|
1377
|
+
if http_client is not None and not isinstance(http_client, httpx.AsyncClient): # pyright: ignore[reportUnnecessaryIsInstance]
|
|
1378
|
+
raise TypeError(
|
|
1379
|
+
f"Invalid `http_client` argument; Expected an instance of `httpx.AsyncClient` but got {type(http_client)}"
|
|
1380
|
+
)
|
|
1381
|
+
|
|
1382
|
+
super().__init__(
|
|
1383
|
+
version=version,
|
|
1384
|
+
base_url=base_url,
|
|
1385
|
+
# cast to a valid type because mypy doesn't understand our type narrowing
|
|
1386
|
+
timeout=cast(Timeout, timeout),
|
|
1387
|
+
max_retries=max_retries,
|
|
1388
|
+
custom_query=custom_query,
|
|
1389
|
+
custom_headers=custom_headers,
|
|
1390
|
+
_strict_response_validation=_strict_response_validation,
|
|
1391
|
+
)
|
|
1392
|
+
self._client = http_client or AsyncHttpxClientWrapper(
|
|
1393
|
+
base_url=base_url,
|
|
1394
|
+
# cast to a valid type because mypy doesn't understand our type narrowing
|
|
1395
|
+
timeout=cast(Timeout, timeout),
|
|
1396
|
+
)
|
|
1397
|
+
|
|
1398
|
+
def is_closed(self) -> bool:
|
|
1399
|
+
return self._client.is_closed
|
|
1400
|
+
|
|
1401
|
+
async def close(self) -> None:
|
|
1402
|
+
"""Close the underlying HTTPX client.
|
|
1403
|
+
|
|
1404
|
+
The client will *not* be usable after this.
|
|
1405
|
+
"""
|
|
1406
|
+
await self._client.aclose()
|
|
1407
|
+
|
|
1408
|
+
async def __aenter__(self: _T) -> _T:
|
|
1409
|
+
return self
|
|
1410
|
+
|
|
1411
|
+
async def __aexit__(
|
|
1412
|
+
self,
|
|
1413
|
+
exc_type: type[BaseException] | None,
|
|
1414
|
+
exc: BaseException | None,
|
|
1415
|
+
exc_tb: TracebackType | None,
|
|
1416
|
+
) -> None:
|
|
1417
|
+
await self.close()
|
|
1418
|
+
|
|
1419
|
+
async def _prepare_options(
|
|
1420
|
+
self,
|
|
1421
|
+
options: FinalRequestOptions, # noqa: ARG002
|
|
1422
|
+
) -> FinalRequestOptions:
|
|
1423
|
+
"""Hook for mutating the given options"""
|
|
1424
|
+
return options
|
|
1425
|
+
|
|
1426
|
+
async def _prepare_request(
|
|
1427
|
+
self,
|
|
1428
|
+
request: httpx.Request, # noqa: ARG002
|
|
1429
|
+
) -> None:
|
|
1430
|
+
"""This method is used as a callback for mutating the `Request` object
|
|
1431
|
+
after it has been constructed.
|
|
1432
|
+
This is useful for cases where you want to add certain headers based off of
|
|
1433
|
+
the request properties, e.g. `url`, `method` etc.
|
|
1434
|
+
"""
|
|
1435
|
+
return None
|
|
1436
|
+
|
|
1437
|
+
@overload
|
|
1438
|
+
async def request(
|
|
1439
|
+
self,
|
|
1440
|
+
cast_to: Type[ResponseT],
|
|
1441
|
+
options: FinalRequestOptions,
|
|
1442
|
+
*,
|
|
1443
|
+
stream: Literal[False] = False,
|
|
1444
|
+
) -> ResponseT: ...
|
|
1445
|
+
|
|
1446
|
+
@overload
|
|
1447
|
+
async def request(
|
|
1448
|
+
self,
|
|
1449
|
+
cast_to: Type[ResponseT],
|
|
1450
|
+
options: FinalRequestOptions,
|
|
1451
|
+
*,
|
|
1452
|
+
stream: Literal[True],
|
|
1453
|
+
stream_cls: type[_AsyncStreamT],
|
|
1454
|
+
) -> _AsyncStreamT: ...
|
|
1455
|
+
|
|
1456
|
+
@overload
|
|
1457
|
+
async def request(
|
|
1458
|
+
self,
|
|
1459
|
+
cast_to: Type[ResponseT],
|
|
1460
|
+
options: FinalRequestOptions,
|
|
1461
|
+
*,
|
|
1462
|
+
stream: bool,
|
|
1463
|
+
stream_cls: type[_AsyncStreamT] | None = None,
|
|
1464
|
+
) -> ResponseT | _AsyncStreamT: ...
|
|
1465
|
+
|
|
1466
|
+
async def request(
|
|
1467
|
+
self,
|
|
1468
|
+
cast_to: Type[ResponseT],
|
|
1469
|
+
options: FinalRequestOptions,
|
|
1470
|
+
*,
|
|
1471
|
+
stream: bool = False,
|
|
1472
|
+
stream_cls: type[_AsyncStreamT] | None = None,
|
|
1473
|
+
) -> ResponseT | _AsyncStreamT:
|
|
1474
|
+
if self._platform is None:
|
|
1475
|
+
# `get_platform` can make blocking IO calls so we
|
|
1476
|
+
# execute it earlier while we are in an async context
|
|
1477
|
+
self._platform = await asyncify(get_platform)()
|
|
1478
|
+
|
|
1479
|
+
cast_to = self._maybe_override_cast_to(cast_to, options)
|
|
1480
|
+
|
|
1481
|
+
# create a copy of the options we were given so that if the
|
|
1482
|
+
# options are mutated later & we then retry, the retries are
|
|
1483
|
+
# given the original options
|
|
1484
|
+
input_options = model_copy(options)
|
|
1485
|
+
if input_options.idempotency_key is None and input_options.method.lower() != "get":
|
|
1486
|
+
# ensure the idempotency key is reused between requests
|
|
1487
|
+
input_options.idempotency_key = self._idempotency_key()
|
|
1488
|
+
|
|
1489
|
+
response: httpx.Response | None = None
|
|
1490
|
+
max_retries = input_options.get_max_retries(self.max_retries)
|
|
1491
|
+
|
|
1492
|
+
retries_taken = 0
|
|
1493
|
+
for retries_taken in range(max_retries + 1):
|
|
1494
|
+
options = model_copy(input_options)
|
|
1495
|
+
options = await self._prepare_options(options)
|
|
1496
|
+
|
|
1497
|
+
remaining_retries = max_retries - retries_taken
|
|
1498
|
+
request = self._build_request(options, retries_taken=retries_taken)
|
|
1499
|
+
await self._prepare_request(request)
|
|
1500
|
+
|
|
1501
|
+
kwargs: HttpxSendArgs = {}
|
|
1502
|
+
if self.custom_auth is not None:
|
|
1503
|
+
kwargs["auth"] = self.custom_auth
|
|
1504
|
+
|
|
1505
|
+
if options.follow_redirects is not None:
|
|
1506
|
+
kwargs["follow_redirects"] = options.follow_redirects
|
|
1507
|
+
|
|
1508
|
+
log.debug("Sending HTTP Request: %s %s", request.method, request.url)
|
|
1509
|
+
|
|
1510
|
+
response = None
|
|
1511
|
+
try:
|
|
1512
|
+
response = await self._client.send(
|
|
1513
|
+
request,
|
|
1514
|
+
stream=stream or self._should_stream_response_body(request=request),
|
|
1515
|
+
**kwargs,
|
|
1516
|
+
)
|
|
1517
|
+
except httpx.TimeoutException as err:
|
|
1518
|
+
log.debug("Encountered httpx.TimeoutException", exc_info=True)
|
|
1519
|
+
|
|
1520
|
+
if remaining_retries > 0:
|
|
1521
|
+
await self._sleep_for_retry(
|
|
1522
|
+
retries_taken=retries_taken,
|
|
1523
|
+
max_retries=max_retries,
|
|
1524
|
+
options=input_options,
|
|
1525
|
+
response=None,
|
|
1526
|
+
)
|
|
1527
|
+
continue
|
|
1528
|
+
|
|
1529
|
+
log.debug("Raising timeout error")
|
|
1530
|
+
raise APITimeoutError(request=request) from err
|
|
1531
|
+
except Exception as err:
|
|
1532
|
+
log.debug("Encountered Exception", exc_info=True)
|
|
1533
|
+
|
|
1534
|
+
if remaining_retries > 0:
|
|
1535
|
+
await self._sleep_for_retry(
|
|
1536
|
+
retries_taken=retries_taken,
|
|
1537
|
+
max_retries=max_retries,
|
|
1538
|
+
options=input_options,
|
|
1539
|
+
response=None,
|
|
1540
|
+
)
|
|
1541
|
+
continue
|
|
1542
|
+
|
|
1543
|
+
log.debug("Raising connection error")
|
|
1544
|
+
raise APIConnectionError(request=request) from err
|
|
1545
|
+
|
|
1546
|
+
log.debug(
|
|
1547
|
+
'HTTP Response: %s %s "%i %s" %s',
|
|
1548
|
+
request.method,
|
|
1549
|
+
request.url,
|
|
1550
|
+
response.status_code,
|
|
1551
|
+
response.reason_phrase,
|
|
1552
|
+
response.headers,
|
|
1553
|
+
)
|
|
1554
|
+
|
|
1555
|
+
try:
|
|
1556
|
+
response.raise_for_status()
|
|
1557
|
+
except httpx.HTTPStatusError as err: # thrown on 4xx and 5xx status code
|
|
1558
|
+
log.debug("Encountered httpx.HTTPStatusError", exc_info=True)
|
|
1559
|
+
|
|
1560
|
+
if remaining_retries > 0 and self._should_retry(err.response):
|
|
1561
|
+
await err.response.aclose()
|
|
1562
|
+
await self._sleep_for_retry(
|
|
1563
|
+
retries_taken=retries_taken,
|
|
1564
|
+
max_retries=max_retries,
|
|
1565
|
+
options=input_options,
|
|
1566
|
+
response=response,
|
|
1567
|
+
)
|
|
1568
|
+
continue
|
|
1569
|
+
|
|
1570
|
+
# If the response is streamed then we need to explicitly read the response
|
|
1571
|
+
# to completion before attempting to access the response text.
|
|
1572
|
+
if not err.response.is_closed:
|
|
1573
|
+
await err.response.aread()
|
|
1574
|
+
|
|
1575
|
+
log.debug("Re-raising status error")
|
|
1576
|
+
raise self._make_status_error_from_response(err.response) from None
|
|
1577
|
+
|
|
1578
|
+
break
|
|
1579
|
+
|
|
1580
|
+
assert response is not None, "could not resolve response (should never happen)"
|
|
1581
|
+
return await self._process_response(
|
|
1582
|
+
cast_to=cast_to,
|
|
1583
|
+
options=options,
|
|
1584
|
+
response=response,
|
|
1585
|
+
stream=stream,
|
|
1586
|
+
stream_cls=stream_cls,
|
|
1587
|
+
retries_taken=retries_taken,
|
|
1588
|
+
)
|
|
1589
|
+
|
|
1590
|
+
async def _sleep_for_retry(
|
|
1591
|
+
self, *, retries_taken: int, max_retries: int, options: FinalRequestOptions, response: httpx.Response | None
|
|
1592
|
+
) -> None:
|
|
1593
|
+
remaining_retries = max_retries - retries_taken
|
|
1594
|
+
if remaining_retries == 1:
|
|
1595
|
+
log.debug("1 retry left")
|
|
1596
|
+
else:
|
|
1597
|
+
log.debug("%i retries left", remaining_retries)
|
|
1598
|
+
|
|
1599
|
+
timeout = self._calculate_retry_timeout(remaining_retries, options, response.headers if response else None)
|
|
1600
|
+
log.info("Retrying request to %s in %f seconds", options.url, timeout)
|
|
1601
|
+
|
|
1602
|
+
await anyio.sleep(timeout)
|
|
1603
|
+
|
|
1604
|
+
async def _process_response(
|
|
1605
|
+
self,
|
|
1606
|
+
*,
|
|
1607
|
+
cast_to: Type[ResponseT],
|
|
1608
|
+
options: FinalRequestOptions,
|
|
1609
|
+
response: httpx.Response,
|
|
1610
|
+
stream: bool,
|
|
1611
|
+
stream_cls: type[Stream[Any]] | type[AsyncStream[Any]] | None,
|
|
1612
|
+
retries_taken: int = 0,
|
|
1613
|
+
) -> ResponseT:
|
|
1614
|
+
origin = get_origin(cast_to) or cast_to
|
|
1615
|
+
|
|
1616
|
+
if (
|
|
1617
|
+
inspect.isclass(origin)
|
|
1618
|
+
and issubclass(origin, BaseAPIResponse)
|
|
1619
|
+
# we only want to actually return the custom BaseAPIResponse class if we're
|
|
1620
|
+
# returning the raw response, or if we're not streaming SSE, as if we're streaming
|
|
1621
|
+
# SSE then `cast_to` doesn't actively reflect the type we need to parse into
|
|
1622
|
+
and (not stream or bool(response.request.headers.get(RAW_RESPONSE_HEADER)))
|
|
1623
|
+
):
|
|
1624
|
+
if not issubclass(origin, AsyncAPIResponse):
|
|
1625
|
+
raise TypeError(f"API Response types must subclass {AsyncAPIResponse}; Received {origin}")
|
|
1626
|
+
|
|
1627
|
+
response_cls = cast("type[BaseAPIResponse[Any]]", cast_to)
|
|
1628
|
+
return cast(
|
|
1629
|
+
"ResponseT",
|
|
1630
|
+
response_cls(
|
|
1631
|
+
raw=response,
|
|
1632
|
+
client=self,
|
|
1633
|
+
cast_to=extract_response_type(response_cls),
|
|
1634
|
+
stream=stream,
|
|
1635
|
+
stream_cls=stream_cls,
|
|
1636
|
+
options=options,
|
|
1637
|
+
retries_taken=retries_taken,
|
|
1638
|
+
),
|
|
1639
|
+
)
|
|
1640
|
+
|
|
1641
|
+
if cast_to == httpx.Response:
|
|
1642
|
+
return cast(ResponseT, response)
|
|
1643
|
+
|
|
1644
|
+
api_response = AsyncAPIResponse(
|
|
1645
|
+
raw=response,
|
|
1646
|
+
client=self,
|
|
1647
|
+
cast_to=cast("type[ResponseT]", cast_to), # pyright: ignore[reportUnnecessaryCast]
|
|
1648
|
+
stream=stream,
|
|
1649
|
+
stream_cls=stream_cls,
|
|
1650
|
+
options=options,
|
|
1651
|
+
retries_taken=retries_taken,
|
|
1652
|
+
)
|
|
1653
|
+
if bool(response.request.headers.get(RAW_RESPONSE_HEADER)):
|
|
1654
|
+
return cast(ResponseT, api_response)
|
|
1655
|
+
|
|
1656
|
+
return await api_response.parse()
|
|
1657
|
+
|
|
1658
|
+
def _request_api_list(
|
|
1659
|
+
self,
|
|
1660
|
+
model: Type[_T],
|
|
1661
|
+
page: Type[AsyncPageT],
|
|
1662
|
+
options: FinalRequestOptions,
|
|
1663
|
+
) -> AsyncPaginator[_T, AsyncPageT]:
|
|
1664
|
+
return AsyncPaginator(client=self, options=options, page_cls=page, model=model)
|
|
1665
|
+
|
|
1666
|
+
@overload
|
|
1667
|
+
async def get(
|
|
1668
|
+
self,
|
|
1669
|
+
path: str,
|
|
1670
|
+
*,
|
|
1671
|
+
cast_to: Type[ResponseT],
|
|
1672
|
+
options: RequestOptions = {},
|
|
1673
|
+
stream: Literal[False] = False,
|
|
1674
|
+
) -> ResponseT: ...
|
|
1675
|
+
|
|
1676
|
+
@overload
|
|
1677
|
+
async def get(
|
|
1678
|
+
self,
|
|
1679
|
+
path: str,
|
|
1680
|
+
*,
|
|
1681
|
+
cast_to: Type[ResponseT],
|
|
1682
|
+
options: RequestOptions = {},
|
|
1683
|
+
stream: Literal[True],
|
|
1684
|
+
stream_cls: type[_AsyncStreamT],
|
|
1685
|
+
) -> _AsyncStreamT: ...
|
|
1686
|
+
|
|
1687
|
+
@overload
|
|
1688
|
+
async def get(
|
|
1689
|
+
self,
|
|
1690
|
+
path: str,
|
|
1691
|
+
*,
|
|
1692
|
+
cast_to: Type[ResponseT],
|
|
1693
|
+
options: RequestOptions = {},
|
|
1694
|
+
stream: bool,
|
|
1695
|
+
stream_cls: type[_AsyncStreamT] | None = None,
|
|
1696
|
+
) -> ResponseT | _AsyncStreamT: ...
|
|
1697
|
+
|
|
1698
|
+
async def get(
|
|
1699
|
+
self,
|
|
1700
|
+
path: str,
|
|
1701
|
+
*,
|
|
1702
|
+
cast_to: Type[ResponseT],
|
|
1703
|
+
options: RequestOptions = {},
|
|
1704
|
+
stream: bool = False,
|
|
1705
|
+
stream_cls: type[_AsyncStreamT] | None = None,
|
|
1706
|
+
) -> ResponseT | _AsyncStreamT:
|
|
1707
|
+
opts = FinalRequestOptions.construct(method="get", url=path, **options)
|
|
1708
|
+
return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
|
|
1709
|
+
|
|
1710
|
+
@overload
|
|
1711
|
+
async def post(
|
|
1712
|
+
self,
|
|
1713
|
+
path: str,
|
|
1714
|
+
*,
|
|
1715
|
+
cast_to: Type[ResponseT],
|
|
1716
|
+
body: Body | None = None,
|
|
1717
|
+
files: RequestFiles | None = None,
|
|
1718
|
+
options: RequestOptions = {},
|
|
1719
|
+
stream: Literal[False] = False,
|
|
1720
|
+
) -> ResponseT: ...
|
|
1721
|
+
|
|
1722
|
+
@overload
|
|
1723
|
+
async def post(
|
|
1724
|
+
self,
|
|
1725
|
+
path: str,
|
|
1726
|
+
*,
|
|
1727
|
+
cast_to: Type[ResponseT],
|
|
1728
|
+
body: Body | None = None,
|
|
1729
|
+
files: RequestFiles | None = None,
|
|
1730
|
+
options: RequestOptions = {},
|
|
1731
|
+
stream: Literal[True],
|
|
1732
|
+
stream_cls: type[_AsyncStreamT],
|
|
1733
|
+
) -> _AsyncStreamT: ...
|
|
1734
|
+
|
|
1735
|
+
@overload
|
|
1736
|
+
async def post(
|
|
1737
|
+
self,
|
|
1738
|
+
path: str,
|
|
1739
|
+
*,
|
|
1740
|
+
cast_to: Type[ResponseT],
|
|
1741
|
+
body: Body | None = None,
|
|
1742
|
+
files: RequestFiles | None = None,
|
|
1743
|
+
options: RequestOptions = {},
|
|
1744
|
+
stream: bool,
|
|
1745
|
+
stream_cls: type[_AsyncStreamT] | None = None,
|
|
1746
|
+
) -> ResponseT | _AsyncStreamT: ...
|
|
1747
|
+
|
|
1748
|
+
async def post(
|
|
1749
|
+
self,
|
|
1750
|
+
path: str,
|
|
1751
|
+
*,
|
|
1752
|
+
cast_to: Type[ResponseT],
|
|
1753
|
+
body: Body | None = None,
|
|
1754
|
+
files: RequestFiles | None = None,
|
|
1755
|
+
options: RequestOptions = {},
|
|
1756
|
+
stream: bool = False,
|
|
1757
|
+
stream_cls: type[_AsyncStreamT] | None = None,
|
|
1758
|
+
) -> ResponseT | _AsyncStreamT:
|
|
1759
|
+
opts = FinalRequestOptions.construct(
|
|
1760
|
+
method="post", url=path, json_data=body, files=await async_to_httpx_files(files), **options
|
|
1761
|
+
)
|
|
1762
|
+
return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
|
|
1763
|
+
|
|
1764
|
+
async def patch(
|
|
1765
|
+
self,
|
|
1766
|
+
path: str,
|
|
1767
|
+
*,
|
|
1768
|
+
cast_to: Type[ResponseT],
|
|
1769
|
+
body: Body | None = None,
|
|
1770
|
+
options: RequestOptions = {},
|
|
1771
|
+
) -> ResponseT:
|
|
1772
|
+
opts = FinalRequestOptions.construct(method="patch", url=path, json_data=body, **options)
|
|
1773
|
+
return await self.request(cast_to, opts)
|
|
1774
|
+
|
|
1775
|
+
async def put(
|
|
1776
|
+
self,
|
|
1777
|
+
path: str,
|
|
1778
|
+
*,
|
|
1779
|
+
cast_to: Type[ResponseT],
|
|
1780
|
+
body: Body | None = None,
|
|
1781
|
+
files: RequestFiles | None = None,
|
|
1782
|
+
options: RequestOptions = {},
|
|
1783
|
+
) -> ResponseT:
|
|
1784
|
+
opts = FinalRequestOptions.construct(
|
|
1785
|
+
method="put", url=path, json_data=body, files=await async_to_httpx_files(files), **options
|
|
1786
|
+
)
|
|
1787
|
+
return await self.request(cast_to, opts)
|
|
1788
|
+
|
|
1789
|
+
async def delete(
|
|
1790
|
+
self,
|
|
1791
|
+
path: str,
|
|
1792
|
+
*,
|
|
1793
|
+
cast_to: Type[ResponseT],
|
|
1794
|
+
body: Body | None = None,
|
|
1795
|
+
options: RequestOptions = {},
|
|
1796
|
+
) -> ResponseT:
|
|
1797
|
+
opts = FinalRequestOptions.construct(method="delete", url=path, json_data=body, **options)
|
|
1798
|
+
return await self.request(cast_to, opts)
|
|
1799
|
+
|
|
1800
|
+
def get_api_list(
|
|
1801
|
+
self,
|
|
1802
|
+
path: str,
|
|
1803
|
+
*,
|
|
1804
|
+
model: Type[_T],
|
|
1805
|
+
page: Type[AsyncPageT],
|
|
1806
|
+
body: Body | None = None,
|
|
1807
|
+
options: RequestOptions = {},
|
|
1808
|
+
method: str = "get",
|
|
1809
|
+
) -> AsyncPaginator[_T, AsyncPageT]:
|
|
1810
|
+
opts = FinalRequestOptions.construct(method=method, url=path, json_data=body, **options)
|
|
1811
|
+
return self._request_api_list(model, page, opts)
|
|
1812
|
+
|
|
1813
|
+
|
|
1814
|
+
def make_request_options(
|
|
1815
|
+
*,
|
|
1816
|
+
query: Query | None = None,
|
|
1817
|
+
extra_headers: Headers | None = None,
|
|
1818
|
+
extra_query: Query | None = None,
|
|
1819
|
+
extra_body: Body | None = None,
|
|
1820
|
+
idempotency_key: str | None = None,
|
|
1821
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
1822
|
+
post_parser: PostParser | NotGiven = NOT_GIVEN,
|
|
1823
|
+
) -> RequestOptions:
|
|
1824
|
+
"""Create a dict of type RequestOptions without keys of NotGiven values."""
|
|
1825
|
+
options: RequestOptions = {}
|
|
1826
|
+
if extra_headers is not None:
|
|
1827
|
+
options["headers"] = extra_headers
|
|
1828
|
+
|
|
1829
|
+
if extra_body is not None:
|
|
1830
|
+
options["extra_json"] = cast(AnyMapping, extra_body)
|
|
1831
|
+
|
|
1832
|
+
if query is not None:
|
|
1833
|
+
options["params"] = query
|
|
1834
|
+
|
|
1835
|
+
if extra_query is not None:
|
|
1836
|
+
options["params"] = {**options.get("params", {}), **extra_query}
|
|
1837
|
+
|
|
1838
|
+
if not isinstance(timeout, NotGiven):
|
|
1839
|
+
options["timeout"] = timeout
|
|
1840
|
+
|
|
1841
|
+
if idempotency_key is not None:
|
|
1842
|
+
options["idempotency_key"] = idempotency_key
|
|
1843
|
+
|
|
1844
|
+
if is_given(post_parser):
|
|
1845
|
+
# internal
|
|
1846
|
+
options["post_parser"] = post_parser # type: ignore
|
|
1847
|
+
|
|
1848
|
+
return options
|
|
1849
|
+
|
|
1850
|
+
|
|
1851
|
+
class ForceMultipartDict(Dict[str, None]):
|
|
1852
|
+
def __bool__(self) -> bool:
|
|
1853
|
+
return True
|
|
1854
|
+
|
|
1855
|
+
|
|
1856
|
+
class OtherPlatform:
|
|
1857
|
+
def __init__(self, name: str) -> None:
|
|
1858
|
+
self.name = name
|
|
1859
|
+
|
|
1860
|
+
@override
|
|
1861
|
+
def __str__(self) -> str:
|
|
1862
|
+
return f"Other:{self.name}"
|
|
1863
|
+
|
|
1864
|
+
|
|
1865
|
+
Platform = Union[
|
|
1866
|
+
OtherPlatform,
|
|
1867
|
+
Literal[
|
|
1868
|
+
"MacOS",
|
|
1869
|
+
"Linux",
|
|
1870
|
+
"Windows",
|
|
1871
|
+
"FreeBSD",
|
|
1872
|
+
"OpenBSD",
|
|
1873
|
+
"iOS",
|
|
1874
|
+
"Android",
|
|
1875
|
+
"Unknown",
|
|
1876
|
+
],
|
|
1877
|
+
]
|
|
1878
|
+
|
|
1879
|
+
|
|
1880
|
+
def get_platform() -> Platform:
|
|
1881
|
+
try:
|
|
1882
|
+
system = platform.system().lower()
|
|
1883
|
+
platform_name = platform.platform().lower()
|
|
1884
|
+
except Exception:
|
|
1885
|
+
return "Unknown"
|
|
1886
|
+
|
|
1887
|
+
if "iphone" in platform_name or "ipad" in platform_name:
|
|
1888
|
+
# Tested using Python3IDE on an iPhone 11 and Pythonista on an iPad 7
|
|
1889
|
+
# system is Darwin and platform_name is a string like:
|
|
1890
|
+
# - Darwin-21.6.0-iPhone12,1-64bit
|
|
1891
|
+
# - Darwin-21.6.0-iPad7,11-64bit
|
|
1892
|
+
return "iOS"
|
|
1893
|
+
|
|
1894
|
+
if system == "darwin":
|
|
1895
|
+
return "MacOS"
|
|
1896
|
+
|
|
1897
|
+
if system == "windows":
|
|
1898
|
+
return "Windows"
|
|
1899
|
+
|
|
1900
|
+
if "android" in platform_name:
|
|
1901
|
+
# Tested using Pydroid 3
|
|
1902
|
+
# system is Linux and platform_name is a string like 'Linux-5.10.81-android12-9-00001-geba40aecb3b7-ab8534902-aarch64-with-libc'
|
|
1903
|
+
return "Android"
|
|
1904
|
+
|
|
1905
|
+
if system == "linux":
|
|
1906
|
+
# https://distro.readthedocs.io/en/latest/#distro.id
|
|
1907
|
+
distro_id = distro.id()
|
|
1908
|
+
if distro_id == "freebsd":
|
|
1909
|
+
return "FreeBSD"
|
|
1910
|
+
|
|
1911
|
+
if distro_id == "openbsd":
|
|
1912
|
+
return "OpenBSD"
|
|
1913
|
+
|
|
1914
|
+
return "Linux"
|
|
1915
|
+
|
|
1916
|
+
if platform_name:
|
|
1917
|
+
return OtherPlatform(platform_name)
|
|
1918
|
+
|
|
1919
|
+
return "Unknown"
|
|
1920
|
+
|
|
1921
|
+
|
|
1922
|
+
@lru_cache(maxsize=None)
|
|
1923
|
+
def platform_headers(version: str, *, platform: Platform | None) -> Dict[str, str]:
|
|
1924
|
+
return {
|
|
1925
|
+
"X-Stainless-Lang": "python",
|
|
1926
|
+
"X-Stainless-Package-Version": version,
|
|
1927
|
+
"X-Stainless-OS": str(platform or get_platform()),
|
|
1928
|
+
"X-Stainless-Arch": str(get_architecture()),
|
|
1929
|
+
"X-Stainless-Runtime": get_python_runtime(),
|
|
1930
|
+
"X-Stainless-Runtime-Version": get_python_version(),
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1933
|
+
|
|
1934
|
+
class OtherArch:
|
|
1935
|
+
def __init__(self, name: str) -> None:
|
|
1936
|
+
self.name = name
|
|
1937
|
+
|
|
1938
|
+
@override
|
|
1939
|
+
def __str__(self) -> str:
|
|
1940
|
+
return f"other:{self.name}"
|
|
1941
|
+
|
|
1942
|
+
|
|
1943
|
+
Arch = Union[OtherArch, Literal["x32", "x64", "arm", "arm64", "unknown"]]
|
|
1944
|
+
|
|
1945
|
+
|
|
1946
|
+
def get_python_runtime() -> str:
|
|
1947
|
+
try:
|
|
1948
|
+
return platform.python_implementation()
|
|
1949
|
+
except Exception:
|
|
1950
|
+
return "unknown"
|
|
1951
|
+
|
|
1952
|
+
|
|
1953
|
+
def get_python_version() -> str:
|
|
1954
|
+
try:
|
|
1955
|
+
return platform.python_version()
|
|
1956
|
+
except Exception:
|
|
1957
|
+
return "unknown"
|
|
1958
|
+
|
|
1959
|
+
|
|
1960
|
+
def get_architecture() -> Arch:
|
|
1961
|
+
try:
|
|
1962
|
+
machine = platform.machine().lower()
|
|
1963
|
+
except Exception:
|
|
1964
|
+
return "unknown"
|
|
1965
|
+
|
|
1966
|
+
if machine in ("arm64", "aarch64"):
|
|
1967
|
+
return "arm64"
|
|
1968
|
+
|
|
1969
|
+
# TODO: untested
|
|
1970
|
+
if machine == "arm":
|
|
1971
|
+
return "arm"
|
|
1972
|
+
|
|
1973
|
+
if machine == "x86_64":
|
|
1974
|
+
return "x64"
|
|
1975
|
+
|
|
1976
|
+
# TODO: untested
|
|
1977
|
+
if sys.maxsize <= 2**32:
|
|
1978
|
+
return "x32"
|
|
1979
|
+
|
|
1980
|
+
if machine:
|
|
1981
|
+
return OtherArch(machine)
|
|
1982
|
+
|
|
1983
|
+
return "unknown"
|
|
1984
|
+
|
|
1985
|
+
|
|
1986
|
+
def _merge_mappings(
|
|
1987
|
+
obj1: Mapping[_T_co, Union[_T, Omit]],
|
|
1988
|
+
obj2: Mapping[_T_co, Union[_T, Omit]],
|
|
1989
|
+
) -> Dict[_T_co, _T]:
|
|
1990
|
+
"""Merge two mappings of the same type, removing any values that are instances of `Omit`.
|
|
1991
|
+
|
|
1992
|
+
In cases with duplicate keys the second mapping takes precedence.
|
|
1993
|
+
"""
|
|
1994
|
+
merged = {**obj1, **obj2}
|
|
1995
|
+
return {key: value for key, value in merged.items() if not isinstance(value, Omit)}
|