diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 6b0fe76f..4eb38c4e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "3.5.0-alpha" + ".": "3.6.0-alpha" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 102386f3..2c4f5c1f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 801 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/telnyx%2Ftelnyx-d5da60e6c0a34ecb5e91fc3e232836c75e32cdc1c1f348e6b12d88e8c1d77aea.yml -openapi_spec_hash: c78b6c372d7b9a5d8735956b67e724ce -config_hash: 239f4f0a795470227c75e4d48b782e04 +configured_endpoints: 846 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/telnyx%2Ftelnyx-cb0994e7d39146470cf25daa458555be4691e50795b9cb9be0cdd76a7d6bf357.yml +openapi_spec_hash: df09e67ae6d4df81593b396048046de5 +config_hash: 53adc7ec630d90dd582727459f58a597 diff --git a/CHANGELOG.md b/CHANGELOG.md index adfb34e1..51fe6fb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## 3.6.0-alpha (2025-09-23) + +Full Changelog: [v3.5.0-alpha...v3.6.0-alpha](https://github.com/team-telnyx/telnyx-python/compare/v3.5.0-alpha...v3.6.0-alpha) + +### Features + +* **api:** manual updates ([12d91f6](https://github.com/team-telnyx/telnyx-python/commit/12d91f63949e7097d424fabd0de50fa74f7cce65)) +* **api:** manual updates ([04e377e](https://github.com/team-telnyx/telnyx-python/commit/04e377ec69cfdfadb46eff9f4008dee6460ec21a)) + + +### Chores + +* do not install brew dependencies in ./scripts/bootstrap by default ([f6d0905](https://github.com/team-telnyx/telnyx-python/commit/f6d09059d41e721669697646dc072b9eca5e2c5b)) +* improve example values ([38fccc3](https://github.com/team-telnyx/telnyx-python/commit/38fccc3883c842b436400beab2f5cc9932bc9039)) + ## 3.5.0-alpha (2025-09-19) Full Changelog: [v3.4.0-alpha...v3.5.0-alpha](https://github.com/team-telnyx/telnyx-python/compare/v3.4.0-alpha...v3.5.0-alpha) diff --git a/api.md b/api.md index 90e06c7b..48115a1a 100644 --- a/api.md +++ b/api.md @@ -39,6 +39,199 @@ Methods: - client.list_objects(bucket_name, \*\*params) -> ListObjectsResponse - client.put_object(object_name, \*, bucket_name, \*\*params) -> None +# Legacy + +## Reporting + +### BatchDetailRecords + +#### Messaging + +Types: + +```python +from telnyx.types.legacy.reporting.batch_detail_records import ( + MessagingCreateResponse, + MessagingRetrieveResponse, + MessagingListResponse, + MessagingDeleteResponse, +) +``` + +Methods: + +- client.legacy.reporting.batch_detail_records.messaging.create(\*\*params) -> MessagingCreateResponse +- client.legacy.reporting.batch_detail_records.messaging.retrieve(id) -> MessagingRetrieveResponse +- client.legacy.reporting.batch_detail_records.messaging.list() -> MessagingListResponse +- client.legacy.reporting.batch_detail_records.messaging.delete(id) -> MessagingDeleteResponse + +#### SpeechToText + +Types: + +```python +from telnyx.types.legacy.reporting.batch_detail_records import ( + SpeechToTextCreateResponse, + SpeechToTextRetrieveResponse, + SpeechToTextListResponse, + SpeechToTextDeleteResponse, +) +``` + +Methods: + +- client.legacy.reporting.batch_detail_records.speech_to_text.create(\*\*params) -> SpeechToTextCreateResponse +- client.legacy.reporting.batch_detail_records.speech_to_text.retrieve(id) -> SpeechToTextRetrieveResponse +- client.legacy.reporting.batch_detail_records.speech_to_text.list() -> SpeechToTextListResponse +- client.legacy.reporting.batch_detail_records.speech_to_text.delete(id) -> SpeechToTextDeleteResponse + +#### Voice + +Types: + +```python +from telnyx.types.legacy.reporting.batch_detail_records import ( + VoiceCreateResponse, + VoiceRetrieveResponse, + VoiceListResponse, + VoiceDeleteResponse, + VoiceRetrieveFieldsResponse, +) +``` + +Methods: + +- client.legacy.reporting.batch_detail_records.voice.create(\*\*params) -> VoiceCreateResponse +- client.legacy.reporting.batch_detail_records.voice.retrieve(id) -> VoiceRetrieveResponse +- client.legacy.reporting.batch_detail_records.voice.list() -> VoiceListResponse +- client.legacy.reporting.batch_detail_records.voice.delete(id) -> VoiceDeleteResponse +- client.legacy.reporting.batch_detail_records.voice.retrieve_fields() -> VoiceRetrieveFieldsResponse + +### UsageReports + +Types: + +```python +from telnyx.types.legacy.reporting import UsageReportRetrieveSpeechToTextResponse +``` + +Methods: + +- client.legacy.reporting.usage_reports.retrieve_speech_to_text(\*\*params) -> UsageReportRetrieveSpeechToTextResponse + +#### Messaging + +Types: + +```python +from telnyx.types.legacy.reporting.usage_reports import ( + MessagingCreateResponse, + MessagingRetrieveResponse, + MessagingListResponse, + MessagingDeleteResponse, +) +``` + +Methods: + +- client.legacy.reporting.usage_reports.messaging.create(\*\*params) -> MessagingCreateResponse +- client.legacy.reporting.usage_reports.messaging.retrieve(id) -> MessagingRetrieveResponse +- client.legacy.reporting.usage_reports.messaging.list(\*\*params) -> MessagingListResponse +- client.legacy.reporting.usage_reports.messaging.delete(id) -> MessagingDeleteResponse + +#### NumberLookup + +Methods: + +- client.legacy.reporting.usage_reports.number_lookup.create(\*\*params) -> None +- client.legacy.reporting.usage_reports.number_lookup.retrieve(id) -> None +- client.legacy.reporting.usage_reports.number_lookup.list(\*\*params) -> None +- client.legacy.reporting.usage_reports.number_lookup.delete(id) -> None + +#### Voice + +Types: + +```python +from telnyx.types.legacy.reporting.usage_reports import ( + VoiceCreateResponse, + VoiceRetrieveResponse, + VoiceListResponse, + VoiceDeleteResponse, +) +``` + +Methods: + +- client.legacy.reporting.usage_reports.voice.create(\*\*params) -> VoiceCreateResponse +- client.legacy.reporting.usage_reports.voice.retrieve(id) -> VoiceRetrieveResponse +- client.legacy.reporting.usage_reports.voice.list(\*\*params) -> VoiceListResponse +- client.legacy.reporting.usage_reports.voice.delete(id) -> VoiceDeleteResponse + +# OAuth + +Types: + +```python +from telnyx.types import ( + OAuthRetrieveResponse, + OAuthGrantsResponse, + OAuthIntrospectResponse, + OAuthRegisterResponse, + OAuthRetrieveJwksResponse, + OAuthTokenResponse, +) +``` + +Methods: + +- client.oauth.retrieve(consent_token) -> OAuthRetrieveResponse +- client.oauth.grants(\*\*params) -> OAuthGrantsResponse +- client.oauth.introspect(\*\*params) -> OAuthIntrospectResponse +- client.oauth.register(\*\*params) -> OAuthRegisterResponse +- client.oauth.retrieve_authorize(\*\*params) -> None +- client.oauth.retrieve_jwks() -> OAuthRetrieveJwksResponse +- client.oauth.token(\*\*params) -> OAuthTokenResponse + +# OAuthClients + +Types: + +```python +from telnyx.types import ( + OAuthClientCreateResponse, + OAuthClientRetrieveResponse, + OAuthClientUpdateResponse, + OAuthClientListResponse, +) +``` + +Methods: + +- client.oauth_clients.create(\*\*params) -> OAuthClientCreateResponse +- client.oauth_clients.retrieve(id) -> OAuthClientRetrieveResponse +- client.oauth_clients.update(id, \*\*params) -> OAuthClientUpdateResponse +- client.oauth_clients.list(\*\*params) -> OAuthClientListResponse +- client.oauth_clients.delete(id) -> None + +# OAuthGrants + +Types: + +```python +from telnyx.types import ( + OAuthGrantRetrieveResponse, + OAuthGrantListResponse, + OAuthGrantDeleteResponse, +) +``` + +Methods: + +- client.oauth_grants.retrieve(id) -> OAuthGrantRetrieveResponse +- client.oauth_grants.list(\*\*params) -> OAuthGrantListResponse +- client.oauth_grants.delete(id) -> OAuthGrantDeleteResponse + # Webhooks Types: @@ -465,6 +658,7 @@ Methods: - client.ai.conversations.update(conversation_id, \*\*params) -> ConversationUpdateResponse - client.ai.conversations.list(\*\*params) -> ConversationListResponse - client.ai.conversations.delete(conversation_id) -> None +- client.ai.conversations.add_message(conversation_id, \*\*params) -> object - client.ai.conversations.retrieve_conversations_insights(conversation_id) -> ConversationRetrieveConversationsInsightsResponse ### InsightGroups @@ -524,7 +718,6 @@ from telnyx.types.ai.conversations import MessageListResponse Methods: -- client.ai.conversations.messages.create(conversation_id, \*\*params) -> object - client.ai.conversations.messages.list(conversation_id) -> MessageListResponse ## Embeddings @@ -4264,7 +4457,9 @@ from telnyx.types import ( VerifyProfile, VerifyProfileData, VerifyProfileListResponse, + VerifyProfileCreateTemplateResponse, VerifyProfileRetrieveTemplatesResponse, + VerifyProfileUpdateTemplateResponse, ) ``` @@ -4275,7 +4470,9 @@ Methods: - client.verify_profiles.update(verify_profile_id, \*\*params) -> VerifyProfileData - client.verify_profiles.list(\*\*params) -> VerifyProfileListResponse - client.verify_profiles.delete(verify_profile_id) -> VerifyProfileData +- client.verify_profiles.create_template(\*\*params) -> VerifyProfileCreateTemplateResponse - client.verify_profiles.retrieve_templates() -> VerifyProfileRetrieveTemplatesResponse +- client.verify_profiles.update_template(template_id, \*\*params) -> VerifyProfileUpdateTemplateResponse # VirtualCrossConnects @@ -4457,3 +4654,19 @@ Methods: - client.partner_campaigns.list(\*\*params) -> PartnerCampaignListResponse - client.partner_campaigns.list_shared_by_me(\*\*params) -> PartnerCampaignListSharedByMeResponse - client.partner_campaigns.retrieve_sharing_status(campaign_id) -> PartnerCampaignRetrieveSharingStatusResponse + +# WellKnown + +Types: + +```python +from telnyx.types import ( + WellKnownRetrieveAuthorizationServerMetadataResponse, + WellKnownRetrieveProtectedResourceMetadataResponse, +) +``` + +Methods: + +- client.well_known.retrieve_authorization_server_metadata() -> WellKnownRetrieveAuthorizationServerMetadataResponse +- client.well_known.retrieve_protected_resource_metadata() -> WellKnownRetrieveProtectedResourceMetadataResponse diff --git a/pyproject.toml b/pyproject.toml index 1c34ad53..b9263d1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "telnyx" -version = "3.5.0-alpha" +version = "3.6.0-alpha" description = "The official Python library for the telnyx API" dynamic = ["readme"] license = "MIT" diff --git a/scripts/bootstrap b/scripts/bootstrap index e84fe62c..b430fee3 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -4,10 +4,18 @@ set -e cd "$(dirname "$0")/.." -if ! command -v rye >/dev/null 2>&1 && [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then brew bundle check >/dev/null 2>&1 || { - echo "==> Installing Homebrew dependencies…" - brew bundle + echo -n "==> Install Homebrew dependencies? (y/N): " + read -r response + case "$response" in + [yY][eE][sS]|[yY]) + brew bundle + ;; + *) + ;; + esac + echo } fi diff --git a/src/telnyx/_client.py b/src/telnyx/_client.py index 6ae82afd..ac0e5bc1 100644 --- a/src/telnyx/_client.py +++ b/src/telnyx/_client.py @@ -60,6 +60,7 @@ seti, fqdns, media, + oauth, balance, regions, comments, @@ -69,15 +70,18 @@ messsages, user_tags, global_ips, + well_known, call_events, connections, ota_updates, short_codes, audit_events, + oauth_grants, requirements, channel_zones, number_lookup, number_orders, + oauth_clients, usage_reports, billing_groups, detail_records, @@ -178,6 +182,7 @@ from .resources.faxes import faxes from .resources.rooms import rooms from .resources.texml import texml +from .resources.legacy import legacy from .resources.queues import queues from .resources.actions import actions from .resources.payment import payment @@ -217,6 +222,10 @@ class Telnyx(SyncAPIClient): + legacy: legacy.LegacyResource + oauth: oauth.OAuthResource + oauth_clients: oauth_clients.OAuthClientsResource + oauth_grants: oauth_grants.OAuthGrantsResource webhooks: webhooks.WebhooksResource access_ip_address: access_ip_address.AccessIPAddressResource access_ip_ranges: access_ip_ranges.AccessIPRangesResource @@ -366,6 +375,7 @@ class Telnyx(SyncAPIClient): wireless_blocklist_values: wireless_blocklist_values.WirelessBlocklistValuesResource wireless_blocklists: wireless_blocklists.WirelessBlocklistsResource partner_campaigns: partner_campaigns.PartnerCampaignsResource + well_known: well_known.WellKnownResource with_raw_response: TelnyxWithRawResponse with_streaming_response: TelnyxWithStreamedResponse @@ -409,6 +419,7 @@ def __init__( if base_url is None: base_url = os.environ.get("TELNYX_BASE_URL") + self._base_url_overridden = base_url is not None if base_url is None: base_url = f"https://api.telnyx.com/v2" @@ -423,6 +434,10 @@ def __init__( _strict_response_validation=_strict_response_validation, ) + self.legacy = legacy.LegacyResource(self) + self.oauth = oauth.OAuthResource(self) + self.oauth_clients = oauth_clients.OAuthClientsResource(self) + self.oauth_grants = oauth_grants.OAuthGrantsResource(self) self.webhooks = webhooks.WebhooksResource(self) self.access_ip_address = access_ip_address.AccessIPAddressResource(self) self.access_ip_ranges = access_ip_ranges.AccessIPRangesResource(self) @@ -578,6 +593,7 @@ def __init__( self.wireless_blocklist_values = wireless_blocklist_values.WirelessBlocklistValuesResource(self) self.wireless_blocklists = wireless_blocklists.WirelessBlocklistsResource(self) self.partner_campaigns = partner_campaigns.PartnerCampaignsResource(self) + self.well_known = well_known.WellKnownResource(self) self.with_raw_response = TelnyxWithRawResponse(self) self.with_streaming_response = TelnyxWithStreamedResponse(self) @@ -637,7 +653,7 @@ def copy( params = set_default_query http_client = http_client or self._client - return self.__class__( + client = self.__class__( api_key=api_key or self.api_key, base_url=base_url or self.base_url, timeout=self.timeout if isinstance(timeout, NotGiven) else timeout, @@ -647,6 +663,8 @@ def copy( default_query=params, **_extra_kwargs, ) + client._base_url_overridden = self._base_url_overridden or base_url is not None + return client # Alias for `copy` for nicer inline usage, e.g. # client.with_options(timeout=10).foo.create(...) @@ -990,6 +1008,10 @@ def _make_status_error( class AsyncTelnyx(AsyncAPIClient): + legacy: legacy.AsyncLegacyResource + oauth: oauth.AsyncOAuthResource + oauth_clients: oauth_clients.AsyncOAuthClientsResource + oauth_grants: oauth_grants.AsyncOAuthGrantsResource webhooks: webhooks.AsyncWebhooksResource access_ip_address: access_ip_address.AsyncAccessIPAddressResource access_ip_ranges: access_ip_ranges.AsyncAccessIPRangesResource @@ -1139,6 +1161,7 @@ class AsyncTelnyx(AsyncAPIClient): wireless_blocklist_values: wireless_blocklist_values.AsyncWirelessBlocklistValuesResource wireless_blocklists: wireless_blocklists.AsyncWirelessBlocklistsResource partner_campaigns: partner_campaigns.AsyncPartnerCampaignsResource + well_known: well_known.AsyncWellKnownResource with_raw_response: AsyncTelnyxWithRawResponse with_streaming_response: AsyncTelnyxWithStreamedResponse @@ -1182,6 +1205,7 @@ def __init__( if base_url is None: base_url = os.environ.get("TELNYX_BASE_URL") + self._base_url_overridden = base_url is not None if base_url is None: base_url = f"https://api.telnyx.com/v2" @@ -1196,6 +1220,10 @@ def __init__( _strict_response_validation=_strict_response_validation, ) + self.legacy = legacy.AsyncLegacyResource(self) + self.oauth = oauth.AsyncOAuthResource(self) + self.oauth_clients = oauth_clients.AsyncOAuthClientsResource(self) + self.oauth_grants = oauth_grants.AsyncOAuthGrantsResource(self) self.webhooks = webhooks.AsyncWebhooksResource(self) self.access_ip_address = access_ip_address.AsyncAccessIPAddressResource(self) self.access_ip_ranges = access_ip_ranges.AsyncAccessIPRangesResource(self) @@ -1357,6 +1385,7 @@ def __init__( self.wireless_blocklist_values = wireless_blocklist_values.AsyncWirelessBlocklistValuesResource(self) self.wireless_blocklists = wireless_blocklists.AsyncWirelessBlocklistsResource(self) self.partner_campaigns = partner_campaigns.AsyncPartnerCampaignsResource(self) + self.well_known = well_known.AsyncWellKnownResource(self) self.with_raw_response = AsyncTelnyxWithRawResponse(self) self.with_streaming_response = AsyncTelnyxWithStreamedResponse(self) @@ -1416,7 +1445,7 @@ def copy( params = set_default_query http_client = http_client or self._client - return self.__class__( + client = self.__class__( api_key=api_key or self.api_key, base_url=base_url or self.base_url, timeout=self.timeout if isinstance(timeout, NotGiven) else timeout, @@ -1426,6 +1455,8 @@ def copy( default_query=params, **_extra_kwargs, ) + client._base_url_overridden = self._base_url_overridden or base_url is not None + return client # Alias for `copy` for nicer inline usage, e.g. # client.with_options(timeout=10).foo.create(...) @@ -1776,6 +1807,10 @@ def _make_status_error( class TelnyxWithRawResponse: def __init__(self, client: Telnyx) -> None: + self.legacy = legacy.LegacyResourceWithRawResponse(client.legacy) + self.oauth = oauth.OAuthResourceWithRawResponse(client.oauth) + self.oauth_clients = oauth_clients.OAuthClientsResourceWithRawResponse(client.oauth_clients) + self.oauth_grants = oauth_grants.OAuthGrantsResourceWithRawResponse(client.oauth_grants) self.access_ip_address = access_ip_address.AccessIPAddressResourceWithRawResponse(client.access_ip_address) self.access_ip_ranges = access_ip_ranges.AccessIPRangesResourceWithRawResponse(client.access_ip_ranges) self.actions = actions.ActionsResourceWithRawResponse(client.actions) @@ -2050,6 +2085,7 @@ def __init__(self, client: Telnyx) -> None: client.wireless_blocklists ) self.partner_campaigns = partner_campaigns.PartnerCampaignsResourceWithRawResponse(client.partner_campaigns) + self.well_known = well_known.WellKnownResourceWithRawResponse(client.well_known) self.create_bucket = to_raw_response_wrapper( client.create_bucket, @@ -2080,6 +2116,10 @@ def __init__(self, client: Telnyx) -> None: class AsyncTelnyxWithRawResponse: def __init__(self, client: AsyncTelnyx) -> None: + self.legacy = legacy.AsyncLegacyResourceWithRawResponse(client.legacy) + self.oauth = oauth.AsyncOAuthResourceWithRawResponse(client.oauth) + self.oauth_clients = oauth_clients.AsyncOAuthClientsResourceWithRawResponse(client.oauth_clients) + self.oauth_grants = oauth_grants.AsyncOAuthGrantsResourceWithRawResponse(client.oauth_grants) self.access_ip_address = access_ip_address.AsyncAccessIPAddressResourceWithRawResponse(client.access_ip_address) self.access_ip_ranges = access_ip_ranges.AsyncAccessIPRangesResourceWithRawResponse(client.access_ip_ranges) self.actions = actions.AsyncActionsResourceWithRawResponse(client.actions) @@ -2394,6 +2434,7 @@ def __init__(self, client: AsyncTelnyx) -> None: self.partner_campaigns = partner_campaigns.AsyncPartnerCampaignsResourceWithRawResponse( client.partner_campaigns ) + self.well_known = well_known.AsyncWellKnownResourceWithRawResponse(client.well_known) self.create_bucket = async_to_raw_response_wrapper( client.create_bucket, @@ -2424,6 +2465,10 @@ def __init__(self, client: AsyncTelnyx) -> None: class TelnyxWithStreamedResponse: def __init__(self, client: Telnyx) -> None: + self.legacy = legacy.LegacyResourceWithStreamingResponse(client.legacy) + self.oauth = oauth.OAuthResourceWithStreamingResponse(client.oauth) + self.oauth_clients = oauth_clients.OAuthClientsResourceWithStreamingResponse(client.oauth_clients) + self.oauth_grants = oauth_grants.OAuthGrantsResourceWithStreamingResponse(client.oauth_grants) self.access_ip_address = access_ip_address.AccessIPAddressResourceWithStreamingResponse( client.access_ip_address ) @@ -2744,6 +2789,7 @@ def __init__(self, client: Telnyx) -> None: self.partner_campaigns = partner_campaigns.PartnerCampaignsResourceWithStreamingResponse( client.partner_campaigns ) + self.well_known = well_known.WellKnownResourceWithStreamingResponse(client.well_known) self.create_bucket = to_streamed_response_wrapper( client.create_bucket, @@ -2774,6 +2820,10 @@ def __init__(self, client: Telnyx) -> None: class AsyncTelnyxWithStreamedResponse: def __init__(self, client: AsyncTelnyx) -> None: + self.legacy = legacy.AsyncLegacyResourceWithStreamingResponse(client.legacy) + self.oauth = oauth.AsyncOAuthResourceWithStreamingResponse(client.oauth) + self.oauth_clients = oauth_clients.AsyncOAuthClientsResourceWithStreamingResponse(client.oauth_clients) + self.oauth_grants = oauth_grants.AsyncOAuthGrantsResourceWithStreamingResponse(client.oauth_grants) self.access_ip_address = access_ip_address.AsyncAccessIPAddressResourceWithStreamingResponse( client.access_ip_address ) @@ -3136,6 +3186,7 @@ def __init__(self, client: AsyncTelnyx) -> None: self.partner_campaigns = partner_campaigns.AsyncPartnerCampaignsResourceWithStreamingResponse( client.partner_campaigns ) + self.well_known = well_known.AsyncWellKnownResourceWithStreamingResponse(client.well_known) self.create_bucket = async_to_streamed_response_wrapper( client.create_bucket, diff --git a/src/telnyx/_version.py b/src/telnyx/_version.py index 2e2f1bb4..cc941aeb 100644 --- a/src/telnyx/_version.py +++ b/src/telnyx/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "telnyx" -__version__ = "3.5.0-alpha" # x-release-please-version +__version__ = "3.6.0-alpha" # x-release-please-version diff --git a/src/telnyx/resources/__init__.py b/src/telnyx/resources/__init__.py index d605508e..f7609b92 100644 --- a/src/telnyx/resources/__init__.py +++ b/src/telnyx/resources/__init__.py @@ -80,6 +80,14 @@ MediaResourceWithStreamingResponse, AsyncMediaResourceWithStreamingResponse, ) +from .oauth import ( + OAuthResource, + AsyncOAuthResource, + OAuthResourceWithRawResponse, + AsyncOAuthResourceWithRawResponse, + OAuthResourceWithStreamingResponse, + AsyncOAuthResourceWithStreamingResponse, +) from .rooms import ( RoomsResource, AsyncRoomsResource, @@ -96,6 +104,14 @@ TexmlResourceWithStreamingResponse, AsyncTexmlResourceWithStreamingResponse, ) +from .legacy import ( + LegacyResource, + AsyncLegacyResource, + LegacyResourceWithRawResponse, + AsyncLegacyResourceWithRawResponse, + LegacyResourceWithStreamingResponse, + AsyncLegacyResourceWithStreamingResponse, +) from .queues import ( QueuesResource, AsyncQueuesResource, @@ -281,6 +297,14 @@ RecordingsResourceWithStreamingResponse, AsyncRecordingsResourceWithStreamingResponse, ) +from .well_known import ( + WellKnownResource, + AsyncWellKnownResource, + WellKnownResourceWithRawResponse, + AsyncWellKnownResourceWithRawResponse, + WellKnownResourceWithStreamingResponse, + AsyncWellKnownResourceWithStreamingResponse, +) from .call_events import ( CallEventsResource, AsyncCallEventsResource, @@ -329,6 +353,14 @@ AuditEventsResourceWithStreamingResponse, AsyncAuditEventsResourceWithStreamingResponse, ) +from .oauth_grants import ( + OAuthGrantsResource, + AsyncOAuthGrantsResource, + OAuthGrantsResourceWithRawResponse, + AsyncOAuthGrantsResourceWithRawResponse, + OAuthGrantsResourceWithStreamingResponse, + AsyncOAuthGrantsResourceWithStreamingResponse, +) from .requirements import ( RequirementsResource, AsyncRequirementsResource, @@ -361,6 +393,14 @@ NumberOrdersResourceWithStreamingResponse, AsyncNumberOrdersResourceWithStreamingResponse, ) +from .oauth_clients import ( + OAuthClientsResource, + AsyncOAuthClientsResource, + OAuthClientsResourceWithRawResponse, + AsyncOAuthClientsResourceWithRawResponse, + OAuthClientsResourceWithStreamingResponse, + AsyncOAuthClientsResourceWithStreamingResponse, +) from .phone_numbers import ( PhoneNumbersResource, AsyncPhoneNumbersResource, @@ -1171,6 +1211,30 @@ ) __all__ = [ + "LegacyResource", + "AsyncLegacyResource", + "LegacyResourceWithRawResponse", + "AsyncLegacyResourceWithRawResponse", + "LegacyResourceWithStreamingResponse", + "AsyncLegacyResourceWithStreamingResponse", + "OAuthResource", + "AsyncOAuthResource", + "OAuthResourceWithRawResponse", + "AsyncOAuthResourceWithRawResponse", + "OAuthResourceWithStreamingResponse", + "AsyncOAuthResourceWithStreamingResponse", + "OAuthClientsResource", + "AsyncOAuthClientsResource", + "OAuthClientsResourceWithRawResponse", + "AsyncOAuthClientsResourceWithRawResponse", + "OAuthClientsResourceWithStreamingResponse", + "AsyncOAuthClientsResourceWithStreamingResponse", + "OAuthGrantsResource", + "AsyncOAuthGrantsResource", + "OAuthGrantsResourceWithRawResponse", + "AsyncOAuthGrantsResourceWithRawResponse", + "OAuthGrantsResourceWithStreamingResponse", + "AsyncOAuthGrantsResourceWithStreamingResponse", "WebhooksResource", "AsyncWebhooksResource", "AccessIPAddressResource", @@ -2049,4 +2113,10 @@ "AsyncPartnerCampaignsResourceWithRawResponse", "PartnerCampaignsResourceWithStreamingResponse", "AsyncPartnerCampaignsResourceWithStreamingResponse", + "WellKnownResource", + "AsyncWellKnownResource", + "WellKnownResourceWithRawResponse", + "AsyncWellKnownResourceWithRawResponse", + "WellKnownResourceWithStreamingResponse", + "AsyncWellKnownResourceWithStreamingResponse", ] diff --git a/src/telnyx/resources/ai/conversations/conversations.py b/src/telnyx/resources/ai/conversations/conversations.py index 465cd26d..894d885c 100644 --- a/src/telnyx/resources/ai/conversations/conversations.py +++ b/src/telnyx/resources/ai/conversations/conversations.py @@ -2,7 +2,8 @@ from __future__ import annotations -from typing import Dict +from typing import Dict, Union, Iterable +from datetime import datetime import httpx @@ -22,10 +23,15 @@ MessagesResourceWithStreamingResponse, AsyncMessagesResourceWithStreamingResponse, ) -from ...._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given +from ...._types import Body, Omit, Query, Headers, NoneType, NotGiven, SequenceNotStr, omit, not_given from ...._utils import maybe_transform, async_maybe_transform from ...._compat import cached_property -from ....types.ai import conversation_list_params, conversation_create_params, conversation_update_params +from ....types.ai import ( + conversation_list_params, + conversation_create_params, + conversation_update_params, + conversation_add_message_params, +) from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( to_raw_response_wrapper, @@ -326,6 +332,64 @@ def delete( cast_to=NoneType, ) + def add_message( + self, + conversation_id: str, + *, + role: str, + content: str | Omit = omit, + metadata: Dict[str, Union[str, int, bool, SequenceNotStr[Union[str, int, bool]]]] | Omit = omit, + name: str | Omit = omit, + sent_at: Union[str, datetime] | Omit = omit, + tool_call_id: str | Omit = omit, + tool_calls: Iterable[Dict[str, object]] | Omit = omit, + tool_choice: Union[str, object] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> object: + """Add a new message to the conversation. + + Used to insert a new messages to a + conversation manually ( without using chat endpoint ) + + Args: + conversation_id: The ID of the conversation + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not conversation_id: + raise ValueError(f"Expected a non-empty value for `conversation_id` but received {conversation_id!r}") + return self._post( + f"/ai/conversations/{conversation_id}/message", + body=maybe_transform( + { + "role": role, + "content": content, + "metadata": metadata, + "name": name, + "sent_at": sent_at, + "tool_call_id": tool_call_id, + "tool_calls": tool_calls, + "tool_choice": tool_choice, + }, + conversation_add_message_params.ConversationAddMessageParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + def retrieve_conversations_insights( self, conversation_id: str, @@ -635,6 +699,64 @@ async def delete( cast_to=NoneType, ) + async def add_message( + self, + conversation_id: str, + *, + role: str, + content: str | Omit = omit, + metadata: Dict[str, Union[str, int, bool, SequenceNotStr[Union[str, int, bool]]]] | Omit = omit, + name: str | Omit = omit, + sent_at: Union[str, datetime] | Omit = omit, + tool_call_id: str | Omit = omit, + tool_calls: Iterable[Dict[str, object]] | Omit = omit, + tool_choice: Union[str, object] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> object: + """Add a new message to the conversation. + + Used to insert a new messages to a + conversation manually ( without using chat endpoint ) + + Args: + conversation_id: The ID of the conversation + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not conversation_id: + raise ValueError(f"Expected a non-empty value for `conversation_id` but received {conversation_id!r}") + return await self._post( + f"/ai/conversations/{conversation_id}/message", + body=await async_maybe_transform( + { + "role": role, + "content": content, + "metadata": metadata, + "name": name, + "sent_at": sent_at, + "tool_call_id": tool_call_id, + "tool_calls": tool_calls, + "tool_choice": tool_choice, + }, + conversation_add_message_params.ConversationAddMessageParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + async def retrieve_conversations_insights( self, conversation_id: str, @@ -688,6 +810,9 @@ def __init__(self, conversations: ConversationsResource) -> None: self.delete = to_raw_response_wrapper( conversations.delete, ) + self.add_message = to_raw_response_wrapper( + conversations.add_message, + ) self.retrieve_conversations_insights = to_raw_response_wrapper( conversations.retrieve_conversations_insights, ) @@ -724,6 +849,9 @@ def __init__(self, conversations: AsyncConversationsResource) -> None: self.delete = async_to_raw_response_wrapper( conversations.delete, ) + self.add_message = async_to_raw_response_wrapper( + conversations.add_message, + ) self.retrieve_conversations_insights = async_to_raw_response_wrapper( conversations.retrieve_conversations_insights, ) @@ -760,6 +888,9 @@ def __init__(self, conversations: ConversationsResource) -> None: self.delete = to_streamed_response_wrapper( conversations.delete, ) + self.add_message = to_streamed_response_wrapper( + conversations.add_message, + ) self.retrieve_conversations_insights = to_streamed_response_wrapper( conversations.retrieve_conversations_insights, ) @@ -796,6 +927,9 @@ def __init__(self, conversations: AsyncConversationsResource) -> None: self.delete = async_to_streamed_response_wrapper( conversations.delete, ) + self.add_message = async_to_streamed_response_wrapper( + conversations.add_message, + ) self.retrieve_conversations_insights = async_to_streamed_response_wrapper( conversations.retrieve_conversations_insights, ) diff --git a/src/telnyx/resources/ai/conversations/messages.py b/src/telnyx/resources/ai/conversations/messages.py index 1ffb8d42..4634f133 100644 --- a/src/telnyx/resources/ai/conversations/messages.py +++ b/src/telnyx/resources/ai/conversations/messages.py @@ -2,13 +2,9 @@ from __future__ import annotations -from typing import Dict, Union, Iterable -from datetime import datetime - import httpx -from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._types import Body, Query, Headers, NotGiven, not_given from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -18,7 +14,6 @@ async_to_streamed_response_wrapper, ) from ...._base_client import make_request_options -from ....types.ai.conversations import message_create_params from ....types.ai.conversations.message_list_response import MessageListResponse __all__ = ["MessagesResource", "AsyncMessagesResource"] @@ -44,64 +39,6 @@ def with_streaming_response(self) -> MessagesResourceWithStreamingResponse: """ return MessagesResourceWithStreamingResponse(self) - def create( - self, - conversation_id: str, - *, - role: str, - content: str | Omit = omit, - metadata: Dict[str, Union[str, int, bool, SequenceNotStr[Union[str, int, bool]]]] | Omit = omit, - name: str | Omit = omit, - sent_at: Union[str, datetime] | Omit = omit, - tool_call_id: str | Omit = omit, - tool_calls: Iterable[Dict[str, object]] | Omit = omit, - tool_choice: Union[str, object] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> object: - """Add a new message to the conversation. - - Used to insert a new messages to a - conversation manually ( without using chat endpoint ) - - Args: - conversation_id: The ID of the conversation - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not conversation_id: - raise ValueError(f"Expected a non-empty value for `conversation_id` but received {conversation_id!r}") - return self._post( - f"/ai/conversations/{conversation_id}/messages", - body=maybe_transform( - { - "role": role, - "content": content, - "metadata": metadata, - "name": name, - "sent_at": sent_at, - "tool_call_id": tool_call_id, - "tool_calls": tool_calls, - "tool_choice": tool_choice, - }, - message_create_params.MessageCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=object, - ) - def list( self, conversation_id: str, @@ -157,64 +94,6 @@ def with_streaming_response(self) -> AsyncMessagesResourceWithStreamingResponse: """ return AsyncMessagesResourceWithStreamingResponse(self) - async def create( - self, - conversation_id: str, - *, - role: str, - content: str | Omit = omit, - metadata: Dict[str, Union[str, int, bool, SequenceNotStr[Union[str, int, bool]]]] | Omit = omit, - name: str | Omit = omit, - sent_at: Union[str, datetime] | Omit = omit, - tool_call_id: str | Omit = omit, - tool_calls: Iterable[Dict[str, object]] | Omit = omit, - tool_choice: Union[str, object] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> object: - """Add a new message to the conversation. - - Used to insert a new messages to a - conversation manually ( without using chat endpoint ) - - Args: - conversation_id: The ID of the conversation - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not conversation_id: - raise ValueError(f"Expected a non-empty value for `conversation_id` but received {conversation_id!r}") - return await self._post( - f"/ai/conversations/{conversation_id}/messages", - body=await async_maybe_transform( - { - "role": role, - "content": content, - "metadata": metadata, - "name": name, - "sent_at": sent_at, - "tool_call_id": tool_call_id, - "tool_calls": tool_calls, - "tool_choice": tool_choice, - }, - message_create_params.MessageCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=object, - ) - async def list( self, conversation_id: str, @@ -254,9 +133,6 @@ class MessagesResourceWithRawResponse: def __init__(self, messages: MessagesResource) -> None: self._messages = messages - self.create = to_raw_response_wrapper( - messages.create, - ) self.list = to_raw_response_wrapper( messages.list, ) @@ -266,9 +142,6 @@ class AsyncMessagesResourceWithRawResponse: def __init__(self, messages: AsyncMessagesResource) -> None: self._messages = messages - self.create = async_to_raw_response_wrapper( - messages.create, - ) self.list = async_to_raw_response_wrapper( messages.list, ) @@ -278,9 +151,6 @@ class MessagesResourceWithStreamingResponse: def __init__(self, messages: MessagesResource) -> None: self._messages = messages - self.create = to_streamed_response_wrapper( - messages.create, - ) self.list = to_streamed_response_wrapper( messages.list, ) @@ -290,9 +160,6 @@ class AsyncMessagesResourceWithStreamingResponse: def __init__(self, messages: AsyncMessagesResource) -> None: self._messages = messages - self.create = async_to_streamed_response_wrapper( - messages.create, - ) self.list = async_to_streamed_response_wrapper( messages.list, ) diff --git a/src/telnyx/resources/calls/actions.py b/src/telnyx/resources/calls/actions.py index 4d761c7f..253e1d26 100644 --- a/src/telnyx/resources/calls/actions.py +++ b/src/telnyx/resources/calls/actions.py @@ -179,9 +179,7 @@ def answer( You must issue this command before executing subsequent commands on an incoming call. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/answer-call#callbacks) - below):** + **Expected Webhooks:** - `call.answered` - `streaming.started`, `streaming.stopped` or `streaming.failed` if `stream_url` @@ -248,7 +246,6 @@ def answer( stream_codec: Specifies the codec to be used for the streamed audio. When set to 'default' or when transcoding is not possible, the codec from the call will be used. - Currently, transcoding is only supported between PCMU and PCMA codecs. stream_track: Specifies which track should be streamed. @@ -384,9 +381,7 @@ def bridge( """ Bridge two call control calls. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/bridge-call#callbacks) - below):** + **Expected Webhooks:** - `call.bridged` for Leg A - `call.bridged` for Leg B @@ -587,9 +582,7 @@ def gather( You can pass a list of valid digits. The `Answer` command must be issued before the `gather` command. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/gather-call#callbacks) - below):** + **Expected Webhooks:** - `call.dtmf.received` (you may receive many of these webhooks) - `call.gather.ended` @@ -684,9 +677,7 @@ def gather_using_ai( You can pass parameters described as a JSON Schema object and the voice assistant will attempt to gather these informations. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/call-gather-using-ai#callbacks) - below):** + **Expected Webhooks:** - `call.ai_gather.ended` - `call.conversation.ended` @@ -721,16 +712,13 @@ def gather_using_ai( information to the voice assistant. send_message_history_updates: Default is `false`. If set to `true`, the voice assistant will send updates to - the message history via the `call.ai_gather.message_history_updated` - [callback](https://developers.telnyx.com/api/call-control/call-gather-using-ai#callbacks) - in real time as the message history is updated. + the message history via the `call.ai_gather.message_history_updated` callback in + real time as the message history is updated. send_partial_results: Default is `false`. If set to `true`, the voice assistant will send partial - results via the `call.ai_gather.partial_results` - [callback](https://developers.telnyx.com/api/call-control/call-gather-using-ai#callbacks) - in real time as individual fields are gathered. If set to `false`, the voice - assistant will only send the final result via the `call.ai_gather.ended` - callback. + results via the `call.ai_gather.partial_results` callback in real time as + individual fields are gathered. If set to `false`, the voice assistant will only + send the final result via the `call.ai_gather.ended` callback. transcription: The settings associated with speech to text for the voice assistant. This is only relevant if the assistant uses a text-to-text language model. Any assistant @@ -835,9 +823,7 @@ def gather_using_audio( interrupted when a DTMF signal is received. The `Answer command must be issued before the `gather_using_audio` command. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/gather-using-audio#callbacks) - below):** + **Expected Webhooks:** - `call.playback.started` - `call.playback.ended` @@ -991,9 +977,7 @@ def gather_using_speak( a DTMF signal is received. The `Answer` command must be issued before the `gather_using_speak` command. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/gather-using-speak#callbacks) - below):** + **Expected Webhooks:** - `call.dtmf.received` (you may receive many of these webhooks) - `call.gather.ended` @@ -1124,9 +1108,7 @@ def hangup( """ Hang up the call. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/hangup-call#callbacks) - below):** + **Expected Webhooks:** - `call.hangup` - `call.recording.saved` @@ -1291,9 +1273,7 @@ def refer( You can initiate a SIP Refer at any point in the duration of a call. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/refer-call#callbacks) - below):** + **Expected Webhooks:** - `call.refer.started` - `call.refer.completed` @@ -1365,9 +1345,7 @@ def reject( """ Reject an incoming call. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/reject-call#callbacks) - below):** + **Expected Webhooks:** - `call.hangup` @@ -1644,9 +1622,7 @@ def speak( commands are issued consecutively, the audio files will be placed in a queue awaiting playback. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/speak-call#callbacks) - below):** + **Expected Webhooks:** - `call.speak.started` - `call.speak.ended` @@ -1759,9 +1735,7 @@ def start_ai_assistant( """ Start an AI assistant on the call. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/call-start-ai-assistant#callbacks) - below):** + **Expected Webhooks:** - `call.conversation.ended` - `call.conversation_insights.generated` @@ -1865,9 +1839,7 @@ def start_forking( audio responses. Requests must specify either the `target` attribute or the `rx` and `tx` attributes. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/start-call-fork#callbacks) - below):** + **Expected Webhooks:** - `call.fork.started` - `call.fork.stopped` @@ -2007,9 +1979,7 @@ def start_playback( - A customer cannot Play Audio with `overlay=true` unless there is a Play Audio with `overlay=false` actively playing. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/start-call-playback#callbacks) - below):** + **Expected Webhooks:** - `call.playback.started` - `call.playback.ended` @@ -2268,9 +2238,7 @@ def start_recording( Recording will stop on call hang-up, or can be initiated via the Stop Recording command. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/start-call-record#callbacks) - below):** + **Expected Webhooks:** - `call.recording.saved` - `call.recording.transcription.saved` @@ -2453,6 +2421,7 @@ def start_streaming( enable_dialogflow: bool | Omit = omit, stream_bidirectional_codec: StreamBidirectionalCodec | Omit = omit, stream_bidirectional_mode: StreamBidirectionalMode | Omit = omit, + stream_bidirectional_sampling_rate: Literal[8000, 16000, 22050, 24000, 48000] | Omit = omit, stream_bidirectional_target_legs: StreamBidirectionalTargetLegs | Omit = omit, stream_codec: StreamCodec | Omit = omit, stream_track: Literal["inbound_track", "outbound_track", "both_tracks"] | Omit = omit, @@ -2486,11 +2455,12 @@ def start_streaming( stream_bidirectional_mode: Configures method of bidirectional streaming (mp3, rtp). + stream_bidirectional_sampling_rate: Audio sampling rate. + stream_bidirectional_target_legs: Specifies which call legs should receive the bidirectional stream audio. stream_codec: Specifies the codec to be used for the streamed audio. When set to 'default' or when transcoding is not possible, the codec from the call will be used. - Currently, transcoding is only supported between PCMU and PCMA codecs. stream_track: Specifies which track should be streamed. @@ -2516,6 +2486,7 @@ def start_streaming( "enable_dialogflow": enable_dialogflow, "stream_bidirectional_codec": stream_bidirectional_codec, "stream_bidirectional_mode": stream_bidirectional_mode, + "stream_bidirectional_sampling_rate": stream_bidirectional_sampling_rate, "stream_bidirectional_target_legs": stream_bidirectional_target_legs, "stream_codec": stream_codec, "stream_track": stream_track, @@ -2550,9 +2521,7 @@ def start_transcription( Transcription will stop on call hang-up, or can be initiated via the Transcription stop command. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/start-call-transcription#callbacks) - below):** + **Expected Webhooks:** - `call.transcription` @@ -2662,9 +2631,7 @@ def stop_forking( """ Stop forking a call. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/stop-call-fork#callbacks) - below):** + **Expected Webhooks:** - `call.fork.stopped` @@ -2720,9 +2687,7 @@ def stop_gather( """ Stop current gather. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/stop-call-gather#callbacks) - below):** + **Expected Webhooks:** - `call.gather.ended` @@ -2824,9 +2789,7 @@ def stop_playback( """ Stop audio being played on the call. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/stop-call-playback#callbacks) - below):** + **Expected Webhooks:** - `call.playback.ended` or `call.speak.ended` @@ -2886,9 +2849,7 @@ def stop_recording( """ Stop recording the call. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/stop-call-recording#callbacks) - below):** + **Expected Webhooks:** - `call.recording.saved` @@ -2996,9 +2957,7 @@ def stop_streaming( """ Stop streaming a call to a WebSocket. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/stop-call-streaming#callbacks) - below):** + **Expected Webhooks:** - `streaming.stopped` @@ -3147,6 +3106,14 @@ def transfer( media_name: str | Omit = omit, mute_dtmf: Literal["none", "both", "self", "opposite"] | Omit = omit, park_after_unbridge: str | Omit = omit, + record: Literal["record-from-answer"] | Omit = omit, + record_channels: Literal["single", "dual"] | Omit = omit, + record_custom_file_name: str | Omit = omit, + record_format: Literal["wav", "mp3"] | Omit = omit, + record_max_length: int | Omit = omit, + record_timeout_secs: int | Omit = omit, + record_track: Literal["both", "inbound", "outbound"] | Omit = omit, + record_trim: Literal["trim-silence"] | Omit = omit, sip_auth_password: str | Omit = omit, sip_auth_username: str | Omit = omit, sip_headers: Iterable[SipHeaderParam] | Omit = omit, @@ -3172,9 +3139,7 @@ def transfer( may be issued additional commands, potentially transfering the call to an alternate destination. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/transfer-call#callbacks) - below):** + **Expected Webhooks:** - `call.initiated` - `call.bridged` to Leg B @@ -3239,6 +3204,33 @@ def transfer( or is transferred). If supplied with the value `self`, the current leg will be parked after unbridge. If not set, the default behavior is to hang up the leg. + record: Start recording automatically after an event. Disabled by default. + + record_channels: Defines which channel should be recorded ('single' or 'dual') when `record` is + specified. + + record_custom_file_name: The custom recording file name to be used instead of the default `call_leg_id`. + Telnyx will still add a Unix timestamp suffix. + + record_format: Defines the format of the recording ('wav' or 'mp3') when `record` is specified. + + record_max_length: Defines the maximum length for the recording in seconds when `record` is + specified. The minimum value is 0. The maximum value is 43200. The default value + is 0 (infinite). + + record_timeout_secs: The number of seconds that Telnyx will wait for the recording to be stopped if + silence is detected when `record` is specified. The timer only starts when the + speech is detected. Please note that call transcription is used to detect + silence and the related charge will be applied. The minimum value is 0. The + default value is 0 (infinite). + + record_track: The audio track to be recorded. Can be either `both`, `inbound` or `outbound`. + If only single track is specified (`inbound`, `outbound`), `channels` + configuration is ignored and it will be recorded as mono (single channel). + + record_trim: When set to `trim-silence`, silence will be removed from the beginning and end + of the recording. + sip_auth_password: SIP Authentication password used for SIP challenges. sip_auth_username: SIP Authentication username used for SIP challenges. @@ -3299,6 +3291,14 @@ def transfer( "media_name": media_name, "mute_dtmf": mute_dtmf, "park_after_unbridge": park_after_unbridge, + "record": record, + "record_channels": record_channels, + "record_custom_file_name": record_custom_file_name, + "record_format": record_format, + "record_max_length": record_max_length, + "record_timeout_secs": record_timeout_secs, + "record_track": record_track, + "record_trim": record_trim, "sip_auth_password": sip_auth_password, "sip_auth_username": sip_auth_username, "sip_headers": sip_headers, @@ -3421,9 +3421,7 @@ async def answer( You must issue this command before executing subsequent commands on an incoming call. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/answer-call#callbacks) - below):** + **Expected Webhooks:** - `call.answered` - `streaming.started`, `streaming.stopped` or `streaming.failed` if `stream_url` @@ -3490,7 +3488,6 @@ async def answer( stream_codec: Specifies the codec to be used for the streamed audio. When set to 'default' or when transcoding is not possible, the codec from the call will be used. - Currently, transcoding is only supported between PCMU and PCMA codecs. stream_track: Specifies which track should be streamed. @@ -3626,9 +3623,7 @@ async def bridge( """ Bridge two call control calls. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/bridge-call#callbacks) - below):** + **Expected Webhooks:** - `call.bridged` for Leg A - `call.bridged` for Leg B @@ -3829,9 +3824,7 @@ async def gather( You can pass a list of valid digits. The `Answer` command must be issued before the `gather` command. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/gather-call#callbacks) - below):** + **Expected Webhooks:** - `call.dtmf.received` (you may receive many of these webhooks) - `call.gather.ended` @@ -3926,9 +3919,7 @@ async def gather_using_ai( You can pass parameters described as a JSON Schema object and the voice assistant will attempt to gather these informations. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/call-gather-using-ai#callbacks) - below):** + **Expected Webhooks:** - `call.ai_gather.ended` - `call.conversation.ended` @@ -3963,16 +3954,13 @@ async def gather_using_ai( information to the voice assistant. send_message_history_updates: Default is `false`. If set to `true`, the voice assistant will send updates to - the message history via the `call.ai_gather.message_history_updated` - [callback](https://developers.telnyx.com/api/call-control/call-gather-using-ai#callbacks) - in real time as the message history is updated. + the message history via the `call.ai_gather.message_history_updated` callback in + real time as the message history is updated. send_partial_results: Default is `false`. If set to `true`, the voice assistant will send partial - results via the `call.ai_gather.partial_results` - [callback](https://developers.telnyx.com/api/call-control/call-gather-using-ai#callbacks) - in real time as individual fields are gathered. If set to `false`, the voice - assistant will only send the final result via the `call.ai_gather.ended` - callback. + results via the `call.ai_gather.partial_results` callback in real time as + individual fields are gathered. If set to `false`, the voice assistant will only + send the final result via the `call.ai_gather.ended` callback. transcription: The settings associated with speech to text for the voice assistant. This is only relevant if the assistant uses a text-to-text language model. Any assistant @@ -4077,9 +4065,7 @@ async def gather_using_audio( interrupted when a DTMF signal is received. The `Answer command must be issued before the `gather_using_audio` command. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/gather-using-audio#callbacks) - below):** + **Expected Webhooks:** - `call.playback.started` - `call.playback.ended` @@ -4233,9 +4219,7 @@ async def gather_using_speak( a DTMF signal is received. The `Answer` command must be issued before the `gather_using_speak` command. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/gather-using-speak#callbacks) - below):** + **Expected Webhooks:** - `call.dtmf.received` (you may receive many of these webhooks) - `call.gather.ended` @@ -4366,9 +4350,7 @@ async def hangup( """ Hang up the call. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/hangup-call#callbacks) - below):** + **Expected Webhooks:** - `call.hangup` - `call.recording.saved` @@ -4533,9 +4515,7 @@ async def refer( You can initiate a SIP Refer at any point in the duration of a call. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/refer-call#callbacks) - below):** + **Expected Webhooks:** - `call.refer.started` - `call.refer.completed` @@ -4607,9 +4587,7 @@ async def reject( """ Reject an incoming call. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/reject-call#callbacks) - below):** + **Expected Webhooks:** - `call.hangup` @@ -4886,9 +4864,7 @@ async def speak( commands are issued consecutively, the audio files will be placed in a queue awaiting playback. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/speak-call#callbacks) - below):** + **Expected Webhooks:** - `call.speak.started` - `call.speak.ended` @@ -5001,9 +4977,7 @@ async def start_ai_assistant( """ Start an AI assistant on the call. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/call-start-ai-assistant#callbacks) - below):** + **Expected Webhooks:** - `call.conversation.ended` - `call.conversation_insights.generated` @@ -5107,9 +5081,7 @@ async def start_forking( audio responses. Requests must specify either the `target` attribute or the `rx` and `tx` attributes. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/start-call-fork#callbacks) - below):** + **Expected Webhooks:** - `call.fork.started` - `call.fork.stopped` @@ -5249,9 +5221,7 @@ async def start_playback( - A customer cannot Play Audio with `overlay=true` unless there is a Play Audio with `overlay=false` actively playing. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/start-call-playback#callbacks) - below):** + **Expected Webhooks:** - `call.playback.started` - `call.playback.ended` @@ -5510,9 +5480,7 @@ async def start_recording( Recording will stop on call hang-up, or can be initiated via the Stop Recording command. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/start-call-record#callbacks) - below):** + **Expected Webhooks:** - `call.recording.saved` - `call.recording.transcription.saved` @@ -5695,6 +5663,7 @@ async def start_streaming( enable_dialogflow: bool | Omit = omit, stream_bidirectional_codec: StreamBidirectionalCodec | Omit = omit, stream_bidirectional_mode: StreamBidirectionalMode | Omit = omit, + stream_bidirectional_sampling_rate: Literal[8000, 16000, 22050, 24000, 48000] | Omit = omit, stream_bidirectional_target_legs: StreamBidirectionalTargetLegs | Omit = omit, stream_codec: StreamCodec | Omit = omit, stream_track: Literal["inbound_track", "outbound_track", "both_tracks"] | Omit = omit, @@ -5728,11 +5697,12 @@ async def start_streaming( stream_bidirectional_mode: Configures method of bidirectional streaming (mp3, rtp). + stream_bidirectional_sampling_rate: Audio sampling rate. + stream_bidirectional_target_legs: Specifies which call legs should receive the bidirectional stream audio. stream_codec: Specifies the codec to be used for the streamed audio. When set to 'default' or when transcoding is not possible, the codec from the call will be used. - Currently, transcoding is only supported between PCMU and PCMA codecs. stream_track: Specifies which track should be streamed. @@ -5758,6 +5728,7 @@ async def start_streaming( "enable_dialogflow": enable_dialogflow, "stream_bidirectional_codec": stream_bidirectional_codec, "stream_bidirectional_mode": stream_bidirectional_mode, + "stream_bidirectional_sampling_rate": stream_bidirectional_sampling_rate, "stream_bidirectional_target_legs": stream_bidirectional_target_legs, "stream_codec": stream_codec, "stream_track": stream_track, @@ -5792,9 +5763,7 @@ async def start_transcription( Transcription will stop on call hang-up, or can be initiated via the Transcription stop command. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/start-call-transcription#callbacks) - below):** + **Expected Webhooks:** - `call.transcription` @@ -5904,9 +5873,7 @@ async def stop_forking( """ Stop forking a call. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/stop-call-fork#callbacks) - below):** + **Expected Webhooks:** - `call.fork.stopped` @@ -5962,9 +5929,7 @@ async def stop_gather( """ Stop current gather. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/stop-call-gather#callbacks) - below):** + **Expected Webhooks:** - `call.gather.ended` @@ -6066,9 +6031,7 @@ async def stop_playback( """ Stop audio being played on the call. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/stop-call-playback#callbacks) - below):** + **Expected Webhooks:** - `call.playback.ended` or `call.speak.ended` @@ -6128,9 +6091,7 @@ async def stop_recording( """ Stop recording the call. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/stop-call-recording#callbacks) - below):** + **Expected Webhooks:** - `call.recording.saved` @@ -6238,9 +6199,7 @@ async def stop_streaming( """ Stop streaming a call to a WebSocket. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/stop-call-streaming#callbacks) - below):** + **Expected Webhooks:** - `streaming.stopped` @@ -6391,6 +6350,14 @@ async def transfer( media_name: str | Omit = omit, mute_dtmf: Literal["none", "both", "self", "opposite"] | Omit = omit, park_after_unbridge: str | Omit = omit, + record: Literal["record-from-answer"] | Omit = omit, + record_channels: Literal["single", "dual"] | Omit = omit, + record_custom_file_name: str | Omit = omit, + record_format: Literal["wav", "mp3"] | Omit = omit, + record_max_length: int | Omit = omit, + record_timeout_secs: int | Omit = omit, + record_track: Literal["both", "inbound", "outbound"] | Omit = omit, + record_trim: Literal["trim-silence"] | Omit = omit, sip_auth_password: str | Omit = omit, sip_auth_username: str | Omit = omit, sip_headers: Iterable[SipHeaderParam] | Omit = omit, @@ -6416,9 +6383,7 @@ async def transfer( may be issued additional commands, potentially transfering the call to an alternate destination. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/transfer-call#callbacks) - below):** + **Expected Webhooks:** - `call.initiated` - `call.bridged` to Leg B @@ -6483,6 +6448,33 @@ async def transfer( or is transferred). If supplied with the value `self`, the current leg will be parked after unbridge. If not set, the default behavior is to hang up the leg. + record: Start recording automatically after an event. Disabled by default. + + record_channels: Defines which channel should be recorded ('single' or 'dual') when `record` is + specified. + + record_custom_file_name: The custom recording file name to be used instead of the default `call_leg_id`. + Telnyx will still add a Unix timestamp suffix. + + record_format: Defines the format of the recording ('wav' or 'mp3') when `record` is specified. + + record_max_length: Defines the maximum length for the recording in seconds when `record` is + specified. The minimum value is 0. The maximum value is 43200. The default value + is 0 (infinite). + + record_timeout_secs: The number of seconds that Telnyx will wait for the recording to be stopped if + silence is detected when `record` is specified. The timer only starts when the + speech is detected. Please note that call transcription is used to detect + silence and the related charge will be applied. The minimum value is 0. The + default value is 0 (infinite). + + record_track: The audio track to be recorded. Can be either `both`, `inbound` or `outbound`. + If only single track is specified (`inbound`, `outbound`), `channels` + configuration is ignored and it will be recorded as mono (single channel). + + record_trim: When set to `trim-silence`, silence will be removed from the beginning and end + of the recording. + sip_auth_password: SIP Authentication password used for SIP challenges. sip_auth_username: SIP Authentication username used for SIP challenges. @@ -6543,6 +6535,14 @@ async def transfer( "media_name": media_name, "mute_dtmf": mute_dtmf, "park_after_unbridge": park_after_unbridge, + "record": record, + "record_channels": record_channels, + "record_custom_file_name": record_custom_file_name, + "record_format": record_format, + "record_max_length": record_max_length, + "record_timeout_secs": record_timeout_secs, + "record_track": record_track, + "record_trim": record_trim, "sip_auth_password": sip_auth_password, "sip_auth_username": sip_auth_username, "sip_headers": sip_headers, diff --git a/src/telnyx/resources/calls/calls.py b/src/telnyx/resources/calls/calls.py index 619ed302..6cd52989 100644 --- a/src/telnyx/resources/calls/calls.py +++ b/src/telnyx/resources/calls/calls.py @@ -114,7 +114,7 @@ def dial( sound_modifications: SoundModificationsParam | Omit = omit, stream_bidirectional_codec: StreamBidirectionalCodec | Omit = omit, stream_bidirectional_mode: StreamBidirectionalMode | Omit = omit, - stream_bidirectional_sampling_rate: Literal[8000, 16000, 48000] | Omit = omit, + stream_bidirectional_sampling_rate: Literal[8000, 16000, 22050, 24000, 48000] | Omit = omit, stream_bidirectional_target_legs: StreamBidirectionalTargetLegs | Omit = omit, stream_codec: StreamCodec | Omit = omit, stream_establish_before_call_originate: bool | Omit = omit, @@ -141,9 +141,7 @@ def dial( include a `call_leg_id` which can be used to correlate the command with subsequent webhooks. - **Expected Webhooks (see - [schema](https://developers.telnyx.com/api/call-control/dial-call#callbacks) - below):** + **Expected Webhooks:** - `call.initiated` - `call.answered` or `call.hangup` @@ -286,7 +284,6 @@ def dial( stream_codec: Specifies the codec to be used for the streamed audio. When set to 'default' or when transcoding is not possible, the codec from the call will be used. - Currently, transcoding is only supported between PCMU and PCMA codecs. stream_establish_before_call_originate: Establish websocket connection before dialing the destination. This is useful for cases where the websocket connection takes a long time to establish. @@ -494,7 +491,7 @@ async def dial( sound_modifications: SoundModificationsParam | Omit = omit, stream_bidirectional_codec: StreamBidirectionalCodec | Omit = omit, stream_bidirectional_mode: StreamBidirectionalMode | Omit = omit, - stream_bidirectional_sampling_rate: Literal[8000, 16000, 48000] | Omit = omit, + stream_bidirectional_sampling_rate: Literal[8000, 16000, 22050, 24000, 48000] | Omit = omit, stream_bidirectional_target_legs: StreamBidirectionalTargetLegs | Omit = omit, stream_codec: StreamCodec | Omit = omit, stream_establish_before_call_originate: bool | Omit = omit, @@ -521,9 +518,7 @@ async def dial( include a `call_leg_id` which can be used to correlate the command with subsequent webhooks. - **Expected Webhooks (see - [schema](https://developers.telnyx.com/api/call-control/dial-call#callbacks) - below):** + **Expected Webhooks:** - `call.initiated` - `call.answered` or `call.hangup` @@ -666,7 +661,6 @@ async def dial( stream_codec: Specifies the codec to be used for the streamed audio. When set to 'default' or when transcoding is not possible, the codec from the call will be used. - Currently, transcoding is only supported between PCMU and PCMA codecs. stream_establish_before_call_originate: Establish websocket connection before dialing the destination. This is useful for cases where the websocket connection takes a long time to establish. diff --git a/src/telnyx/resources/conferences/actions.py b/src/telnyx/resources/conferences/actions.py index c8d270e4..7e71cd63 100644 --- a/src/telnyx/resources/conferences/actions.py +++ b/src/telnyx/resources/conferences/actions.py @@ -221,9 +221,7 @@ def join( certain amount of active participants, as set by the `max_participants` parameter in conference creation request. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/join-conference#callbacks) - below):** + **Expected Webhooks:** - `conference.participant.joined` - `conference.participant.left` @@ -334,9 +332,7 @@ def leave( """ Removes a call leg from a conference and moves it back to parked state. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/leave-conference#callbacks) - below):** + **Expected Webhooks:** - `conference.participant.left` @@ -589,9 +585,7 @@ def record_start( Recording will stop on conference end, or via the Stop Recording command. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/start-conference-recording#callbacks) - below):** + **Expected Webhooks:** - `conference.recording.saved` @@ -655,9 +649,7 @@ def record_stop( """ Stop recording the conference. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/stop-conference-recording#callbacks) - below):** + **Expected Webhooks:** - `conference.recording.saved` @@ -1109,9 +1101,7 @@ async def join( certain amount of active participants, as set by the `max_participants` parameter in conference creation request. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/join-conference#callbacks) - below):** + **Expected Webhooks:** - `conference.participant.joined` - `conference.participant.left` @@ -1222,9 +1212,7 @@ async def leave( """ Removes a call leg from a conference and moves it back to parked state. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/leave-conference#callbacks) - below):** + **Expected Webhooks:** - `conference.participant.left` @@ -1479,9 +1467,7 @@ async def record_start( Recording will stop on conference end, or via the Stop Recording command. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/start-conference-recording#callbacks) - below):** + **Expected Webhooks:** - `conference.recording.saved` @@ -1545,9 +1531,7 @@ async def record_stop( """ Stop recording the conference. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/stop-conference-recording#callbacks) - below):** + **Expected Webhooks:** - `conference.recording.saved` diff --git a/src/telnyx/resources/conferences/conferences.py b/src/telnyx/resources/conferences/conferences.py index f21c55b2..bfc0f923 100644 --- a/src/telnyx/resources/conferences/conferences.py +++ b/src/telnyx/resources/conferences/conferences.py @@ -86,9 +86,7 @@ def create( left the conference or after 4 hours regardless of the number of active participants. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/create-conference#callbacks) - below):** + **Expected Webhooks:** - `conference.created` - `conference.participant.joined` @@ -360,9 +358,7 @@ async def create( left the conference or after 4 hours regardless of the number of active participants. - **Expected Webhooks (see - [callback schema](https://developers.telnyx.com/api/call-control/create-conference#callbacks) - below):** + **Expected Webhooks:** - `conference.created` - `conference.participant.joined` diff --git a/src/telnyx/resources/legacy/__init__.py b/src/telnyx/resources/legacy/__init__.py new file mode 100644 index 00000000..f909bc02 --- /dev/null +++ b/src/telnyx/resources/legacy/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .legacy import ( + LegacyResource, + AsyncLegacyResource, + LegacyResourceWithRawResponse, + AsyncLegacyResourceWithRawResponse, + LegacyResourceWithStreamingResponse, + AsyncLegacyResourceWithStreamingResponse, +) +from .reporting import ( + ReportingResource, + AsyncReportingResource, + ReportingResourceWithRawResponse, + AsyncReportingResourceWithRawResponse, + ReportingResourceWithStreamingResponse, + AsyncReportingResourceWithStreamingResponse, +) + +__all__ = [ + "ReportingResource", + "AsyncReportingResource", + "ReportingResourceWithRawResponse", + "AsyncReportingResourceWithRawResponse", + "ReportingResourceWithStreamingResponse", + "AsyncReportingResourceWithStreamingResponse", + "LegacyResource", + "AsyncLegacyResource", + "LegacyResourceWithRawResponse", + "AsyncLegacyResourceWithRawResponse", + "LegacyResourceWithStreamingResponse", + "AsyncLegacyResourceWithStreamingResponse", +] diff --git a/src/telnyx/resources/legacy/legacy.py b/src/telnyx/resources/legacy/legacy.py new file mode 100644 index 00000000..7b2b92b1 --- /dev/null +++ b/src/telnyx/resources/legacy/legacy.py @@ -0,0 +1,102 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from .reporting.reporting import ( + ReportingResource, + AsyncReportingResource, + ReportingResourceWithRawResponse, + AsyncReportingResourceWithRawResponse, + ReportingResourceWithStreamingResponse, + AsyncReportingResourceWithStreamingResponse, +) + +__all__ = ["LegacyResource", "AsyncLegacyResource"] + + +class LegacyResource(SyncAPIResource): + @cached_property + def reporting(self) -> ReportingResource: + return ReportingResource(self._client) + + @cached_property + def with_raw_response(self) -> LegacyResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return LegacyResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> LegacyResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return LegacyResourceWithStreamingResponse(self) + + +class AsyncLegacyResource(AsyncAPIResource): + @cached_property + def reporting(self) -> AsyncReportingResource: + return AsyncReportingResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncLegacyResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return AsyncLegacyResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncLegacyResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return AsyncLegacyResourceWithStreamingResponse(self) + + +class LegacyResourceWithRawResponse: + def __init__(self, legacy: LegacyResource) -> None: + self._legacy = legacy + + @cached_property + def reporting(self) -> ReportingResourceWithRawResponse: + return ReportingResourceWithRawResponse(self._legacy.reporting) + + +class AsyncLegacyResourceWithRawResponse: + def __init__(self, legacy: AsyncLegacyResource) -> None: + self._legacy = legacy + + @cached_property + def reporting(self) -> AsyncReportingResourceWithRawResponse: + return AsyncReportingResourceWithRawResponse(self._legacy.reporting) + + +class LegacyResourceWithStreamingResponse: + def __init__(self, legacy: LegacyResource) -> None: + self._legacy = legacy + + @cached_property + def reporting(self) -> ReportingResourceWithStreamingResponse: + return ReportingResourceWithStreamingResponse(self._legacy.reporting) + + +class AsyncLegacyResourceWithStreamingResponse: + def __init__(self, legacy: AsyncLegacyResource) -> None: + self._legacy = legacy + + @cached_property + def reporting(self) -> AsyncReportingResourceWithStreamingResponse: + return AsyncReportingResourceWithStreamingResponse(self._legacy.reporting) diff --git a/src/telnyx/resources/legacy/reporting/__init__.py b/src/telnyx/resources/legacy/reporting/__init__.py new file mode 100644 index 00000000..6181add0 --- /dev/null +++ b/src/telnyx/resources/legacy/reporting/__init__.py @@ -0,0 +1,47 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .reporting import ( + ReportingResource, + AsyncReportingResource, + ReportingResourceWithRawResponse, + AsyncReportingResourceWithRawResponse, + ReportingResourceWithStreamingResponse, + AsyncReportingResourceWithStreamingResponse, +) +from .usage_reports import ( + UsageReportsResource, + AsyncUsageReportsResource, + UsageReportsResourceWithRawResponse, + AsyncUsageReportsResourceWithRawResponse, + UsageReportsResourceWithStreamingResponse, + AsyncUsageReportsResourceWithStreamingResponse, +) +from .batch_detail_records import ( + BatchDetailRecordsResource, + AsyncBatchDetailRecordsResource, + BatchDetailRecordsResourceWithRawResponse, + AsyncBatchDetailRecordsResourceWithRawResponse, + BatchDetailRecordsResourceWithStreamingResponse, + AsyncBatchDetailRecordsResourceWithStreamingResponse, +) + +__all__ = [ + "BatchDetailRecordsResource", + "AsyncBatchDetailRecordsResource", + "BatchDetailRecordsResourceWithRawResponse", + "AsyncBatchDetailRecordsResourceWithRawResponse", + "BatchDetailRecordsResourceWithStreamingResponse", + "AsyncBatchDetailRecordsResourceWithStreamingResponse", + "UsageReportsResource", + "AsyncUsageReportsResource", + "UsageReportsResourceWithRawResponse", + "AsyncUsageReportsResourceWithRawResponse", + "UsageReportsResourceWithStreamingResponse", + "AsyncUsageReportsResourceWithStreamingResponse", + "ReportingResource", + "AsyncReportingResource", + "ReportingResourceWithRawResponse", + "AsyncReportingResourceWithRawResponse", + "ReportingResourceWithStreamingResponse", + "AsyncReportingResourceWithStreamingResponse", +] diff --git a/src/telnyx/resources/legacy/reporting/batch_detail_records/__init__.py b/src/telnyx/resources/legacy/reporting/batch_detail_records/__init__.py new file mode 100644 index 00000000..e13b8570 --- /dev/null +++ b/src/telnyx/resources/legacy/reporting/batch_detail_records/__init__.py @@ -0,0 +1,61 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .voice import ( + VoiceResource, + AsyncVoiceResource, + VoiceResourceWithRawResponse, + AsyncVoiceResourceWithRawResponse, + VoiceResourceWithStreamingResponse, + AsyncVoiceResourceWithStreamingResponse, +) +from .messaging import ( + MessagingResource, + AsyncMessagingResource, + MessagingResourceWithRawResponse, + AsyncMessagingResourceWithRawResponse, + MessagingResourceWithStreamingResponse, + AsyncMessagingResourceWithStreamingResponse, +) +from .speech_to_text import ( + SpeechToTextResource, + AsyncSpeechToTextResource, + SpeechToTextResourceWithRawResponse, + AsyncSpeechToTextResourceWithRawResponse, + SpeechToTextResourceWithStreamingResponse, + AsyncSpeechToTextResourceWithStreamingResponse, +) +from .batch_detail_records import ( + BatchDetailRecordsResource, + AsyncBatchDetailRecordsResource, + BatchDetailRecordsResourceWithRawResponse, + AsyncBatchDetailRecordsResourceWithRawResponse, + BatchDetailRecordsResourceWithStreamingResponse, + AsyncBatchDetailRecordsResourceWithStreamingResponse, +) + +__all__ = [ + "MessagingResource", + "AsyncMessagingResource", + "MessagingResourceWithRawResponse", + "AsyncMessagingResourceWithRawResponse", + "MessagingResourceWithStreamingResponse", + "AsyncMessagingResourceWithStreamingResponse", + "SpeechToTextResource", + "AsyncSpeechToTextResource", + "SpeechToTextResourceWithRawResponse", + "AsyncSpeechToTextResourceWithRawResponse", + "SpeechToTextResourceWithStreamingResponse", + "AsyncSpeechToTextResourceWithStreamingResponse", + "VoiceResource", + "AsyncVoiceResource", + "VoiceResourceWithRawResponse", + "AsyncVoiceResourceWithRawResponse", + "VoiceResourceWithStreamingResponse", + "AsyncVoiceResourceWithStreamingResponse", + "BatchDetailRecordsResource", + "AsyncBatchDetailRecordsResource", + "BatchDetailRecordsResourceWithRawResponse", + "AsyncBatchDetailRecordsResourceWithRawResponse", + "BatchDetailRecordsResourceWithStreamingResponse", + "AsyncBatchDetailRecordsResourceWithStreamingResponse", +] diff --git a/src/telnyx/resources/legacy/reporting/batch_detail_records/batch_detail_records.py b/src/telnyx/resources/legacy/reporting/batch_detail_records/batch_detail_records.py new file mode 100644 index 00000000..ab4ee79d --- /dev/null +++ b/src/telnyx/resources/legacy/reporting/batch_detail_records/batch_detail_records.py @@ -0,0 +1,166 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .voice import ( + VoiceResource, + AsyncVoiceResource, + VoiceResourceWithRawResponse, + AsyncVoiceResourceWithRawResponse, + VoiceResourceWithStreamingResponse, + AsyncVoiceResourceWithStreamingResponse, +) +from .messaging import ( + MessagingResource, + AsyncMessagingResource, + MessagingResourceWithRawResponse, + AsyncMessagingResourceWithRawResponse, + MessagingResourceWithStreamingResponse, + AsyncMessagingResourceWithStreamingResponse, +) +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from .speech_to_text import ( + SpeechToTextResource, + AsyncSpeechToTextResource, + SpeechToTextResourceWithRawResponse, + AsyncSpeechToTextResourceWithRawResponse, + SpeechToTextResourceWithStreamingResponse, + AsyncSpeechToTextResourceWithStreamingResponse, +) + +__all__ = ["BatchDetailRecordsResource", "AsyncBatchDetailRecordsResource"] + + +class BatchDetailRecordsResource(SyncAPIResource): + @cached_property + def messaging(self) -> MessagingResource: + return MessagingResource(self._client) + + @cached_property + def speech_to_text(self) -> SpeechToTextResource: + return SpeechToTextResource(self._client) + + @cached_property + def voice(self) -> VoiceResource: + return VoiceResource(self._client) + + @cached_property + def with_raw_response(self) -> BatchDetailRecordsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return BatchDetailRecordsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> BatchDetailRecordsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return BatchDetailRecordsResourceWithStreamingResponse(self) + + +class AsyncBatchDetailRecordsResource(AsyncAPIResource): + @cached_property + def messaging(self) -> AsyncMessagingResource: + return AsyncMessagingResource(self._client) + + @cached_property + def speech_to_text(self) -> AsyncSpeechToTextResource: + return AsyncSpeechToTextResource(self._client) + + @cached_property + def voice(self) -> AsyncVoiceResource: + return AsyncVoiceResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncBatchDetailRecordsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return AsyncBatchDetailRecordsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncBatchDetailRecordsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return AsyncBatchDetailRecordsResourceWithStreamingResponse(self) + + +class BatchDetailRecordsResourceWithRawResponse: + def __init__(self, batch_detail_records: BatchDetailRecordsResource) -> None: + self._batch_detail_records = batch_detail_records + + @cached_property + def messaging(self) -> MessagingResourceWithRawResponse: + return MessagingResourceWithRawResponse(self._batch_detail_records.messaging) + + @cached_property + def speech_to_text(self) -> SpeechToTextResourceWithRawResponse: + return SpeechToTextResourceWithRawResponse(self._batch_detail_records.speech_to_text) + + @cached_property + def voice(self) -> VoiceResourceWithRawResponse: + return VoiceResourceWithRawResponse(self._batch_detail_records.voice) + + +class AsyncBatchDetailRecordsResourceWithRawResponse: + def __init__(self, batch_detail_records: AsyncBatchDetailRecordsResource) -> None: + self._batch_detail_records = batch_detail_records + + @cached_property + def messaging(self) -> AsyncMessagingResourceWithRawResponse: + return AsyncMessagingResourceWithRawResponse(self._batch_detail_records.messaging) + + @cached_property + def speech_to_text(self) -> AsyncSpeechToTextResourceWithRawResponse: + return AsyncSpeechToTextResourceWithRawResponse(self._batch_detail_records.speech_to_text) + + @cached_property + def voice(self) -> AsyncVoiceResourceWithRawResponse: + return AsyncVoiceResourceWithRawResponse(self._batch_detail_records.voice) + + +class BatchDetailRecordsResourceWithStreamingResponse: + def __init__(self, batch_detail_records: BatchDetailRecordsResource) -> None: + self._batch_detail_records = batch_detail_records + + @cached_property + def messaging(self) -> MessagingResourceWithStreamingResponse: + return MessagingResourceWithStreamingResponse(self._batch_detail_records.messaging) + + @cached_property + def speech_to_text(self) -> SpeechToTextResourceWithStreamingResponse: + return SpeechToTextResourceWithStreamingResponse(self._batch_detail_records.speech_to_text) + + @cached_property + def voice(self) -> VoiceResourceWithStreamingResponse: + return VoiceResourceWithStreamingResponse(self._batch_detail_records.voice) + + +class AsyncBatchDetailRecordsResourceWithStreamingResponse: + def __init__(self, batch_detail_records: AsyncBatchDetailRecordsResource) -> None: + self._batch_detail_records = batch_detail_records + + @cached_property + def messaging(self) -> AsyncMessagingResourceWithStreamingResponse: + return AsyncMessagingResourceWithStreamingResponse(self._batch_detail_records.messaging) + + @cached_property + def speech_to_text(self) -> AsyncSpeechToTextResourceWithStreamingResponse: + return AsyncSpeechToTextResourceWithStreamingResponse(self._batch_detail_records.speech_to_text) + + @cached_property + def voice(self) -> AsyncVoiceResourceWithStreamingResponse: + return AsyncVoiceResourceWithStreamingResponse(self._batch_detail_records.voice) diff --git a/src/telnyx/resources/legacy/reporting/batch_detail_records/messaging.py b/src/telnyx/resources/legacy/reporting/batch_detail_records/messaging.py new file mode 100644 index 00000000..05e22c3e --- /dev/null +++ b/src/telnyx/resources/legacy/reporting/batch_detail_records/messaging.py @@ -0,0 +1,481 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union, Iterable +from datetime import datetime + +import httpx + +from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ....._utils import maybe_transform, async_maybe_transform +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....._base_client import make_request_options +from .....types.legacy.reporting.batch_detail_records import messaging_create_params +from .....types.legacy.reporting.batch_detail_records.messaging_list_response import MessagingListResponse +from .....types.legacy.reporting.batch_detail_records.messaging_create_response import MessagingCreateResponse +from .....types.legacy.reporting.batch_detail_records.messaging_delete_response import MessagingDeleteResponse +from .....types.legacy.reporting.batch_detail_records.messaging_retrieve_response import MessagingRetrieveResponse + +__all__ = ["MessagingResource", "AsyncMessagingResource"] + + +class MessagingResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> MessagingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return MessagingResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> MessagingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return MessagingResourceWithStreamingResponse(self) + + def create( + self, + *, + end_time: Union[str, datetime], + start_time: Union[str, datetime], + connections: Iterable[int] | Omit = omit, + directions: Iterable[int] | Omit = omit, + filters: Iterable[messaging_create_params.Filter] | Omit = omit, + include_message_body: bool | Omit = omit, + managed_accounts: SequenceNotStr[str] | Omit = omit, + profiles: SequenceNotStr[str] | Omit = omit, + record_types: Iterable[int] | Omit = omit, + report_name: str | Omit = omit, + select_all_managed_accounts: bool | Omit = omit, + timezone: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MessagingCreateResponse: + """ + Creates a new MDR detailed report request with the specified filters + + Args: + end_time: End time in ISO format. Note: If end time includes the last 4 hours, some MDRs + might not appear in this report, due to wait time for downstream message + delivery confirmation + + start_time: Start time in ISO format + + connections: List of connections to filter by + + directions: List of directions to filter by (Inbound = 1, Outbound = 2) + + filters: List of filters to apply + + include_message_body: Whether to include message body in the report + + managed_accounts: List of managed accounts to include + + profiles: List of messaging profile IDs to filter by + + record_types: List of record types to filter by (Complete = 1, Incomplete = 2, Errors = 3) + + report_name: Name of the report + + select_all_managed_accounts: Whether to select all managed accounts + + timezone: Timezone for the report + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/legacy/reporting/batch_detail_records/messaging", + body=maybe_transform( + { + "end_time": end_time, + "start_time": start_time, + "connections": connections, + "directions": directions, + "filters": filters, + "include_message_body": include_message_body, + "managed_accounts": managed_accounts, + "profiles": profiles, + "record_types": record_types, + "report_name": report_name, + "select_all_managed_accounts": select_all_managed_accounts, + "timezone": timezone, + }, + messaging_create_params.MessagingCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=MessagingCreateResponse, + ) + + def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MessagingRetrieveResponse: + """ + Retrieves a specific MDR detailed report request by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + f"/legacy/reporting/batch_detail_records/messaging/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=MessagingRetrieveResponse, + ) + + def list( + self, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MessagingListResponse: + """Retrieves all MDR detailed report requests for the authenticated user""" + return self._get( + "/legacy/reporting/batch_detail_records/messaging", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=MessagingListResponse, + ) + + def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MessagingDeleteResponse: + """ + Deletes a specific MDR detailed report request by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._delete( + f"/legacy/reporting/batch_detail_records/messaging/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=MessagingDeleteResponse, + ) + + +class AsyncMessagingResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncMessagingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return AsyncMessagingResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncMessagingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return AsyncMessagingResourceWithStreamingResponse(self) + + async def create( + self, + *, + end_time: Union[str, datetime], + start_time: Union[str, datetime], + connections: Iterable[int] | Omit = omit, + directions: Iterable[int] | Omit = omit, + filters: Iterable[messaging_create_params.Filter] | Omit = omit, + include_message_body: bool | Omit = omit, + managed_accounts: SequenceNotStr[str] | Omit = omit, + profiles: SequenceNotStr[str] | Omit = omit, + record_types: Iterable[int] | Omit = omit, + report_name: str | Omit = omit, + select_all_managed_accounts: bool | Omit = omit, + timezone: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MessagingCreateResponse: + """ + Creates a new MDR detailed report request with the specified filters + + Args: + end_time: End time in ISO format. Note: If end time includes the last 4 hours, some MDRs + might not appear in this report, due to wait time for downstream message + delivery confirmation + + start_time: Start time in ISO format + + connections: List of connections to filter by + + directions: List of directions to filter by (Inbound = 1, Outbound = 2) + + filters: List of filters to apply + + include_message_body: Whether to include message body in the report + + managed_accounts: List of managed accounts to include + + profiles: List of messaging profile IDs to filter by + + record_types: List of record types to filter by (Complete = 1, Incomplete = 2, Errors = 3) + + report_name: Name of the report + + select_all_managed_accounts: Whether to select all managed accounts + + timezone: Timezone for the report + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/legacy/reporting/batch_detail_records/messaging", + body=await async_maybe_transform( + { + "end_time": end_time, + "start_time": start_time, + "connections": connections, + "directions": directions, + "filters": filters, + "include_message_body": include_message_body, + "managed_accounts": managed_accounts, + "profiles": profiles, + "record_types": record_types, + "report_name": report_name, + "select_all_managed_accounts": select_all_managed_accounts, + "timezone": timezone, + }, + messaging_create_params.MessagingCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=MessagingCreateResponse, + ) + + async def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MessagingRetrieveResponse: + """ + Retrieves a specific MDR detailed report request by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + f"/legacy/reporting/batch_detail_records/messaging/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=MessagingRetrieveResponse, + ) + + async def list( + self, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MessagingListResponse: + """Retrieves all MDR detailed report requests for the authenticated user""" + return await self._get( + "/legacy/reporting/batch_detail_records/messaging", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=MessagingListResponse, + ) + + async def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MessagingDeleteResponse: + """ + Deletes a specific MDR detailed report request by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._delete( + f"/legacy/reporting/batch_detail_records/messaging/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=MessagingDeleteResponse, + ) + + +class MessagingResourceWithRawResponse: + def __init__(self, messaging: MessagingResource) -> None: + self._messaging = messaging + + self.create = to_raw_response_wrapper( + messaging.create, + ) + self.retrieve = to_raw_response_wrapper( + messaging.retrieve, + ) + self.list = to_raw_response_wrapper( + messaging.list, + ) + self.delete = to_raw_response_wrapper( + messaging.delete, + ) + + +class AsyncMessagingResourceWithRawResponse: + def __init__(self, messaging: AsyncMessagingResource) -> None: + self._messaging = messaging + + self.create = async_to_raw_response_wrapper( + messaging.create, + ) + self.retrieve = async_to_raw_response_wrapper( + messaging.retrieve, + ) + self.list = async_to_raw_response_wrapper( + messaging.list, + ) + self.delete = async_to_raw_response_wrapper( + messaging.delete, + ) + + +class MessagingResourceWithStreamingResponse: + def __init__(self, messaging: MessagingResource) -> None: + self._messaging = messaging + + self.create = to_streamed_response_wrapper( + messaging.create, + ) + self.retrieve = to_streamed_response_wrapper( + messaging.retrieve, + ) + self.list = to_streamed_response_wrapper( + messaging.list, + ) + self.delete = to_streamed_response_wrapper( + messaging.delete, + ) + + +class AsyncMessagingResourceWithStreamingResponse: + def __init__(self, messaging: AsyncMessagingResource) -> None: + self._messaging = messaging + + self.create = async_to_streamed_response_wrapper( + messaging.create, + ) + self.retrieve = async_to_streamed_response_wrapper( + messaging.retrieve, + ) + self.list = async_to_streamed_response_wrapper( + messaging.list, + ) + self.delete = async_to_streamed_response_wrapper( + messaging.delete, + ) diff --git a/src/telnyx/resources/legacy/reporting/batch_detail_records/speech_to_text.py b/src/telnyx/resources/legacy/reporting/batch_detail_records/speech_to_text.py new file mode 100644 index 00000000..a472c37d --- /dev/null +++ b/src/telnyx/resources/legacy/reporting/batch_detail_records/speech_to_text.py @@ -0,0 +1,399 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import datetime + +import httpx + +from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import maybe_transform, async_maybe_transform +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....._base_client import make_request_options +from .....types.legacy.reporting.batch_detail_records import speech_to_text_create_params +from .....types.legacy.reporting.batch_detail_records.speech_to_text_list_response import SpeechToTextListResponse +from .....types.legacy.reporting.batch_detail_records.speech_to_text_create_response import SpeechToTextCreateResponse +from .....types.legacy.reporting.batch_detail_records.speech_to_text_delete_response import SpeechToTextDeleteResponse +from .....types.legacy.reporting.batch_detail_records.speech_to_text_retrieve_response import ( + SpeechToTextRetrieveResponse, +) + +__all__ = ["SpeechToTextResource", "AsyncSpeechToTextResource"] + + +class SpeechToTextResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> SpeechToTextResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return SpeechToTextResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SpeechToTextResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return SpeechToTextResourceWithStreamingResponse(self) + + def create( + self, + *, + end_date: Union[str, datetime], + start_date: Union[str, datetime], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SpeechToTextCreateResponse: + """ + Creates a new Speech to Text batch report request with the specified filters + + Args: + end_date: End date in ISO format with timezone (date range must be up to one month) + + start_date: Start date in ISO format with timezone + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/legacy/reporting/batch_detail_records/speech_to_text", + body=maybe_transform( + { + "end_date": end_date, + "start_date": start_date, + }, + speech_to_text_create_params.SpeechToTextCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SpeechToTextCreateResponse, + ) + + def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SpeechToTextRetrieveResponse: + """ + Retrieves a specific Speech to Text batch report request by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + f"/legacy/reporting/batch_detail_records/speech_to_text/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SpeechToTextRetrieveResponse, + ) + + def list( + self, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SpeechToTextListResponse: + """Retrieves all Speech to Text batch report requests for the authenticated user""" + return self._get( + "/legacy/reporting/batch_detail_records/speech_to_text", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SpeechToTextListResponse, + ) + + def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SpeechToTextDeleteResponse: + """ + Deletes a specific Speech to Text batch report request by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._delete( + f"/legacy/reporting/batch_detail_records/speech_to_text/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SpeechToTextDeleteResponse, + ) + + +class AsyncSpeechToTextResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncSpeechToTextResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return AsyncSpeechToTextResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSpeechToTextResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return AsyncSpeechToTextResourceWithStreamingResponse(self) + + async def create( + self, + *, + end_date: Union[str, datetime], + start_date: Union[str, datetime], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SpeechToTextCreateResponse: + """ + Creates a new Speech to Text batch report request with the specified filters + + Args: + end_date: End date in ISO format with timezone (date range must be up to one month) + + start_date: Start date in ISO format with timezone + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/legacy/reporting/batch_detail_records/speech_to_text", + body=await async_maybe_transform( + { + "end_date": end_date, + "start_date": start_date, + }, + speech_to_text_create_params.SpeechToTextCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SpeechToTextCreateResponse, + ) + + async def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SpeechToTextRetrieveResponse: + """ + Retrieves a specific Speech to Text batch report request by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + f"/legacy/reporting/batch_detail_records/speech_to_text/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SpeechToTextRetrieveResponse, + ) + + async def list( + self, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SpeechToTextListResponse: + """Retrieves all Speech to Text batch report requests for the authenticated user""" + return await self._get( + "/legacy/reporting/batch_detail_records/speech_to_text", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SpeechToTextListResponse, + ) + + async def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SpeechToTextDeleteResponse: + """ + Deletes a specific Speech to Text batch report request by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._delete( + f"/legacy/reporting/batch_detail_records/speech_to_text/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SpeechToTextDeleteResponse, + ) + + +class SpeechToTextResourceWithRawResponse: + def __init__(self, speech_to_text: SpeechToTextResource) -> None: + self._speech_to_text = speech_to_text + + self.create = to_raw_response_wrapper( + speech_to_text.create, + ) + self.retrieve = to_raw_response_wrapper( + speech_to_text.retrieve, + ) + self.list = to_raw_response_wrapper( + speech_to_text.list, + ) + self.delete = to_raw_response_wrapper( + speech_to_text.delete, + ) + + +class AsyncSpeechToTextResourceWithRawResponse: + def __init__(self, speech_to_text: AsyncSpeechToTextResource) -> None: + self._speech_to_text = speech_to_text + + self.create = async_to_raw_response_wrapper( + speech_to_text.create, + ) + self.retrieve = async_to_raw_response_wrapper( + speech_to_text.retrieve, + ) + self.list = async_to_raw_response_wrapper( + speech_to_text.list, + ) + self.delete = async_to_raw_response_wrapper( + speech_to_text.delete, + ) + + +class SpeechToTextResourceWithStreamingResponse: + def __init__(self, speech_to_text: SpeechToTextResource) -> None: + self._speech_to_text = speech_to_text + + self.create = to_streamed_response_wrapper( + speech_to_text.create, + ) + self.retrieve = to_streamed_response_wrapper( + speech_to_text.retrieve, + ) + self.list = to_streamed_response_wrapper( + speech_to_text.list, + ) + self.delete = to_streamed_response_wrapper( + speech_to_text.delete, + ) + + +class AsyncSpeechToTextResourceWithStreamingResponse: + def __init__(self, speech_to_text: AsyncSpeechToTextResource) -> None: + self._speech_to_text = speech_to_text + + self.create = async_to_streamed_response_wrapper( + speech_to_text.create, + ) + self.retrieve = async_to_streamed_response_wrapper( + speech_to_text.retrieve, + ) + self.list = async_to_streamed_response_wrapper( + speech_to_text.list, + ) + self.delete = async_to_streamed_response_wrapper( + speech_to_text.delete, + ) diff --git a/src/telnyx/resources/legacy/reporting/batch_detail_records/voice.py b/src/telnyx/resources/legacy/reporting/batch_detail_records/voice.py new file mode 100644 index 00000000..7d10c83f --- /dev/null +++ b/src/telnyx/resources/legacy/reporting/batch_detail_records/voice.py @@ -0,0 +1,538 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union, Iterable +from datetime import datetime + +import httpx + +from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ....._utils import maybe_transform, async_maybe_transform +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....._base_client import make_request_options +from .....types.legacy.reporting.batch_detail_records import voice_create_params +from .....types.legacy.reporting.batch_detail_records.voice_list_response import VoiceListResponse +from .....types.legacy.reporting.batch_detail_records.voice_create_response import VoiceCreateResponse +from .....types.legacy.reporting.batch_detail_records.voice_delete_response import VoiceDeleteResponse +from .....types.legacy.reporting.batch_detail_records.voice_retrieve_response import VoiceRetrieveResponse +from .....types.legacy.reporting.batch_detail_records.voice_retrieve_fields_response import VoiceRetrieveFieldsResponse + +__all__ = ["VoiceResource", "AsyncVoiceResource"] + + +class VoiceResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> VoiceResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return VoiceResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> VoiceResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return VoiceResourceWithStreamingResponse(self) + + def create( + self, + *, + end_time: Union[str, datetime], + start_time: Union[str, datetime], + call_types: Iterable[int] | Omit = omit, + connections: Iterable[int] | Omit = omit, + fields: SequenceNotStr[str] | Omit = omit, + filters: Iterable[voice_create_params.Filter] | Omit = omit, + include_all_metadata: bool | Omit = omit, + managed_accounts: SequenceNotStr[str] | Omit = omit, + record_types: Iterable[int] | Omit = omit, + report_name: str | Omit = omit, + select_all_managed_accounts: bool | Omit = omit, + source: str | Omit = omit, + timezone: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VoiceCreateResponse: + """ + Creates a new CDR report request with the specified filters + + Args: + end_time: End time in ISO format + + start_time: Start time in ISO format + + call_types: List of call types to filter by (Inbound = 1, Outbound = 2) + + connections: List of connections to filter by + + fields: Set of fields to include in the report + + filters: List of filters to apply + + include_all_metadata: Whether to include all metadata + + managed_accounts: List of managed accounts to include + + record_types: List of record types to filter by (Complete = 1, Incomplete = 2, Errors = 3) + + report_name: Name of the report + + select_all_managed_accounts: Whether to select all managed accounts + + source: Source of the report. Valid values: calls (default), call-control, fax-api, + webrtc + + timezone: Timezone for the report + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/legacy/reporting/batch_detail_records/voice", + body=maybe_transform( + { + "end_time": end_time, + "start_time": start_time, + "call_types": call_types, + "connections": connections, + "fields": fields, + "filters": filters, + "include_all_metadata": include_all_metadata, + "managed_accounts": managed_accounts, + "record_types": record_types, + "report_name": report_name, + "select_all_managed_accounts": select_all_managed_accounts, + "source": source, + "timezone": timezone, + }, + voice_create_params.VoiceCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VoiceCreateResponse, + ) + + def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VoiceRetrieveResponse: + """ + Retrieves a specific CDR report request by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + f"/legacy/reporting/batch_detail_records/voice/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VoiceRetrieveResponse, + ) + + def list( + self, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VoiceListResponse: + """Retrieves all CDR report requests for the authenticated user""" + return self._get( + "/legacy/reporting/batch_detail_records/voice", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VoiceListResponse, + ) + + def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VoiceDeleteResponse: + """ + Deletes a specific CDR report request by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._delete( + f"/legacy/reporting/batch_detail_records/voice/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VoiceDeleteResponse, + ) + + def retrieve_fields( + self, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VoiceRetrieveFieldsResponse: + """Retrieves all available fields that can be used in CDR reports""" + return self._get( + "/legacy/reporting/batch_detail_records/voice/fields", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VoiceRetrieveFieldsResponse, + ) + + +class AsyncVoiceResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncVoiceResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return AsyncVoiceResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncVoiceResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return AsyncVoiceResourceWithStreamingResponse(self) + + async def create( + self, + *, + end_time: Union[str, datetime], + start_time: Union[str, datetime], + call_types: Iterable[int] | Omit = omit, + connections: Iterable[int] | Omit = omit, + fields: SequenceNotStr[str] | Omit = omit, + filters: Iterable[voice_create_params.Filter] | Omit = omit, + include_all_metadata: bool | Omit = omit, + managed_accounts: SequenceNotStr[str] | Omit = omit, + record_types: Iterable[int] | Omit = omit, + report_name: str | Omit = omit, + select_all_managed_accounts: bool | Omit = omit, + source: str | Omit = omit, + timezone: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VoiceCreateResponse: + """ + Creates a new CDR report request with the specified filters + + Args: + end_time: End time in ISO format + + start_time: Start time in ISO format + + call_types: List of call types to filter by (Inbound = 1, Outbound = 2) + + connections: List of connections to filter by + + fields: Set of fields to include in the report + + filters: List of filters to apply + + include_all_metadata: Whether to include all metadata + + managed_accounts: List of managed accounts to include + + record_types: List of record types to filter by (Complete = 1, Incomplete = 2, Errors = 3) + + report_name: Name of the report + + select_all_managed_accounts: Whether to select all managed accounts + + source: Source of the report. Valid values: calls (default), call-control, fax-api, + webrtc + + timezone: Timezone for the report + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/legacy/reporting/batch_detail_records/voice", + body=await async_maybe_transform( + { + "end_time": end_time, + "start_time": start_time, + "call_types": call_types, + "connections": connections, + "fields": fields, + "filters": filters, + "include_all_metadata": include_all_metadata, + "managed_accounts": managed_accounts, + "record_types": record_types, + "report_name": report_name, + "select_all_managed_accounts": select_all_managed_accounts, + "source": source, + "timezone": timezone, + }, + voice_create_params.VoiceCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VoiceCreateResponse, + ) + + async def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VoiceRetrieveResponse: + """ + Retrieves a specific CDR report request by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + f"/legacy/reporting/batch_detail_records/voice/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VoiceRetrieveResponse, + ) + + async def list( + self, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VoiceListResponse: + """Retrieves all CDR report requests for the authenticated user""" + return await self._get( + "/legacy/reporting/batch_detail_records/voice", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VoiceListResponse, + ) + + async def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VoiceDeleteResponse: + """ + Deletes a specific CDR report request by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._delete( + f"/legacy/reporting/batch_detail_records/voice/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VoiceDeleteResponse, + ) + + async def retrieve_fields( + self, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VoiceRetrieveFieldsResponse: + """Retrieves all available fields that can be used in CDR reports""" + return await self._get( + "/legacy/reporting/batch_detail_records/voice/fields", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VoiceRetrieveFieldsResponse, + ) + + +class VoiceResourceWithRawResponse: + def __init__(self, voice: VoiceResource) -> None: + self._voice = voice + + self.create = to_raw_response_wrapper( + voice.create, + ) + self.retrieve = to_raw_response_wrapper( + voice.retrieve, + ) + self.list = to_raw_response_wrapper( + voice.list, + ) + self.delete = to_raw_response_wrapper( + voice.delete, + ) + self.retrieve_fields = to_raw_response_wrapper( + voice.retrieve_fields, + ) + + +class AsyncVoiceResourceWithRawResponse: + def __init__(self, voice: AsyncVoiceResource) -> None: + self._voice = voice + + self.create = async_to_raw_response_wrapper( + voice.create, + ) + self.retrieve = async_to_raw_response_wrapper( + voice.retrieve, + ) + self.list = async_to_raw_response_wrapper( + voice.list, + ) + self.delete = async_to_raw_response_wrapper( + voice.delete, + ) + self.retrieve_fields = async_to_raw_response_wrapper( + voice.retrieve_fields, + ) + + +class VoiceResourceWithStreamingResponse: + def __init__(self, voice: VoiceResource) -> None: + self._voice = voice + + self.create = to_streamed_response_wrapper( + voice.create, + ) + self.retrieve = to_streamed_response_wrapper( + voice.retrieve, + ) + self.list = to_streamed_response_wrapper( + voice.list, + ) + self.delete = to_streamed_response_wrapper( + voice.delete, + ) + self.retrieve_fields = to_streamed_response_wrapper( + voice.retrieve_fields, + ) + + +class AsyncVoiceResourceWithStreamingResponse: + def __init__(self, voice: AsyncVoiceResource) -> None: + self._voice = voice + + self.create = async_to_streamed_response_wrapper( + voice.create, + ) + self.retrieve = async_to_streamed_response_wrapper( + voice.retrieve, + ) + self.list = async_to_streamed_response_wrapper( + voice.list, + ) + self.delete = async_to_streamed_response_wrapper( + voice.delete, + ) + self.retrieve_fields = async_to_streamed_response_wrapper( + voice.retrieve_fields, + ) diff --git a/src/telnyx/resources/legacy/reporting/reporting.py b/src/telnyx/resources/legacy/reporting/reporting.py new file mode 100644 index 00000000..3aeca0f1 --- /dev/null +++ b/src/telnyx/resources/legacy/reporting/reporting.py @@ -0,0 +1,134 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from .usage_reports.usage_reports import ( + UsageReportsResource, + AsyncUsageReportsResource, + UsageReportsResourceWithRawResponse, + AsyncUsageReportsResourceWithRawResponse, + UsageReportsResourceWithStreamingResponse, + AsyncUsageReportsResourceWithStreamingResponse, +) +from .batch_detail_records.batch_detail_records import ( + BatchDetailRecordsResource, + AsyncBatchDetailRecordsResource, + BatchDetailRecordsResourceWithRawResponse, + AsyncBatchDetailRecordsResourceWithRawResponse, + BatchDetailRecordsResourceWithStreamingResponse, + AsyncBatchDetailRecordsResourceWithStreamingResponse, +) + +__all__ = ["ReportingResource", "AsyncReportingResource"] + + +class ReportingResource(SyncAPIResource): + @cached_property + def batch_detail_records(self) -> BatchDetailRecordsResource: + return BatchDetailRecordsResource(self._client) + + @cached_property + def usage_reports(self) -> UsageReportsResource: + return UsageReportsResource(self._client) + + @cached_property + def with_raw_response(self) -> ReportingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return ReportingResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ReportingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return ReportingResourceWithStreamingResponse(self) + + +class AsyncReportingResource(AsyncAPIResource): + @cached_property + def batch_detail_records(self) -> AsyncBatchDetailRecordsResource: + return AsyncBatchDetailRecordsResource(self._client) + + @cached_property + def usage_reports(self) -> AsyncUsageReportsResource: + return AsyncUsageReportsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncReportingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return AsyncReportingResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncReportingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return AsyncReportingResourceWithStreamingResponse(self) + + +class ReportingResourceWithRawResponse: + def __init__(self, reporting: ReportingResource) -> None: + self._reporting = reporting + + @cached_property + def batch_detail_records(self) -> BatchDetailRecordsResourceWithRawResponse: + return BatchDetailRecordsResourceWithRawResponse(self._reporting.batch_detail_records) + + @cached_property + def usage_reports(self) -> UsageReportsResourceWithRawResponse: + return UsageReportsResourceWithRawResponse(self._reporting.usage_reports) + + +class AsyncReportingResourceWithRawResponse: + def __init__(self, reporting: AsyncReportingResource) -> None: + self._reporting = reporting + + @cached_property + def batch_detail_records(self) -> AsyncBatchDetailRecordsResourceWithRawResponse: + return AsyncBatchDetailRecordsResourceWithRawResponse(self._reporting.batch_detail_records) + + @cached_property + def usage_reports(self) -> AsyncUsageReportsResourceWithRawResponse: + return AsyncUsageReportsResourceWithRawResponse(self._reporting.usage_reports) + + +class ReportingResourceWithStreamingResponse: + def __init__(self, reporting: ReportingResource) -> None: + self._reporting = reporting + + @cached_property + def batch_detail_records(self) -> BatchDetailRecordsResourceWithStreamingResponse: + return BatchDetailRecordsResourceWithStreamingResponse(self._reporting.batch_detail_records) + + @cached_property + def usage_reports(self) -> UsageReportsResourceWithStreamingResponse: + return UsageReportsResourceWithStreamingResponse(self._reporting.usage_reports) + + +class AsyncReportingResourceWithStreamingResponse: + def __init__(self, reporting: AsyncReportingResource) -> None: + self._reporting = reporting + + @cached_property + def batch_detail_records(self) -> AsyncBatchDetailRecordsResourceWithStreamingResponse: + return AsyncBatchDetailRecordsResourceWithStreamingResponse(self._reporting.batch_detail_records) + + @cached_property + def usage_reports(self) -> AsyncUsageReportsResourceWithStreamingResponse: + return AsyncUsageReportsResourceWithStreamingResponse(self._reporting.usage_reports) diff --git a/src/telnyx/resources/legacy/reporting/usage_reports/__init__.py b/src/telnyx/resources/legacy/reporting/usage_reports/__init__.py new file mode 100644 index 00000000..4a280283 --- /dev/null +++ b/src/telnyx/resources/legacy/reporting/usage_reports/__init__.py @@ -0,0 +1,61 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .voice import ( + VoiceResource, + AsyncVoiceResource, + VoiceResourceWithRawResponse, + AsyncVoiceResourceWithRawResponse, + VoiceResourceWithStreamingResponse, + AsyncVoiceResourceWithStreamingResponse, +) +from .messaging import ( + MessagingResource, + AsyncMessagingResource, + MessagingResourceWithRawResponse, + AsyncMessagingResourceWithRawResponse, + MessagingResourceWithStreamingResponse, + AsyncMessagingResourceWithStreamingResponse, +) +from .number_lookup import ( + NumberLookupResource, + AsyncNumberLookupResource, + NumberLookupResourceWithRawResponse, + AsyncNumberLookupResourceWithRawResponse, + NumberLookupResourceWithStreamingResponse, + AsyncNumberLookupResourceWithStreamingResponse, +) +from .usage_reports import ( + UsageReportsResource, + AsyncUsageReportsResource, + UsageReportsResourceWithRawResponse, + AsyncUsageReportsResourceWithRawResponse, + UsageReportsResourceWithStreamingResponse, + AsyncUsageReportsResourceWithStreamingResponse, +) + +__all__ = [ + "MessagingResource", + "AsyncMessagingResource", + "MessagingResourceWithRawResponse", + "AsyncMessagingResourceWithRawResponse", + "MessagingResourceWithStreamingResponse", + "AsyncMessagingResourceWithStreamingResponse", + "NumberLookupResource", + "AsyncNumberLookupResource", + "NumberLookupResourceWithRawResponse", + "AsyncNumberLookupResourceWithRawResponse", + "NumberLookupResourceWithStreamingResponse", + "AsyncNumberLookupResourceWithStreamingResponse", + "VoiceResource", + "AsyncVoiceResource", + "VoiceResourceWithRawResponse", + "AsyncVoiceResourceWithRawResponse", + "VoiceResourceWithStreamingResponse", + "AsyncVoiceResourceWithStreamingResponse", + "UsageReportsResource", + "AsyncUsageReportsResource", + "UsageReportsResourceWithRawResponse", + "AsyncUsageReportsResourceWithRawResponse", + "UsageReportsResourceWithStreamingResponse", + "AsyncUsageReportsResourceWithStreamingResponse", +] diff --git a/src/telnyx/resources/legacy/reporting/usage_reports/messaging.py b/src/telnyx/resources/legacy/reporting/usage_reports/messaging.py new file mode 100644 index 00000000..c39b3e64 --- /dev/null +++ b/src/telnyx/resources/legacy/reporting/usage_reports/messaging.py @@ -0,0 +1,471 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import datetime + +import httpx + +from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ....._utils import maybe_transform, async_maybe_transform +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....._base_client import make_request_options +from .....types.legacy.reporting.usage_reports import messaging_list_params, messaging_create_params +from .....types.legacy.reporting.usage_reports.messaging_list_response import MessagingListResponse +from .....types.legacy.reporting.usage_reports.messaging_create_response import MessagingCreateResponse +from .....types.legacy.reporting.usage_reports.messaging_delete_response import MessagingDeleteResponse +from .....types.legacy.reporting.usage_reports.messaging_retrieve_response import MessagingRetrieveResponse + +__all__ = ["MessagingResource", "AsyncMessagingResource"] + + +class MessagingResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> MessagingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return MessagingResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> MessagingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return MessagingResourceWithStreamingResponse(self) + + def create( + self, + *, + aggregation_type: int, + end_time: Union[str, datetime] | Omit = omit, + managed_accounts: SequenceNotStr[str] | Omit = omit, + profiles: SequenceNotStr[str] | Omit = omit, + select_all_managed_accounts: bool | Omit = omit, + start_time: Union[str, datetime] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MessagingCreateResponse: + """ + Creates a new legacy usage V2 MDR report request with the specified filters + + Args: + aggregation_type: Aggregation type: No aggregation = 0, By Messaging Profile = 1, By Tags = 2 + + managed_accounts: List of managed accounts to include + + profiles: List of messaging profile IDs to filter by + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/legacy/reporting/usage_reports/messaging", + body=maybe_transform( + { + "aggregation_type": aggregation_type, + "end_time": end_time, + "managed_accounts": managed_accounts, + "profiles": profiles, + "select_all_managed_accounts": select_all_managed_accounts, + "start_time": start_time, + }, + messaging_create_params.MessagingCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=MessagingCreateResponse, + ) + + def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MessagingRetrieveResponse: + """ + Fetch single MDR usage report by id. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + f"/legacy/reporting/usage_reports/messaging/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=MessagingRetrieveResponse, + ) + + def list( + self, + *, + page: int | Omit = omit, + per_page: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MessagingListResponse: + """ + Fetch all previous requests for MDR usage reports. + + Args: + page: Page number + + per_page: Size of the page + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + "/legacy/reporting/usage_reports/messaging", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + }, + messaging_list_params.MessagingListParams, + ), + ), + cast_to=MessagingListResponse, + ) + + def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MessagingDeleteResponse: + """ + Deletes a specific V2 legacy usage MDR report request by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._delete( + f"/legacy/reporting/usage_reports/messaging/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=MessagingDeleteResponse, + ) + + +class AsyncMessagingResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncMessagingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return AsyncMessagingResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncMessagingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return AsyncMessagingResourceWithStreamingResponse(self) + + async def create( + self, + *, + aggregation_type: int, + end_time: Union[str, datetime] | Omit = omit, + managed_accounts: SequenceNotStr[str] | Omit = omit, + profiles: SequenceNotStr[str] | Omit = omit, + select_all_managed_accounts: bool | Omit = omit, + start_time: Union[str, datetime] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MessagingCreateResponse: + """ + Creates a new legacy usage V2 MDR report request with the specified filters + + Args: + aggregation_type: Aggregation type: No aggregation = 0, By Messaging Profile = 1, By Tags = 2 + + managed_accounts: List of managed accounts to include + + profiles: List of messaging profile IDs to filter by + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/legacy/reporting/usage_reports/messaging", + body=await async_maybe_transform( + { + "aggregation_type": aggregation_type, + "end_time": end_time, + "managed_accounts": managed_accounts, + "profiles": profiles, + "select_all_managed_accounts": select_all_managed_accounts, + "start_time": start_time, + }, + messaging_create_params.MessagingCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=MessagingCreateResponse, + ) + + async def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MessagingRetrieveResponse: + """ + Fetch single MDR usage report by id. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + f"/legacy/reporting/usage_reports/messaging/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=MessagingRetrieveResponse, + ) + + async def list( + self, + *, + page: int | Omit = omit, + per_page: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MessagingListResponse: + """ + Fetch all previous requests for MDR usage reports. + + Args: + page: Page number + + per_page: Size of the page + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + "/legacy/reporting/usage_reports/messaging", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "page": page, + "per_page": per_page, + }, + messaging_list_params.MessagingListParams, + ), + ), + cast_to=MessagingListResponse, + ) + + async def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MessagingDeleteResponse: + """ + Deletes a specific V2 legacy usage MDR report request by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._delete( + f"/legacy/reporting/usage_reports/messaging/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=MessagingDeleteResponse, + ) + + +class MessagingResourceWithRawResponse: + def __init__(self, messaging: MessagingResource) -> None: + self._messaging = messaging + + self.create = to_raw_response_wrapper( + messaging.create, + ) + self.retrieve = to_raw_response_wrapper( + messaging.retrieve, + ) + self.list = to_raw_response_wrapper( + messaging.list, + ) + self.delete = to_raw_response_wrapper( + messaging.delete, + ) + + +class AsyncMessagingResourceWithRawResponse: + def __init__(self, messaging: AsyncMessagingResource) -> None: + self._messaging = messaging + + self.create = async_to_raw_response_wrapper( + messaging.create, + ) + self.retrieve = async_to_raw_response_wrapper( + messaging.retrieve, + ) + self.list = async_to_raw_response_wrapper( + messaging.list, + ) + self.delete = async_to_raw_response_wrapper( + messaging.delete, + ) + + +class MessagingResourceWithStreamingResponse: + def __init__(self, messaging: MessagingResource) -> None: + self._messaging = messaging + + self.create = to_streamed_response_wrapper( + messaging.create, + ) + self.retrieve = to_streamed_response_wrapper( + messaging.retrieve, + ) + self.list = to_streamed_response_wrapper( + messaging.list, + ) + self.delete = to_streamed_response_wrapper( + messaging.delete, + ) + + +class AsyncMessagingResourceWithStreamingResponse: + def __init__(self, messaging: AsyncMessagingResource) -> None: + self._messaging = messaging + + self.create = async_to_streamed_response_wrapper( + messaging.create, + ) + self.retrieve = async_to_streamed_response_wrapper( + messaging.retrieve, + ) + self.list = async_to_streamed_response_wrapper( + messaging.list, + ) + self.delete = async_to_streamed_response_wrapper( + messaging.delete, + ) diff --git a/src/telnyx/resources/legacy/reporting/usage_reports/number_lookup.py b/src/telnyx/resources/legacy/reporting/usage_reports/number_lookup.py new file mode 100644 index 00000000..1b20a72b --- /dev/null +++ b/src/telnyx/resources/legacy/reporting/usage_reports/number_lookup.py @@ -0,0 +1,464 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import date +from typing_extensions import Literal + +import httpx + +from ....._types import Body, Omit, Query, Headers, NoneType, NotGiven, SequenceNotStr, omit, not_given +from ....._utils import maybe_transform, async_maybe_transform +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....._base_client import make_request_options +from .....types.legacy.reporting.usage_reports import number_lookup_list_params, number_lookup_create_params + +__all__ = ["NumberLookupResource", "AsyncNumberLookupResource"] + + +class NumberLookupResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> NumberLookupResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return NumberLookupResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> NumberLookupResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return NumberLookupResourceWithStreamingResponse(self) + + def create( + self, + *, + aggregation_type: Literal["ALL", "BY_ORGANIZATION_MEMBER"] | Omit = omit, + end_date: Union[str, date] | Omit = omit, + managed_accounts: SequenceNotStr[str] | Omit = omit, + start_date: Union[str, date] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Submit a new telco data usage report + + Args: + aggregation_type: Type of aggregation for the report + + end_date: End date for the usage report + + managed_accounts: List of managed accounts to include in the report + + start_date: Start date for the usage report + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._post( + "/legacy/reporting/usage_reports/number_lookup", + body=maybe_transform( + { + "aggregation_type": aggregation_type, + "end_date": end_date, + "managed_accounts": managed_accounts, + "start_date": start_date, + }, + number_lookup_create_params.NumberLookupCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Retrieve a specific telco data usage report by its ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._get( + f"/legacy/reporting/usage_reports/number_lookup/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + def list( + self, + *, + page: int | Omit = omit, + per_page: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Retrieve a paginated list of telco data usage reports + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._get( + "/legacy/reporting/usage_reports/number_lookup", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + }, + number_lookup_list_params.NumberLookupListParams, + ), + ), + cast_to=NoneType, + ) + + def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Delete a specific telco data usage report by its ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._delete( + f"/legacy/reporting/usage_reports/number_lookup/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + +class AsyncNumberLookupResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncNumberLookupResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return AsyncNumberLookupResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncNumberLookupResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return AsyncNumberLookupResourceWithStreamingResponse(self) + + async def create( + self, + *, + aggregation_type: Literal["ALL", "BY_ORGANIZATION_MEMBER"] | Omit = omit, + end_date: Union[str, date] | Omit = omit, + managed_accounts: SequenceNotStr[str] | Omit = omit, + start_date: Union[str, date] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Submit a new telco data usage report + + Args: + aggregation_type: Type of aggregation for the report + + end_date: End date for the usage report + + managed_accounts: List of managed accounts to include in the report + + start_date: Start date for the usage report + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._post( + "/legacy/reporting/usage_reports/number_lookup", + body=await async_maybe_transform( + { + "aggregation_type": aggregation_type, + "end_date": end_date, + "managed_accounts": managed_accounts, + "start_date": start_date, + }, + number_lookup_create_params.NumberLookupCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + async def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Retrieve a specific telco data usage report by its ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._get( + f"/legacy/reporting/usage_reports/number_lookup/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + async def list( + self, + *, + page: int | Omit = omit, + per_page: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Retrieve a paginated list of telco data usage reports + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._get( + "/legacy/reporting/usage_reports/number_lookup", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "page": page, + "per_page": per_page, + }, + number_lookup_list_params.NumberLookupListParams, + ), + ), + cast_to=NoneType, + ) + + async def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Delete a specific telco data usage report by its ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._delete( + f"/legacy/reporting/usage_reports/number_lookup/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + +class NumberLookupResourceWithRawResponse: + def __init__(self, number_lookup: NumberLookupResource) -> None: + self._number_lookup = number_lookup + + self.create = to_raw_response_wrapper( + number_lookup.create, + ) + self.retrieve = to_raw_response_wrapper( + number_lookup.retrieve, + ) + self.list = to_raw_response_wrapper( + number_lookup.list, + ) + self.delete = to_raw_response_wrapper( + number_lookup.delete, + ) + + +class AsyncNumberLookupResourceWithRawResponse: + def __init__(self, number_lookup: AsyncNumberLookupResource) -> None: + self._number_lookup = number_lookup + + self.create = async_to_raw_response_wrapper( + number_lookup.create, + ) + self.retrieve = async_to_raw_response_wrapper( + number_lookup.retrieve, + ) + self.list = async_to_raw_response_wrapper( + number_lookup.list, + ) + self.delete = async_to_raw_response_wrapper( + number_lookup.delete, + ) + + +class NumberLookupResourceWithStreamingResponse: + def __init__(self, number_lookup: NumberLookupResource) -> None: + self._number_lookup = number_lookup + + self.create = to_streamed_response_wrapper( + number_lookup.create, + ) + self.retrieve = to_streamed_response_wrapper( + number_lookup.retrieve, + ) + self.list = to_streamed_response_wrapper( + number_lookup.list, + ) + self.delete = to_streamed_response_wrapper( + number_lookup.delete, + ) + + +class AsyncNumberLookupResourceWithStreamingResponse: + def __init__(self, number_lookup: AsyncNumberLookupResource) -> None: + self._number_lookup = number_lookup + + self.create = async_to_streamed_response_wrapper( + number_lookup.create, + ) + self.retrieve = async_to_streamed_response_wrapper( + number_lookup.retrieve, + ) + self.list = async_to_streamed_response_wrapper( + number_lookup.list, + ) + self.delete = async_to_streamed_response_wrapper( + number_lookup.delete, + ) diff --git a/src/telnyx/resources/legacy/reporting/usage_reports/usage_reports.py b/src/telnyx/resources/legacy/reporting/usage_reports/usage_reports.py new file mode 100644 index 00000000..0b069495 --- /dev/null +++ b/src/telnyx/resources/legacy/reporting/usage_reports/usage_reports.py @@ -0,0 +1,288 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import datetime + +import httpx + +from .voice import ( + VoiceResource, + AsyncVoiceResource, + VoiceResourceWithRawResponse, + AsyncVoiceResourceWithRawResponse, + VoiceResourceWithStreamingResponse, + AsyncVoiceResourceWithStreamingResponse, +) +from .messaging import ( + MessagingResource, + AsyncMessagingResource, + MessagingResourceWithRawResponse, + AsyncMessagingResourceWithRawResponse, + MessagingResourceWithStreamingResponse, + AsyncMessagingResourceWithStreamingResponse, +) +from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ....._utils import maybe_transform, async_maybe_transform +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from .number_lookup import ( + NumberLookupResource, + AsyncNumberLookupResource, + NumberLookupResourceWithRawResponse, + AsyncNumberLookupResourceWithRawResponse, + NumberLookupResourceWithStreamingResponse, + AsyncNumberLookupResourceWithStreamingResponse, +) +from ....._base_client import make_request_options +from .....types.legacy.reporting import usage_report_retrieve_speech_to_text_params +from .....types.legacy.reporting.usage_report_retrieve_speech_to_text_response import ( + UsageReportRetrieveSpeechToTextResponse, +) + +__all__ = ["UsageReportsResource", "AsyncUsageReportsResource"] + + +class UsageReportsResource(SyncAPIResource): + @cached_property + def messaging(self) -> MessagingResource: + return MessagingResource(self._client) + + @cached_property + def number_lookup(self) -> NumberLookupResource: + return NumberLookupResource(self._client) + + @cached_property + def voice(self) -> VoiceResource: + return VoiceResource(self._client) + + @cached_property + def with_raw_response(self) -> UsageReportsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return UsageReportsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> UsageReportsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return UsageReportsResourceWithStreamingResponse(self) + + def retrieve_speech_to_text( + self, + *, + end_date: Union[str, datetime] | Omit = omit, + start_date: Union[str, datetime] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UsageReportRetrieveSpeechToTextResponse: + """Generate and fetch speech to text usage report synchronously. + + This endpoint will + both generate and fetch the speech to text report over a specified time period. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + "/legacy/reporting/usage_reports/speech_to_text", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "end_date": end_date, + "start_date": start_date, + }, + usage_report_retrieve_speech_to_text_params.UsageReportRetrieveSpeechToTextParams, + ), + ), + cast_to=UsageReportRetrieveSpeechToTextResponse, + ) + + +class AsyncUsageReportsResource(AsyncAPIResource): + @cached_property + def messaging(self) -> AsyncMessagingResource: + return AsyncMessagingResource(self._client) + + @cached_property + def number_lookup(self) -> AsyncNumberLookupResource: + return AsyncNumberLookupResource(self._client) + + @cached_property + def voice(self) -> AsyncVoiceResource: + return AsyncVoiceResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncUsageReportsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return AsyncUsageReportsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncUsageReportsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return AsyncUsageReportsResourceWithStreamingResponse(self) + + async def retrieve_speech_to_text( + self, + *, + end_date: Union[str, datetime] | Omit = omit, + start_date: Union[str, datetime] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UsageReportRetrieveSpeechToTextResponse: + """Generate and fetch speech to text usage report synchronously. + + This endpoint will + both generate and fetch the speech to text report over a specified time period. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + "/legacy/reporting/usage_reports/speech_to_text", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "end_date": end_date, + "start_date": start_date, + }, + usage_report_retrieve_speech_to_text_params.UsageReportRetrieveSpeechToTextParams, + ), + ), + cast_to=UsageReportRetrieveSpeechToTextResponse, + ) + + +class UsageReportsResourceWithRawResponse: + def __init__(self, usage_reports: UsageReportsResource) -> None: + self._usage_reports = usage_reports + + self.retrieve_speech_to_text = to_raw_response_wrapper( + usage_reports.retrieve_speech_to_text, + ) + + @cached_property + def messaging(self) -> MessagingResourceWithRawResponse: + return MessagingResourceWithRawResponse(self._usage_reports.messaging) + + @cached_property + def number_lookup(self) -> NumberLookupResourceWithRawResponse: + return NumberLookupResourceWithRawResponse(self._usage_reports.number_lookup) + + @cached_property + def voice(self) -> VoiceResourceWithRawResponse: + return VoiceResourceWithRawResponse(self._usage_reports.voice) + + +class AsyncUsageReportsResourceWithRawResponse: + def __init__(self, usage_reports: AsyncUsageReportsResource) -> None: + self._usage_reports = usage_reports + + self.retrieve_speech_to_text = async_to_raw_response_wrapper( + usage_reports.retrieve_speech_to_text, + ) + + @cached_property + def messaging(self) -> AsyncMessagingResourceWithRawResponse: + return AsyncMessagingResourceWithRawResponse(self._usage_reports.messaging) + + @cached_property + def number_lookup(self) -> AsyncNumberLookupResourceWithRawResponse: + return AsyncNumberLookupResourceWithRawResponse(self._usage_reports.number_lookup) + + @cached_property + def voice(self) -> AsyncVoiceResourceWithRawResponse: + return AsyncVoiceResourceWithRawResponse(self._usage_reports.voice) + + +class UsageReportsResourceWithStreamingResponse: + def __init__(self, usage_reports: UsageReportsResource) -> None: + self._usage_reports = usage_reports + + self.retrieve_speech_to_text = to_streamed_response_wrapper( + usage_reports.retrieve_speech_to_text, + ) + + @cached_property + def messaging(self) -> MessagingResourceWithStreamingResponse: + return MessagingResourceWithStreamingResponse(self._usage_reports.messaging) + + @cached_property + def number_lookup(self) -> NumberLookupResourceWithStreamingResponse: + return NumberLookupResourceWithStreamingResponse(self._usage_reports.number_lookup) + + @cached_property + def voice(self) -> VoiceResourceWithStreamingResponse: + return VoiceResourceWithStreamingResponse(self._usage_reports.voice) + + +class AsyncUsageReportsResourceWithStreamingResponse: + def __init__(self, usage_reports: AsyncUsageReportsResource) -> None: + self._usage_reports = usage_reports + + self.retrieve_speech_to_text = async_to_streamed_response_wrapper( + usage_reports.retrieve_speech_to_text, + ) + + @cached_property + def messaging(self) -> AsyncMessagingResourceWithStreamingResponse: + return AsyncMessagingResourceWithStreamingResponse(self._usage_reports.messaging) + + @cached_property + def number_lookup(self) -> AsyncNumberLookupResourceWithStreamingResponse: + return AsyncNumberLookupResourceWithStreamingResponse(self._usage_reports.number_lookup) + + @cached_property + def voice(self) -> AsyncVoiceResourceWithStreamingResponse: + return AsyncVoiceResourceWithStreamingResponse(self._usage_reports.voice) diff --git a/src/telnyx/resources/legacy/reporting/usage_reports/voice.py b/src/telnyx/resources/legacy/reporting/usage_reports/voice.py new file mode 100644 index 00000000..3c1e58fb --- /dev/null +++ b/src/telnyx/resources/legacy/reporting/usage_reports/voice.py @@ -0,0 +1,493 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union, Iterable +from datetime import datetime + +import httpx + +from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ....._utils import maybe_transform, async_maybe_transform +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....._base_client import make_request_options +from .....types.legacy.reporting.usage_reports import voice_list_params, voice_create_params +from .....types.legacy.reporting.usage_reports.voice_list_response import VoiceListResponse +from .....types.legacy.reporting.usage_reports.voice_create_response import VoiceCreateResponse +from .....types.legacy.reporting.usage_reports.voice_delete_response import VoiceDeleteResponse +from .....types.legacy.reporting.usage_reports.voice_retrieve_response import VoiceRetrieveResponse + +__all__ = ["VoiceResource", "AsyncVoiceResource"] + + +class VoiceResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> VoiceResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return VoiceResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> VoiceResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return VoiceResourceWithStreamingResponse(self) + + def create( + self, + *, + end_time: Union[str, datetime], + start_time: Union[str, datetime], + aggregation_type: int | Omit = omit, + connections: Iterable[int] | Omit = omit, + managed_accounts: SequenceNotStr[str] | Omit = omit, + product_breakdown: int | Omit = omit, + select_all_managed_accounts: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VoiceCreateResponse: + """ + Creates a new legacy usage V2 CDR report request with the specified filters + + Args: + end_time: End time in ISO format + + start_time: Start time in ISO format + + aggregation_type: Aggregation type: All = 0, By Connections = 1, By Tags = 2, By Billing Group = 3 + + connections: List of connections to filter by + + managed_accounts: List of managed accounts to include + + product_breakdown: Product breakdown type: No breakdown = 0, DID vs Toll-free = 1, Country = 2, DID + vs Toll-free per Country = 3 + + select_all_managed_accounts: Whether to select all managed accounts + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/legacy/reporting/usage_reports/voice", + body=maybe_transform( + { + "end_time": end_time, + "start_time": start_time, + "aggregation_type": aggregation_type, + "connections": connections, + "managed_accounts": managed_accounts, + "product_breakdown": product_breakdown, + "select_all_managed_accounts": select_all_managed_accounts, + }, + voice_create_params.VoiceCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VoiceCreateResponse, + ) + + def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VoiceRetrieveResponse: + """ + Fetch single cdr usage report by id. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + f"/legacy/reporting/usage_reports/voice/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VoiceRetrieveResponse, + ) + + def list( + self, + *, + page: int | Omit = omit, + per_page: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VoiceListResponse: + """ + Fetch all previous requests for cdr usage reports. + + Args: + page: Page number + + per_page: Size of the page + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + "/legacy/reporting/usage_reports/voice", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + }, + voice_list_params.VoiceListParams, + ), + ), + cast_to=VoiceListResponse, + ) + + def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VoiceDeleteResponse: + """ + Deletes a specific V2 legacy usage CDR report request by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._delete( + f"/legacy/reporting/usage_reports/voice/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VoiceDeleteResponse, + ) + + +class AsyncVoiceResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncVoiceResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return AsyncVoiceResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncVoiceResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return AsyncVoiceResourceWithStreamingResponse(self) + + async def create( + self, + *, + end_time: Union[str, datetime], + start_time: Union[str, datetime], + aggregation_type: int | Omit = omit, + connections: Iterable[int] | Omit = omit, + managed_accounts: SequenceNotStr[str] | Omit = omit, + product_breakdown: int | Omit = omit, + select_all_managed_accounts: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VoiceCreateResponse: + """ + Creates a new legacy usage V2 CDR report request with the specified filters + + Args: + end_time: End time in ISO format + + start_time: Start time in ISO format + + aggregation_type: Aggregation type: All = 0, By Connections = 1, By Tags = 2, By Billing Group = 3 + + connections: List of connections to filter by + + managed_accounts: List of managed accounts to include + + product_breakdown: Product breakdown type: No breakdown = 0, DID vs Toll-free = 1, Country = 2, DID + vs Toll-free per Country = 3 + + select_all_managed_accounts: Whether to select all managed accounts + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/legacy/reporting/usage_reports/voice", + body=await async_maybe_transform( + { + "end_time": end_time, + "start_time": start_time, + "aggregation_type": aggregation_type, + "connections": connections, + "managed_accounts": managed_accounts, + "product_breakdown": product_breakdown, + "select_all_managed_accounts": select_all_managed_accounts, + }, + voice_create_params.VoiceCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VoiceCreateResponse, + ) + + async def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VoiceRetrieveResponse: + """ + Fetch single cdr usage report by id. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + f"/legacy/reporting/usage_reports/voice/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VoiceRetrieveResponse, + ) + + async def list( + self, + *, + page: int | Omit = omit, + per_page: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VoiceListResponse: + """ + Fetch all previous requests for cdr usage reports. + + Args: + page: Page number + + per_page: Size of the page + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + "/legacy/reporting/usage_reports/voice", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "page": page, + "per_page": per_page, + }, + voice_list_params.VoiceListParams, + ), + ), + cast_to=VoiceListResponse, + ) + + async def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VoiceDeleteResponse: + """ + Deletes a specific V2 legacy usage CDR report request by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._delete( + f"/legacy/reporting/usage_reports/voice/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VoiceDeleteResponse, + ) + + +class VoiceResourceWithRawResponse: + def __init__(self, voice: VoiceResource) -> None: + self._voice = voice + + self.create = to_raw_response_wrapper( + voice.create, + ) + self.retrieve = to_raw_response_wrapper( + voice.retrieve, + ) + self.list = to_raw_response_wrapper( + voice.list, + ) + self.delete = to_raw_response_wrapper( + voice.delete, + ) + + +class AsyncVoiceResourceWithRawResponse: + def __init__(self, voice: AsyncVoiceResource) -> None: + self._voice = voice + + self.create = async_to_raw_response_wrapper( + voice.create, + ) + self.retrieve = async_to_raw_response_wrapper( + voice.retrieve, + ) + self.list = async_to_raw_response_wrapper( + voice.list, + ) + self.delete = async_to_raw_response_wrapper( + voice.delete, + ) + + +class VoiceResourceWithStreamingResponse: + def __init__(self, voice: VoiceResource) -> None: + self._voice = voice + + self.create = to_streamed_response_wrapper( + voice.create, + ) + self.retrieve = to_streamed_response_wrapper( + voice.retrieve, + ) + self.list = to_streamed_response_wrapper( + voice.list, + ) + self.delete = to_streamed_response_wrapper( + voice.delete, + ) + + +class AsyncVoiceResourceWithStreamingResponse: + def __init__(self, voice: AsyncVoiceResource) -> None: + self._voice = voice + + self.create = async_to_streamed_response_wrapper( + voice.create, + ) + self.retrieve = async_to_streamed_response_wrapper( + voice.retrieve, + ) + self.list = async_to_streamed_response_wrapper( + voice.list, + ) + self.delete = async_to_streamed_response_wrapper( + voice.delete, + ) diff --git a/src/telnyx/resources/oauth.py b/src/telnyx/resources/oauth.py new file mode 100644 index 00000000..ebfb38ea --- /dev/null +++ b/src/telnyx/resources/oauth.py @@ -0,0 +1,855 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Literal + +import httpx + +from ..types import ( + oauth_token_params, + oauth_grants_params, + oauth_register_params, + oauth_introspect_params, + oauth_retrieve_authorize_params, +) +from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, SequenceNotStr, omit, not_given +from .._utils import maybe_transform, async_maybe_transform +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from .._base_client import make_request_options +from ..types.oauth_token_response import OAuthTokenResponse +from ..types.oauth_grants_response import OAuthGrantsResponse +from ..types.oauth_register_response import OAuthRegisterResponse +from ..types.oauth_retrieve_response import OAuthRetrieveResponse +from ..types.oauth_introspect_response import OAuthIntrospectResponse +from ..types.oauth_retrieve_jwks_response import OAuthRetrieveJwksResponse + +__all__ = ["OAuthResource", "AsyncOAuthResource"] + + +class OAuthResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> OAuthResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return OAuthResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> OAuthResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return OAuthResourceWithStreamingResponse(self) + + def retrieve( + self, + consent_token: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthRetrieveResponse: + """ + Retrieve details about an OAuth consent token + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not consent_token: + raise ValueError(f"Expected a non-empty value for `consent_token` but received {consent_token!r}") + return self._get( + f"/oauth/consent/{consent_token}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthRetrieveResponse, + ) + + def grants( + self, + *, + allowed: bool, + consent_token: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthGrantsResponse: + """ + Create an OAuth authorization grant + + Args: + allowed: Whether the grant is allowed + + consent_token: Consent token + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/oauth/grants", + body=maybe_transform( + { + "allowed": allowed, + "consent_token": consent_token, + }, + oauth_grants_params.OAuthGrantsParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthGrantsResponse, + ) + + def introspect( + self, + *, + token: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthIntrospectResponse: + """ + Introspect an OAuth access token to check its validity and metadata + + Args: + token: The token to introspect + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/oauth/introspect", + body=maybe_transform({"token": token}, oauth_introspect_params.OAuthIntrospectParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthIntrospectResponse, + ) + + def register( + self, + *, + client_name: str | Omit = omit, + grant_types: List[Literal["authorization_code", "client_credentials", "refresh_token"]] | Omit = omit, + logo_uri: str | Omit = omit, + policy_uri: str | Omit = omit, + redirect_uris: SequenceNotStr[str] | Omit = omit, + response_types: SequenceNotStr[str] | Omit = omit, + scope: str | Omit = omit, + token_endpoint_auth_method: Literal["none", "client_secret_basic", "client_secret_post"] | Omit = omit, + tos_uri: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthRegisterResponse: + """ + Register a new OAuth client dynamically (RFC 7591) + + Args: + client_name: Human-readable string name of the client to be presented to the end-user + + grant_types: Array of OAuth 2.0 grant type strings that the client may use + + logo_uri: URL of the client logo + + policy_uri: URL of the client's privacy policy + + redirect_uris: Array of redirection URI strings for use in redirect-based flows + + response_types: Array of the OAuth 2.0 response type strings that the client may use + + scope: Space-separated string of scope values that the client may use + + token_endpoint_auth_method: Authentication method for the token endpoint + + tos_uri: URL of the client's terms of service + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/oauth/register", + body=maybe_transform( + { + "client_name": client_name, + "grant_types": grant_types, + "logo_uri": logo_uri, + "policy_uri": policy_uri, + "redirect_uris": redirect_uris, + "response_types": response_types, + "scope": scope, + "token_endpoint_auth_method": token_endpoint_auth_method, + "tos_uri": tos_uri, + }, + oauth_register_params.OAuthRegisterParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthRegisterResponse, + ) + + def retrieve_authorize( + self, + *, + client_id: str, + redirect_uri: str, + response_type: Literal["code"], + code_challenge: str | Omit = omit, + code_challenge_method: Literal["plain", "S256"] | Omit = omit, + scope: str | Omit = omit, + state: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + OAuth 2.0 authorization endpoint for the authorization code flow + + Args: + client_id: OAuth client identifier + + redirect_uri: Redirect URI + + response_type: OAuth response type + + code_challenge: PKCE code challenge + + code_challenge_method: PKCE code challenge method + + scope: Space-separated list of requested scopes + + state: State parameter for CSRF protection + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._get( + "/oauth/authorize", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "client_id": client_id, + "redirect_uri": redirect_uri, + "response_type": response_type, + "code_challenge": code_challenge, + "code_challenge_method": code_challenge_method, + "scope": scope, + "state": state, + }, + oauth_retrieve_authorize_params.OAuthRetrieveAuthorizeParams, + ), + ), + cast_to=NoneType, + ) + + def retrieve_jwks( + self, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthRetrieveJwksResponse: + """Retrieve the JSON Web Key Set for token verification""" + return self._get( + "/oauth/jwks", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthRetrieveJwksResponse, + ) + + def token( + self, + *, + grant_type: Literal["client_credentials", "authorization_code", "refresh_token"], + client_id: str | Omit = omit, + client_secret: str | Omit = omit, + code: str | Omit = omit, + code_verifier: str | Omit = omit, + redirect_uri: str | Omit = omit, + refresh_token: str | Omit = omit, + scope: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthTokenResponse: + """ + Exchange authorization code, client credentials, or refresh token for access + token + + Args: + grant_type: OAuth 2.0 grant type + + client_id: OAuth client ID (if not using HTTP Basic auth) + + client_secret: OAuth client secret (if not using HTTP Basic auth) + + code: Authorization code (for authorization_code flow) + + code_verifier: PKCE code verifier (for authorization_code flow) + + redirect_uri: Redirect URI (for authorization_code flow) + + refresh_token: Refresh token (for refresh_token flow) + + scope: Space-separated list of requested scopes (for client_credentials) + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/oauth/token", + body=maybe_transform( + { + "grant_type": grant_type, + "client_id": client_id, + "client_secret": client_secret, + "code": code, + "code_verifier": code_verifier, + "redirect_uri": redirect_uri, + "refresh_token": refresh_token, + "scope": scope, + }, + oauth_token_params.OAuthTokenParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthTokenResponse, + ) + + +class AsyncOAuthResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncOAuthResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return AsyncOAuthResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncOAuthResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return AsyncOAuthResourceWithStreamingResponse(self) + + async def retrieve( + self, + consent_token: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthRetrieveResponse: + """ + Retrieve details about an OAuth consent token + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not consent_token: + raise ValueError(f"Expected a non-empty value for `consent_token` but received {consent_token!r}") + return await self._get( + f"/oauth/consent/{consent_token}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthRetrieveResponse, + ) + + async def grants( + self, + *, + allowed: bool, + consent_token: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthGrantsResponse: + """ + Create an OAuth authorization grant + + Args: + allowed: Whether the grant is allowed + + consent_token: Consent token + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/oauth/grants", + body=await async_maybe_transform( + { + "allowed": allowed, + "consent_token": consent_token, + }, + oauth_grants_params.OAuthGrantsParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthGrantsResponse, + ) + + async def introspect( + self, + *, + token: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthIntrospectResponse: + """ + Introspect an OAuth access token to check its validity and metadata + + Args: + token: The token to introspect + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/oauth/introspect", + body=await async_maybe_transform({"token": token}, oauth_introspect_params.OAuthIntrospectParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthIntrospectResponse, + ) + + async def register( + self, + *, + client_name: str | Omit = omit, + grant_types: List[Literal["authorization_code", "client_credentials", "refresh_token"]] | Omit = omit, + logo_uri: str | Omit = omit, + policy_uri: str | Omit = omit, + redirect_uris: SequenceNotStr[str] | Omit = omit, + response_types: SequenceNotStr[str] | Omit = omit, + scope: str | Omit = omit, + token_endpoint_auth_method: Literal["none", "client_secret_basic", "client_secret_post"] | Omit = omit, + tos_uri: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthRegisterResponse: + """ + Register a new OAuth client dynamically (RFC 7591) + + Args: + client_name: Human-readable string name of the client to be presented to the end-user + + grant_types: Array of OAuth 2.0 grant type strings that the client may use + + logo_uri: URL of the client logo + + policy_uri: URL of the client's privacy policy + + redirect_uris: Array of redirection URI strings for use in redirect-based flows + + response_types: Array of the OAuth 2.0 response type strings that the client may use + + scope: Space-separated string of scope values that the client may use + + token_endpoint_auth_method: Authentication method for the token endpoint + + tos_uri: URL of the client's terms of service + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/oauth/register", + body=await async_maybe_transform( + { + "client_name": client_name, + "grant_types": grant_types, + "logo_uri": logo_uri, + "policy_uri": policy_uri, + "redirect_uris": redirect_uris, + "response_types": response_types, + "scope": scope, + "token_endpoint_auth_method": token_endpoint_auth_method, + "tos_uri": tos_uri, + }, + oauth_register_params.OAuthRegisterParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthRegisterResponse, + ) + + async def retrieve_authorize( + self, + *, + client_id: str, + redirect_uri: str, + response_type: Literal["code"], + code_challenge: str | Omit = omit, + code_challenge_method: Literal["plain", "S256"] | Omit = omit, + scope: str | Omit = omit, + state: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + OAuth 2.0 authorization endpoint for the authorization code flow + + Args: + client_id: OAuth client identifier + + redirect_uri: Redirect URI + + response_type: OAuth response type + + code_challenge: PKCE code challenge + + code_challenge_method: PKCE code challenge method + + scope: Space-separated list of requested scopes + + state: State parameter for CSRF protection + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._get( + "/oauth/authorize", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "client_id": client_id, + "redirect_uri": redirect_uri, + "response_type": response_type, + "code_challenge": code_challenge, + "code_challenge_method": code_challenge_method, + "scope": scope, + "state": state, + }, + oauth_retrieve_authorize_params.OAuthRetrieveAuthorizeParams, + ), + ), + cast_to=NoneType, + ) + + async def retrieve_jwks( + self, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthRetrieveJwksResponse: + """Retrieve the JSON Web Key Set for token verification""" + return await self._get( + "/oauth/jwks", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthRetrieveJwksResponse, + ) + + async def token( + self, + *, + grant_type: Literal["client_credentials", "authorization_code", "refresh_token"], + client_id: str | Omit = omit, + client_secret: str | Omit = omit, + code: str | Omit = omit, + code_verifier: str | Omit = omit, + redirect_uri: str | Omit = omit, + refresh_token: str | Omit = omit, + scope: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthTokenResponse: + """ + Exchange authorization code, client credentials, or refresh token for access + token + + Args: + grant_type: OAuth 2.0 grant type + + client_id: OAuth client ID (if not using HTTP Basic auth) + + client_secret: OAuth client secret (if not using HTTP Basic auth) + + code: Authorization code (for authorization_code flow) + + code_verifier: PKCE code verifier (for authorization_code flow) + + redirect_uri: Redirect URI (for authorization_code flow) + + refresh_token: Refresh token (for refresh_token flow) + + scope: Space-separated list of requested scopes (for client_credentials) + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/oauth/token", + body=await async_maybe_transform( + { + "grant_type": grant_type, + "client_id": client_id, + "client_secret": client_secret, + "code": code, + "code_verifier": code_verifier, + "redirect_uri": redirect_uri, + "refresh_token": refresh_token, + "scope": scope, + }, + oauth_token_params.OAuthTokenParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthTokenResponse, + ) + + +class OAuthResourceWithRawResponse: + def __init__(self, oauth: OAuthResource) -> None: + self._oauth = oauth + + self.retrieve = to_raw_response_wrapper( + oauth.retrieve, + ) + self.grants = to_raw_response_wrapper( + oauth.grants, + ) + self.introspect = to_raw_response_wrapper( + oauth.introspect, + ) + self.register = to_raw_response_wrapper( + oauth.register, + ) + self.retrieve_authorize = to_raw_response_wrapper( + oauth.retrieve_authorize, + ) + self.retrieve_jwks = to_raw_response_wrapper( + oauth.retrieve_jwks, + ) + self.token = to_raw_response_wrapper( + oauth.token, + ) + + +class AsyncOAuthResourceWithRawResponse: + def __init__(self, oauth: AsyncOAuthResource) -> None: + self._oauth = oauth + + self.retrieve = async_to_raw_response_wrapper( + oauth.retrieve, + ) + self.grants = async_to_raw_response_wrapper( + oauth.grants, + ) + self.introspect = async_to_raw_response_wrapper( + oauth.introspect, + ) + self.register = async_to_raw_response_wrapper( + oauth.register, + ) + self.retrieve_authorize = async_to_raw_response_wrapper( + oauth.retrieve_authorize, + ) + self.retrieve_jwks = async_to_raw_response_wrapper( + oauth.retrieve_jwks, + ) + self.token = async_to_raw_response_wrapper( + oauth.token, + ) + + +class OAuthResourceWithStreamingResponse: + def __init__(self, oauth: OAuthResource) -> None: + self._oauth = oauth + + self.retrieve = to_streamed_response_wrapper( + oauth.retrieve, + ) + self.grants = to_streamed_response_wrapper( + oauth.grants, + ) + self.introspect = to_streamed_response_wrapper( + oauth.introspect, + ) + self.register = to_streamed_response_wrapper( + oauth.register, + ) + self.retrieve_authorize = to_streamed_response_wrapper( + oauth.retrieve_authorize, + ) + self.retrieve_jwks = to_streamed_response_wrapper( + oauth.retrieve_jwks, + ) + self.token = to_streamed_response_wrapper( + oauth.token, + ) + + +class AsyncOAuthResourceWithStreamingResponse: + def __init__(self, oauth: AsyncOAuthResource) -> None: + self._oauth = oauth + + self.retrieve = async_to_streamed_response_wrapper( + oauth.retrieve, + ) + self.grants = async_to_streamed_response_wrapper( + oauth.grants, + ) + self.introspect = async_to_streamed_response_wrapper( + oauth.introspect, + ) + self.register = async_to_streamed_response_wrapper( + oauth.register, + ) + self.retrieve_authorize = async_to_streamed_response_wrapper( + oauth.retrieve_authorize, + ) + self.retrieve_jwks = async_to_streamed_response_wrapper( + oauth.retrieve_jwks, + ) + self.token = async_to_streamed_response_wrapper( + oauth.token, + ) diff --git a/src/telnyx/resources/oauth_clients.py b/src/telnyx/resources/oauth_clients.py new file mode 100644 index 00000000..1926d45e --- /dev/null +++ b/src/telnyx/resources/oauth_clients.py @@ -0,0 +1,711 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Literal + +import httpx + +from ..types import oauth_client_list_params, oauth_client_create_params, oauth_client_update_params +from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, SequenceNotStr, omit, not_given +from .._utils import maybe_transform, async_maybe_transform +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from .._base_client import make_request_options +from ..types.oauth_client_list_response import OAuthClientListResponse +from ..types.oauth_client_create_response import OAuthClientCreateResponse +from ..types.oauth_client_update_response import OAuthClientUpdateResponse +from ..types.oauth_client_retrieve_response import OAuthClientRetrieveResponse + +__all__ = ["OAuthClientsResource", "AsyncOAuthClientsResource"] + + +class OAuthClientsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> OAuthClientsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return OAuthClientsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> OAuthClientsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return OAuthClientsResourceWithStreamingResponse(self) + + def create( + self, + *, + allowed_grant_types: List[Literal["client_credentials", "authorization_code", "refresh_token"]], + allowed_scopes: SequenceNotStr[str], + client_type: Literal["public", "confidential"], + name: str, + logo_uri: str | Omit = omit, + policy_uri: str | Omit = omit, + redirect_uris: SequenceNotStr[str] | Omit = omit, + require_pkce: bool | Omit = omit, + tos_uri: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthClientCreateResponse: + """ + Create a new OAuth client + + Args: + allowed_grant_types: List of allowed OAuth grant types + + allowed_scopes: List of allowed OAuth scopes + + client_type: OAuth client type + + name: The name of the OAuth client + + logo_uri: URL of the client logo + + policy_uri: URL of the client's privacy policy + + redirect_uris: List of redirect URIs (required for authorization_code flow) + + require_pkce: Whether PKCE (Proof Key for Code Exchange) is required for this client + + tos_uri: URL of the client's terms of service + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/oauth_clients", + body=maybe_transform( + { + "allowed_grant_types": allowed_grant_types, + "allowed_scopes": allowed_scopes, + "client_type": client_type, + "name": name, + "logo_uri": logo_uri, + "policy_uri": policy_uri, + "redirect_uris": redirect_uris, + "require_pkce": require_pkce, + "tos_uri": tos_uri, + }, + oauth_client_create_params.OAuthClientCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthClientCreateResponse, + ) + + def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthClientRetrieveResponse: + """ + Retrieve a single OAuth client by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + f"/oauth_clients/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthClientRetrieveResponse, + ) + + def update( + self, + id: str, + *, + allowed_grant_types: List[Literal["client_credentials", "authorization_code", "refresh_token"]] | Omit = omit, + allowed_scopes: SequenceNotStr[str] | Omit = omit, + logo_uri: str | Omit = omit, + name: str | Omit = omit, + policy_uri: str | Omit = omit, + redirect_uris: SequenceNotStr[str] | Omit = omit, + require_pkce: bool | Omit = omit, + tos_uri: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthClientUpdateResponse: + """ + Update an existing OAuth client + + Args: + allowed_grant_types: List of allowed OAuth grant types + + allowed_scopes: List of allowed OAuth scopes + + logo_uri: URL of the client logo + + name: The name of the OAuth client + + policy_uri: URL of the client's privacy policy + + redirect_uris: List of redirect URIs + + require_pkce: Whether PKCE (Proof Key for Code Exchange) is required for this client + + tos_uri: URL of the client's terms of service + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._put( + f"/oauth_clients/{id}", + body=maybe_transform( + { + "allowed_grant_types": allowed_grant_types, + "allowed_scopes": allowed_scopes, + "logo_uri": logo_uri, + "name": name, + "policy_uri": policy_uri, + "redirect_uris": redirect_uris, + "require_pkce": require_pkce, + "tos_uri": tos_uri, + }, + oauth_client_update_params.OAuthClientUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthClientUpdateResponse, + ) + + def list( + self, + *, + filter_allowed_grant_types_contains: Literal["client_credentials", "authorization_code", "refresh_token"] + | Omit = omit, + filter_client_id: str | Omit = omit, + filter_client_type: Literal["confidential", "public"] | Omit = omit, + filter_name: str | Omit = omit, + filter_name_contains: str | Omit = omit, + filter_verified: bool | Omit = omit, + page_number: int | Omit = omit, + page_size: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthClientListResponse: + """ + Retrieve a paginated list of OAuth clients for the authenticated user + + Args: + filter_allowed_grant_types_contains: Filter by allowed grant type + + filter_client_id: Filter by client ID + + filter_client_type: Filter by client type + + filter_name: Filter by exact client name + + filter_name_contains: Filter by client name containing text + + filter_verified: Filter by verification status + + page_number: Page number + + page_size: Number of results per page + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + "/oauth_clients", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "filter_allowed_grant_types_contains": filter_allowed_grant_types_contains, + "filter_client_id": filter_client_id, + "filter_client_type": filter_client_type, + "filter_name": filter_name, + "filter_name_contains": filter_name_contains, + "filter_verified": filter_verified, + "page_number": page_number, + "page_size": page_size, + }, + oauth_client_list_params.OAuthClientListParams, + ), + ), + cast_to=OAuthClientListResponse, + ) + + def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Delete an OAuth client + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._delete( + f"/oauth_clients/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + +class AsyncOAuthClientsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncOAuthClientsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return AsyncOAuthClientsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncOAuthClientsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return AsyncOAuthClientsResourceWithStreamingResponse(self) + + async def create( + self, + *, + allowed_grant_types: List[Literal["client_credentials", "authorization_code", "refresh_token"]], + allowed_scopes: SequenceNotStr[str], + client_type: Literal["public", "confidential"], + name: str, + logo_uri: str | Omit = omit, + policy_uri: str | Omit = omit, + redirect_uris: SequenceNotStr[str] | Omit = omit, + require_pkce: bool | Omit = omit, + tos_uri: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthClientCreateResponse: + """ + Create a new OAuth client + + Args: + allowed_grant_types: List of allowed OAuth grant types + + allowed_scopes: List of allowed OAuth scopes + + client_type: OAuth client type + + name: The name of the OAuth client + + logo_uri: URL of the client logo + + policy_uri: URL of the client's privacy policy + + redirect_uris: List of redirect URIs (required for authorization_code flow) + + require_pkce: Whether PKCE (Proof Key for Code Exchange) is required for this client + + tos_uri: URL of the client's terms of service + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/oauth_clients", + body=await async_maybe_transform( + { + "allowed_grant_types": allowed_grant_types, + "allowed_scopes": allowed_scopes, + "client_type": client_type, + "name": name, + "logo_uri": logo_uri, + "policy_uri": policy_uri, + "redirect_uris": redirect_uris, + "require_pkce": require_pkce, + "tos_uri": tos_uri, + }, + oauth_client_create_params.OAuthClientCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthClientCreateResponse, + ) + + async def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthClientRetrieveResponse: + """ + Retrieve a single OAuth client by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + f"/oauth_clients/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthClientRetrieveResponse, + ) + + async def update( + self, + id: str, + *, + allowed_grant_types: List[Literal["client_credentials", "authorization_code", "refresh_token"]] | Omit = omit, + allowed_scopes: SequenceNotStr[str] | Omit = omit, + logo_uri: str | Omit = omit, + name: str | Omit = omit, + policy_uri: str | Omit = omit, + redirect_uris: SequenceNotStr[str] | Omit = omit, + require_pkce: bool | Omit = omit, + tos_uri: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthClientUpdateResponse: + """ + Update an existing OAuth client + + Args: + allowed_grant_types: List of allowed OAuth grant types + + allowed_scopes: List of allowed OAuth scopes + + logo_uri: URL of the client logo + + name: The name of the OAuth client + + policy_uri: URL of the client's privacy policy + + redirect_uris: List of redirect URIs + + require_pkce: Whether PKCE (Proof Key for Code Exchange) is required for this client + + tos_uri: URL of the client's terms of service + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._put( + f"/oauth_clients/{id}", + body=await async_maybe_transform( + { + "allowed_grant_types": allowed_grant_types, + "allowed_scopes": allowed_scopes, + "logo_uri": logo_uri, + "name": name, + "policy_uri": policy_uri, + "redirect_uris": redirect_uris, + "require_pkce": require_pkce, + "tos_uri": tos_uri, + }, + oauth_client_update_params.OAuthClientUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthClientUpdateResponse, + ) + + async def list( + self, + *, + filter_allowed_grant_types_contains: Literal["client_credentials", "authorization_code", "refresh_token"] + | Omit = omit, + filter_client_id: str | Omit = omit, + filter_client_type: Literal["confidential", "public"] | Omit = omit, + filter_name: str | Omit = omit, + filter_name_contains: str | Omit = omit, + filter_verified: bool | Omit = omit, + page_number: int | Omit = omit, + page_size: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthClientListResponse: + """ + Retrieve a paginated list of OAuth clients for the authenticated user + + Args: + filter_allowed_grant_types_contains: Filter by allowed grant type + + filter_client_id: Filter by client ID + + filter_client_type: Filter by client type + + filter_name: Filter by exact client name + + filter_name_contains: Filter by client name containing text + + filter_verified: Filter by verification status + + page_number: Page number + + page_size: Number of results per page + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + "/oauth_clients", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "filter_allowed_grant_types_contains": filter_allowed_grant_types_contains, + "filter_client_id": filter_client_id, + "filter_client_type": filter_client_type, + "filter_name": filter_name, + "filter_name_contains": filter_name_contains, + "filter_verified": filter_verified, + "page_number": page_number, + "page_size": page_size, + }, + oauth_client_list_params.OAuthClientListParams, + ), + ), + cast_to=OAuthClientListResponse, + ) + + async def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Delete an OAuth client + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._delete( + f"/oauth_clients/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + +class OAuthClientsResourceWithRawResponse: + def __init__(self, oauth_clients: OAuthClientsResource) -> None: + self._oauth_clients = oauth_clients + + self.create = to_raw_response_wrapper( + oauth_clients.create, + ) + self.retrieve = to_raw_response_wrapper( + oauth_clients.retrieve, + ) + self.update = to_raw_response_wrapper( + oauth_clients.update, + ) + self.list = to_raw_response_wrapper( + oauth_clients.list, + ) + self.delete = to_raw_response_wrapper( + oauth_clients.delete, + ) + + +class AsyncOAuthClientsResourceWithRawResponse: + def __init__(self, oauth_clients: AsyncOAuthClientsResource) -> None: + self._oauth_clients = oauth_clients + + self.create = async_to_raw_response_wrapper( + oauth_clients.create, + ) + self.retrieve = async_to_raw_response_wrapper( + oauth_clients.retrieve, + ) + self.update = async_to_raw_response_wrapper( + oauth_clients.update, + ) + self.list = async_to_raw_response_wrapper( + oauth_clients.list, + ) + self.delete = async_to_raw_response_wrapper( + oauth_clients.delete, + ) + + +class OAuthClientsResourceWithStreamingResponse: + def __init__(self, oauth_clients: OAuthClientsResource) -> None: + self._oauth_clients = oauth_clients + + self.create = to_streamed_response_wrapper( + oauth_clients.create, + ) + self.retrieve = to_streamed_response_wrapper( + oauth_clients.retrieve, + ) + self.update = to_streamed_response_wrapper( + oauth_clients.update, + ) + self.list = to_streamed_response_wrapper( + oauth_clients.list, + ) + self.delete = to_streamed_response_wrapper( + oauth_clients.delete, + ) + + +class AsyncOAuthClientsResourceWithStreamingResponse: + def __init__(self, oauth_clients: AsyncOAuthClientsResource) -> None: + self._oauth_clients = oauth_clients + + self.create = async_to_streamed_response_wrapper( + oauth_clients.create, + ) + self.retrieve = async_to_streamed_response_wrapper( + oauth_clients.retrieve, + ) + self.update = async_to_streamed_response_wrapper( + oauth_clients.update, + ) + self.list = async_to_streamed_response_wrapper( + oauth_clients.list, + ) + self.delete = async_to_streamed_response_wrapper( + oauth_clients.delete, + ) diff --git a/src/telnyx/resources/oauth_grants.py b/src/telnyx/resources/oauth_grants.py new file mode 100644 index 00000000..3bec2f22 --- /dev/null +++ b/src/telnyx/resources/oauth_grants.py @@ -0,0 +1,349 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ..types import oauth_grant_list_params +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from .._utils import maybe_transform, async_maybe_transform +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from .._base_client import make_request_options +from ..types.oauth_grant_list_response import OAuthGrantListResponse +from ..types.oauth_grant_delete_response import OAuthGrantDeleteResponse +from ..types.oauth_grant_retrieve_response import OAuthGrantRetrieveResponse + +__all__ = ["OAuthGrantsResource", "AsyncOAuthGrantsResource"] + + +class OAuthGrantsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> OAuthGrantsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return OAuthGrantsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> OAuthGrantsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return OAuthGrantsResourceWithStreamingResponse(self) + + def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthGrantRetrieveResponse: + """ + Retrieve a single OAuth grant by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + f"/oauth_grants/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthGrantRetrieveResponse, + ) + + def list( + self, + *, + page_number: int | Omit = omit, + page_size: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthGrantListResponse: + """ + Retrieve a paginated list of OAuth grants for the authenticated user + + Args: + page_number: Page number + + page_size: Number of results per page + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + "/oauth_grants", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page_number": page_number, + "page_size": page_size, + }, + oauth_grant_list_params.OAuthGrantListParams, + ), + ), + cast_to=OAuthGrantListResponse, + ) + + def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthGrantDeleteResponse: + """ + Revoke an OAuth grant + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._delete( + f"/oauth_grants/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthGrantDeleteResponse, + ) + + +class AsyncOAuthGrantsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncOAuthGrantsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return AsyncOAuthGrantsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncOAuthGrantsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return AsyncOAuthGrantsResourceWithStreamingResponse(self) + + async def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthGrantRetrieveResponse: + """ + Retrieve a single OAuth grant by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + f"/oauth_grants/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthGrantRetrieveResponse, + ) + + async def list( + self, + *, + page_number: int | Omit = omit, + page_size: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthGrantListResponse: + """ + Retrieve a paginated list of OAuth grants for the authenticated user + + Args: + page_number: Page number + + page_size: Number of results per page + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + "/oauth_grants", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "page_number": page_number, + "page_size": page_size, + }, + oauth_grant_list_params.OAuthGrantListParams, + ), + ), + cast_to=OAuthGrantListResponse, + ) + + async def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OAuthGrantDeleteResponse: + """ + Revoke an OAuth grant + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._delete( + f"/oauth_grants/{id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthGrantDeleteResponse, + ) + + +class OAuthGrantsResourceWithRawResponse: + def __init__(self, oauth_grants: OAuthGrantsResource) -> None: + self._oauth_grants = oauth_grants + + self.retrieve = to_raw_response_wrapper( + oauth_grants.retrieve, + ) + self.list = to_raw_response_wrapper( + oauth_grants.list, + ) + self.delete = to_raw_response_wrapper( + oauth_grants.delete, + ) + + +class AsyncOAuthGrantsResourceWithRawResponse: + def __init__(self, oauth_grants: AsyncOAuthGrantsResource) -> None: + self._oauth_grants = oauth_grants + + self.retrieve = async_to_raw_response_wrapper( + oauth_grants.retrieve, + ) + self.list = async_to_raw_response_wrapper( + oauth_grants.list, + ) + self.delete = async_to_raw_response_wrapper( + oauth_grants.delete, + ) + + +class OAuthGrantsResourceWithStreamingResponse: + def __init__(self, oauth_grants: OAuthGrantsResource) -> None: + self._oauth_grants = oauth_grants + + self.retrieve = to_streamed_response_wrapper( + oauth_grants.retrieve, + ) + self.list = to_streamed_response_wrapper( + oauth_grants.list, + ) + self.delete = to_streamed_response_wrapper( + oauth_grants.delete, + ) + + +class AsyncOAuthGrantsResourceWithStreamingResponse: + def __init__(self, oauth_grants: AsyncOAuthGrantsResource) -> None: + self._oauth_grants = oauth_grants + + self.retrieve = async_to_streamed_response_wrapper( + oauth_grants.retrieve, + ) + self.list = async_to_streamed_response_wrapper( + oauth_grants.list, + ) + self.delete = async_to_streamed_response_wrapper( + oauth_grants.delete, + ) diff --git a/src/telnyx/resources/phone_numbers/jobs.py b/src/telnyx/resources/phone_numbers/jobs.py index 8414821a..0aa87353 100644 --- a/src/telnyx/resources/phone_numbers/jobs.py +++ b/src/telnyx/resources/phone_numbers/jobs.py @@ -181,6 +181,7 @@ def update_batch( billing_group_id: str | Omit = omit, connection_id: str | Omit = omit, customer_reference: str | Omit = omit, + deletion_lock_enabled: bool | Omit = omit, external_pin: str | Omit = omit, hd_voice_enabled: bool | Omit = omit, tags: SequenceNotStr[str] | Omit = omit, @@ -224,6 +225,10 @@ def update_batch( customer_reference: A customer reference string for customer look ups. + deletion_lock_enabled: Indicates whether to enable or disable the deletion lock on each phone number. + When enabled, this prevents the phone number from being deleted via the API or + Telnyx portal. + external_pin: If someone attempts to port your phone number away from Telnyx and your phone number has an external PIN set, we will attempt to verify that you provided the correct external PIN to the winning carrier. Note that not all carriers @@ -251,6 +256,7 @@ def update_batch( "billing_group_id": billing_group_id, "connection_id": connection_id, "customer_reference": customer_reference, + "deletion_lock_enabled": deletion_lock_enabled, "external_pin": external_pin, "hd_voice_enabled": hd_voice_enabled, "tags": tags, @@ -466,6 +472,7 @@ async def update_batch( billing_group_id: str | Omit = omit, connection_id: str | Omit = omit, customer_reference: str | Omit = omit, + deletion_lock_enabled: bool | Omit = omit, external_pin: str | Omit = omit, hd_voice_enabled: bool | Omit = omit, tags: SequenceNotStr[str] | Omit = omit, @@ -509,6 +516,10 @@ async def update_batch( customer_reference: A customer reference string for customer look ups. + deletion_lock_enabled: Indicates whether to enable or disable the deletion lock on each phone number. + When enabled, this prevents the phone number from being deleted via the API or + Telnyx portal. + external_pin: If someone attempts to port your phone number away from Telnyx and your phone number has an external PIN set, we will attempt to verify that you provided the correct external PIN to the winning carrier. Note that not all carriers @@ -536,6 +547,7 @@ async def update_batch( "billing_group_id": billing_group_id, "connection_id": connection_id, "customer_reference": customer_reference, + "deletion_lock_enabled": deletion_lock_enabled, "external_pin": external_pin, "hd_voice_enabled": hd_voice_enabled, "tags": tags, diff --git a/src/telnyx/resources/porting_orders/porting_orders.py b/src/telnyx/resources/porting_orders/porting_orders.py index 06f7df7b..8679fd82 100644 --- a/src/telnyx/resources/porting_orders/porting_orders.py +++ b/src/telnyx/resources/porting_orders/porting_orders.py @@ -194,6 +194,7 @@ def create( self, *, phone_numbers: SequenceNotStr[str], + customer_group_reference: str | Omit = omit, customer_reference: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -208,6 +209,8 @@ def create( Args: phone_numbers: The list of +E.164 formatted phone numbers + customer_group_reference: A customer-specified group reference for customer bookkeeping purposes + customer_reference: A customer-specified reference number for customer bookkeeping purposes extra_headers: Send extra headers @@ -223,6 +226,7 @@ def create( body=maybe_transform( { "phone_numbers": phone_numbers, + "customer_group_reference": customer_group_reference, "customer_reference": customer_reference, }, porting_order_create_params.PortingOrderCreateParams, @@ -281,6 +285,7 @@ def update( id: str, *, activation_settings: porting_order_update_params.ActivationSettings | Omit = omit, + customer_group_reference: str | Omit = omit, customer_reference: str | Omit = omit, documents: PortingOrderDocumentsParam | Omit = omit, end_user: PortingOrderEndUserParam | Omit = omit, @@ -335,6 +340,7 @@ def update( body=maybe_transform( { "activation_settings": activation_settings, + "customer_group_reference": customer_group_reference, "customer_reference": customer_reference, "documents": documents, "end_user": end_user, @@ -374,10 +380,10 @@ def list( Args: filter: Consolidated filter parameter (deepObject style). Originally: - filter[customer_reference], filter[parent_support_key], - filter[phone_numbers.country_code], filter[phone_numbers.carrier_name], - filter[misc.type], filter[end_user.admin.entity_name], - filter[end_user.admin.auth_person_name], + filter[customer_reference], filter[customer_group_reference], + filter[parent_support_key], filter[phone_numbers.country_code], + filter[phone_numbers.carrier_name], filter[misc.type], + filter[end_user.admin.entity_name], filter[end_user.admin.auth_person_name], filter[activation_settings.fast_port_eligible], filter[activation_settings.foc_datetime_requested][gt], filter[activation_settings.foc_datetime_requested][lt], @@ -693,6 +699,7 @@ async def create( self, *, phone_numbers: SequenceNotStr[str], + customer_group_reference: str | Omit = omit, customer_reference: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -707,6 +714,8 @@ async def create( Args: phone_numbers: The list of +E.164 formatted phone numbers + customer_group_reference: A customer-specified group reference for customer bookkeeping purposes + customer_reference: A customer-specified reference number for customer bookkeeping purposes extra_headers: Send extra headers @@ -722,6 +731,7 @@ async def create( body=await async_maybe_transform( { "phone_numbers": phone_numbers, + "customer_group_reference": customer_group_reference, "customer_reference": customer_reference, }, porting_order_create_params.PortingOrderCreateParams, @@ -780,6 +790,7 @@ async def update( id: str, *, activation_settings: porting_order_update_params.ActivationSettings | Omit = omit, + customer_group_reference: str | Omit = omit, customer_reference: str | Omit = omit, documents: PortingOrderDocumentsParam | Omit = omit, end_user: PortingOrderEndUserParam | Omit = omit, @@ -834,6 +845,7 @@ async def update( body=await async_maybe_transform( { "activation_settings": activation_settings, + "customer_group_reference": customer_group_reference, "customer_reference": customer_reference, "documents": documents, "end_user": end_user, @@ -873,10 +885,10 @@ async def list( Args: filter: Consolidated filter parameter (deepObject style). Originally: - filter[customer_reference], filter[parent_support_key], - filter[phone_numbers.country_code], filter[phone_numbers.carrier_name], - filter[misc.type], filter[end_user.admin.entity_name], - filter[end_user.admin.auth_person_name], + filter[customer_reference], filter[customer_group_reference], + filter[parent_support_key], filter[phone_numbers.country_code], + filter[phone_numbers.carrier_name], filter[misc.type], + filter[end_user.admin.entity_name], filter[end_user.admin.auth_person_name], filter[activation_settings.fast_port_eligible], filter[activation_settings.foc_datetime_requested][gt], filter[activation_settings.foc_datetime_requested][lt], diff --git a/src/telnyx/resources/sim_cards/sim_cards.py b/src/telnyx/resources/sim_cards/sim_cards.py index bde587ba..2bc2da17 100644 --- a/src/telnyx/resources/sim_cards/sim_cards.py +++ b/src/telnyx/resources/sim_cards/sim_cards.py @@ -2,6 +2,7 @@ from __future__ import annotations +from typing import Optional from typing_extensions import Literal import httpx @@ -124,7 +125,7 @@ def update( self, id: str, *, - authorized_imeis: SequenceNotStr[str] | Omit = omit, + authorized_imeis: Optional[SequenceNotStr[str]] | Omit = omit, data_limit: sim_card_update_params.DataLimit | Omit = omit, sim_card_group_id: str | Omit = omit, status: SimCardStatus | Omit = omit, @@ -517,7 +518,7 @@ async def update( self, id: str, *, - authorized_imeis: SequenceNotStr[str] | Omit = omit, + authorized_imeis: Optional[SequenceNotStr[str]] | Omit = omit, data_limit: sim_card_update_params.DataLimit | Omit = omit, sim_card_group_id: str | Omit = omit, status: SimCardStatus | Omit = omit, diff --git a/src/telnyx/resources/verifications/verifications.py b/src/telnyx/resources/verifications/verifications.py index 00d2c910..8eea1be8 100644 --- a/src/telnyx/resources/verifications/verifications.py +++ b/src/telnyx/resources/verifications/verifications.py @@ -111,6 +111,7 @@ def trigger_call( phone_number: str, verify_profile_id: str, custom_code: Optional[str] | Omit = omit, + extension: Optional[str] | Omit = omit, timeout_secs: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -129,6 +130,9 @@ def trigger_call( custom_code: Send a self-generated numeric code to the end-user + extension: Optional extension to dial after call is answered using DTMF digits. Valid + digits are 0-9, A-D, \\**, and #. Pauses can be added using w (0.5s) and W (1s). + timeout_secs: The number of seconds the verification code is valid for. extra_headers: Send extra headers @@ -146,6 +150,7 @@ def trigger_call( "phone_number": phone_number, "verify_profile_id": verify_profile_id, "custom_code": custom_code, + "extension": extension, "timeout_secs": timeout_secs, }, verification_trigger_call_params.VerificationTriggerCallParams, @@ -322,6 +327,7 @@ async def trigger_call( phone_number: str, verify_profile_id: str, custom_code: Optional[str] | Omit = omit, + extension: Optional[str] | Omit = omit, timeout_secs: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -340,6 +346,9 @@ async def trigger_call( custom_code: Send a self-generated numeric code to the end-user + extension: Optional extension to dial after call is answered using DTMF digits. Valid + digits are 0-9, A-D, \\**, and #. Pauses can be added using w (0.5s) and W (1s). + timeout_secs: The number of seconds the verification code is valid for. extra_headers: Send extra headers @@ -357,6 +366,7 @@ async def trigger_call( "phone_number": phone_number, "verify_profile_id": verify_profile_id, "custom_code": custom_code, + "extension": extension, "timeout_secs": timeout_secs, }, verification_trigger_call_params.VerificationTriggerCallParams, diff --git a/src/telnyx/resources/verify_profiles.py b/src/telnyx/resources/verify_profiles.py index c345aeb9..81dbab0a 100644 --- a/src/telnyx/resources/verify_profiles.py +++ b/src/telnyx/resources/verify_profiles.py @@ -4,7 +4,13 @@ import httpx -from ..types import verify_profile_list_params, verify_profile_create_params, verify_profile_update_params +from ..types import ( + verify_profile_list_params, + verify_profile_create_params, + verify_profile_update_params, + verify_profile_create_template_params, + verify_profile_update_template_params, +) from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property @@ -18,6 +24,8 @@ from .._base_client import make_request_options from ..types.verify_profile_data import VerifyProfileData from ..types.verify_profile_list_response import VerifyProfileListResponse +from ..types.verify_profile_create_template_response import VerifyProfileCreateTemplateResponse +from ..types.verify_profile_update_template_response import VerifyProfileUpdateTemplateResponse from ..types.verify_profile_retrieve_templates_response import VerifyProfileRetrieveTemplatesResponse __all__ = ["VerifyProfilesResource", "AsyncVerifyProfilesResource"] @@ -257,6 +265,42 @@ def delete( cast_to=VerifyProfileData, ) + def create_template( + self, + *, + text: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VerifyProfileCreateTemplateResponse: + """ + Create a new Verify profile message template. + + Args: + text: The text content of the message template. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/verify_profiles/templates", + body=maybe_transform( + {"text": text}, verify_profile_create_template_params.VerifyProfileCreateTemplateParams + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VerifyProfileCreateTemplateResponse, + ) + def retrieve_templates( self, *, @@ -276,6 +320,45 @@ def retrieve_templates( cast_to=VerifyProfileRetrieveTemplatesResponse, ) + def update_template( + self, + template_id: str, + *, + text: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VerifyProfileUpdateTemplateResponse: + """ + Update an existing Verify profile message template. + + Args: + text: The text content of the message template. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not template_id: + raise ValueError(f"Expected a non-empty value for `template_id` but received {template_id!r}") + return self._patch( + f"/verify_profiles/templates/{template_id}", + body=maybe_transform( + {"text": text}, verify_profile_update_template_params.VerifyProfileUpdateTemplateParams + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VerifyProfileUpdateTemplateResponse, + ) + class AsyncVerifyProfilesResource(AsyncAPIResource): @cached_property @@ -511,6 +594,42 @@ async def delete( cast_to=VerifyProfileData, ) + async def create_template( + self, + *, + text: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VerifyProfileCreateTemplateResponse: + """ + Create a new Verify profile message template. + + Args: + text: The text content of the message template. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/verify_profiles/templates", + body=await async_maybe_transform( + {"text": text}, verify_profile_create_template_params.VerifyProfileCreateTemplateParams + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VerifyProfileCreateTemplateResponse, + ) + async def retrieve_templates( self, *, @@ -530,6 +649,45 @@ async def retrieve_templates( cast_to=VerifyProfileRetrieveTemplatesResponse, ) + async def update_template( + self, + template_id: str, + *, + text: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VerifyProfileUpdateTemplateResponse: + """ + Update an existing Verify profile message template. + + Args: + text: The text content of the message template. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not template_id: + raise ValueError(f"Expected a non-empty value for `template_id` but received {template_id!r}") + return await self._patch( + f"/verify_profiles/templates/{template_id}", + body=await async_maybe_transform( + {"text": text}, verify_profile_update_template_params.VerifyProfileUpdateTemplateParams + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VerifyProfileUpdateTemplateResponse, + ) + class VerifyProfilesResourceWithRawResponse: def __init__(self, verify_profiles: VerifyProfilesResource) -> None: @@ -550,9 +708,15 @@ def __init__(self, verify_profiles: VerifyProfilesResource) -> None: self.delete = to_raw_response_wrapper( verify_profiles.delete, ) + self.create_template = to_raw_response_wrapper( + verify_profiles.create_template, + ) self.retrieve_templates = to_raw_response_wrapper( verify_profiles.retrieve_templates, ) + self.update_template = to_raw_response_wrapper( + verify_profiles.update_template, + ) class AsyncVerifyProfilesResourceWithRawResponse: @@ -574,9 +738,15 @@ def __init__(self, verify_profiles: AsyncVerifyProfilesResource) -> None: self.delete = async_to_raw_response_wrapper( verify_profiles.delete, ) + self.create_template = async_to_raw_response_wrapper( + verify_profiles.create_template, + ) self.retrieve_templates = async_to_raw_response_wrapper( verify_profiles.retrieve_templates, ) + self.update_template = async_to_raw_response_wrapper( + verify_profiles.update_template, + ) class VerifyProfilesResourceWithStreamingResponse: @@ -598,9 +768,15 @@ def __init__(self, verify_profiles: VerifyProfilesResource) -> None: self.delete = to_streamed_response_wrapper( verify_profiles.delete, ) + self.create_template = to_streamed_response_wrapper( + verify_profiles.create_template, + ) self.retrieve_templates = to_streamed_response_wrapper( verify_profiles.retrieve_templates, ) + self.update_template = to_streamed_response_wrapper( + verify_profiles.update_template, + ) class AsyncVerifyProfilesResourceWithStreamingResponse: @@ -622,6 +798,12 @@ def __init__(self, verify_profiles: AsyncVerifyProfilesResource) -> None: self.delete = async_to_streamed_response_wrapper( verify_profiles.delete, ) + self.create_template = async_to_streamed_response_wrapper( + verify_profiles.create_template, + ) self.retrieve_templates = async_to_streamed_response_wrapper( verify_profiles.retrieve_templates, ) + self.update_template = async_to_streamed_response_wrapper( + verify_profiles.update_template, + ) diff --git a/src/telnyx/resources/well_known.py b/src/telnyx/resources/well_known.py new file mode 100644 index 00000000..a813d354 --- /dev/null +++ b/src/telnyx/resources/well_known.py @@ -0,0 +1,198 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from .._types import Body, Query, Headers, NotGiven, not_given +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from .._base_client import make_request_options +from ..types.well_known_retrieve_protected_resource_metadata_response import ( + WellKnownRetrieveProtectedResourceMetadataResponse, +) +from ..types.well_known_retrieve_authorization_server_metadata_response import ( + WellKnownRetrieveAuthorizationServerMetadataResponse, +) + +__all__ = ["WellKnownResource", "AsyncWellKnownResource"] + + +class WellKnownResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> WellKnownResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return WellKnownResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> WellKnownResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return WellKnownResourceWithStreamingResponse(self) + + def retrieve_authorization_server_metadata( + self, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WellKnownRetrieveAuthorizationServerMetadataResponse: + """OAuth 2.0 Authorization Server Metadata (RFC 8414)""" + return self._get( + "/.well-known/oauth-authorization-server" + if self._client._base_url_overridden + else "https://api.telnyx.com/.well-known/oauth-authorization-server", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WellKnownRetrieveAuthorizationServerMetadataResponse, + ) + + def retrieve_protected_resource_metadata( + self, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WellKnownRetrieveProtectedResourceMetadataResponse: + """OAuth 2.0 Protected Resource Metadata for resource discovery""" + return self._get( + "/.well-known/oauth-protected-resource" + if self._client._base_url_overridden + else "https://api.telnyx.com/.well-known/oauth-protected-resource", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WellKnownRetrieveProtectedResourceMetadataResponse, + ) + + +class AsyncWellKnownResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncWellKnownResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers + """ + return AsyncWellKnownResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncWellKnownResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response + """ + return AsyncWellKnownResourceWithStreamingResponse(self) + + async def retrieve_authorization_server_metadata( + self, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WellKnownRetrieveAuthorizationServerMetadataResponse: + """OAuth 2.0 Authorization Server Metadata (RFC 8414)""" + return await self._get( + "/.well-known/oauth-authorization-server" + if self._client._base_url_overridden + else "https://api.telnyx.com/.well-known/oauth-authorization-server", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WellKnownRetrieveAuthorizationServerMetadataResponse, + ) + + async def retrieve_protected_resource_metadata( + self, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WellKnownRetrieveProtectedResourceMetadataResponse: + """OAuth 2.0 Protected Resource Metadata for resource discovery""" + return await self._get( + "/.well-known/oauth-protected-resource" + if self._client._base_url_overridden + else "https://api.telnyx.com/.well-known/oauth-protected-resource", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WellKnownRetrieveProtectedResourceMetadataResponse, + ) + + +class WellKnownResourceWithRawResponse: + def __init__(self, well_known: WellKnownResource) -> None: + self._well_known = well_known + + self.retrieve_authorization_server_metadata = to_raw_response_wrapper( + well_known.retrieve_authorization_server_metadata, + ) + self.retrieve_protected_resource_metadata = to_raw_response_wrapper( + well_known.retrieve_protected_resource_metadata, + ) + + +class AsyncWellKnownResourceWithRawResponse: + def __init__(self, well_known: AsyncWellKnownResource) -> None: + self._well_known = well_known + + self.retrieve_authorization_server_metadata = async_to_raw_response_wrapper( + well_known.retrieve_authorization_server_metadata, + ) + self.retrieve_protected_resource_metadata = async_to_raw_response_wrapper( + well_known.retrieve_protected_resource_metadata, + ) + + +class WellKnownResourceWithStreamingResponse: + def __init__(self, well_known: WellKnownResource) -> None: + self._well_known = well_known + + self.retrieve_authorization_server_metadata = to_streamed_response_wrapper( + well_known.retrieve_authorization_server_metadata, + ) + self.retrieve_protected_resource_metadata = to_streamed_response_wrapper( + well_known.retrieve_protected_resource_metadata, + ) + + +class AsyncWellKnownResourceWithStreamingResponse: + def __init__(self, well_known: AsyncWellKnownResource) -> None: + self._well_known = well_known + + self.retrieve_authorization_server_metadata = async_to_streamed_response_wrapper( + well_known.retrieve_authorization_server_metadata, + ) + self.retrieve_protected_resource_metadata = async_to_streamed_response_wrapper( + well_known.retrieve_protected_resource_metadata, + ) diff --git a/src/telnyx/types/__init__.py b/src/telnyx/types/__init__.py index e350e496..f1ee7b36 100644 --- a/src/telnyx/types/__init__.py +++ b/src/telnyx/types/__init__.py @@ -112,6 +112,7 @@ from .ip_update_response import IPUpdateResponse as IPUpdateResponse from .number_block_order import NumberBlockOrder as NumberBlockOrder from .number_reservation import NumberReservation as NumberReservation +from .oauth_token_params import OAuthTokenParams as OAuthTokenParams from .porting_order_misc import PortingOrderMisc as PortingOrderMisc from .porting_order_type import PortingOrderType as PortingOrderType from .rcs_agent_response import RcsAgentResponse as RcsAgentResponse @@ -138,6 +139,7 @@ from .message_send_params import MessageSendParams as MessageSendParams from .messsage_rcs_params import MesssageRcsParams as MesssageRcsParams from .network_list_params import NetworkListParams as NetworkListParams +from .oauth_grants_params import OAuthGrantsParams as OAuthGrantsParams from .outbound_fqdn_param import OutboundFqdnParam as OutboundFqdnParam from .portout_list_params import PortoutListParams as PortoutListParams from .telnyx_campaign_csp import TelnyxCampaignCsp as TelnyxCampaignCsp @@ -156,6 +158,7 @@ from .notification_profile import NotificationProfile as NotificationProfile from .notification_setting import NotificationSetting as NotificationSetting from .number_pool_settings import NumberPoolSettings as NumberPoolSettings +from .oauth_token_response import OAuthTokenResponse as OAuthTokenResponse from .rcs_suggestion_param import RcsSuggestionParam as RcsSuggestionParam from .region_list_response import RegionListResponse as RegionListResponse from .room_create_response import RoomCreateResponse as RoomCreateResponse @@ -187,6 +190,8 @@ from .network_create_params import NetworkCreateParams as NetworkCreateParams from .network_list_response import NetworkListResponse as NetworkListResponse from .network_update_params import NetworkUpdateParams as NetworkUpdateParams +from .oauth_grants_response import OAuthGrantsResponse as OAuthGrantsResponse +from .oauth_register_params import OAuthRegisterParams as OAuthRegisterParams from .phone_number_campaign import PhoneNumberCampaign as PhoneNumberCampaign from .phone_number_detailed import PhoneNumberDetailed as PhoneNumberDetailed from .portout_list_response import PortoutListResponse as PortoutListResponse @@ -237,6 +242,10 @@ from .network_create_response import NetworkCreateResponse as NetworkCreateResponse from .network_delete_response import NetworkDeleteResponse as NetworkDeleteResponse from .network_update_response import NetworkUpdateResponse as NetworkUpdateResponse +from .oauth_grant_list_params import OAuthGrantListParams as OAuthGrantListParams +from .oauth_introspect_params import OAuthIntrospectParams as OAuthIntrospectParams +from .oauth_register_response import OAuthRegisterResponse as OAuthRegisterResponse +from .oauth_retrieve_response import OAuthRetrieveResponse as OAuthRetrieveResponse from .outbound_call_recording import OutboundCallRecording as OutboundCallRecording from .porting_order_documents import PortingOrderDocuments as PortingOrderDocuments from .porting_order_messaging import PortingOrderMessaging as PortingOrderMessaging @@ -265,6 +274,7 @@ from .fax_failed_webhook_event import FaxFailedWebhookEvent as FaxFailedWebhookEvent from .fax_queued_webhook_event import FaxQueuedWebhookEvent as FaxQueuedWebhookEvent from .number_order_list_params import NumberOrderListParams as NumberOrderListParams +from .oauth_client_list_params import OAuthClientListParams as OAuthClientListParams from .ota_update_list_response import OtaUpdateListResponse as OtaUpdateListResponse from .outbound_message_payload import OutboundMessagePayload as OutboundMessagePayload from .phone_number_list_params import PhoneNumberListParams as PhoneNumberListParams @@ -296,6 +306,8 @@ from .message_schedule_response import MessageScheduleResponse as MessageScheduleResponse from .network_retrieve_response import NetworkRetrieveResponse as NetworkRetrieveResponse from .number_order_phone_number import NumberOrderPhoneNumber as NumberOrderPhoneNumber +from .oauth_grant_list_response import OAuthGrantListResponse as OAuthGrantListResponse +from .oauth_introspect_response import OAuthIntrospectResponse as OAuthIntrospectResponse from .porting_order_list_params import PortingOrderListParams as PortingOrderListParams from .porting_order_requirement import PortingOrderRequirement as PortingOrderRequirement from .portout_retrieve_response import PortoutRetrieveResponse as PortoutRetrieveResponse @@ -319,6 +331,9 @@ from .number_order_list_response import NumberOrderListResponse as NumberOrderListResponse from .number_order_update_params import NumberOrderUpdateParams as NumberOrderUpdateParams from .number_pool_settings_param import NumberPoolSettingsParam as NumberPoolSettingsParam +from .oauth_client_create_params import OAuthClientCreateParams as OAuthClientCreateParams +from .oauth_client_list_response import OAuthClientListResponse as OAuthClientListResponse +from .oauth_client_update_params import OAuthClientUpdateParams as OAuthClientUpdateParams from .phone_number_list_response import PhoneNumberListResponse as PhoneNumberListResponse from .phone_number_update_params import PhoneNumberUpdateParams as PhoneNumberUpdateParams from .room_recording_list_params import RoomRecordingListParams as RoomRecordingListParams @@ -353,6 +368,7 @@ from .ip_connection_update_params import IPConnectionUpdateParams as IPConnectionUpdateParams from .ledger_billing_group_report import LedgerBillingGroupReport as LedgerBillingGroupReport from .managed_account_list_params import ManagedAccountListParams as ManagedAccountListParams +from .oauth_grant_delete_response import OAuthGrantDeleteResponse as OAuthGrantDeleteResponse from .porting_order_create_params import PortingOrderCreateParams as PortingOrderCreateParams from .porting_order_list_response import PortingOrderListResponse as PortingOrderListResponse from .porting_order_update_params import PortingOrderUpdateParams as PortingOrderUpdateParams @@ -377,6 +393,9 @@ from .network_coverage_list_params import NetworkCoverageListParams as NetworkCoverageListParams from .number_order_create_response import NumberOrderCreateResponse as NumberOrderCreateResponse from .number_order_update_response import NumberOrderUpdateResponse as NumberOrderUpdateResponse +from .oauth_client_create_response import OAuthClientCreateResponse as OAuthClientCreateResponse +from .oauth_client_update_response import OAuthClientUpdateResponse as OAuthClientUpdateResponse +from .oauth_retrieve_jwks_response import OAuthRetrieveJwksResponse as OAuthRetrieveJwksResponse from .ota_update_retrieve_response import OtaUpdateRetrieveResponse as OtaUpdateRetrieveResponse from .partner_campaign_list_params import PartnerCampaignListParams as PartnerCampaignListParams from .phone_number_delete_response import PhoneNumberDeleteResponse as PhoneNumberDeleteResponse @@ -437,6 +456,7 @@ from .messaging_profile_list_params import MessagingProfileListParams as MessagingProfileListParams from .number_lookup_retrieve_params import NumberLookupRetrieveParams as NumberLookupRetrieveParams from .numbers_feature_create_params import NumbersFeatureCreateParams as NumbersFeatureCreateParams +from .oauth_grant_retrieve_response import OAuthGrantRetrieveResponse as OAuthGrantRetrieveResponse from .outbound_call_recording_param import OutboundCallRecordingParam as OutboundCallRecordingParam from .phone_number_slim_list_params import PhoneNumberSlimListParams as PhoneNumberSlimListParams from .porting_order_create_response import PortingOrderCreateResponse as PortingOrderCreateResponse @@ -465,6 +485,7 @@ from .number_block_order_list_params import NumberBlockOrderListParams as NumberBlockOrderListParams from .number_order_retrieve_response import NumberOrderRetrieveResponse as NumberOrderRetrieveResponse from .number_reservation_list_params import NumberReservationListParams as NumberReservationListParams +from .oauth_client_retrieve_response import OAuthClientRetrieveResponse as OAuthClientRetrieveResponse from .partner_campaign_list_response import PartnerCampaignListResponse as PartnerCampaignListResponse from .partner_campaign_update_params import PartnerCampaignUpdateParams as PartnerCampaignUpdateParams from .phone_number_retrieve_response import PhoneNumberRetrieveResponse as PhoneNumberRetrieveResponse @@ -522,6 +543,7 @@ from .number_lookup_retrieve_response import NumberLookupRetrieveResponse as NumberLookupRetrieveResponse from .number_order_with_phone_numbers import NumberOrderWithPhoneNumbers as NumberOrderWithPhoneNumbers from .numbers_feature_create_response import NumbersFeatureCreateResponse as NumbersFeatureCreateResponse +from .oauth_retrieve_authorize_params import OAuthRetrieveAuthorizeParams as OAuthRetrieveAuthorizeParams from .phone_number_slim_list_response import PhoneNumberSlimListResponse as PhoneNumberSlimListResponse from .porting_order_end_user_location import PortingOrderEndUserLocation as PortingOrderEndUserLocation from .porting_order_retrieve_response import PortingOrderRetrieveResponse as PortingOrderRetrieveResponse @@ -794,6 +816,12 @@ from .verification_trigger_flashcall_params import ( VerificationTriggerFlashcallParams as VerificationTriggerFlashcallParams, ) +from .verify_profile_create_template_params import ( + VerifyProfileCreateTemplateParams as VerifyProfileCreateTemplateParams, +) +from .verify_profile_update_template_params import ( + VerifyProfileUpdateTemplateParams as VerifyProfileUpdateTemplateParams, +) from .virtual_cross_connect_create_response import ( VirtualCrossConnectCreateResponse as VirtualCrossConnectCreateResponse, ) @@ -932,6 +960,12 @@ from .sub_number_order_regulatory_requirement import ( SubNumberOrderRegulatoryRequirement as SubNumberOrderRegulatoryRequirement, ) +from .verify_profile_create_template_response import ( + VerifyProfileCreateTemplateResponse as VerifyProfileCreateTemplateResponse, +) +from .verify_profile_update_template_response import ( + VerifyProfileUpdateTemplateResponse as VerifyProfileUpdateTemplateResponse, +) from .virtual_cross_connect_retrieve_response import ( VirtualCrossConnectRetrieveResponse as VirtualCrossConnectRetrieveResponse, ) @@ -1295,9 +1329,15 @@ from .messaging_hosted_number_order_check_eligibility_response import ( MessagingHostedNumberOrderCheckEligibilityResponse as MessagingHostedNumberOrderCheckEligibilityResponse, ) +from .well_known_retrieve_protected_resource_metadata_response import ( + WellKnownRetrieveProtectedResourceMetadataResponse as WellKnownRetrieveProtectedResourceMetadataResponse, +) from .number_order_phone_number_update_requirement_group_params import ( NumberOrderPhoneNumberUpdateRequirementGroupParams as NumberOrderPhoneNumberUpdateRequirementGroupParams, ) +from .well_known_retrieve_authorization_server_metadata_response import ( + WellKnownRetrieveAuthorizationServerMetadataResponse as WellKnownRetrieveAuthorizationServerMetadataResponse, +) from .customer_service_record_verify_phone_number_coverage_params import ( CustomerServiceRecordVerifyPhoneNumberCoverageParams as CustomerServiceRecordVerifyPhoneNumberCoverageParams, ) diff --git a/src/telnyx/types/ai/__init__.py b/src/telnyx/types/ai/__init__.py index 4505e635..f6f7de93 100644 --- a/src/telnyx/types/ai/__init__.py +++ b/src/telnyx/types/ai/__init__.py @@ -67,6 +67,7 @@ from .chat_create_completion_params import ChatCreateCompletionParams as ChatCreateCompletionParams from .conversation_retrieve_response import ConversationRetrieveResponse as ConversationRetrieveResponse from .inference_embedding_bucket_ids import InferenceEmbeddingBucketIDs as InferenceEmbeddingBucketIDs +from .conversation_add_message_params import ConversationAddMessageParams as ConversationAddMessageParams from .embedding_similarity_search_params import EmbeddingSimilaritySearchParams as EmbeddingSimilaritySearchParams from .embedding_similarity_search_response import EmbeddingSimilaritySearchResponse as EmbeddingSimilaritySearchResponse from .inference_embedding_bucket_ids_param import InferenceEmbeddingBucketIDsParam as InferenceEmbeddingBucketIDsParam diff --git a/src/telnyx/types/ai/conversations/message_create_params.py b/src/telnyx/types/ai/conversation_add_message_params.py similarity index 77% rename from src/telnyx/types/ai/conversations/message_create_params.py rename to src/telnyx/types/ai/conversation_add_message_params.py index 995c1232..da743ef9 100644 --- a/src/telnyx/types/ai/conversations/message_create_params.py +++ b/src/telnyx/types/ai/conversation_add_message_params.py @@ -6,13 +6,13 @@ from datetime import datetime from typing_extensions import Required, Annotated, TypedDict -from ...._types import SequenceNotStr -from ...._utils import PropertyInfo +from ..._types import SequenceNotStr +from ..._utils import PropertyInfo -__all__ = ["MessageCreateParams"] +__all__ = ["ConversationAddMessageParams"] -class MessageCreateParams(TypedDict, total=False): +class ConversationAddMessageParams(TypedDict, total=False): role: Required[str] content: str diff --git a/src/telnyx/types/ai/conversations/__init__.py b/src/telnyx/types/ai/conversations/__init__.py index 4607e755..e9848020 100644 --- a/src/telnyx/types/ai/conversations/__init__.py +++ b/src/telnyx/types/ai/conversations/__init__.py @@ -7,7 +7,6 @@ from .insight_create_params import InsightCreateParams as InsightCreateParams from .insight_list_response import InsightListResponse as InsightListResponse from .insight_update_params import InsightUpdateParams as InsightUpdateParams -from .message_create_params import MessageCreateParams as MessageCreateParams from .message_list_response import MessageListResponse as MessageListResponse from .insight_template_group import InsightTemplateGroup as InsightTemplateGroup from .insight_template_detail import InsightTemplateDetail as InsightTemplateDetail diff --git a/src/telnyx/types/ai/inference_embedding_webhook_tool_params.py b/src/telnyx/types/ai/inference_embedding_webhook_tool_params.py index 0a134a04..80d0045d 100644 --- a/src/telnyx/types/ai/inference_embedding_webhook_tool_params.py +++ b/src/telnyx/types/ai/inference_embedding_webhook_tool_params.py @@ -27,6 +27,8 @@ class Header(BaseModel): Note that we support mustache templating for the value. For example you can use `Bearer {{#integration_secret}}test-secret{{/integration_secret}}` to pass the value of the integration secret as the bearer token. + [Telnyx signature headers](https://developers.telnyx.com/docs/voice/programmable-voice/voice-api-webhooks) + will be automatically added to the request. """ diff --git a/src/telnyx/types/ai/inference_embedding_webhook_tool_params_param.py b/src/telnyx/types/ai/inference_embedding_webhook_tool_params_param.py index ccc8c7a8..954d19e2 100644 --- a/src/telnyx/types/ai/inference_embedding_webhook_tool_params_param.py +++ b/src/telnyx/types/ai/inference_embedding_webhook_tool_params_param.py @@ -29,6 +29,8 @@ class Header(TypedDict, total=False): Note that we support mustache templating for the value. For example you can use `Bearer {{#integration_secret}}test-secret{{/integration_secret}}` to pass the value of the integration secret as the bearer token. + [Telnyx signature headers](https://developers.telnyx.com/docs/voice/programmable-voice/voice-api-webhooks) + will be automatically added to the request. """ diff --git a/src/telnyx/types/call_dial_params.py b/src/telnyx/types/call_dial_params.py index 74c44328..c765222b 100644 --- a/src/telnyx/types/call_dial_params.py +++ b/src/telnyx/types/call_dial_params.py @@ -225,7 +225,7 @@ class CallDialParams(TypedDict, total=False): stream_bidirectional_mode: StreamBidirectionalMode """Configures method of bidirectional streaming (mp3, rtp).""" - stream_bidirectional_sampling_rate: Literal[8000, 16000, 48000] + stream_bidirectional_sampling_rate: Literal[8000, 16000, 22050, 24000, 48000] """Audio sampling rate.""" stream_bidirectional_target_legs: StreamBidirectionalTargetLegs @@ -235,8 +235,7 @@ class CallDialParams(TypedDict, total=False): """Specifies the codec to be used for the streamed audio. When set to 'default' or when transcoding is not possible, the codec from the - call will be used. Currently, transcoding is only supported between PCMU and - PCMA codecs. + call will be used. """ stream_establish_before_call_originate: bool diff --git a/src/telnyx/types/calls/action_answer_params.py b/src/telnyx/types/calls/action_answer_params.py index 89d5a30c..e4345264 100644 --- a/src/telnyx/types/calls/action_answer_params.py +++ b/src/telnyx/types/calls/action_answer_params.py @@ -124,8 +124,7 @@ class ActionAnswerParams(TypedDict, total=False): """Specifies the codec to be used for the streamed audio. When set to 'default' or when transcoding is not possible, the codec from the - call will be used. Currently, transcoding is only supported between PCMU and - PCMA codecs. + call will be used. """ stream_track: Literal["inbound_track", "outbound_track", "both_tracks"] diff --git a/src/telnyx/types/calls/action_gather_using_ai_params.py b/src/telnyx/types/calls/action_gather_using_ai_params.py index 845c71db..cc35bed5 100644 --- a/src/telnyx/types/calls/action_gather_using_ai_params.py +++ b/src/telnyx/types/calls/action_gather_using_ai_params.py @@ -67,20 +67,17 @@ class ActionGatherUsingAIParams(TypedDict, total=False): """Default is `false`. If set to `true`, the voice assistant will send updates to the message history - via the `call.ai_gather.message_history_updated` - [callback](https://developers.telnyx.com/api/call-control/call-gather-using-ai#callbacks) - in real time as the message history is updated. + via the `call.ai_gather.message_history_updated` callback in real time as the + message history is updated. """ send_partial_results: bool """Default is `false`. If set to `true`, the voice assistant will send partial results via the - `call.ai_gather.partial_results` - [callback](https://developers.telnyx.com/api/call-control/call-gather-using-ai#callbacks) - in real time as individual fields are gathered. If set to `false`, the voice - assistant will only send the final result via the `call.ai_gather.ended` - callback. + `call.ai_gather.partial_results` callback in real time as individual fields are + gathered. If set to `false`, the voice assistant will only send the final result + via the `call.ai_gather.ended` callback. """ transcription: TranscriptionConfigParam diff --git a/src/telnyx/types/calls/action_start_streaming_params.py b/src/telnyx/types/calls/action_start_streaming_params.py index 1e355c16..293fdbc8 100644 --- a/src/telnyx/types/calls/action_start_streaming_params.py +++ b/src/telnyx/types/calls/action_start_streaming_params.py @@ -41,6 +41,9 @@ class ActionStartStreamingParams(TypedDict, total=False): stream_bidirectional_mode: StreamBidirectionalMode """Configures method of bidirectional streaming (mp3, rtp).""" + stream_bidirectional_sampling_rate: Literal[8000, 16000, 22050, 24000, 48000] + """Audio sampling rate.""" + stream_bidirectional_target_legs: StreamBidirectionalTargetLegs """Specifies which call legs should receive the bidirectional stream audio.""" @@ -48,8 +51,7 @@ class ActionStartStreamingParams(TypedDict, total=False): """Specifies the codec to be used for the streamed audio. When set to 'default' or when transcoding is not possible, the codec from the - call will be used. Currently, transcoding is only supported between PCMU and - PCMA codecs. + call will be used. """ stream_track: Literal["inbound_track", "outbound_track", "both_tracks"] diff --git a/src/telnyx/types/calls/action_transfer_params.py b/src/telnyx/types/calls/action_transfer_params.py index 10095f43..d781d1ad 100644 --- a/src/telnyx/types/calls/action_transfer_params.py +++ b/src/telnyx/types/calls/action_transfer_params.py @@ -102,6 +102,56 @@ class ActionTransferParams(TypedDict, total=False): behavior is to hang up the leg. """ + record: Literal["record-from-answer"] + """Start recording automatically after an event. Disabled by default.""" + + record_channels: Literal["single", "dual"] + """ + Defines which channel should be recorded ('single' or 'dual') when `record` is + specified. + """ + + record_custom_file_name: str + """The custom recording file name to be used instead of the default `call_leg_id`. + + Telnyx will still add a Unix timestamp suffix. + """ + + record_format: Literal["wav", "mp3"] + """ + Defines the format of the recording ('wav' or 'mp3') when `record` is specified. + """ + + record_max_length: int + """ + Defines the maximum length for the recording in seconds when `record` is + specified. The minimum value is 0. The maximum value is 43200. The default value + is 0 (infinite). + """ + + record_timeout_secs: int + """ + The number of seconds that Telnyx will wait for the recording to be stopped if + silence is detected when `record` is specified. The timer only starts when the + speech is detected. Please note that call transcription is used to detect + silence and the related charge will be applied. The minimum value is 0. The + default value is 0 (infinite). + """ + + record_track: Literal["both", "inbound", "outbound"] + """The audio track to be recorded. + + Can be either `both`, `inbound` or `outbound`. If only single track is specified + (`inbound`, `outbound`), `channels` configuration is ignored and it will be + recorded as mono (single channel). + """ + + record_trim: Literal["trim-silence"] + """ + When set to `trim-silence`, silence will be removed from the beginning and end + of the recording. + """ + sip_auth_password: str """SIP Authentication password used for SIP challenges.""" diff --git a/src/telnyx/types/campaign_submit_appeal_response.py b/src/telnyx/types/campaign_submit_appeal_response.py index 6b87f549..546a8c11 100644 --- a/src/telnyx/types/campaign_submit_appeal_response.py +++ b/src/telnyx/types/campaign_submit_appeal_response.py @@ -11,6 +11,3 @@ class CampaignSubmitAppealResponse(BaseModel): appealed_at: Optional[datetime] = None """Timestamp when the appeal was submitted""" - - previous_status: Optional[str] = None - """Previous campaign status (currently always null)""" diff --git a/src/telnyx/types/legacy/__init__.py b/src/telnyx/types/legacy/__init__.py new file mode 100644 index 00000000..f8ee8b14 --- /dev/null +++ b/src/telnyx/types/legacy/__init__.py @@ -0,0 +1,3 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations diff --git a/src/telnyx/types/legacy/reporting/__init__.py b/src/telnyx/types/legacy/reporting/__init__.py new file mode 100644 index 00000000..f829303b --- /dev/null +++ b/src/telnyx/types/legacy/reporting/__init__.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .usage_report_retrieve_speech_to_text_params import ( + UsageReportRetrieveSpeechToTextParams as UsageReportRetrieveSpeechToTextParams, +) +from .usage_report_retrieve_speech_to_text_response import ( + UsageReportRetrieveSpeechToTextResponse as UsageReportRetrieveSpeechToTextResponse, +) diff --git a/src/telnyx/types/legacy/reporting/batch_detail_records/__init__.py b/src/telnyx/types/legacy/reporting/batch_detail_records/__init__.py new file mode 100644 index 00000000..704e1439 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/batch_detail_records/__init__.py @@ -0,0 +1,20 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .voice_create_params import VoiceCreateParams as VoiceCreateParams +from .voice_list_response import VoiceListResponse as VoiceListResponse +from .voice_create_response import VoiceCreateResponse as VoiceCreateResponse +from .voice_delete_response import VoiceDeleteResponse as VoiceDeleteResponse +from .messaging_create_params import MessagingCreateParams as MessagingCreateParams +from .messaging_list_response import MessagingListResponse as MessagingListResponse +from .voice_retrieve_response import VoiceRetrieveResponse as VoiceRetrieveResponse +from .messaging_create_response import MessagingCreateResponse as MessagingCreateResponse +from .messaging_delete_response import MessagingDeleteResponse as MessagingDeleteResponse +from .messaging_retrieve_response import MessagingRetrieveResponse as MessagingRetrieveResponse +from .speech_to_text_create_params import SpeechToTextCreateParams as SpeechToTextCreateParams +from .speech_to_text_list_response import SpeechToTextListResponse as SpeechToTextListResponse +from .speech_to_text_create_response import SpeechToTextCreateResponse as SpeechToTextCreateResponse +from .speech_to_text_delete_response import SpeechToTextDeleteResponse as SpeechToTextDeleteResponse +from .voice_retrieve_fields_response import VoiceRetrieveFieldsResponse as VoiceRetrieveFieldsResponse +from .speech_to_text_retrieve_response import SpeechToTextRetrieveResponse as SpeechToTextRetrieveResponse diff --git a/src/telnyx/types/legacy/reporting/batch_detail_records/messaging_create_params.py b/src/telnyx/types/legacy/reporting/batch_detail_records/messaging_create_params.py new file mode 100644 index 00000000..7253ff15 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/batch_detail_records/messaging_create_params.py @@ -0,0 +1,77 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union, Iterable +from datetime import datetime +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ....._types import SequenceNotStr +from ....._utils import PropertyInfo + +__all__ = ["MessagingCreateParams", "Filter"] + + +class MessagingCreateParams(TypedDict, total=False): + end_time: Required[Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]] + """End time in ISO format. + + Note: If end time includes the last 4 hours, some MDRs might not appear in this + report, due to wait time for downstream message delivery confirmation + """ + + start_time: Required[Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]] + """Start time in ISO format""" + + connections: Iterable[int] + """List of connections to filter by""" + + directions: Iterable[int] + """List of directions to filter by (Inbound = 1, Outbound = 2)""" + + filters: Iterable[Filter] + """List of filters to apply""" + + include_message_body: bool + """Whether to include message body in the report""" + + managed_accounts: SequenceNotStr[str] + """List of managed accounts to include""" + + profiles: SequenceNotStr[str] + """List of messaging profile IDs to filter by""" + + record_types: Iterable[int] + """List of record types to filter by (Complete = 1, Incomplete = 2, Errors = 3)""" + + report_name: str + """Name of the report""" + + select_all_managed_accounts: bool + """Whether to select all managed accounts""" + + timezone: str + """Timezone for the report""" + + +class Filter(TypedDict, total=False): + billing_group: str + """Billing group UUID to filter by""" + + cld: str + """Called line identification (destination number)""" + + cld_filter: Literal["contains", "starts_with", "ends_with"] + """Filter type for CLD matching""" + + cli: str + """Calling line identification (caller ID)""" + + cli_filter: Literal["contains", "starts_with", "ends_with"] + """Filter type for CLI matching""" + + filter_type: Literal["and", "or"] + """Logical operator for combining filters""" + + tags_list: str + """Tag name to filter by""" diff --git a/src/telnyx/types/legacy/reporting/batch_detail_records/messaging_create_response.py b/src/telnyx/types/legacy/reporting/batch_detail_records/messaging_create_response.py new file mode 100644 index 00000000..ecdbc98c --- /dev/null +++ b/src/telnyx/types/legacy/reporting/batch_detail_records/messaging_create_response.py @@ -0,0 +1,68 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["MessagingCreateResponse", "Data", "DataFilter"] + + +class DataFilter(BaseModel): + billing_group: Optional[str] = None + """Billing group UUID to filter by""" + + cld: Optional[str] = None + """Called line identification (destination number)""" + + cld_filter: Optional[Literal["contains", "starts_with", "ends_with"]] = None + """Filter type for CLD matching""" + + cli: Optional[str] = None + """Calling line identification (caller ID)""" + + cli_filter: Optional[Literal["contains", "starts_with", "ends_with"]] = None + """Filter type for CLI matching""" + + filter_type: Optional[Literal["and", "or"]] = None + """Logical operator for combining filters""" + + tags_list: Optional[str] = None + """Tag name to filter by""" + + +class Data(BaseModel): + id: Optional[str] = None + """Identifies the resource""" + + connections: Optional[List[int]] = None + + created_at: Optional[datetime] = None + + directions: Optional[List[Literal["INBOUND", "OUTBOUND"]]] = None + + end_date: Optional[datetime] = None + + filters: Optional[List[DataFilter]] = None + + profiles: Optional[List[str]] = None + """List of messaging profile IDs""" + + record_type: Optional[str] = None + + record_types: Optional[List[Literal["INCOMPLETE", "COMPLETED", "ERRORS"]]] = None + + report_name: Optional[str] = None + + report_url: Optional[str] = None + + start_date: Optional[datetime] = None + + status: Optional[Literal["PENDING", "COMPLETE", "FAILED", "EXPIRED"]] = None + + updated_at: Optional[datetime] = None + + +class MessagingCreateResponse(BaseModel): + data: Optional[Data] = None diff --git a/src/telnyx/types/legacy/reporting/batch_detail_records/messaging_delete_response.py b/src/telnyx/types/legacy/reporting/batch_detail_records/messaging_delete_response.py new file mode 100644 index 00000000..4e8fdcd7 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/batch_detail_records/messaging_delete_response.py @@ -0,0 +1,68 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["MessagingDeleteResponse", "Data", "DataFilter"] + + +class DataFilter(BaseModel): + billing_group: Optional[str] = None + """Billing group UUID to filter by""" + + cld: Optional[str] = None + """Called line identification (destination number)""" + + cld_filter: Optional[Literal["contains", "starts_with", "ends_with"]] = None + """Filter type for CLD matching""" + + cli: Optional[str] = None + """Calling line identification (caller ID)""" + + cli_filter: Optional[Literal["contains", "starts_with", "ends_with"]] = None + """Filter type for CLI matching""" + + filter_type: Optional[Literal["and", "or"]] = None + """Logical operator for combining filters""" + + tags_list: Optional[str] = None + """Tag name to filter by""" + + +class Data(BaseModel): + id: Optional[str] = None + """Identifies the resource""" + + connections: Optional[List[int]] = None + + created_at: Optional[datetime] = None + + directions: Optional[List[Literal["INBOUND", "OUTBOUND"]]] = None + + end_date: Optional[datetime] = None + + filters: Optional[List[DataFilter]] = None + + profiles: Optional[List[str]] = None + """List of messaging profile IDs""" + + record_type: Optional[str] = None + + record_types: Optional[List[Literal["INCOMPLETE", "COMPLETED", "ERRORS"]]] = None + + report_name: Optional[str] = None + + report_url: Optional[str] = None + + start_date: Optional[datetime] = None + + status: Optional[Literal["PENDING", "COMPLETE", "FAILED", "EXPIRED"]] = None + + updated_at: Optional[datetime] = None + + +class MessagingDeleteResponse(BaseModel): + data: Optional[Data] = None diff --git a/src/telnyx/types/legacy/reporting/batch_detail_records/messaging_list_response.py b/src/telnyx/types/legacy/reporting/batch_detail_records/messaging_list_response.py new file mode 100644 index 00000000..c9e57fa8 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/batch_detail_records/messaging_list_response.py @@ -0,0 +1,80 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["MessagingListResponse", "Data", "DataFilter", "Meta"] + + +class DataFilter(BaseModel): + billing_group: Optional[str] = None + """Billing group UUID to filter by""" + + cld: Optional[str] = None + """Called line identification (destination number)""" + + cld_filter: Optional[Literal["contains", "starts_with", "ends_with"]] = None + """Filter type for CLD matching""" + + cli: Optional[str] = None + """Calling line identification (caller ID)""" + + cli_filter: Optional[Literal["contains", "starts_with", "ends_with"]] = None + """Filter type for CLI matching""" + + filter_type: Optional[Literal["and", "or"]] = None + """Logical operator for combining filters""" + + tags_list: Optional[str] = None + """Tag name to filter by""" + + +class Data(BaseModel): + id: Optional[str] = None + """Identifies the resource""" + + connections: Optional[List[int]] = None + + created_at: Optional[datetime] = None + + directions: Optional[List[Literal["INBOUND", "OUTBOUND"]]] = None + + end_date: Optional[datetime] = None + + filters: Optional[List[DataFilter]] = None + + profiles: Optional[List[str]] = None + """List of messaging profile IDs""" + + record_type: Optional[str] = None + + record_types: Optional[List[Literal["INCOMPLETE", "COMPLETED", "ERRORS"]]] = None + + report_name: Optional[str] = None + + report_url: Optional[str] = None + + start_date: Optional[datetime] = None + + status: Optional[Literal["PENDING", "COMPLETE", "FAILED", "EXPIRED"]] = None + + updated_at: Optional[datetime] = None + + +class Meta(BaseModel): + page_number: Optional[int] = None + + page_size: Optional[int] = None + + total_pages: Optional[int] = None + + total_results: Optional[int] = None + + +class MessagingListResponse(BaseModel): + data: Optional[List[Data]] = None + + meta: Optional[Meta] = None diff --git a/src/telnyx/types/legacy/reporting/batch_detail_records/messaging_retrieve_response.py b/src/telnyx/types/legacy/reporting/batch_detail_records/messaging_retrieve_response.py new file mode 100644 index 00000000..92dd962d --- /dev/null +++ b/src/telnyx/types/legacy/reporting/batch_detail_records/messaging_retrieve_response.py @@ -0,0 +1,68 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["MessagingRetrieveResponse", "Data", "DataFilter"] + + +class DataFilter(BaseModel): + billing_group: Optional[str] = None + """Billing group UUID to filter by""" + + cld: Optional[str] = None + """Called line identification (destination number)""" + + cld_filter: Optional[Literal["contains", "starts_with", "ends_with"]] = None + """Filter type for CLD matching""" + + cli: Optional[str] = None + """Calling line identification (caller ID)""" + + cli_filter: Optional[Literal["contains", "starts_with", "ends_with"]] = None + """Filter type for CLI matching""" + + filter_type: Optional[Literal["and", "or"]] = None + """Logical operator for combining filters""" + + tags_list: Optional[str] = None + """Tag name to filter by""" + + +class Data(BaseModel): + id: Optional[str] = None + """Identifies the resource""" + + connections: Optional[List[int]] = None + + created_at: Optional[datetime] = None + + directions: Optional[List[Literal["INBOUND", "OUTBOUND"]]] = None + + end_date: Optional[datetime] = None + + filters: Optional[List[DataFilter]] = None + + profiles: Optional[List[str]] = None + """List of messaging profile IDs""" + + record_type: Optional[str] = None + + record_types: Optional[List[Literal["INCOMPLETE", "COMPLETED", "ERRORS"]]] = None + + report_name: Optional[str] = None + + report_url: Optional[str] = None + + start_date: Optional[datetime] = None + + status: Optional[Literal["PENDING", "COMPLETE", "FAILED", "EXPIRED"]] = None + + updated_at: Optional[datetime] = None + + +class MessagingRetrieveResponse(BaseModel): + data: Optional[Data] = None diff --git a/src/telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_create_params.py b/src/telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_create_params.py new file mode 100644 index 00000000..a40b4554 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_create_params.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import datetime +from typing_extensions import Required, Annotated, TypedDict + +from ....._utils import PropertyInfo + +__all__ = ["SpeechToTextCreateParams"] + + +class SpeechToTextCreateParams(TypedDict, total=False): + end_date: Required[Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]] + """End date in ISO format with timezone (date range must be up to one month)""" + + start_date: Required[Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]] + """Start date in ISO format with timezone""" diff --git a/src/telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_create_response.py b/src/telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_create_response.py new file mode 100644 index 00000000..1da54a7a --- /dev/null +++ b/src/telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_create_response.py @@ -0,0 +1,31 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["SpeechToTextCreateResponse", "Data"] + + +class Data(BaseModel): + id: Optional[str] = None + """Identifies the resource""" + + created_at: Optional[datetime] = None + + download_link: Optional[str] = None + """URL to download the report""" + + end_date: Optional[datetime] = None + + record_type: Optional[str] = None + + start_date: Optional[datetime] = None + + status: Optional[Literal["PENDING", "COMPLETE", "FAILED", "EXPIRED"]] = None + + +class SpeechToTextCreateResponse(BaseModel): + data: Optional[Data] = None diff --git a/src/telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_delete_response.py b/src/telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_delete_response.py new file mode 100644 index 00000000..6977b0c9 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_delete_response.py @@ -0,0 +1,31 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["SpeechToTextDeleteResponse", "Data"] + + +class Data(BaseModel): + id: Optional[str] = None + """Identifies the resource""" + + created_at: Optional[datetime] = None + + download_link: Optional[str] = None + """URL to download the report""" + + end_date: Optional[datetime] = None + + record_type: Optional[str] = None + + start_date: Optional[datetime] = None + + status: Optional[Literal["PENDING", "COMPLETE", "FAILED", "EXPIRED"]] = None + + +class SpeechToTextDeleteResponse(BaseModel): + data: Optional[Data] = None diff --git a/src/telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_list_response.py b/src/telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_list_response.py new file mode 100644 index 00000000..2ce734fa --- /dev/null +++ b/src/telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_list_response.py @@ -0,0 +1,31 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["SpeechToTextListResponse", "Data"] + + +class Data(BaseModel): + id: Optional[str] = None + """Identifies the resource""" + + created_at: Optional[datetime] = None + + download_link: Optional[str] = None + """URL to download the report""" + + end_date: Optional[datetime] = None + + record_type: Optional[str] = None + + start_date: Optional[datetime] = None + + status: Optional[Literal["PENDING", "COMPLETE", "FAILED", "EXPIRED"]] = None + + +class SpeechToTextListResponse(BaseModel): + data: Optional[List[Data]] = None diff --git a/src/telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_retrieve_response.py b/src/telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_retrieve_response.py new file mode 100644 index 00000000..37ce457e --- /dev/null +++ b/src/telnyx/types/legacy/reporting/batch_detail_records/speech_to_text_retrieve_response.py @@ -0,0 +1,31 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["SpeechToTextRetrieveResponse", "Data"] + + +class Data(BaseModel): + id: Optional[str] = None + """Identifies the resource""" + + created_at: Optional[datetime] = None + + download_link: Optional[str] = None + """URL to download the report""" + + end_date: Optional[datetime] = None + + record_type: Optional[str] = None + + start_date: Optional[datetime] = None + + status: Optional[Literal["PENDING", "COMPLETE", "FAILED", "EXPIRED"]] = None + + +class SpeechToTextRetrieveResponse(BaseModel): + data: Optional[Data] = None diff --git a/src/telnyx/types/legacy/reporting/batch_detail_records/voice_create_params.py b/src/telnyx/types/legacy/reporting/batch_detail_records/voice_create_params.py new file mode 100644 index 00000000..210781ac --- /dev/null +++ b/src/telnyx/types/legacy/reporting/batch_detail_records/voice_create_params.py @@ -0,0 +1,79 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union, Iterable +from datetime import datetime +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ....._types import SequenceNotStr +from ....._utils import PropertyInfo + +__all__ = ["VoiceCreateParams", "Filter"] + + +class VoiceCreateParams(TypedDict, total=False): + end_time: Required[Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]] + """End time in ISO format""" + + start_time: Required[Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]] + """Start time in ISO format""" + + call_types: Iterable[int] + """List of call types to filter by (Inbound = 1, Outbound = 2)""" + + connections: Iterable[int] + """List of connections to filter by""" + + fields: SequenceNotStr[str] + """Set of fields to include in the report""" + + filters: Iterable[Filter] + """List of filters to apply""" + + include_all_metadata: bool + """Whether to include all metadata""" + + managed_accounts: SequenceNotStr[str] + """List of managed accounts to include""" + + record_types: Iterable[int] + """List of record types to filter by (Complete = 1, Incomplete = 2, Errors = 3)""" + + report_name: str + """Name of the report""" + + select_all_managed_accounts: bool + """Whether to select all managed accounts""" + + source: str + """Source of the report. + + Valid values: calls (default), call-control, fax-api, webrtc + """ + + timezone: str + """Timezone for the report""" + + +class Filter(TypedDict, total=False): + billing_group: str + """Billing group UUID to filter by""" + + cld: str + """Called line identification (destination number)""" + + cld_filter: Literal["contains", "starts_with", "ends_with"] + """Filter type for CLD matching""" + + cli: str + """Calling line identification (caller ID)""" + + cli_filter: Literal["contains", "starts_with", "ends_with"] + """Filter type for CLI matching""" + + filter_type: Literal["and", "or"] + """Logical operator for combining filters""" + + tags_list: str + """Tag name to filter by""" diff --git a/src/telnyx/types/legacy/reporting/batch_detail_records/voice_create_response.py b/src/telnyx/types/legacy/reporting/batch_detail_records/voice_create_response.py new file mode 100644 index 00000000..b54cee87 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/batch_detail_records/voice_create_response.py @@ -0,0 +1,91 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["VoiceCreateResponse", "Data", "DataFilter"] + + +class DataFilter(BaseModel): + billing_group: Optional[str] = None + """Billing group UUID to filter by""" + + cld: Optional[str] = None + """Called line identification (destination number)""" + + cld_filter: Optional[Literal["contains", "starts_with", "ends_with"]] = None + """Filter type for CLD matching""" + + cli: Optional[str] = None + """Calling line identification (caller ID)""" + + cli_filter: Optional[Literal["contains", "starts_with", "ends_with"]] = None + """Filter type for CLI matching""" + + filter_type: Optional[Literal["and", "or"]] = None + """Logical operator for combining filters""" + + tags_list: Optional[str] = None + """Tag name to filter by""" + + +class Data(BaseModel): + id: Optional[str] = None + """Unique identifier for the report""" + + call_types: Optional[List[int]] = None + """List of call types (Inbound = 1, Outbound = 2)""" + + connections: Optional[List[int]] = None + """List of connections""" + + created_at: Optional[str] = None + """Creation date of the report""" + + end_time: Optional[str] = None + """End time in ISO format""" + + filters: Optional[List[DataFilter]] = None + """List of filters""" + + managed_accounts: Optional[List[str]] = None + """List of managed accounts""" + + record_type: Optional[str] = None + + record_types: Optional[List[int]] = None + """List of record types (Complete = 1, Incomplete = 2, Errors = 3)""" + + report_name: Optional[str] = None + """Name of the report""" + + report_url: Optional[str] = None + """URL to download the report""" + + retry: Optional[int] = None + """Number of retries""" + + source: Optional[str] = None + """Source of the report. + + Valid values: calls (default), call-control, fax-api, webrtc + """ + + start_time: Optional[str] = None + """Start time in ISO format""" + + status: Optional[int] = None + """Status of the report (Pending = 1, Complete = 2, Failed = 3, Expired = 4)""" + + timezone: Optional[str] = None + """Timezone for the report""" + + updated_at: Optional[str] = None + """Last update date of the report""" + + +class VoiceCreateResponse(BaseModel): + data: Optional[Data] = None + """Response object for CDR detailed report""" diff --git a/src/telnyx/types/legacy/reporting/batch_detail_records/voice_delete_response.py b/src/telnyx/types/legacy/reporting/batch_detail_records/voice_delete_response.py new file mode 100644 index 00000000..60fa3226 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/batch_detail_records/voice_delete_response.py @@ -0,0 +1,91 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["VoiceDeleteResponse", "Data", "DataFilter"] + + +class DataFilter(BaseModel): + billing_group: Optional[str] = None + """Billing group UUID to filter by""" + + cld: Optional[str] = None + """Called line identification (destination number)""" + + cld_filter: Optional[Literal["contains", "starts_with", "ends_with"]] = None + """Filter type for CLD matching""" + + cli: Optional[str] = None + """Calling line identification (caller ID)""" + + cli_filter: Optional[Literal["contains", "starts_with", "ends_with"]] = None + """Filter type for CLI matching""" + + filter_type: Optional[Literal["and", "or"]] = None + """Logical operator for combining filters""" + + tags_list: Optional[str] = None + """Tag name to filter by""" + + +class Data(BaseModel): + id: Optional[str] = None + """Unique identifier for the report""" + + call_types: Optional[List[int]] = None + """List of call types (Inbound = 1, Outbound = 2)""" + + connections: Optional[List[int]] = None + """List of connections""" + + created_at: Optional[str] = None + """Creation date of the report""" + + end_time: Optional[str] = None + """End time in ISO format""" + + filters: Optional[List[DataFilter]] = None + """List of filters""" + + managed_accounts: Optional[List[str]] = None + """List of managed accounts""" + + record_type: Optional[str] = None + + record_types: Optional[List[int]] = None + """List of record types (Complete = 1, Incomplete = 2, Errors = 3)""" + + report_name: Optional[str] = None + """Name of the report""" + + report_url: Optional[str] = None + """URL to download the report""" + + retry: Optional[int] = None + """Number of retries""" + + source: Optional[str] = None + """Source of the report. + + Valid values: calls (default), call-control, fax-api, webrtc + """ + + start_time: Optional[str] = None + """Start time in ISO format""" + + status: Optional[int] = None + """Status of the report (Pending = 1, Complete = 2, Failed = 3, Expired = 4)""" + + timezone: Optional[str] = None + """Timezone for the report""" + + updated_at: Optional[str] = None + """Last update date of the report""" + + +class VoiceDeleteResponse(BaseModel): + data: Optional[Data] = None + """Response object for CDR detailed report""" diff --git a/src/telnyx/types/legacy/reporting/batch_detail_records/voice_list_response.py b/src/telnyx/types/legacy/reporting/batch_detail_records/voice_list_response.py new file mode 100644 index 00000000..d0f78166 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/batch_detail_records/voice_list_response.py @@ -0,0 +1,102 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["VoiceListResponse", "Data", "DataFilter", "Meta"] + + +class DataFilter(BaseModel): + billing_group: Optional[str] = None + """Billing group UUID to filter by""" + + cld: Optional[str] = None + """Called line identification (destination number)""" + + cld_filter: Optional[Literal["contains", "starts_with", "ends_with"]] = None + """Filter type for CLD matching""" + + cli: Optional[str] = None + """Calling line identification (caller ID)""" + + cli_filter: Optional[Literal["contains", "starts_with", "ends_with"]] = None + """Filter type for CLI matching""" + + filter_type: Optional[Literal["and", "or"]] = None + """Logical operator for combining filters""" + + tags_list: Optional[str] = None + """Tag name to filter by""" + + +class Data(BaseModel): + id: Optional[str] = None + """Unique identifier for the report""" + + call_types: Optional[List[int]] = None + """List of call types (Inbound = 1, Outbound = 2)""" + + connections: Optional[List[int]] = None + """List of connections""" + + created_at: Optional[str] = None + """Creation date of the report""" + + end_time: Optional[str] = None + """End time in ISO format""" + + filters: Optional[List[DataFilter]] = None + """List of filters""" + + managed_accounts: Optional[List[str]] = None + """List of managed accounts""" + + record_type: Optional[str] = None + + record_types: Optional[List[int]] = None + """List of record types (Complete = 1, Incomplete = 2, Errors = 3)""" + + report_name: Optional[str] = None + """Name of the report""" + + report_url: Optional[str] = None + """URL to download the report""" + + retry: Optional[int] = None + """Number of retries""" + + source: Optional[str] = None + """Source of the report. + + Valid values: calls (default), call-control, fax-api, webrtc + """ + + start_time: Optional[str] = None + """Start time in ISO format""" + + status: Optional[int] = None + """Status of the report (Pending = 1, Complete = 2, Failed = 3, Expired = 4)""" + + timezone: Optional[str] = None + """Timezone for the report""" + + updated_at: Optional[str] = None + """Last update date of the report""" + + +class Meta(BaseModel): + page_number: Optional[int] = None + + page_size: Optional[int] = None + + total_pages: Optional[int] = None + + total_results: Optional[int] = None + + +class VoiceListResponse(BaseModel): + data: Optional[List[Data]] = None + + meta: Optional[Meta] = None diff --git a/src/telnyx/types/legacy/reporting/batch_detail_records/voice_retrieve_fields_response.py b/src/telnyx/types/legacy/reporting/batch_detail_records/voice_retrieve_fields_response.py new file mode 100644 index 00000000..bc3a153c --- /dev/null +++ b/src/telnyx/types/legacy/reporting/batch_detail_records/voice_retrieve_fields_response.py @@ -0,0 +1,23 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from pydantic import Field as FieldInfo + +from ....._models import BaseModel + +__all__ = ["VoiceRetrieveFieldsResponse"] + + +class VoiceRetrieveFieldsResponse(BaseModel): + billing: Optional[List[str]] = FieldInfo(alias="Billing", default=None) + """Cost and billing related information""" + + interaction_data: Optional[List[str]] = FieldInfo(alias="Interaction Data", default=None) + """Fields related to call interaction and basic call information""" + + number_information: Optional[List[str]] = FieldInfo(alias="Number Information", default=None) + """Geographic and routing information for phone numbers""" + + telephony_data: Optional[List[str]] = FieldInfo(alias="Telephony Data", default=None) + """Technical telephony and call control information""" diff --git a/src/telnyx/types/legacy/reporting/batch_detail_records/voice_retrieve_response.py b/src/telnyx/types/legacy/reporting/batch_detail_records/voice_retrieve_response.py new file mode 100644 index 00000000..a11bd4a3 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/batch_detail_records/voice_retrieve_response.py @@ -0,0 +1,91 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["VoiceRetrieveResponse", "Data", "DataFilter"] + + +class DataFilter(BaseModel): + billing_group: Optional[str] = None + """Billing group UUID to filter by""" + + cld: Optional[str] = None + """Called line identification (destination number)""" + + cld_filter: Optional[Literal["contains", "starts_with", "ends_with"]] = None + """Filter type for CLD matching""" + + cli: Optional[str] = None + """Calling line identification (caller ID)""" + + cli_filter: Optional[Literal["contains", "starts_with", "ends_with"]] = None + """Filter type for CLI matching""" + + filter_type: Optional[Literal["and", "or"]] = None + """Logical operator for combining filters""" + + tags_list: Optional[str] = None + """Tag name to filter by""" + + +class Data(BaseModel): + id: Optional[str] = None + """Unique identifier for the report""" + + call_types: Optional[List[int]] = None + """List of call types (Inbound = 1, Outbound = 2)""" + + connections: Optional[List[int]] = None + """List of connections""" + + created_at: Optional[str] = None + """Creation date of the report""" + + end_time: Optional[str] = None + """End time in ISO format""" + + filters: Optional[List[DataFilter]] = None + """List of filters""" + + managed_accounts: Optional[List[str]] = None + """List of managed accounts""" + + record_type: Optional[str] = None + + record_types: Optional[List[int]] = None + """List of record types (Complete = 1, Incomplete = 2, Errors = 3)""" + + report_name: Optional[str] = None + """Name of the report""" + + report_url: Optional[str] = None + """URL to download the report""" + + retry: Optional[int] = None + """Number of retries""" + + source: Optional[str] = None + """Source of the report. + + Valid values: calls (default), call-control, fax-api, webrtc + """ + + start_time: Optional[str] = None + """Start time in ISO format""" + + status: Optional[int] = None + """Status of the report (Pending = 1, Complete = 2, Failed = 3, Expired = 4)""" + + timezone: Optional[str] = None + """Timezone for the report""" + + updated_at: Optional[str] = None + """Last update date of the report""" + + +class VoiceRetrieveResponse(BaseModel): + data: Optional[Data] = None + """Response object for CDR detailed report""" diff --git a/src/telnyx/types/legacy/reporting/usage_report_retrieve_speech_to_text_params.py b/src/telnyx/types/legacy/reporting/usage_report_retrieve_speech_to_text_params.py new file mode 100644 index 00000000..5ae8bf24 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/usage_report_retrieve_speech_to_text_params.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import datetime +from typing_extensions import Annotated, TypedDict + +from ...._utils import PropertyInfo + +__all__ = ["UsageReportRetrieveSpeechToTextParams"] + + +class UsageReportRetrieveSpeechToTextParams(TypedDict, total=False): + end_date: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + + start_date: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] diff --git a/src/telnyx/types/legacy/reporting/usage_report_retrieve_speech_to_text_response.py b/src/telnyx/types/legacy/reporting/usage_report_retrieve_speech_to_text_response.py new file mode 100644 index 00000000..e8af6b05 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/usage_report_retrieve_speech_to_text_response.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ...._models import BaseModel + +__all__ = ["UsageReportRetrieveSpeechToTextResponse"] + + +class UsageReportRetrieveSpeechToTextResponse(BaseModel): + data: Optional[object] = None diff --git a/src/telnyx/types/legacy/reporting/usage_reports/__init__.py b/src/telnyx/types/legacy/reporting/usage_reports/__init__.py new file mode 100644 index 00000000..420577e7 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/usage_reports/__init__.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .voice_list_params import VoiceListParams as VoiceListParams +from .voice_create_params import VoiceCreateParams as VoiceCreateParams +from .voice_list_response import VoiceListResponse as VoiceListResponse +from .messaging_list_params import MessagingListParams as MessagingListParams +from .voice_create_response import VoiceCreateResponse as VoiceCreateResponse +from .voice_delete_response import VoiceDeleteResponse as VoiceDeleteResponse +from .messaging_create_params import MessagingCreateParams as MessagingCreateParams +from .messaging_list_response import MessagingListResponse as MessagingListResponse +from .voice_retrieve_response import VoiceRetrieveResponse as VoiceRetrieveResponse +from .messaging_create_response import MessagingCreateResponse as MessagingCreateResponse +from .messaging_delete_response import MessagingDeleteResponse as MessagingDeleteResponse +from .number_lookup_list_params import NumberLookupListParams as NumberLookupListParams +from .messaging_retrieve_response import MessagingRetrieveResponse as MessagingRetrieveResponse +from .number_lookup_create_params import NumberLookupCreateParams as NumberLookupCreateParams diff --git a/src/telnyx/types/legacy/reporting/usage_reports/messaging_create_params.py b/src/telnyx/types/legacy/reporting/usage_reports/messaging_create_params.py new file mode 100644 index 00000000..37139df6 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/usage_reports/messaging_create_params.py @@ -0,0 +1,29 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import datetime +from typing_extensions import Required, Annotated, TypedDict + +from ....._types import SequenceNotStr +from ....._utils import PropertyInfo + +__all__ = ["MessagingCreateParams"] + + +class MessagingCreateParams(TypedDict, total=False): + aggregation_type: Required[int] + """Aggregation type: No aggregation = 0, By Messaging Profile = 1, By Tags = 2""" + + end_time: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + + managed_accounts: SequenceNotStr[str] + """List of managed accounts to include""" + + profiles: SequenceNotStr[str] + """List of messaging profile IDs to filter by""" + + select_all_managed_accounts: bool + + start_time: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] diff --git a/src/telnyx/types/legacy/reporting/usage_reports/messaging_create_response.py b/src/telnyx/types/legacy/reporting/usage_reports/messaging_create_response.py new file mode 100644 index 00000000..65069d1b --- /dev/null +++ b/src/telnyx/types/legacy/reporting/usage_reports/messaging_create_response.py @@ -0,0 +1,43 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from ....._models import BaseModel + +__all__ = ["MessagingCreateResponse", "Data"] + + +class Data(BaseModel): + id: Optional[str] = None + """Identifies the resource""" + + aggregation_type: Optional[int] = None + """Aggregation type: No aggregation = 0, By Messaging Profile = 1, By Tags = 2""" + + connections: Optional[List[int]] = None + + created_at: Optional[datetime] = None + + end_time: Optional[datetime] = None + + profiles: Optional[List[str]] = None + """List of messaging profile IDs""" + + record_type: Optional[str] = None + + report_url: Optional[str] = None + + result: Optional[object] = None + + start_time: Optional[datetime] = None + + status: Optional[int] = None + """Status of the report (Pending = 1, Complete = 2, Failed = 3, Expired = 4)""" + + updated_at: Optional[datetime] = None + + +class MessagingCreateResponse(BaseModel): + data: Optional[Data] = None + """Legacy V2 MDR usage report response""" diff --git a/src/telnyx/types/legacy/reporting/usage_reports/messaging_delete_response.py b/src/telnyx/types/legacy/reporting/usage_reports/messaging_delete_response.py new file mode 100644 index 00000000..0e5ff6cb --- /dev/null +++ b/src/telnyx/types/legacy/reporting/usage_reports/messaging_delete_response.py @@ -0,0 +1,43 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from ....._models import BaseModel + +__all__ = ["MessagingDeleteResponse", "Data"] + + +class Data(BaseModel): + id: Optional[str] = None + """Identifies the resource""" + + aggregation_type: Optional[int] = None + """Aggregation type: No aggregation = 0, By Messaging Profile = 1, By Tags = 2""" + + connections: Optional[List[int]] = None + + created_at: Optional[datetime] = None + + end_time: Optional[datetime] = None + + profiles: Optional[List[str]] = None + """List of messaging profile IDs""" + + record_type: Optional[str] = None + + report_url: Optional[str] = None + + result: Optional[object] = None + + start_time: Optional[datetime] = None + + status: Optional[int] = None + """Status of the report (Pending = 1, Complete = 2, Failed = 3, Expired = 4)""" + + updated_at: Optional[datetime] = None + + +class MessagingDeleteResponse(BaseModel): + data: Optional[Data] = None + """Legacy V2 MDR usage report response""" diff --git a/src/telnyx/types/legacy/reporting/usage_reports/messaging_list_params.py b/src/telnyx/types/legacy/reporting/usage_reports/messaging_list_params.py new file mode 100644 index 00000000..df143ad8 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/usage_reports/messaging_list_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["MessagingListParams"] + + +class MessagingListParams(TypedDict, total=False): + page: int + """Page number""" + + per_page: int + """Size of the page""" diff --git a/src/telnyx/types/legacy/reporting/usage_reports/messaging_list_response.py b/src/telnyx/types/legacy/reporting/usage_reports/messaging_list_response.py new file mode 100644 index 00000000..abf66bec --- /dev/null +++ b/src/telnyx/types/legacy/reporting/usage_reports/messaging_list_response.py @@ -0,0 +1,54 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from ....._models import BaseModel + +__all__ = ["MessagingListResponse", "Data", "Meta"] + + +class Data(BaseModel): + id: Optional[str] = None + """Identifies the resource""" + + aggregation_type: Optional[int] = None + """Aggregation type: No aggregation = 0, By Messaging Profile = 1, By Tags = 2""" + + connections: Optional[List[int]] = None + + created_at: Optional[datetime] = None + + end_time: Optional[datetime] = None + + profiles: Optional[List[str]] = None + """List of messaging profile IDs""" + + record_type: Optional[str] = None + + report_url: Optional[str] = None + + result: Optional[object] = None + + start_time: Optional[datetime] = None + + status: Optional[int] = None + """Status of the report (Pending = 1, Complete = 2, Failed = 3, Expired = 4)""" + + updated_at: Optional[datetime] = None + + +class Meta(BaseModel): + page_number: Optional[int] = None + + page_size: Optional[int] = None + + total_pages: Optional[int] = None + + total_results: Optional[int] = None + + +class MessagingListResponse(BaseModel): + data: Optional[List[Data]] = None + + meta: Optional[Meta] = None diff --git a/src/telnyx/types/legacy/reporting/usage_reports/messaging_retrieve_response.py b/src/telnyx/types/legacy/reporting/usage_reports/messaging_retrieve_response.py new file mode 100644 index 00000000..7cb5d759 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/usage_reports/messaging_retrieve_response.py @@ -0,0 +1,43 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from ....._models import BaseModel + +__all__ = ["MessagingRetrieveResponse", "Data"] + + +class Data(BaseModel): + id: Optional[str] = None + """Identifies the resource""" + + aggregation_type: Optional[int] = None + """Aggregation type: No aggregation = 0, By Messaging Profile = 1, By Tags = 2""" + + connections: Optional[List[int]] = None + + created_at: Optional[datetime] = None + + end_time: Optional[datetime] = None + + profiles: Optional[List[str]] = None + """List of messaging profile IDs""" + + record_type: Optional[str] = None + + report_url: Optional[str] = None + + result: Optional[object] = None + + start_time: Optional[datetime] = None + + status: Optional[int] = None + """Status of the report (Pending = 1, Complete = 2, Failed = 3, Expired = 4)""" + + updated_at: Optional[datetime] = None + + +class MessagingRetrieveResponse(BaseModel): + data: Optional[Data] = None + """Legacy V2 MDR usage report response""" diff --git a/src/telnyx/types/legacy/reporting/usage_reports/number_lookup_create_params.py b/src/telnyx/types/legacy/reporting/usage_reports/number_lookup_create_params.py new file mode 100644 index 00000000..e198e181 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/usage_reports/number_lookup_create_params.py @@ -0,0 +1,26 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import date +from typing_extensions import Literal, Annotated, TypedDict + +from ....._types import SequenceNotStr +from ....._utils import PropertyInfo + +__all__ = ["NumberLookupCreateParams"] + + +class NumberLookupCreateParams(TypedDict, total=False): + aggregation_type: Annotated[Literal["ALL", "BY_ORGANIZATION_MEMBER"], PropertyInfo(alias="aggregationType")] + """Type of aggregation for the report""" + + end_date: Annotated[Union[str, date], PropertyInfo(alias="endDate", format="iso8601")] + """End date for the usage report""" + + managed_accounts: Annotated[SequenceNotStr[str], PropertyInfo(alias="managedAccounts")] + """List of managed accounts to include in the report""" + + start_date: Annotated[Union[str, date], PropertyInfo(alias="startDate", format="iso8601")] + """Start date for the usage report""" diff --git a/src/telnyx/types/legacy/reporting/usage_reports/number_lookup_list_params.py b/src/telnyx/types/legacy/reporting/usage_reports/number_lookup_list_params.py new file mode 100644 index 00000000..d9308324 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/usage_reports/number_lookup_list_params.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["NumberLookupListParams"] + + +class NumberLookupListParams(TypedDict, total=False): + page: int + + per_page: int diff --git a/src/telnyx/types/legacy/reporting/usage_reports/voice_create_params.py b/src/telnyx/types/legacy/reporting/usage_reports/voice_create_params.py new file mode 100644 index 00000000..8d31e8ce --- /dev/null +++ b/src/telnyx/types/legacy/reporting/usage_reports/voice_create_params.py @@ -0,0 +1,40 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union, Iterable +from datetime import datetime +from typing_extensions import Required, Annotated, TypedDict + +from ....._types import SequenceNotStr +from ....._utils import PropertyInfo + +__all__ = ["VoiceCreateParams"] + + +class VoiceCreateParams(TypedDict, total=False): + end_time: Required[Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]] + """End time in ISO format""" + + start_time: Required[Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]] + """Start time in ISO format""" + + aggregation_type: int + """ + Aggregation type: All = 0, By Connections = 1, By Tags = 2, By Billing Group = 3 + """ + + connections: Iterable[int] + """List of connections to filter by""" + + managed_accounts: SequenceNotStr[str] + """List of managed accounts to include""" + + product_breakdown: int + """ + Product breakdown type: No breakdown = 0, DID vs Toll-free = 1, Country = 2, DID + vs Toll-free per Country = 3 + """ + + select_all_managed_accounts: bool + """Whether to select all managed accounts""" diff --git a/src/telnyx/types/legacy/reporting/usage_reports/voice_create_response.py b/src/telnyx/types/legacy/reporting/usage_reports/voice_create_response.py new file mode 100644 index 00000000..fbb4b1b2 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/usage_reports/voice_create_response.py @@ -0,0 +1,48 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from ....._models import BaseModel + +__all__ = ["VoiceCreateResponse", "Data"] + + +class Data(BaseModel): + id: Optional[str] = None + """Identifies the resource""" + + aggregation_type: Optional[int] = None + """ + Aggregation type: All = 0, By Connections = 1, By Tags = 2, By Billing Group = 3 + """ + + connections: Optional[List[int]] = None + + created_at: Optional[datetime] = None + + end_time: Optional[datetime] = None + + product_breakdown: Optional[int] = None + """ + Product breakdown type: No breakdown = 0, DID vs Toll-free = 1, Country = 2, DID + vs Toll-free per Country = 3 + """ + + record_type: Optional[str] = None + + report_url: Optional[str] = None + + result: Optional[object] = None + + start_time: Optional[datetime] = None + + status: Optional[int] = None + """Status of the report: Pending = 1, Complete = 2, Failed = 3, Expired = 4""" + + updated_at: Optional[datetime] = None + + +class VoiceCreateResponse(BaseModel): + data: Optional[Data] = None + """Legacy V2 CDR usage report response""" diff --git a/src/telnyx/types/legacy/reporting/usage_reports/voice_delete_response.py b/src/telnyx/types/legacy/reporting/usage_reports/voice_delete_response.py new file mode 100644 index 00000000..62106217 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/usage_reports/voice_delete_response.py @@ -0,0 +1,48 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from ....._models import BaseModel + +__all__ = ["VoiceDeleteResponse", "Data"] + + +class Data(BaseModel): + id: Optional[str] = None + """Identifies the resource""" + + aggregation_type: Optional[int] = None + """ + Aggregation type: All = 0, By Connections = 1, By Tags = 2, By Billing Group = 3 + """ + + connections: Optional[List[int]] = None + + created_at: Optional[datetime] = None + + end_time: Optional[datetime] = None + + product_breakdown: Optional[int] = None + """ + Product breakdown type: No breakdown = 0, DID vs Toll-free = 1, Country = 2, DID + vs Toll-free per Country = 3 + """ + + record_type: Optional[str] = None + + report_url: Optional[str] = None + + result: Optional[object] = None + + start_time: Optional[datetime] = None + + status: Optional[int] = None + """Status of the report: Pending = 1, Complete = 2, Failed = 3, Expired = 4""" + + updated_at: Optional[datetime] = None + + +class VoiceDeleteResponse(BaseModel): + data: Optional[Data] = None + """Legacy V2 CDR usage report response""" diff --git a/src/telnyx/types/legacy/reporting/usage_reports/voice_list_params.py b/src/telnyx/types/legacy/reporting/usage_reports/voice_list_params.py new file mode 100644 index 00000000..fb2591f0 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/usage_reports/voice_list_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["VoiceListParams"] + + +class VoiceListParams(TypedDict, total=False): + page: int + """Page number""" + + per_page: int + """Size of the page""" diff --git a/src/telnyx/types/legacy/reporting/usage_reports/voice_list_response.py b/src/telnyx/types/legacy/reporting/usage_reports/voice_list_response.py new file mode 100644 index 00000000..e668b8b0 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/usage_reports/voice_list_response.py @@ -0,0 +1,59 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from ....._models import BaseModel + +__all__ = ["VoiceListResponse", "Data", "Meta"] + + +class Data(BaseModel): + id: Optional[str] = None + """Identifies the resource""" + + aggregation_type: Optional[int] = None + """ + Aggregation type: All = 0, By Connections = 1, By Tags = 2, By Billing Group = 3 + """ + + connections: Optional[List[int]] = None + + created_at: Optional[datetime] = None + + end_time: Optional[datetime] = None + + product_breakdown: Optional[int] = None + """ + Product breakdown type: No breakdown = 0, DID vs Toll-free = 1, Country = 2, DID + vs Toll-free per Country = 3 + """ + + record_type: Optional[str] = None + + report_url: Optional[str] = None + + result: Optional[object] = None + + start_time: Optional[datetime] = None + + status: Optional[int] = None + """Status of the report: Pending = 1, Complete = 2, Failed = 3, Expired = 4""" + + updated_at: Optional[datetime] = None + + +class Meta(BaseModel): + page_number: Optional[int] = None + + page_size: Optional[int] = None + + total_pages: Optional[int] = None + + total_results: Optional[int] = None + + +class VoiceListResponse(BaseModel): + data: Optional[List[Data]] = None + + meta: Optional[Meta] = None diff --git a/src/telnyx/types/legacy/reporting/usage_reports/voice_retrieve_response.py b/src/telnyx/types/legacy/reporting/usage_reports/voice_retrieve_response.py new file mode 100644 index 00000000..4a1069b8 --- /dev/null +++ b/src/telnyx/types/legacy/reporting/usage_reports/voice_retrieve_response.py @@ -0,0 +1,48 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from ....._models import BaseModel + +__all__ = ["VoiceRetrieveResponse", "Data"] + + +class Data(BaseModel): + id: Optional[str] = None + """Identifies the resource""" + + aggregation_type: Optional[int] = None + """ + Aggregation type: All = 0, By Connections = 1, By Tags = 2, By Billing Group = 3 + """ + + connections: Optional[List[int]] = None + + created_at: Optional[datetime] = None + + end_time: Optional[datetime] = None + + product_breakdown: Optional[int] = None + """ + Product breakdown type: No breakdown = 0, DID vs Toll-free = 1, Country = 2, DID + vs Toll-free per Country = 3 + """ + + record_type: Optional[str] = None + + report_url: Optional[str] = None + + result: Optional[object] = None + + start_time: Optional[datetime] = None + + status: Optional[int] = None + """Status of the report: Pending = 1, Complete = 2, Failed = 3, Expired = 4""" + + updated_at: Optional[datetime] = None + + +class VoiceRetrieveResponse(BaseModel): + data: Optional[Data] = None + """Legacy V2 CDR usage report response""" diff --git a/src/telnyx/types/number_order_status_update_webhook_event.py b/src/telnyx/types/number_order_status_update_webhook_event.py index db6ce9a0..66bd4e25 100644 --- a/src/telnyx/types/number_order_status_update_webhook_event.py +++ b/src/telnyx/types/number_order_status_update_webhook_event.py @@ -1,12 +1,38 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Optional +from datetime import datetime from .._models import BaseModel -from .number_block_order import NumberBlockOrder +from .number_order_with_phone_numbers import NumberOrderWithPhoneNumbers -__all__ = ["NumberOrderStatusUpdateWebhookEvent"] +__all__ = ["NumberOrderStatusUpdateWebhookEvent", "Data", "Meta"] + + +class Data(BaseModel): + id: str + """Unique identifier for the event""" + + event_type: str + """The type of event being sent""" + + occurred_at: datetime + """ISO 8601 timestamp of when the event occurred""" + + payload: NumberOrderWithPhoneNumbers + + record_type: str + """Type of record""" + + +class Meta(BaseModel): + attempt: int + """Webhook delivery attempt number""" + + delivered_to: str + """URL where the webhook was delivered""" class NumberOrderStatusUpdateWebhookEvent(BaseModel): - data: Optional[NumberBlockOrder] = None + data: Data + + meta: Meta diff --git a/src/telnyx/types/oauth_client_create_params.py b/src/telnyx/types/oauth_client_create_params.py new file mode 100644 index 00000000..40ebb73c --- /dev/null +++ b/src/telnyx/types/oauth_client_create_params.py @@ -0,0 +1,39 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Literal, Required, TypedDict + +from .._types import SequenceNotStr + +__all__ = ["OAuthClientCreateParams"] + + +class OAuthClientCreateParams(TypedDict, total=False): + allowed_grant_types: Required[List[Literal["client_credentials", "authorization_code", "refresh_token"]]] + """List of allowed OAuth grant types""" + + allowed_scopes: Required[SequenceNotStr[str]] + """List of allowed OAuth scopes""" + + client_type: Required[Literal["public", "confidential"]] + """OAuth client type""" + + name: Required[str] + """The name of the OAuth client""" + + logo_uri: str + """URL of the client logo""" + + policy_uri: str + """URL of the client's privacy policy""" + + redirect_uris: SequenceNotStr[str] + """List of redirect URIs (required for authorization_code flow)""" + + require_pkce: bool + """Whether PKCE (Proof Key for Code Exchange) is required for this client""" + + tos_uri: str + """URL of the client's terms of service""" diff --git a/src/telnyx/types/oauth_client_create_response.py b/src/telnyx/types/oauth_client_create_response.py new file mode 100644 index 00000000..d5790e60 --- /dev/null +++ b/src/telnyx/types/oauth_client_create_response.py @@ -0,0 +1,63 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["OAuthClientCreateResponse", "Data"] + + +class Data(BaseModel): + client_id: str + """OAuth client identifier""" + + client_type: Literal["public", "confidential"] + """OAuth client type""" + + created_at: datetime + """Timestamp when the client was created""" + + name: str + """Human-readable name for the OAuth client""" + + org_id: str + """Organization ID that owns this OAuth client""" + + record_type: Literal["oauth_client"] + """Record type identifier""" + + require_pkce: bool + """Whether PKCE (Proof Key for Code Exchange) is required for this client""" + + updated_at: datetime + """Timestamp when the client was last updated""" + + user_id: str + """User ID that created this OAuth client""" + + allowed_grant_types: Optional[List[Literal["client_credentials", "authorization_code", "refresh_token"]]] = None + """List of allowed OAuth grant types""" + + allowed_scopes: Optional[List[str]] = None + """List of allowed OAuth scopes""" + + client_secret: Optional[str] = None + """Client secret (only included when available, for confidential clients)""" + + logo_uri: Optional[str] = None + """URL of the client logo""" + + policy_uri: Optional[str] = None + """URL of the client's privacy policy""" + + redirect_uris: Optional[List[str]] = None + """List of allowed redirect URIs""" + + tos_uri: Optional[str] = None + """URL of the client's terms of service""" + + +class OAuthClientCreateResponse(BaseModel): + data: Optional[Data] = None diff --git a/src/telnyx/types/oauth_client_list_params.py b/src/telnyx/types/oauth_client_list_params.py new file mode 100644 index 00000000..9a17a11a --- /dev/null +++ b/src/telnyx/types/oauth_client_list_params.py @@ -0,0 +1,38 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Annotated, TypedDict + +from .._utils import PropertyInfo + +__all__ = ["OAuthClientListParams"] + + +class OAuthClientListParams(TypedDict, total=False): + filter_allowed_grant_types_contains: Annotated[ + Literal["client_credentials", "authorization_code", "refresh_token"], + PropertyInfo(alias="filter[allowed_grant_types][contains]"), + ] + """Filter by allowed grant type""" + + filter_client_id: Annotated[str, PropertyInfo(alias="filter[client_id]")] + """Filter by client ID""" + + filter_client_type: Annotated[Literal["confidential", "public"], PropertyInfo(alias="filter[client_type]")] + """Filter by client type""" + + filter_name: Annotated[str, PropertyInfo(alias="filter[name]")] + """Filter by exact client name""" + + filter_name_contains: Annotated[str, PropertyInfo(alias="filter[name][contains]")] + """Filter by client name containing text""" + + filter_verified: Annotated[bool, PropertyInfo(alias="filter[verified]")] + """Filter by verification status""" + + page_number: Annotated[int, PropertyInfo(alias="page[number]")] + """Page number""" + + page_size: Annotated[int, PropertyInfo(alias="page[size]")] + """Number of results per page""" diff --git a/src/telnyx/types/oauth_client_list_response.py b/src/telnyx/types/oauth_client_list_response.py new file mode 100644 index 00000000..725377e3 --- /dev/null +++ b/src/telnyx/types/oauth_client_list_response.py @@ -0,0 +1,79 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["OAuthClientListResponse", "Data", "Meta"] + + +class Data(BaseModel): + client_id: str + """OAuth client identifier""" + + client_type: Literal["public", "confidential"] + """OAuth client type""" + + created_at: datetime + """Timestamp when the client was created""" + + name: str + """Human-readable name for the OAuth client""" + + org_id: str + """Organization ID that owns this OAuth client""" + + record_type: Literal["oauth_client"] + """Record type identifier""" + + require_pkce: bool + """Whether PKCE (Proof Key for Code Exchange) is required for this client""" + + updated_at: datetime + """Timestamp when the client was last updated""" + + user_id: str + """User ID that created this OAuth client""" + + allowed_grant_types: Optional[List[Literal["client_credentials", "authorization_code", "refresh_token"]]] = None + """List of allowed OAuth grant types""" + + allowed_scopes: Optional[List[str]] = None + """List of allowed OAuth scopes""" + + client_secret: Optional[str] = None + """Client secret (only included when available, for confidential clients)""" + + logo_uri: Optional[str] = None + """URL of the client logo""" + + policy_uri: Optional[str] = None + """URL of the client's privacy policy""" + + redirect_uris: Optional[List[str]] = None + """List of allowed redirect URIs""" + + tos_uri: Optional[str] = None + """URL of the client's terms of service""" + + +class Meta(BaseModel): + page_number: Optional[int] = None + """Current page number""" + + page_size: Optional[int] = None + """Number of items per page""" + + total_pages: Optional[int] = None + """Total number of pages""" + + total_results: Optional[int] = None + """Total number of results""" + + +class OAuthClientListResponse(BaseModel): + data: Optional[List[Data]] = None + + meta: Optional[Meta] = None diff --git a/src/telnyx/types/oauth_client_retrieve_response.py b/src/telnyx/types/oauth_client_retrieve_response.py new file mode 100644 index 00000000..1cffc552 --- /dev/null +++ b/src/telnyx/types/oauth_client_retrieve_response.py @@ -0,0 +1,63 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["OAuthClientRetrieveResponse", "Data"] + + +class Data(BaseModel): + client_id: str + """OAuth client identifier""" + + client_type: Literal["public", "confidential"] + """OAuth client type""" + + created_at: datetime + """Timestamp when the client was created""" + + name: str + """Human-readable name for the OAuth client""" + + org_id: str + """Organization ID that owns this OAuth client""" + + record_type: Literal["oauth_client"] + """Record type identifier""" + + require_pkce: bool + """Whether PKCE (Proof Key for Code Exchange) is required for this client""" + + updated_at: datetime + """Timestamp when the client was last updated""" + + user_id: str + """User ID that created this OAuth client""" + + allowed_grant_types: Optional[List[Literal["client_credentials", "authorization_code", "refresh_token"]]] = None + """List of allowed OAuth grant types""" + + allowed_scopes: Optional[List[str]] = None + """List of allowed OAuth scopes""" + + client_secret: Optional[str] = None + """Client secret (only included when available, for confidential clients)""" + + logo_uri: Optional[str] = None + """URL of the client logo""" + + policy_uri: Optional[str] = None + """URL of the client's privacy policy""" + + redirect_uris: Optional[List[str]] = None + """List of allowed redirect URIs""" + + tos_uri: Optional[str] = None + """URL of the client's terms of service""" + + +class OAuthClientRetrieveResponse(BaseModel): + data: Optional[Data] = None diff --git a/src/telnyx/types/oauth_client_update_params.py b/src/telnyx/types/oauth_client_update_params.py new file mode 100644 index 00000000..36090a53 --- /dev/null +++ b/src/telnyx/types/oauth_client_update_params.py @@ -0,0 +1,36 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Literal, TypedDict + +from .._types import SequenceNotStr + +__all__ = ["OAuthClientUpdateParams"] + + +class OAuthClientUpdateParams(TypedDict, total=False): + allowed_grant_types: List[Literal["client_credentials", "authorization_code", "refresh_token"]] + """List of allowed OAuth grant types""" + + allowed_scopes: SequenceNotStr[str] + """List of allowed OAuth scopes""" + + logo_uri: str + """URL of the client logo""" + + name: str + """The name of the OAuth client""" + + policy_uri: str + """URL of the client's privacy policy""" + + redirect_uris: SequenceNotStr[str] + """List of redirect URIs""" + + require_pkce: bool + """Whether PKCE (Proof Key for Code Exchange) is required for this client""" + + tos_uri: str + """URL of the client's terms of service""" diff --git a/src/telnyx/types/oauth_client_update_response.py b/src/telnyx/types/oauth_client_update_response.py new file mode 100644 index 00000000..3d44d15f --- /dev/null +++ b/src/telnyx/types/oauth_client_update_response.py @@ -0,0 +1,63 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["OAuthClientUpdateResponse", "Data"] + + +class Data(BaseModel): + client_id: str + """OAuth client identifier""" + + client_type: Literal["public", "confidential"] + """OAuth client type""" + + created_at: datetime + """Timestamp when the client was created""" + + name: str + """Human-readable name for the OAuth client""" + + org_id: str + """Organization ID that owns this OAuth client""" + + record_type: Literal["oauth_client"] + """Record type identifier""" + + require_pkce: bool + """Whether PKCE (Proof Key for Code Exchange) is required for this client""" + + updated_at: datetime + """Timestamp when the client was last updated""" + + user_id: str + """User ID that created this OAuth client""" + + allowed_grant_types: Optional[List[Literal["client_credentials", "authorization_code", "refresh_token"]]] = None + """List of allowed OAuth grant types""" + + allowed_scopes: Optional[List[str]] = None + """List of allowed OAuth scopes""" + + client_secret: Optional[str] = None + """Client secret (only included when available, for confidential clients)""" + + logo_uri: Optional[str] = None + """URL of the client logo""" + + policy_uri: Optional[str] = None + """URL of the client's privacy policy""" + + redirect_uris: Optional[List[str]] = None + """List of allowed redirect URIs""" + + tos_uri: Optional[str] = None + """URL of the client's terms of service""" + + +class OAuthClientUpdateResponse(BaseModel): + data: Optional[Data] = None diff --git a/src/telnyx/types/oauth_grant_delete_response.py b/src/telnyx/types/oauth_grant_delete_response.py new file mode 100644 index 00000000..070257c9 --- /dev/null +++ b/src/telnyx/types/oauth_grant_delete_response.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["OAuthGrantDeleteResponse", "Data"] + + +class Data(BaseModel): + id: str + """Unique identifier for the OAuth grant""" + + client_id: str + """OAuth client identifier""" + + created_at: datetime + """Timestamp when the grant was created""" + + record_type: Literal["oauth_grant"] + """Record type identifier""" + + scopes: List[str] + """List of granted OAuth scopes""" + + last_used_at: Optional[datetime] = None + """Timestamp when the grant was last used""" + + +class OAuthGrantDeleteResponse(BaseModel): + data: Optional[Data] = None diff --git a/src/telnyx/types/oauth_grant_list_params.py b/src/telnyx/types/oauth_grant_list_params.py new file mode 100644 index 00000000..d7a9216c --- /dev/null +++ b/src/telnyx/types/oauth_grant_list_params.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Annotated, TypedDict + +from .._utils import PropertyInfo + +__all__ = ["OAuthGrantListParams"] + + +class OAuthGrantListParams(TypedDict, total=False): + page_number: Annotated[int, PropertyInfo(alias="page[number]")] + """Page number""" + + page_size: Annotated[int, PropertyInfo(alias="page[size]")] + """Number of results per page""" diff --git a/src/telnyx/types/oauth_grant_list_response.py b/src/telnyx/types/oauth_grant_list_response.py new file mode 100644 index 00000000..64d9fd14 --- /dev/null +++ b/src/telnyx/types/oauth_grant_list_response.py @@ -0,0 +1,49 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["OAuthGrantListResponse", "Data", "Meta"] + + +class Data(BaseModel): + id: str + """Unique identifier for the OAuth grant""" + + client_id: str + """OAuth client identifier""" + + created_at: datetime + """Timestamp when the grant was created""" + + record_type: Literal["oauth_grant"] + """Record type identifier""" + + scopes: List[str] + """List of granted OAuth scopes""" + + last_used_at: Optional[datetime] = None + """Timestamp when the grant was last used""" + + +class Meta(BaseModel): + page_number: Optional[int] = None + """Current page number""" + + page_size: Optional[int] = None + """Number of items per page""" + + total_pages: Optional[int] = None + """Total number of pages""" + + total_results: Optional[int] = None + """Total number of results""" + + +class OAuthGrantListResponse(BaseModel): + data: Optional[List[Data]] = None + + meta: Optional[Meta] = None diff --git a/src/telnyx/types/oauth_grant_retrieve_response.py b/src/telnyx/types/oauth_grant_retrieve_response.py new file mode 100644 index 00000000..cbc55a5e --- /dev/null +++ b/src/telnyx/types/oauth_grant_retrieve_response.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["OAuthGrantRetrieveResponse", "Data"] + + +class Data(BaseModel): + id: str + """Unique identifier for the OAuth grant""" + + client_id: str + """OAuth client identifier""" + + created_at: datetime + """Timestamp when the grant was created""" + + record_type: Literal["oauth_grant"] + """Record type identifier""" + + scopes: List[str] + """List of granted OAuth scopes""" + + last_used_at: Optional[datetime] = None + """Timestamp when the grant was last used""" + + +class OAuthGrantRetrieveResponse(BaseModel): + data: Optional[Data] = None diff --git a/src/telnyx/types/oauth_grants_params.py b/src/telnyx/types/oauth_grants_params.py new file mode 100644 index 00000000..58c922f6 --- /dev/null +++ b/src/telnyx/types/oauth_grants_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["OAuthGrantsParams"] + + +class OAuthGrantsParams(TypedDict, total=False): + allowed: Required[bool] + """Whether the grant is allowed""" + + consent_token: Required[str] + """Consent token""" diff --git a/src/telnyx/types/oauth_grants_response.py b/src/telnyx/types/oauth_grants_response.py new file mode 100644 index 00000000..a79bed8b --- /dev/null +++ b/src/telnyx/types/oauth_grants_response.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .._models import BaseModel + +__all__ = ["OAuthGrantsResponse"] + + +class OAuthGrantsResponse(BaseModel): + redirect_uri: str + """Redirect URI with authorization code or error""" diff --git a/src/telnyx/types/oauth_introspect_params.py b/src/telnyx/types/oauth_introspect_params.py new file mode 100644 index 00000000..20fcd29c --- /dev/null +++ b/src/telnyx/types/oauth_introspect_params.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["OAuthIntrospectParams"] + + +class OAuthIntrospectParams(TypedDict, total=False): + token: Required[str] + """The token to introspect""" diff --git a/src/telnyx/types/oauth_introspect_response.py b/src/telnyx/types/oauth_introspect_response.py new file mode 100644 index 00000000..4a99c2fc --- /dev/null +++ b/src/telnyx/types/oauth_introspect_response.py @@ -0,0 +1,30 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from .._models import BaseModel + +__all__ = ["OAuthIntrospectResponse"] + + +class OAuthIntrospectResponse(BaseModel): + active: bool + """Whether the token is active""" + + aud: Optional[str] = None + """Audience""" + + client_id: Optional[str] = None + """Client identifier""" + + exp: Optional[int] = None + """Expiration timestamp""" + + iat: Optional[int] = None + """Issued at timestamp""" + + iss: Optional[str] = None + """Issuer""" + + scope: Optional[str] = None + """Space-separated list of scopes""" diff --git a/src/telnyx/types/oauth_register_params.py b/src/telnyx/types/oauth_register_params.py new file mode 100644 index 00000000..0ac1bc98 --- /dev/null +++ b/src/telnyx/types/oauth_register_params.py @@ -0,0 +1,39 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Literal, TypedDict + +from .._types import SequenceNotStr + +__all__ = ["OAuthRegisterParams"] + + +class OAuthRegisterParams(TypedDict, total=False): + client_name: str + """Human-readable string name of the client to be presented to the end-user""" + + grant_types: List[Literal["authorization_code", "client_credentials", "refresh_token"]] + """Array of OAuth 2.0 grant type strings that the client may use""" + + logo_uri: str + """URL of the client logo""" + + policy_uri: str + """URL of the client's privacy policy""" + + redirect_uris: SequenceNotStr[str] + """Array of redirection URI strings for use in redirect-based flows""" + + response_types: SequenceNotStr[str] + """Array of the OAuth 2.0 response type strings that the client may use""" + + scope: str + """Space-separated string of scope values that the client may use""" + + token_endpoint_auth_method: Literal["none", "client_secret_basic", "client_secret_post"] + """Authentication method for the token endpoint""" + + tos_uri: str + """URL of the client's terms of service""" diff --git a/src/telnyx/types/oauth_register_response.py b/src/telnyx/types/oauth_register_response.py new file mode 100644 index 00000000..23ca187b --- /dev/null +++ b/src/telnyx/types/oauth_register_response.py @@ -0,0 +1,45 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from .._models import BaseModel + +__all__ = ["OAuthRegisterResponse"] + + +class OAuthRegisterResponse(BaseModel): + client_id: str + """Unique client identifier""" + + client_id_issued_at: int + """Unix timestamp of when the client ID was issued""" + + client_name: Optional[str] = None + """Human-readable client name""" + + client_secret: Optional[str] = None + """Client secret (only for confidential clients)""" + + grant_types: Optional[List[str]] = None + """Array of allowed grant types""" + + logo_uri: Optional[str] = None + """URL of the client logo""" + + policy_uri: Optional[str] = None + """URL of the client's privacy policy""" + + redirect_uris: Optional[List[str]] = None + """Array of redirection URIs""" + + response_types: Optional[List[str]] = None + """Array of allowed response types""" + + scope: Optional[str] = None + """Space-separated scope values""" + + token_endpoint_auth_method: Optional[str] = None + """Token endpoint authentication method""" + + tos_uri: Optional[str] = None + """URL of the client's terms of service""" diff --git a/src/telnyx/types/oauth_retrieve_authorize_params.py b/src/telnyx/types/oauth_retrieve_authorize_params.py new file mode 100644 index 00000000..b3b993f3 --- /dev/null +++ b/src/telnyx/types/oauth_retrieve_authorize_params.py @@ -0,0 +1,30 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["OAuthRetrieveAuthorizeParams"] + + +class OAuthRetrieveAuthorizeParams(TypedDict, total=False): + client_id: Required[str] + """OAuth client identifier""" + + redirect_uri: Required[str] + """Redirect URI""" + + response_type: Required[Literal["code"]] + """OAuth response type""" + + code_challenge: str + """PKCE code challenge""" + + code_challenge_method: Literal["plain", "S256"] + """PKCE code challenge method""" + + scope: str + """Space-separated list of requested scopes""" + + state: str + """State parameter for CSRF protection""" diff --git a/src/telnyx/types/oauth_retrieve_jwks_response.py b/src/telnyx/types/oauth_retrieve_jwks_response.py new file mode 100644 index 00000000..fae9db63 --- /dev/null +++ b/src/telnyx/types/oauth_retrieve_jwks_response.py @@ -0,0 +1,25 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from .._models import BaseModel + +__all__ = ["OAuthRetrieveJwksResponse", "Key"] + + +class Key(BaseModel): + alg: Optional[str] = None + """Algorithm""" + + kid: Optional[str] = None + """Key ID""" + + kty: Optional[str] = None + """Key type""" + + use: Optional[str] = None + """Key use""" + + +class OAuthRetrieveJwksResponse(BaseModel): + keys: Optional[List[Key]] = None diff --git a/src/telnyx/types/oauth_retrieve_response.py b/src/telnyx/types/oauth_retrieve_response.py new file mode 100644 index 00000000..32544742 --- /dev/null +++ b/src/telnyx/types/oauth_retrieve_response.py @@ -0,0 +1,47 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from .._models import BaseModel + +__all__ = ["OAuthRetrieveResponse", "Data", "DataRequestedScope"] + + +class DataRequestedScope(BaseModel): + id: Optional[str] = None + """Scope ID""" + + description: Optional[str] = None + """Scope description""" + + name: Optional[str] = None + """Scope name""" + + +class Data(BaseModel): + client_id: Optional[str] = None + """Client ID""" + + logo_uri: Optional[str] = None + """URL of the client logo""" + + name: Optional[str] = None + """Client name""" + + policy_uri: Optional[str] = None + """URL of the client's privacy policy""" + + redirect_uri: Optional[str] = None + """The redirect URI for this authorization""" + + requested_scopes: Optional[List[DataRequestedScope]] = None + + tos_uri: Optional[str] = None + """URL of the client's terms of service""" + + verified: Optional[bool] = None + """Whether the client is verified""" + + +class OAuthRetrieveResponse(BaseModel): + data: Optional[Data] = None diff --git a/src/telnyx/types/oauth_token_params.py b/src/telnyx/types/oauth_token_params.py new file mode 100644 index 00000000..f64d5399 --- /dev/null +++ b/src/telnyx/types/oauth_token_params.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["OAuthTokenParams"] + + +class OAuthTokenParams(TypedDict, total=False): + grant_type: Required[Literal["client_credentials", "authorization_code", "refresh_token"]] + """OAuth 2.0 grant type""" + + client_id: str + """OAuth client ID (if not using HTTP Basic auth)""" + + client_secret: str + """OAuth client secret (if not using HTTP Basic auth)""" + + code: str + """Authorization code (for authorization_code flow)""" + + code_verifier: str + """PKCE code verifier (for authorization_code flow)""" + + redirect_uri: str + """Redirect URI (for authorization_code flow)""" + + refresh_token: str + """Refresh token (for refresh_token flow)""" + + scope: str + """Space-separated list of requested scopes (for client_credentials)""" diff --git a/src/telnyx/types/oauth_token_response.py b/src/telnyx/types/oauth_token_response.py new file mode 100644 index 00000000..2166991d --- /dev/null +++ b/src/telnyx/types/oauth_token_response.py @@ -0,0 +1,25 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["OAuthTokenResponse"] + + +class OAuthTokenResponse(BaseModel): + access_token: str + """The access token""" + + expires_in: int + """Token lifetime in seconds""" + + token_type: Literal["Bearer"] + """Token type""" + + refresh_token: Optional[str] = None + """Refresh token (if applicable)""" + + scope: Optional[str] = None + """Space-separated list of granted scopes""" diff --git a/src/telnyx/types/phone_number_delete_response.py b/src/telnyx/types/phone_number_delete_response.py index a8a820ba..ba74790e 100644 --- a/src/telnyx/types/phone_number_delete_response.py +++ b/src/telnyx/types/phone_number_delete_response.py @@ -49,6 +49,13 @@ class Data(BaseModel): customer_reference: Optional[str] = None """A customer reference string for customer look ups.""" + deletion_lock_enabled: Optional[bool] = None + """Indicates whether deletion lock is enabled for this number. + + When enabled, this prevents the phone number from being deleted via the API or + Telnyx portal. + """ + emergency_address_id: Optional[str] = None """Identifies the emergency address associated with the phone number.""" diff --git a/src/telnyx/types/phone_number_detailed.py b/src/telnyx/types/phone_number_detailed.py index a6811ad0..07a51e4f 100644 --- a/src/telnyx/types/phone_number_detailed.py +++ b/src/telnyx/types/phone_number_detailed.py @@ -49,6 +49,13 @@ class PhoneNumberDetailed(BaseModel): customer_reference: Optional[str] = None """A customer reference string for customer look ups.""" + deletion_lock_enabled: Optional[bool] = None + """Indicates whether deletion lock is enabled for this number. + + When enabled, this prevents the phone number from being deleted via the API or + Telnyx portal. + """ + emergency_address_id: Optional[str] = None """Identifies the emergency address associated with the phone number.""" diff --git a/src/telnyx/types/phone_number_list_params.py b/src/telnyx/types/phone_number_list_params.py index f4186df6..71871515 100644 --- a/src/telnyx/types/phone_number_list_params.py +++ b/src/telnyx/types/phone_number_list_params.py @@ -122,6 +122,12 @@ class Filter(TypedDict, total=False): ] """Filter by usage_payment_method.""" + without_tags: Literal["true", "false"] + """When set to 'true', filters for phone numbers that do not have any tags applied. + + All other values are ignored. + """ + class Page(TypedDict, total=False): number: int diff --git a/src/telnyx/types/phone_numbers/job_update_batch_params.py b/src/telnyx/types/phone_numbers/job_update_batch_params.py index 8f8841fd..fcb49b64 100644 --- a/src/telnyx/types/phone_numbers/job_update_batch_params.py +++ b/src/telnyx/types/phone_numbers/job_update_batch_params.py @@ -39,6 +39,13 @@ class JobUpdateBatchParams(TypedDict, total=False): customer_reference: str """A customer reference string for customer look ups.""" + deletion_lock_enabled: bool + """Indicates whether to enable or disable the deletion lock on each phone number. + + When enabled, this prevents the phone number from being deleted via the API or + Telnyx portal. + """ + external_pin: str """ If someone attempts to port your phone number away from Telnyx and your phone diff --git a/src/telnyx/types/porting_order.py b/src/telnyx/types/porting_order.py index eb230a95..0fb90f6d 100644 --- a/src/telnyx/types/porting_order.py +++ b/src/telnyx/types/porting_order.py @@ -33,6 +33,9 @@ class PortingOrder(BaseModel): created_at: Optional[datetime] = None """ISO 8601 formatted date indicating when the resource was created.""" + customer_group_reference: Optional[str] = None + """A customer-specified group reference for customer bookkeeping purposes""" + customer_reference: Optional[str] = None """A customer-specified reference number for customer bookkeeping purposes""" diff --git a/src/telnyx/types/porting_order_create_params.py b/src/telnyx/types/porting_order_create_params.py index fb27d30c..37b64faf 100644 --- a/src/telnyx/types/porting_order_create_params.py +++ b/src/telnyx/types/porting_order_create_params.py @@ -13,5 +13,8 @@ class PortingOrderCreateParams(TypedDict, total=False): phone_numbers: Required[SequenceNotStr[str]] """The list of +E.164 formatted phone numbers""" + customer_group_reference: str + """A customer-specified group reference for customer bookkeeping purposes""" + customer_reference: str """A customer-specified reference number for customer bookkeeping purposes""" diff --git a/src/telnyx/types/porting_order_list_params.py b/src/telnyx/types/porting_order_list_params.py index b0d5b80c..0bc1909e 100644 --- a/src/telnyx/types/porting_order_list_params.py +++ b/src/telnyx/types/porting_order_list_params.py @@ -2,15 +2,19 @@ from __future__ import annotations -from typing_extensions import Literal, Annotated, TypedDict +from typing_extensions import Literal, TypedDict -from .._utils import PropertyInfo from .porting_order_type import PortingOrderType __all__ = [ "PortingOrderListParams", "Filter", + "FilterActivationSettings", "FilterActivationSettingsFocDatetimeRequested", + "FilterEndUser", + "FilterEndUserAdmin", + "FilterMisc", + "FilterPhoneNumbers", "FilterPhoneNumbersPhoneNumber", "Page", "Sort", @@ -21,10 +25,10 @@ class PortingOrderListParams(TypedDict, total=False): filter: Filter """Consolidated filter parameter (deepObject style). - Originally: filter[customer_reference], filter[parent_support_key], - filter[phone_numbers.country_code], filter[phone_numbers.carrier_name], - filter[misc.type], filter[end_user.admin.entity_name], - filter[end_user.admin.auth_person_name], + Originally: filter[customer_reference], filter[customer_group_reference], + filter[parent_support_key], filter[phone_numbers.country_code], + filter[phone_numbers.carrier_name], filter[misc.type], + filter[end_user.admin.entity_name], filter[end_user.admin.auth_person_name], filter[activation_settings.fast_port_eligible], filter[activation_settings.foc_datetime_requested][gt], filter[activation_settings.foc_datetime_requested][lt], @@ -52,47 +56,64 @@ class FilterActivationSettingsFocDatetimeRequested(TypedDict, total=False): """Filter results by foc date earlier than this value""" -class FilterPhoneNumbersPhoneNumber(TypedDict, total=False): - contains: str - """Filter results by full or partial phone_number""" - - -class Filter(TypedDict, total=False): - activation_settings_fast_port_eligible: Annotated[ - bool, PropertyInfo(alias="activation_settings.fast_port_eligible") - ] +class FilterActivationSettings(TypedDict, total=False): + fast_port_eligible: bool """Filter results by fast port eligible""" - activation_settings_foc_datetime_requested: Annotated[ - FilterActivationSettingsFocDatetimeRequested, PropertyInfo(alias="activation_settings.foc_datetime_requested") - ] + foc_datetime_requested: FilterActivationSettingsFocDatetimeRequested """FOC datetime range filtering operations""" - customer_reference: str - """Filter results by customer_reference""" - end_user_admin_auth_person_name: Annotated[str, PropertyInfo(alias="end_user.admin.auth_person_name")] +class FilterEndUserAdmin(TypedDict, total=False): + auth_person_name: str """Filter results by authorized person""" - end_user_admin_entity_name: Annotated[str, PropertyInfo(alias="end_user.admin.entity_name")] + entity_name: str """Filter results by person or company name""" - misc_type: Annotated[PortingOrderType, PropertyInfo(alias="misc.type")] + +class FilterEndUser(TypedDict, total=False): + admin: FilterEndUserAdmin + + +class FilterMisc(TypedDict, total=False): + type: PortingOrderType """Filter results by porting order type""" - parent_support_key: str - """Filter results by parent_support_key""" - phone_numbers_carrier_name: Annotated[str, PropertyInfo(alias="phone_numbers.carrier_name")] +class FilterPhoneNumbersPhoneNumber(TypedDict, total=False): + contains: str + """Filter results by full or partial phone_number""" + + +class FilterPhoneNumbers(TypedDict, total=False): + carrier_name: str """Filter results by old service provider""" - phone_numbers_country_code: Annotated[str, PropertyInfo(alias="phone_numbers.country_code")] + country_code: str """Filter results by country ISO 3166-1 alpha-2 code""" - phone_numbers_phone_number: Annotated[ - FilterPhoneNumbersPhoneNumber, PropertyInfo(alias="phone_numbers.phone_number") - ] - """Phone number filtering operations""" + phone_number: FilterPhoneNumbersPhoneNumber + """Phone number pattern filtering operations""" + + +class Filter(TypedDict, total=False): + activation_settings: FilterActivationSettings + + customer_group_reference: str + """Filter results by customer_group_reference""" + + customer_reference: str + """Filter results by customer_reference""" + + end_user: FilterEndUser + + misc: FilterMisc + + parent_support_key: str + """Filter results by parent_support_key""" + + phone_numbers: FilterPhoneNumbers class Page(TypedDict, total=False): diff --git a/src/telnyx/types/porting_order_update_params.py b/src/telnyx/types/porting_order_update_params.py index f4bffb09..87e94c39 100644 --- a/src/telnyx/types/porting_order_update_params.py +++ b/src/telnyx/types/porting_order_update_params.py @@ -19,6 +19,8 @@ class PortingOrderUpdateParams(TypedDict, total=False): activation_settings: ActivationSettings + customer_group_reference: str + customer_reference: str documents: PortingOrderDocumentsParam diff --git a/src/telnyx/types/porting_orders/phone_number_configuration_list_params.py b/src/telnyx/types/porting_orders/phone_number_configuration_list_params.py index 1edd7bca..6a0700df 100644 --- a/src/telnyx/types/porting_orders/phone_number_configuration_list_params.py +++ b/src/telnyx/types/porting_orders/phone_number_configuration_list_params.py @@ -3,12 +3,11 @@ from __future__ import annotations from typing import List -from typing_extensions import Literal, Annotated, TypedDict +from typing_extensions import Literal, TypedDict from ..._types import SequenceNotStr -from ..._utils import PropertyInfo -__all__ = ["PhoneNumberConfigurationListParams", "Filter", "Page", "Sort"] +__all__ = ["PhoneNumberConfigurationListParams", "Filter", "FilterPortingOrder", "Page", "Sort"] class PhoneNumberConfigurationListParams(TypedDict, total=False): @@ -29,25 +28,26 @@ class PhoneNumberConfigurationListParams(TypedDict, total=False): """Consolidated sort parameter (deepObject style). Originally: sort[value]""" -class Filter(TypedDict, total=False): - porting_order_status: Annotated[ - List[ - Literal[ - "activation-in-progress", - "cancel-pending", - "cancelled", - "draft", - "exception", - "foc-date-confirmed", - "in-process", - "ported", - "submitted", - ] - ], - PropertyInfo(alias="porting_order.status"), +class FilterPortingOrder(TypedDict, total=False): + status: List[ + Literal[ + "activation-in-progress", + "cancel-pending", + "cancelled", + "draft", + "exception", + "foc-date-confirmed", + "in-process", + "ported", + "submitted", + ] ] """Filter results by specific porting order statuses""" + +class Filter(TypedDict, total=False): + porting_order: FilterPortingOrder + porting_phone_number: SequenceNotStr[str] """Filter results by a list of porting phone number IDs""" diff --git a/src/telnyx/types/shared/simple_sim_card.py b/src/telnyx/types/shared/simple_sim_card.py index cbcf82b0..1f199cbc 100644 --- a/src/telnyx/types/shared/simple_sim_card.py +++ b/src/telnyx/types/shared/simple_sim_card.py @@ -28,6 +28,9 @@ class SimpleSimCard(BaseModel): actions_in_progress: Optional[bool] = None """Indicate whether the SIM card has any pending (in-progress) actions.""" + authorized_imeis: Optional[List[str]] = None + """List of IMEIs authorized to use a given SIM card.""" + created_at: Optional[str] = None """ISO 8601 formatted date-time indicating when the resource was created.""" @@ -37,6 +40,12 @@ class SimpleSimCard(BaseModel): data_limit: Optional[DataLimit] = None """The SIM card individual data limit configuration.""" + eid: Optional[str] = None + """The Embedded Identity Document (eID) for eSIM cards.""" + + esim_installation_status: Optional[Literal["released", "disabled"]] = None + """The installation status of the eSIM. Only applicable for eSIM cards.""" + iccid: Optional[str] = None """The ICCID is the identifier of the specific SIM card/chip. @@ -66,6 +75,9 @@ class SimpleSimCard(BaseModel): record_type: Optional[str] = None + resources_with_in_progress_actions: Optional[List[object]] = None + """List of resources with actions in progress.""" + sim_card_group_id: Optional[str] = None """The group SIMCardGroup identification. @@ -83,3 +95,6 @@ class SimpleSimCard(BaseModel): updated_at: Optional[str] = None """ISO 8601 formatted date-time indicating when the resource was updated.""" + + version: Optional[str] = None + """The version of the SIM card.""" diff --git a/src/telnyx/types/sim_card.py b/src/telnyx/types/sim_card.py index e823d5e4..7b139608 100644 --- a/src/telnyx/types/sim_card.py +++ b/src/telnyx/types/sim_card.py @@ -103,6 +103,12 @@ class SimCard(BaseModel): data_limit: Optional[DataLimit] = None """The SIM card individual data limit configuration.""" + eid: Optional[str] = None + """The Embedded Identity Document (eID) for eSIM cards.""" + + esim_installation_status: Optional[Literal["released", "disabled"]] = None + """The installation status of the eSIM. Only applicable for eSIM cards.""" + iccid: Optional[str] = None """The ICCID is the identifier of the specific SIM card/chip. @@ -158,6 +164,9 @@ class SimCard(BaseModel): record_type: Optional[str] = None + resources_with_in_progress_actions: Optional[List[object]] = None + """List of resources with actions in progress.""" + sim_card_group_id: Optional[str] = None """The group SIMCardGroup identification. @@ -175,3 +184,6 @@ class SimCard(BaseModel): updated_at: Optional[str] = None """ISO 8601 formatted date-time indicating when the resource was updated.""" + + version: Optional[str] = None + """The version of the SIM card.""" diff --git a/src/telnyx/types/sim_card_update_params.py b/src/telnyx/types/sim_card_update_params.py index 317d3fb5..d2d173a0 100644 --- a/src/telnyx/types/sim_card_update_params.py +++ b/src/telnyx/types/sim_card_update_params.py @@ -2,6 +2,7 @@ from __future__ import annotations +from typing import Optional from typing_extensions import Literal, TypedDict from .._types import SequenceNotStr @@ -11,7 +12,7 @@ class SimCardUpdateParams(TypedDict, total=False): - authorized_imeis: SequenceNotStr[str] + authorized_imeis: Optional[SequenceNotStr[str]] """List of IMEIs authorized to use a given SIM card.""" data_limit: DataLimit diff --git a/src/telnyx/types/stream_bidirectional_codec.py b/src/telnyx/types/stream_bidirectional_codec.py index 11c92778..10bdbb4c 100644 --- a/src/telnyx/types/stream_bidirectional_codec.py +++ b/src/telnyx/types/stream_bidirectional_codec.py @@ -4,4 +4,4 @@ __all__ = ["StreamBidirectionalCodec"] -StreamBidirectionalCodec: TypeAlias = Literal["PCMU", "PCMA", "G722", "OPUS", "AMR-WB"] +StreamBidirectionalCodec: TypeAlias = Literal["PCMU", "PCMA", "G722", "OPUS", "AMR-WB", "L16"] diff --git a/src/telnyx/types/stream_codec.py b/src/telnyx/types/stream_codec.py index 8c62e0c1..f7e5471a 100644 --- a/src/telnyx/types/stream_codec.py +++ b/src/telnyx/types/stream_codec.py @@ -4,4 +4,4 @@ __all__ = ["StreamCodec"] -StreamCodec: TypeAlias = Literal["PCMA", "PCMU", "default"] +StreamCodec: TypeAlias = Literal["PCMU", "PCMA", "G722", "OPUS", "AMR-WB", "L16", "default"] diff --git a/src/telnyx/types/verification_trigger_call_params.py b/src/telnyx/types/verification_trigger_call_params.py index 0ac4550e..e85714e3 100644 --- a/src/telnyx/types/verification_trigger_call_params.py +++ b/src/telnyx/types/verification_trigger_call_params.py @@ -18,5 +18,12 @@ class VerificationTriggerCallParams(TypedDict, total=False): custom_code: Optional[str] """Send a self-generated numeric code to the end-user""" + extension: Optional[str] + """Optional extension to dial after call is answered using DTMF digits. + + Valid digits are 0-9, A-D, \\**, and #. Pauses can be added using w (0.5s) and W + (1s). + """ + timeout_secs: int """The number of seconds the verification code is valid for.""" diff --git a/src/telnyx/types/verify_profile_create_template_params.py b/src/telnyx/types/verify_profile_create_template_params.py new file mode 100644 index 00000000..d0187b74 --- /dev/null +++ b/src/telnyx/types/verify_profile_create_template_params.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["VerifyProfileCreateTemplateParams"] + + +class VerifyProfileCreateTemplateParams(TypedDict, total=False): + text: Required[str] + """The text content of the message template.""" diff --git a/src/telnyx/types/verify_profile_create_template_response.py b/src/telnyx/types/verify_profile_create_template_response.py new file mode 100644 index 00000000..4f9a619a --- /dev/null +++ b/src/telnyx/types/verify_profile_create_template_response.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from .._models import BaseModel + +__all__ = ["VerifyProfileCreateTemplateResponse", "Data"] + + +class Data(BaseModel): + id: Optional[str] = None + + text: Optional[str] = None + + +class VerifyProfileCreateTemplateResponse(BaseModel): + data: Optional[Data] = None diff --git a/src/telnyx/types/verify_profile_update_template_params.py b/src/telnyx/types/verify_profile_update_template_params.py new file mode 100644 index 00000000..ba03b033 --- /dev/null +++ b/src/telnyx/types/verify_profile_update_template_params.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["VerifyProfileUpdateTemplateParams"] + + +class VerifyProfileUpdateTemplateParams(TypedDict, total=False): + text: Required[str] + """The text content of the message template.""" diff --git a/src/telnyx/types/verify_profile_update_template_response.py b/src/telnyx/types/verify_profile_update_template_response.py new file mode 100644 index 00000000..0b78feb8 --- /dev/null +++ b/src/telnyx/types/verify_profile_update_template_response.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from .._models import BaseModel + +__all__ = ["VerifyProfileUpdateTemplateResponse", "Data"] + + +class Data(BaseModel): + id: Optional[str] = None + + text: Optional[str] = None + + +class VerifyProfileUpdateTemplateResponse(BaseModel): + data: Optional[Data] = None diff --git a/src/telnyx/types/well_known_retrieve_authorization_server_metadata_response.py b/src/telnyx/types/well_known_retrieve_authorization_server_metadata_response.py new file mode 100644 index 00000000..27a95c36 --- /dev/null +++ b/src/telnyx/types/well_known_retrieve_authorization_server_metadata_response.py @@ -0,0 +1,42 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from .._models import BaseModel + +__all__ = ["WellKnownRetrieveAuthorizationServerMetadataResponse"] + + +class WellKnownRetrieveAuthorizationServerMetadataResponse(BaseModel): + authorization_endpoint: Optional[str] = None + """Authorization endpoint URL""" + + code_challenge_methods_supported: Optional[List[str]] = None + """Supported PKCE code challenge methods""" + + grant_types_supported: Optional[List[str]] = None + """Supported grant types""" + + introspection_endpoint: Optional[str] = None + """Token introspection endpoint URL""" + + issuer: Optional[str] = None + """Authorization server issuer URL""" + + jwks_uri: Optional[str] = None + """JWK Set endpoint URL""" + + registration_endpoint: Optional[str] = None + """Dynamic client registration endpoint URL""" + + response_types_supported: Optional[List[str]] = None + """Supported response types""" + + scopes_supported: Optional[List[str]] = None + """Supported OAuth scopes""" + + token_endpoint: Optional[str] = None + """Token endpoint URL""" + + token_endpoint_auth_methods_supported: Optional[List[str]] = None + """Supported token endpoint authentication methods""" diff --git a/src/telnyx/types/well_known_retrieve_protected_resource_metadata_response.py b/src/telnyx/types/well_known_retrieve_protected_resource_metadata_response.py new file mode 100644 index 00000000..2a879bb3 --- /dev/null +++ b/src/telnyx/types/well_known_retrieve_protected_resource_metadata_response.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from .._models import BaseModel + +__all__ = ["WellKnownRetrieveProtectedResourceMetadataResponse"] + + +class WellKnownRetrieveProtectedResourceMetadataResponse(BaseModel): + authorization_servers: Optional[List[str]] = None + """List of authorization server URLs""" + + resource: Optional[str] = None + """Protected resource URL""" diff --git a/tests/api_resources/ai/conversations/test_messages.py b/tests/api_resources/ai/conversations/test_messages.py index 36d8b6ec..f47be995 100644 --- a/tests/api_resources/ai/conversations/test_messages.py +++ b/tests/api_resources/ai/conversations/test_messages.py @@ -9,7 +9,6 @@ from telnyx import Telnyx, AsyncTelnyx from tests.utils import assert_matches_type -from telnyx._utils import parse_datetime from telnyx.types.ai.conversations import MessageListResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -18,68 +17,6 @@ class TestMessages: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip(reason="Prism tests are disabled") - @parametrize - def test_method_create(self, client: Telnyx) -> None: - message = client.ai.conversations.messages.create( - conversation_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - role="role", - ) - assert_matches_type(object, message, path=["response"]) - - @pytest.mark.skip(reason="Prism tests are disabled") - @parametrize - def test_method_create_with_all_params(self, client: Telnyx) -> None: - message = client.ai.conversations.messages.create( - conversation_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - role="role", - content="content", - metadata={"foo": "string"}, - name="name", - sent_at=parse_datetime("2019-12-27T18:11:19.117Z"), - tool_call_id="tool_call_id", - tool_calls=[{"foo": "bar"}], - tool_choice="string", - ) - assert_matches_type(object, message, path=["response"]) - - @pytest.mark.skip(reason="Prism tests are disabled") - @parametrize - def test_raw_response_create(self, client: Telnyx) -> None: - response = client.ai.conversations.messages.with_raw_response.create( - conversation_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - role="role", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - message = response.parse() - assert_matches_type(object, message, path=["response"]) - - @pytest.mark.skip(reason="Prism tests are disabled") - @parametrize - def test_streaming_response_create(self, client: Telnyx) -> None: - with client.ai.conversations.messages.with_streaming_response.create( - conversation_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - role="role", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - message = response.parse() - assert_matches_type(object, message, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Prism tests are disabled") - @parametrize - def test_path_params_create(self, client: Telnyx) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `conversation_id` but received ''"): - client.ai.conversations.messages.with_raw_response.create( - conversation_id="", - role="role", - ) - @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_list(self, client: Telnyx) -> None: @@ -128,68 +65,6 @@ class TestAsyncMessages: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) - @pytest.mark.skip(reason="Prism tests are disabled") - @parametrize - async def test_method_create(self, async_client: AsyncTelnyx) -> None: - message = await async_client.ai.conversations.messages.create( - conversation_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - role="role", - ) - assert_matches_type(object, message, path=["response"]) - - @pytest.mark.skip(reason="Prism tests are disabled") - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncTelnyx) -> None: - message = await async_client.ai.conversations.messages.create( - conversation_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - role="role", - content="content", - metadata={"foo": "string"}, - name="name", - sent_at=parse_datetime("2019-12-27T18:11:19.117Z"), - tool_call_id="tool_call_id", - tool_calls=[{"foo": "bar"}], - tool_choice="string", - ) - assert_matches_type(object, message, path=["response"]) - - @pytest.mark.skip(reason="Prism tests are disabled") - @parametrize - async def test_raw_response_create(self, async_client: AsyncTelnyx) -> None: - response = await async_client.ai.conversations.messages.with_raw_response.create( - conversation_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - role="role", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - message = await response.parse() - assert_matches_type(object, message, path=["response"]) - - @pytest.mark.skip(reason="Prism tests are disabled") - @parametrize - async def test_streaming_response_create(self, async_client: AsyncTelnyx) -> None: - async with async_client.ai.conversations.messages.with_streaming_response.create( - conversation_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - role="role", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - message = await response.parse() - assert_matches_type(object, message, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Prism tests are disabled") - @parametrize - async def test_path_params_create(self, async_client: AsyncTelnyx) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `conversation_id` but received ''"): - await async_client.ai.conversations.messages.with_raw_response.create( - conversation_id="", - role="role", - ) - @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_list(self, async_client: AsyncTelnyx) -> None: diff --git a/tests/api_resources/ai/test_conversations.py b/tests/api_resources/ai/test_conversations.py index f7b975ee..a51e901f 100644 --- a/tests/api_resources/ai/test_conversations.py +++ b/tests/api_resources/ai/test_conversations.py @@ -9,6 +9,7 @@ from telnyx import Telnyx, AsyncTelnyx from tests.utils import assert_matches_type +from telnyx._utils import parse_datetime from telnyx.types.ai import ( Conversation, ConversationListResponse, @@ -242,6 +243,68 @@ def test_path_params_delete(self, client: Telnyx) -> None: "", ) + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_add_message(self, client: Telnyx) -> None: + conversation = client.ai.conversations.add_message( + conversation_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + role="role", + ) + assert_matches_type(object, conversation, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_add_message_with_all_params(self, client: Telnyx) -> None: + conversation = client.ai.conversations.add_message( + conversation_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + role="role", + content="content", + metadata={"foo": "string"}, + name="name", + sent_at=parse_datetime("2019-12-27T18:11:19.117Z"), + tool_call_id="tool_call_id", + tool_calls=[{"foo": "bar"}], + tool_choice="string", + ) + assert_matches_type(object, conversation, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_add_message(self, client: Telnyx) -> None: + response = client.ai.conversations.with_raw_response.add_message( + conversation_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + role="role", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + conversation = response.parse() + assert_matches_type(object, conversation, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_add_message(self, client: Telnyx) -> None: + with client.ai.conversations.with_streaming_response.add_message( + conversation_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + role="role", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + conversation = response.parse() + assert_matches_type(object, conversation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_add_message(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `conversation_id` but received ''"): + client.ai.conversations.with_raw_response.add_message( + conversation_id="", + role="role", + ) + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_retrieve_conversations_insights(self, client: Telnyx) -> None: @@ -509,6 +572,68 @@ async def test_path_params_delete(self, async_client: AsyncTelnyx) -> None: "", ) + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_add_message(self, async_client: AsyncTelnyx) -> None: + conversation = await async_client.ai.conversations.add_message( + conversation_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + role="role", + ) + assert_matches_type(object, conversation, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_add_message_with_all_params(self, async_client: AsyncTelnyx) -> None: + conversation = await async_client.ai.conversations.add_message( + conversation_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + role="role", + content="content", + metadata={"foo": "string"}, + name="name", + sent_at=parse_datetime("2019-12-27T18:11:19.117Z"), + tool_call_id="tool_call_id", + tool_calls=[{"foo": "bar"}], + tool_choice="string", + ) + assert_matches_type(object, conversation, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_add_message(self, async_client: AsyncTelnyx) -> None: + response = await async_client.ai.conversations.with_raw_response.add_message( + conversation_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + role="role", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + conversation = await response.parse() + assert_matches_type(object, conversation, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_add_message(self, async_client: AsyncTelnyx) -> None: + async with async_client.ai.conversations.with_streaming_response.add_message( + conversation_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + role="role", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + conversation = await response.parse() + assert_matches_type(object, conversation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_add_message(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `conversation_id` but received ''"): + await async_client.ai.conversations.with_raw_response.add_message( + conversation_id="", + role="role", + ) + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_retrieve_conversations_insights(self, async_client: AsyncTelnyx) -> None: diff --git a/tests/api_resources/calls/test_actions.py b/tests/api_resources/calls/test_actions.py index 1926129d..70c0ac46 100644 --- a/tests/api_resources/calls/test_actions.py +++ b/tests/api_resources/calls/test_actions.py @@ -1572,6 +1572,7 @@ def test_method_start_streaming_with_all_params(self, client: Telnyx) -> None: enable_dialogflow=False, stream_bidirectional_codec="G722", stream_bidirectional_mode="rtp", + stream_bidirectional_sampling_rate=16000, stream_bidirectional_target_legs="both", stream_codec="PCMA", stream_track="both_tracks", @@ -2252,6 +2253,14 @@ def test_method_transfer_with_all_params(self, client: Telnyx) -> None: media_name="my_media_uploaded_to_media_storage_api", mute_dtmf="opposite", park_after_unbridge="self", + record="record-from-answer", + record_channels="single", + record_custom_file_name="my_recording_file_name", + record_format="wav", + record_max_length=1000, + record_timeout_secs=100, + record_track="outbound", + record_trim="trim-silence", sip_auth_password="password", sip_auth_username="username", sip_headers=[ @@ -3882,6 +3891,7 @@ async def test_method_start_streaming_with_all_params(self, async_client: AsyncT enable_dialogflow=False, stream_bidirectional_codec="G722", stream_bidirectional_mode="rtp", + stream_bidirectional_sampling_rate=16000, stream_bidirectional_target_legs="both", stream_codec="PCMA", stream_track="both_tracks", @@ -4562,6 +4572,14 @@ async def test_method_transfer_with_all_params(self, async_client: AsyncTelnyx) media_name="my_media_uploaded_to_media_storage_api", mute_dtmf="opposite", park_after_unbridge="self", + record="record-from-answer", + record_channels="single", + record_custom_file_name="my_recording_file_name", + record_format="wav", + record_max_length=1000, + record_timeout_secs=100, + record_track="outbound", + record_trim="trim-silence", sip_auth_password="password", sip_auth_username="username", sip_headers=[ diff --git a/tests/api_resources/legacy/__init__.py b/tests/api_resources/legacy/__init__.py new file mode 100644 index 00000000..fd8019a9 --- /dev/null +++ b/tests/api_resources/legacy/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/legacy/reporting/__init__.py b/tests/api_resources/legacy/reporting/__init__.py new file mode 100644 index 00000000..fd8019a9 --- /dev/null +++ b/tests/api_resources/legacy/reporting/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/legacy/reporting/batch_detail_records/__init__.py b/tests/api_resources/legacy/reporting/batch_detail_records/__init__.py new file mode 100644 index 00000000..fd8019a9 --- /dev/null +++ b/tests/api_resources/legacy/reporting/batch_detail_records/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/legacy/reporting/batch_detail_records/test_messaging.py b/tests/api_resources/legacy/reporting/batch_detail_records/test_messaging.py new file mode 100644 index 00000000..afc335e9 --- /dev/null +++ b/tests/api_resources/legacy/reporting/batch_detail_records/test_messaging.py @@ -0,0 +1,388 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from telnyx import Telnyx, AsyncTelnyx +from tests.utils import assert_matches_type +from telnyx._utils import parse_datetime +from telnyx.types.legacy.reporting.batch_detail_records import ( + MessagingListResponse, + MessagingCreateResponse, + MessagingDeleteResponse, + MessagingRetrieveResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestMessaging: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create(self, client: Telnyx) -> None: + messaging = client.legacy.reporting.batch_detail_records.messaging.create( + end_time=parse_datetime("2024-02-12T23:59:59Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + ) + assert_matches_type(MessagingCreateResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: Telnyx) -> None: + messaging = client.legacy.reporting.batch_detail_records.messaging.create( + end_time=parse_datetime("2024-02-12T23:59:59Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + connections=[123, 456], + directions=[1, 2], + filters=[ + { + "billing_group": "adfaa016-f921-4b6c-97bb-e4c1dad231c5", + "cld": "+13129457420", + "cld_filter": "contains", + "cli": "+13129457420", + "cli_filter": "contains", + "filter_type": "and", + "tags_list": "tag1", + } + ], + include_message_body=True, + managed_accounts=["f47ac10b-58cc-4372-a567-0e02b2c3d479", "6ba7b810-9dad-11d1-80b4-00c04fd430c8"], + profiles=["3fa85f64-5717-4562-b3fc-2c963f66afa6", "7d4e3f8a-9b2c-4e1d-8f5a-1a2b3c4d5e6f"], + record_types=[1, 2], + report_name="My MDR Report", + select_all_managed_accounts=False, + timezone="UTC", + ) + assert_matches_type(MessagingCreateResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_create(self, client: Telnyx) -> None: + response = client.legacy.reporting.batch_detail_records.messaging.with_raw_response.create( + end_time=parse_datetime("2024-02-12T23:59:59Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + messaging = response.parse() + assert_matches_type(MessagingCreateResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_create(self, client: Telnyx) -> None: + with client.legacy.reporting.batch_detail_records.messaging.with_streaming_response.create( + end_time=parse_datetime("2024-02-12T23:59:59Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + messaging = response.parse() + assert_matches_type(MessagingCreateResponse, messaging, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_retrieve(self, client: Telnyx) -> None: + messaging = client.legacy.reporting.batch_detail_records.messaging.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(MessagingRetrieveResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_retrieve(self, client: Telnyx) -> None: + response = client.legacy.reporting.batch_detail_records.messaging.with_raw_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + messaging = response.parse() + assert_matches_type(MessagingRetrieveResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_retrieve(self, client: Telnyx) -> None: + with client.legacy.reporting.batch_detail_records.messaging.with_streaming_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + messaging = response.parse() + assert_matches_type(MessagingRetrieveResponse, messaging, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_retrieve(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.legacy.reporting.batch_detail_records.messaging.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_list(self, client: Telnyx) -> None: + messaging = client.legacy.reporting.batch_detail_records.messaging.list() + assert_matches_type(MessagingListResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_list(self, client: Telnyx) -> None: + response = client.legacy.reporting.batch_detail_records.messaging.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + messaging = response.parse() + assert_matches_type(MessagingListResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_list(self, client: Telnyx) -> None: + with client.legacy.reporting.batch_detail_records.messaging.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + messaging = response.parse() + assert_matches_type(MessagingListResponse, messaging, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_delete(self, client: Telnyx) -> None: + messaging = client.legacy.reporting.batch_detail_records.messaging.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(MessagingDeleteResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_delete(self, client: Telnyx) -> None: + response = client.legacy.reporting.batch_detail_records.messaging.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + messaging = response.parse() + assert_matches_type(MessagingDeleteResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: Telnyx) -> None: + with client.legacy.reporting.batch_detail_records.messaging.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + messaging = response.parse() + assert_matches_type(MessagingDeleteResponse, messaging, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_delete(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.legacy.reporting.batch_detail_records.messaging.with_raw_response.delete( + "", + ) + + +class TestAsyncMessaging: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncTelnyx) -> None: + messaging = await async_client.legacy.reporting.batch_detail_records.messaging.create( + end_time=parse_datetime("2024-02-12T23:59:59Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + ) + assert_matches_type(MessagingCreateResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncTelnyx) -> None: + messaging = await async_client.legacy.reporting.batch_detail_records.messaging.create( + end_time=parse_datetime("2024-02-12T23:59:59Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + connections=[123, 456], + directions=[1, 2], + filters=[ + { + "billing_group": "adfaa016-f921-4b6c-97bb-e4c1dad231c5", + "cld": "+13129457420", + "cld_filter": "contains", + "cli": "+13129457420", + "cli_filter": "contains", + "filter_type": "and", + "tags_list": "tag1", + } + ], + include_message_body=True, + managed_accounts=["f47ac10b-58cc-4372-a567-0e02b2c3d479", "6ba7b810-9dad-11d1-80b4-00c04fd430c8"], + profiles=["3fa85f64-5717-4562-b3fc-2c963f66afa6", "7d4e3f8a-9b2c-4e1d-8f5a-1a2b3c4d5e6f"], + record_types=[1, 2], + report_name="My MDR Report", + select_all_managed_accounts=False, + timezone="UTC", + ) + assert_matches_type(MessagingCreateResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.batch_detail_records.messaging.with_raw_response.create( + end_time=parse_datetime("2024-02-12T23:59:59Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + messaging = await response.parse() + assert_matches_type(MessagingCreateResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.batch_detail_records.messaging.with_streaming_response.create( + end_time=parse_datetime("2024-02-12T23:59:59Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + messaging = await response.parse() + assert_matches_type(MessagingCreateResponse, messaging, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: + messaging = await async_client.legacy.reporting.batch_detail_records.messaging.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(MessagingRetrieveResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.batch_detail_records.messaging.with_raw_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + messaging = await response.parse() + assert_matches_type(MessagingRetrieveResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.batch_detail_records.messaging.with_streaming_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + messaging = await response.parse() + assert_matches_type(MessagingRetrieveResponse, messaging, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.legacy.reporting.batch_detail_records.messaging.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncTelnyx) -> None: + messaging = await async_client.legacy.reporting.batch_detail_records.messaging.list() + assert_matches_type(MessagingListResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.batch_detail_records.messaging.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + messaging = await response.parse() + assert_matches_type(MessagingListResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncTelnyx) -> None: + async with ( + async_client.legacy.reporting.batch_detail_records.messaging.with_streaming_response.list() + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + messaging = await response.parse() + assert_matches_type(MessagingListResponse, messaging, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncTelnyx) -> None: + messaging = await async_client.legacy.reporting.batch_detail_records.messaging.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(MessagingDeleteResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.batch_detail_records.messaging.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + messaging = await response.parse() + assert_matches_type(MessagingDeleteResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.batch_detail_records.messaging.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + messaging = await response.parse() + assert_matches_type(MessagingDeleteResponse, messaging, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.legacy.reporting.batch_detail_records.messaging.with_raw_response.delete( + "", + ) diff --git a/tests/api_resources/legacy/reporting/batch_detail_records/test_speech_to_text.py b/tests/api_resources/legacy/reporting/batch_detail_records/test_speech_to_text.py new file mode 100644 index 00000000..d3c30e68 --- /dev/null +++ b/tests/api_resources/legacy/reporting/batch_detail_records/test_speech_to_text.py @@ -0,0 +1,330 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from telnyx import Telnyx, AsyncTelnyx +from tests.utils import assert_matches_type +from telnyx._utils import parse_datetime +from telnyx.types.legacy.reporting.batch_detail_records import ( + SpeechToTextListResponse, + SpeechToTextCreateResponse, + SpeechToTextDeleteResponse, + SpeechToTextRetrieveResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestSpeechToText: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create(self, client: Telnyx) -> None: + speech_to_text = client.legacy.reporting.batch_detail_records.speech_to_text.create( + end_date=parse_datetime("2020-07-01T00:00:00-06:00"), + start_date=parse_datetime("2020-07-01T00:00:00-06:00"), + ) + assert_matches_type(SpeechToTextCreateResponse, speech_to_text, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_create(self, client: Telnyx) -> None: + response = client.legacy.reporting.batch_detail_records.speech_to_text.with_raw_response.create( + end_date=parse_datetime("2020-07-01T00:00:00-06:00"), + start_date=parse_datetime("2020-07-01T00:00:00-06:00"), + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + speech_to_text = response.parse() + assert_matches_type(SpeechToTextCreateResponse, speech_to_text, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_create(self, client: Telnyx) -> None: + with client.legacy.reporting.batch_detail_records.speech_to_text.with_streaming_response.create( + end_date=parse_datetime("2020-07-01T00:00:00-06:00"), + start_date=parse_datetime("2020-07-01T00:00:00-06:00"), + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + speech_to_text = response.parse() + assert_matches_type(SpeechToTextCreateResponse, speech_to_text, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_retrieve(self, client: Telnyx) -> None: + speech_to_text = client.legacy.reporting.batch_detail_records.speech_to_text.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(SpeechToTextRetrieveResponse, speech_to_text, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_retrieve(self, client: Telnyx) -> None: + response = client.legacy.reporting.batch_detail_records.speech_to_text.with_raw_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + speech_to_text = response.parse() + assert_matches_type(SpeechToTextRetrieveResponse, speech_to_text, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_retrieve(self, client: Telnyx) -> None: + with client.legacy.reporting.batch_detail_records.speech_to_text.with_streaming_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + speech_to_text = response.parse() + assert_matches_type(SpeechToTextRetrieveResponse, speech_to_text, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_retrieve(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.legacy.reporting.batch_detail_records.speech_to_text.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_list(self, client: Telnyx) -> None: + speech_to_text = client.legacy.reporting.batch_detail_records.speech_to_text.list() + assert_matches_type(SpeechToTextListResponse, speech_to_text, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_list(self, client: Telnyx) -> None: + response = client.legacy.reporting.batch_detail_records.speech_to_text.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + speech_to_text = response.parse() + assert_matches_type(SpeechToTextListResponse, speech_to_text, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_list(self, client: Telnyx) -> None: + with client.legacy.reporting.batch_detail_records.speech_to_text.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + speech_to_text = response.parse() + assert_matches_type(SpeechToTextListResponse, speech_to_text, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_delete(self, client: Telnyx) -> None: + speech_to_text = client.legacy.reporting.batch_detail_records.speech_to_text.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(SpeechToTextDeleteResponse, speech_to_text, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_delete(self, client: Telnyx) -> None: + response = client.legacy.reporting.batch_detail_records.speech_to_text.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + speech_to_text = response.parse() + assert_matches_type(SpeechToTextDeleteResponse, speech_to_text, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: Telnyx) -> None: + with client.legacy.reporting.batch_detail_records.speech_to_text.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + speech_to_text = response.parse() + assert_matches_type(SpeechToTextDeleteResponse, speech_to_text, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_delete(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.legacy.reporting.batch_detail_records.speech_to_text.with_raw_response.delete( + "", + ) + + +class TestAsyncSpeechToText: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncTelnyx) -> None: + speech_to_text = await async_client.legacy.reporting.batch_detail_records.speech_to_text.create( + end_date=parse_datetime("2020-07-01T00:00:00-06:00"), + start_date=parse_datetime("2020-07-01T00:00:00-06:00"), + ) + assert_matches_type(SpeechToTextCreateResponse, speech_to_text, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.batch_detail_records.speech_to_text.with_raw_response.create( + end_date=parse_datetime("2020-07-01T00:00:00-06:00"), + start_date=parse_datetime("2020-07-01T00:00:00-06:00"), + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + speech_to_text = await response.parse() + assert_matches_type(SpeechToTextCreateResponse, speech_to_text, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.batch_detail_records.speech_to_text.with_streaming_response.create( + end_date=parse_datetime("2020-07-01T00:00:00-06:00"), + start_date=parse_datetime("2020-07-01T00:00:00-06:00"), + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + speech_to_text = await response.parse() + assert_matches_type(SpeechToTextCreateResponse, speech_to_text, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: + speech_to_text = await async_client.legacy.reporting.batch_detail_records.speech_to_text.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(SpeechToTextRetrieveResponse, speech_to_text, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.batch_detail_records.speech_to_text.with_raw_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + speech_to_text = await response.parse() + assert_matches_type(SpeechToTextRetrieveResponse, speech_to_text, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.batch_detail_records.speech_to_text.with_streaming_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + speech_to_text = await response.parse() + assert_matches_type(SpeechToTextRetrieveResponse, speech_to_text, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.legacy.reporting.batch_detail_records.speech_to_text.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncTelnyx) -> None: + speech_to_text = await async_client.legacy.reporting.batch_detail_records.speech_to_text.list() + assert_matches_type(SpeechToTextListResponse, speech_to_text, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.batch_detail_records.speech_to_text.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + speech_to_text = await response.parse() + assert_matches_type(SpeechToTextListResponse, speech_to_text, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncTelnyx) -> None: + async with ( + async_client.legacy.reporting.batch_detail_records.speech_to_text.with_streaming_response.list() + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + speech_to_text = await response.parse() + assert_matches_type(SpeechToTextListResponse, speech_to_text, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncTelnyx) -> None: + speech_to_text = await async_client.legacy.reporting.batch_detail_records.speech_to_text.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(SpeechToTextDeleteResponse, speech_to_text, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.batch_detail_records.speech_to_text.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + speech_to_text = await response.parse() + assert_matches_type(SpeechToTextDeleteResponse, speech_to_text, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.batch_detail_records.speech_to_text.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + speech_to_text = await response.parse() + assert_matches_type(SpeechToTextDeleteResponse, speech_to_text, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.legacy.reporting.batch_detail_records.speech_to_text.with_raw_response.delete( + "", + ) diff --git a/tests/api_resources/legacy/reporting/batch_detail_records/test_voice.py b/tests/api_resources/legacy/reporting/batch_detail_records/test_voice.py new file mode 100644 index 00000000..f83f8384 --- /dev/null +++ b/tests/api_resources/legacy/reporting/batch_detail_records/test_voice.py @@ -0,0 +1,447 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from telnyx import Telnyx, AsyncTelnyx +from tests.utils import assert_matches_type +from telnyx._utils import parse_datetime +from telnyx.types.legacy.reporting.batch_detail_records import ( + VoiceListResponse, + VoiceCreateResponse, + VoiceDeleteResponse, + VoiceRetrieveResponse, + VoiceRetrieveFieldsResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestVoice: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create(self, client: Telnyx) -> None: + voice = client.legacy.reporting.batch_detail_records.voice.create( + end_time=parse_datetime("2024-02-12T23:59:59Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + ) + assert_matches_type(VoiceCreateResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: Telnyx) -> None: + voice = client.legacy.reporting.batch_detail_records.voice.create( + end_time=parse_datetime("2024-02-12T23:59:59Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + call_types=[1, 2], + connections=[123, 456], + fields=["call_leg_id", "start_time", "end_time"], + filters=[ + { + "billing_group": "adfaa016-f921-4b6c-97bb-e4c1dad231c5", + "cld": "+13129457420", + "cld_filter": "contains", + "cli": "+13129457420", + "cli_filter": "contains", + "filter_type": "and", + "tags_list": "tag1", + } + ], + include_all_metadata=True, + managed_accounts=["f47ac10b-58cc-4372-a567-0e02b2c3d479", "6ba7b810-9dad-11d1-80b4-00c04fd430c8"], + record_types=[1, 2], + report_name="My CDR Report", + select_all_managed_accounts=False, + source="calls", + timezone="UTC", + ) + assert_matches_type(VoiceCreateResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_create(self, client: Telnyx) -> None: + response = client.legacy.reporting.batch_detail_records.voice.with_raw_response.create( + end_time=parse_datetime("2024-02-12T23:59:59Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + voice = response.parse() + assert_matches_type(VoiceCreateResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_create(self, client: Telnyx) -> None: + with client.legacy.reporting.batch_detail_records.voice.with_streaming_response.create( + end_time=parse_datetime("2024-02-12T23:59:59Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + voice = response.parse() + assert_matches_type(VoiceCreateResponse, voice, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_retrieve(self, client: Telnyx) -> None: + voice = client.legacy.reporting.batch_detail_records.voice.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(VoiceRetrieveResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_retrieve(self, client: Telnyx) -> None: + response = client.legacy.reporting.batch_detail_records.voice.with_raw_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + voice = response.parse() + assert_matches_type(VoiceRetrieveResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_retrieve(self, client: Telnyx) -> None: + with client.legacy.reporting.batch_detail_records.voice.with_streaming_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + voice = response.parse() + assert_matches_type(VoiceRetrieveResponse, voice, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_retrieve(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.legacy.reporting.batch_detail_records.voice.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_list(self, client: Telnyx) -> None: + voice = client.legacy.reporting.batch_detail_records.voice.list() + assert_matches_type(VoiceListResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_list(self, client: Telnyx) -> None: + response = client.legacy.reporting.batch_detail_records.voice.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + voice = response.parse() + assert_matches_type(VoiceListResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_list(self, client: Telnyx) -> None: + with client.legacy.reporting.batch_detail_records.voice.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + voice = response.parse() + assert_matches_type(VoiceListResponse, voice, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_delete(self, client: Telnyx) -> None: + voice = client.legacy.reporting.batch_detail_records.voice.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(VoiceDeleteResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_delete(self, client: Telnyx) -> None: + response = client.legacy.reporting.batch_detail_records.voice.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + voice = response.parse() + assert_matches_type(VoiceDeleteResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: Telnyx) -> None: + with client.legacy.reporting.batch_detail_records.voice.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + voice = response.parse() + assert_matches_type(VoiceDeleteResponse, voice, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_delete(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.legacy.reporting.batch_detail_records.voice.with_raw_response.delete( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_retrieve_fields(self, client: Telnyx) -> None: + voice = client.legacy.reporting.batch_detail_records.voice.retrieve_fields() + assert_matches_type(VoiceRetrieveFieldsResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_retrieve_fields(self, client: Telnyx) -> None: + response = client.legacy.reporting.batch_detail_records.voice.with_raw_response.retrieve_fields() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + voice = response.parse() + assert_matches_type(VoiceRetrieveFieldsResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_retrieve_fields(self, client: Telnyx) -> None: + with client.legacy.reporting.batch_detail_records.voice.with_streaming_response.retrieve_fields() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + voice = response.parse() + assert_matches_type(VoiceRetrieveFieldsResponse, voice, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncVoice: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncTelnyx) -> None: + voice = await async_client.legacy.reporting.batch_detail_records.voice.create( + end_time=parse_datetime("2024-02-12T23:59:59Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + ) + assert_matches_type(VoiceCreateResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncTelnyx) -> None: + voice = await async_client.legacy.reporting.batch_detail_records.voice.create( + end_time=parse_datetime("2024-02-12T23:59:59Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + call_types=[1, 2], + connections=[123, 456], + fields=["call_leg_id", "start_time", "end_time"], + filters=[ + { + "billing_group": "adfaa016-f921-4b6c-97bb-e4c1dad231c5", + "cld": "+13129457420", + "cld_filter": "contains", + "cli": "+13129457420", + "cli_filter": "contains", + "filter_type": "and", + "tags_list": "tag1", + } + ], + include_all_metadata=True, + managed_accounts=["f47ac10b-58cc-4372-a567-0e02b2c3d479", "6ba7b810-9dad-11d1-80b4-00c04fd430c8"], + record_types=[1, 2], + report_name="My CDR Report", + select_all_managed_accounts=False, + source="calls", + timezone="UTC", + ) + assert_matches_type(VoiceCreateResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.batch_detail_records.voice.with_raw_response.create( + end_time=parse_datetime("2024-02-12T23:59:59Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + voice = await response.parse() + assert_matches_type(VoiceCreateResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.batch_detail_records.voice.with_streaming_response.create( + end_time=parse_datetime("2024-02-12T23:59:59Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + voice = await response.parse() + assert_matches_type(VoiceCreateResponse, voice, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: + voice = await async_client.legacy.reporting.batch_detail_records.voice.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(VoiceRetrieveResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.batch_detail_records.voice.with_raw_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + voice = await response.parse() + assert_matches_type(VoiceRetrieveResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.batch_detail_records.voice.with_streaming_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + voice = await response.parse() + assert_matches_type(VoiceRetrieveResponse, voice, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.legacy.reporting.batch_detail_records.voice.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncTelnyx) -> None: + voice = await async_client.legacy.reporting.batch_detail_records.voice.list() + assert_matches_type(VoiceListResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.batch_detail_records.voice.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + voice = await response.parse() + assert_matches_type(VoiceListResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.batch_detail_records.voice.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + voice = await response.parse() + assert_matches_type(VoiceListResponse, voice, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncTelnyx) -> None: + voice = await async_client.legacy.reporting.batch_detail_records.voice.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(VoiceDeleteResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.batch_detail_records.voice.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + voice = await response.parse() + assert_matches_type(VoiceDeleteResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.batch_detail_records.voice.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + voice = await response.parse() + assert_matches_type(VoiceDeleteResponse, voice, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.legacy.reporting.batch_detail_records.voice.with_raw_response.delete( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_retrieve_fields(self, async_client: AsyncTelnyx) -> None: + voice = await async_client.legacy.reporting.batch_detail_records.voice.retrieve_fields() + assert_matches_type(VoiceRetrieveFieldsResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_retrieve_fields(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.batch_detail_records.voice.with_raw_response.retrieve_fields() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + voice = await response.parse() + assert_matches_type(VoiceRetrieveFieldsResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_retrieve_fields(self, async_client: AsyncTelnyx) -> None: + async with ( + async_client.legacy.reporting.batch_detail_records.voice.with_streaming_response.retrieve_fields() + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + voice = await response.parse() + assert_matches_type(VoiceRetrieveFieldsResponse, voice, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/legacy/reporting/test_usage_reports.py b/tests/api_resources/legacy/reporting/test_usage_reports.py new file mode 100644 index 00000000..6e26c25c --- /dev/null +++ b/tests/api_resources/legacy/reporting/test_usage_reports.py @@ -0,0 +1,103 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from telnyx import Telnyx, AsyncTelnyx +from tests.utils import assert_matches_type +from telnyx._utils import parse_datetime +from telnyx.types.legacy.reporting import ( + UsageReportRetrieveSpeechToTextResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestUsageReports: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_retrieve_speech_to_text(self, client: Telnyx) -> None: + usage_report = client.legacy.reporting.usage_reports.retrieve_speech_to_text() + assert_matches_type(UsageReportRetrieveSpeechToTextResponse, usage_report, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_retrieve_speech_to_text_with_all_params(self, client: Telnyx) -> None: + usage_report = client.legacy.reporting.usage_reports.retrieve_speech_to_text( + end_date=parse_datetime("2020-07-01T00:00:00-06:00"), + start_date=parse_datetime("2020-07-01T00:00:00-06:00"), + ) + assert_matches_type(UsageReportRetrieveSpeechToTextResponse, usage_report, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_retrieve_speech_to_text(self, client: Telnyx) -> None: + response = client.legacy.reporting.usage_reports.with_raw_response.retrieve_speech_to_text() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + usage_report = response.parse() + assert_matches_type(UsageReportRetrieveSpeechToTextResponse, usage_report, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_retrieve_speech_to_text(self, client: Telnyx) -> None: + with client.legacy.reporting.usage_reports.with_streaming_response.retrieve_speech_to_text() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + usage_report = response.parse() + assert_matches_type(UsageReportRetrieveSpeechToTextResponse, usage_report, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncUsageReports: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_retrieve_speech_to_text(self, async_client: AsyncTelnyx) -> None: + usage_report = await async_client.legacy.reporting.usage_reports.retrieve_speech_to_text() + assert_matches_type(UsageReportRetrieveSpeechToTextResponse, usage_report, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_retrieve_speech_to_text_with_all_params(self, async_client: AsyncTelnyx) -> None: + usage_report = await async_client.legacy.reporting.usage_reports.retrieve_speech_to_text( + end_date=parse_datetime("2020-07-01T00:00:00-06:00"), + start_date=parse_datetime("2020-07-01T00:00:00-06:00"), + ) + assert_matches_type(UsageReportRetrieveSpeechToTextResponse, usage_report, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_retrieve_speech_to_text(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.usage_reports.with_raw_response.retrieve_speech_to_text() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + usage_report = await response.parse() + assert_matches_type(UsageReportRetrieveSpeechToTextResponse, usage_report, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_retrieve_speech_to_text(self, async_client: AsyncTelnyx) -> None: + async with ( + async_client.legacy.reporting.usage_reports.with_streaming_response.retrieve_speech_to_text() + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + usage_report = await response.parse() + assert_matches_type(UsageReportRetrieveSpeechToTextResponse, usage_report, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/legacy/reporting/usage_reports/__init__.py b/tests/api_resources/legacy/reporting/usage_reports/__init__.py new file mode 100644 index 00000000..fd8019a9 --- /dev/null +++ b/tests/api_resources/legacy/reporting/usage_reports/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/legacy/reporting/usage_reports/test_messaging.py b/tests/api_resources/legacy/reporting/usage_reports/test_messaging.py new file mode 100644 index 00000000..b951cb48 --- /dev/null +++ b/tests/api_resources/legacy/reporting/usage_reports/test_messaging.py @@ -0,0 +1,366 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from telnyx import Telnyx, AsyncTelnyx +from tests.utils import assert_matches_type +from telnyx._utils import parse_datetime +from telnyx.types.legacy.reporting.usage_reports import ( + MessagingListResponse, + MessagingCreateResponse, + MessagingDeleteResponse, + MessagingRetrieveResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestMessaging: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create(self, client: Telnyx) -> None: + messaging = client.legacy.reporting.usage_reports.messaging.create( + aggregation_type=0, + ) + assert_matches_type(MessagingCreateResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: Telnyx) -> None: + messaging = client.legacy.reporting.usage_reports.messaging.create( + aggregation_type=0, + end_time=parse_datetime("2020-01-02T00:00:00Z"), + managed_accounts=["f47ac10b-58cc-4372-a567-0e02b2c3d479", "6ba7b810-9dad-11d1-80b4-00c04fd430c8"], + profiles=["3fa85f64-5717-4562-b3fc-2c963f66afa6", "7d4e3f8a-9b2c-4e1d-8f5a-1a2b3c4d5e6f"], + select_all_managed_accounts=True, + start_time=parse_datetime("2020-01-01T00:00:00Z"), + ) + assert_matches_type(MessagingCreateResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_create(self, client: Telnyx) -> None: + response = client.legacy.reporting.usage_reports.messaging.with_raw_response.create( + aggregation_type=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + messaging = response.parse() + assert_matches_type(MessagingCreateResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_create(self, client: Telnyx) -> None: + with client.legacy.reporting.usage_reports.messaging.with_streaming_response.create( + aggregation_type=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + messaging = response.parse() + assert_matches_type(MessagingCreateResponse, messaging, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_retrieve(self, client: Telnyx) -> None: + messaging = client.legacy.reporting.usage_reports.messaging.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(MessagingRetrieveResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_retrieve(self, client: Telnyx) -> None: + response = client.legacy.reporting.usage_reports.messaging.with_raw_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + messaging = response.parse() + assert_matches_type(MessagingRetrieveResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_retrieve(self, client: Telnyx) -> None: + with client.legacy.reporting.usage_reports.messaging.with_streaming_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + messaging = response.parse() + assert_matches_type(MessagingRetrieveResponse, messaging, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_retrieve(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.legacy.reporting.usage_reports.messaging.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_list(self, client: Telnyx) -> None: + messaging = client.legacy.reporting.usage_reports.messaging.list() + assert_matches_type(MessagingListResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: Telnyx) -> None: + messaging = client.legacy.reporting.usage_reports.messaging.list( + page=1, + per_page=1, + ) + assert_matches_type(MessagingListResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_list(self, client: Telnyx) -> None: + response = client.legacy.reporting.usage_reports.messaging.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + messaging = response.parse() + assert_matches_type(MessagingListResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_list(self, client: Telnyx) -> None: + with client.legacy.reporting.usage_reports.messaging.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + messaging = response.parse() + assert_matches_type(MessagingListResponse, messaging, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_delete(self, client: Telnyx) -> None: + messaging = client.legacy.reporting.usage_reports.messaging.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(MessagingDeleteResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_delete(self, client: Telnyx) -> None: + response = client.legacy.reporting.usage_reports.messaging.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + messaging = response.parse() + assert_matches_type(MessagingDeleteResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: Telnyx) -> None: + with client.legacy.reporting.usage_reports.messaging.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + messaging = response.parse() + assert_matches_type(MessagingDeleteResponse, messaging, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_delete(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.legacy.reporting.usage_reports.messaging.with_raw_response.delete( + "", + ) + + +class TestAsyncMessaging: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncTelnyx) -> None: + messaging = await async_client.legacy.reporting.usage_reports.messaging.create( + aggregation_type=0, + ) + assert_matches_type(MessagingCreateResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncTelnyx) -> None: + messaging = await async_client.legacy.reporting.usage_reports.messaging.create( + aggregation_type=0, + end_time=parse_datetime("2020-01-02T00:00:00Z"), + managed_accounts=["f47ac10b-58cc-4372-a567-0e02b2c3d479", "6ba7b810-9dad-11d1-80b4-00c04fd430c8"], + profiles=["3fa85f64-5717-4562-b3fc-2c963f66afa6", "7d4e3f8a-9b2c-4e1d-8f5a-1a2b3c4d5e6f"], + select_all_managed_accounts=True, + start_time=parse_datetime("2020-01-01T00:00:00Z"), + ) + assert_matches_type(MessagingCreateResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.usage_reports.messaging.with_raw_response.create( + aggregation_type=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + messaging = await response.parse() + assert_matches_type(MessagingCreateResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.usage_reports.messaging.with_streaming_response.create( + aggregation_type=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + messaging = await response.parse() + assert_matches_type(MessagingCreateResponse, messaging, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: + messaging = await async_client.legacy.reporting.usage_reports.messaging.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(MessagingRetrieveResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.usage_reports.messaging.with_raw_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + messaging = await response.parse() + assert_matches_type(MessagingRetrieveResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.usage_reports.messaging.with_streaming_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + messaging = await response.parse() + assert_matches_type(MessagingRetrieveResponse, messaging, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.legacy.reporting.usage_reports.messaging.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncTelnyx) -> None: + messaging = await async_client.legacy.reporting.usage_reports.messaging.list() + assert_matches_type(MessagingListResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncTelnyx) -> None: + messaging = await async_client.legacy.reporting.usage_reports.messaging.list( + page=1, + per_page=1, + ) + assert_matches_type(MessagingListResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.usage_reports.messaging.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + messaging = await response.parse() + assert_matches_type(MessagingListResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.usage_reports.messaging.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + messaging = await response.parse() + assert_matches_type(MessagingListResponse, messaging, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncTelnyx) -> None: + messaging = await async_client.legacy.reporting.usage_reports.messaging.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(MessagingDeleteResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.usage_reports.messaging.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + messaging = await response.parse() + assert_matches_type(MessagingDeleteResponse, messaging, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.usage_reports.messaging.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + messaging = await response.parse() + assert_matches_type(MessagingDeleteResponse, messaging, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.legacy.reporting.usage_reports.messaging.with_raw_response.delete( + "", + ) diff --git a/tests/api_resources/legacy/reporting/usage_reports/test_number_lookup.py b/tests/api_resources/legacy/reporting/usage_reports/test_number_lookup.py new file mode 100644 index 00000000..29b03002 --- /dev/null +++ b/tests/api_resources/legacy/reporting/usage_reports/test_number_lookup.py @@ -0,0 +1,345 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from telnyx import Telnyx, AsyncTelnyx +from telnyx._utils import parse_date + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestNumberLookup: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create(self, client: Telnyx) -> None: + number_lookup = client.legacy.reporting.usage_reports.number_lookup.create() + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: Telnyx) -> None: + number_lookup = client.legacy.reporting.usage_reports.number_lookup.create( + aggregation_type="ALL", + end_date=parse_date("2025-02-10"), + managed_accounts=["f47ac10b-58cc-4372-a567-0e02b2c3d479", "6ba7b810-9dad-11d1-80b4-00c04fd430c8"], + start_date=parse_date("2025-02-10"), + ) + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_create(self, client: Telnyx) -> None: + response = client.legacy.reporting.usage_reports.number_lookup.with_raw_response.create() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + number_lookup = response.parse() + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_create(self, client: Telnyx) -> None: + with client.legacy.reporting.usage_reports.number_lookup.with_streaming_response.create() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + number_lookup = response.parse() + assert number_lookup is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_retrieve(self, client: Telnyx) -> None: + number_lookup = client.legacy.reporting.usage_reports.number_lookup.retrieve( + "id", + ) + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_retrieve(self, client: Telnyx) -> None: + response = client.legacy.reporting.usage_reports.number_lookup.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + number_lookup = response.parse() + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_retrieve(self, client: Telnyx) -> None: + with client.legacy.reporting.usage_reports.number_lookup.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + number_lookup = response.parse() + assert number_lookup is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_retrieve(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.legacy.reporting.usage_reports.number_lookup.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_list(self, client: Telnyx) -> None: + number_lookup = client.legacy.reporting.usage_reports.number_lookup.list() + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: Telnyx) -> None: + number_lookup = client.legacy.reporting.usage_reports.number_lookup.list( + page=0, + per_page=0, + ) + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_list(self, client: Telnyx) -> None: + response = client.legacy.reporting.usage_reports.number_lookup.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + number_lookup = response.parse() + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_list(self, client: Telnyx) -> None: + with client.legacy.reporting.usage_reports.number_lookup.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + number_lookup = response.parse() + assert number_lookup is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_delete(self, client: Telnyx) -> None: + number_lookup = client.legacy.reporting.usage_reports.number_lookup.delete( + "id", + ) + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_delete(self, client: Telnyx) -> None: + response = client.legacy.reporting.usage_reports.number_lookup.with_raw_response.delete( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + number_lookup = response.parse() + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: Telnyx) -> None: + with client.legacy.reporting.usage_reports.number_lookup.with_streaming_response.delete( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + number_lookup = response.parse() + assert number_lookup is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_delete(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.legacy.reporting.usage_reports.number_lookup.with_raw_response.delete( + "", + ) + + +class TestAsyncNumberLookup: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncTelnyx) -> None: + number_lookup = await async_client.legacy.reporting.usage_reports.number_lookup.create() + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncTelnyx) -> None: + number_lookup = await async_client.legacy.reporting.usage_reports.number_lookup.create( + aggregation_type="ALL", + end_date=parse_date("2025-02-10"), + managed_accounts=["f47ac10b-58cc-4372-a567-0e02b2c3d479", "6ba7b810-9dad-11d1-80b4-00c04fd430c8"], + start_date=parse_date("2025-02-10"), + ) + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.usage_reports.number_lookup.with_raw_response.create() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + number_lookup = await response.parse() + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncTelnyx) -> None: + async with ( + async_client.legacy.reporting.usage_reports.number_lookup.with_streaming_response.create() + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + number_lookup = await response.parse() + assert number_lookup is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: + number_lookup = await async_client.legacy.reporting.usage_reports.number_lookup.retrieve( + "id", + ) + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.usage_reports.number_lookup.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + number_lookup = await response.parse() + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.usage_reports.number_lookup.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + number_lookup = await response.parse() + assert number_lookup is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.legacy.reporting.usage_reports.number_lookup.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncTelnyx) -> None: + number_lookup = await async_client.legacy.reporting.usage_reports.number_lookup.list() + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncTelnyx) -> None: + number_lookup = await async_client.legacy.reporting.usage_reports.number_lookup.list( + page=0, + per_page=0, + ) + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.usage_reports.number_lookup.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + number_lookup = await response.parse() + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.usage_reports.number_lookup.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + number_lookup = await response.parse() + assert number_lookup is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncTelnyx) -> None: + number_lookup = await async_client.legacy.reporting.usage_reports.number_lookup.delete( + "id", + ) + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.usage_reports.number_lookup.with_raw_response.delete( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + number_lookup = await response.parse() + assert number_lookup is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.usage_reports.number_lookup.with_streaming_response.delete( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + number_lookup = await response.parse() + assert number_lookup is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.legacy.reporting.usage_reports.number_lookup.with_raw_response.delete( + "", + ) diff --git a/tests/api_resources/legacy/reporting/usage_reports/test_voice.py b/tests/api_resources/legacy/reporting/usage_reports/test_voice.py new file mode 100644 index 00000000..ba1f1125 --- /dev/null +++ b/tests/api_resources/legacy/reporting/usage_reports/test_voice.py @@ -0,0 +1,374 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from telnyx import Telnyx, AsyncTelnyx +from tests.utils import assert_matches_type +from telnyx._utils import parse_datetime +from telnyx.types.legacy.reporting.usage_reports import ( + VoiceListResponse, + VoiceCreateResponse, + VoiceDeleteResponse, + VoiceRetrieveResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestVoice: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create(self, client: Telnyx) -> None: + voice = client.legacy.reporting.usage_reports.voice.create( + end_time=parse_datetime("2024-02-01T00:00:00Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + ) + assert_matches_type(VoiceCreateResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: Telnyx) -> None: + voice = client.legacy.reporting.usage_reports.voice.create( + end_time=parse_datetime("2024-02-01T00:00:00Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + aggregation_type=0, + connections=[123, 456], + managed_accounts=["f47ac10b-58cc-4372-a567-0e02b2c3d479", "6ba7b810-9dad-11d1-80b4-00c04fd430c8"], + product_breakdown=0, + select_all_managed_accounts=False, + ) + assert_matches_type(VoiceCreateResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_create(self, client: Telnyx) -> None: + response = client.legacy.reporting.usage_reports.voice.with_raw_response.create( + end_time=parse_datetime("2024-02-01T00:00:00Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + voice = response.parse() + assert_matches_type(VoiceCreateResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_create(self, client: Telnyx) -> None: + with client.legacy.reporting.usage_reports.voice.with_streaming_response.create( + end_time=parse_datetime("2024-02-01T00:00:00Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + voice = response.parse() + assert_matches_type(VoiceCreateResponse, voice, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_retrieve(self, client: Telnyx) -> None: + voice = client.legacy.reporting.usage_reports.voice.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(VoiceRetrieveResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_retrieve(self, client: Telnyx) -> None: + response = client.legacy.reporting.usage_reports.voice.with_raw_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + voice = response.parse() + assert_matches_type(VoiceRetrieveResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_retrieve(self, client: Telnyx) -> None: + with client.legacy.reporting.usage_reports.voice.with_streaming_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + voice = response.parse() + assert_matches_type(VoiceRetrieveResponse, voice, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_retrieve(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.legacy.reporting.usage_reports.voice.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_list(self, client: Telnyx) -> None: + voice = client.legacy.reporting.usage_reports.voice.list() + assert_matches_type(VoiceListResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: Telnyx) -> None: + voice = client.legacy.reporting.usage_reports.voice.list( + page=1, + per_page=1, + ) + assert_matches_type(VoiceListResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_list(self, client: Telnyx) -> None: + response = client.legacy.reporting.usage_reports.voice.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + voice = response.parse() + assert_matches_type(VoiceListResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_list(self, client: Telnyx) -> None: + with client.legacy.reporting.usage_reports.voice.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + voice = response.parse() + assert_matches_type(VoiceListResponse, voice, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_delete(self, client: Telnyx) -> None: + voice = client.legacy.reporting.usage_reports.voice.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(VoiceDeleteResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_delete(self, client: Telnyx) -> None: + response = client.legacy.reporting.usage_reports.voice.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + voice = response.parse() + assert_matches_type(VoiceDeleteResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: Telnyx) -> None: + with client.legacy.reporting.usage_reports.voice.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + voice = response.parse() + assert_matches_type(VoiceDeleteResponse, voice, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_delete(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.legacy.reporting.usage_reports.voice.with_raw_response.delete( + "", + ) + + +class TestAsyncVoice: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncTelnyx) -> None: + voice = await async_client.legacy.reporting.usage_reports.voice.create( + end_time=parse_datetime("2024-02-01T00:00:00Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + ) + assert_matches_type(VoiceCreateResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncTelnyx) -> None: + voice = await async_client.legacy.reporting.usage_reports.voice.create( + end_time=parse_datetime("2024-02-01T00:00:00Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + aggregation_type=0, + connections=[123, 456], + managed_accounts=["f47ac10b-58cc-4372-a567-0e02b2c3d479", "6ba7b810-9dad-11d1-80b4-00c04fd430c8"], + product_breakdown=0, + select_all_managed_accounts=False, + ) + assert_matches_type(VoiceCreateResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.usage_reports.voice.with_raw_response.create( + end_time=parse_datetime("2024-02-01T00:00:00Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + voice = await response.parse() + assert_matches_type(VoiceCreateResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.usage_reports.voice.with_streaming_response.create( + end_time=parse_datetime("2024-02-01T00:00:00Z"), + start_time=parse_datetime("2024-02-01T00:00:00Z"), + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + voice = await response.parse() + assert_matches_type(VoiceCreateResponse, voice, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: + voice = await async_client.legacy.reporting.usage_reports.voice.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(VoiceRetrieveResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.usage_reports.voice.with_raw_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + voice = await response.parse() + assert_matches_type(VoiceRetrieveResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.usage_reports.voice.with_streaming_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + voice = await response.parse() + assert_matches_type(VoiceRetrieveResponse, voice, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.legacy.reporting.usage_reports.voice.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncTelnyx) -> None: + voice = await async_client.legacy.reporting.usage_reports.voice.list() + assert_matches_type(VoiceListResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncTelnyx) -> None: + voice = await async_client.legacy.reporting.usage_reports.voice.list( + page=1, + per_page=1, + ) + assert_matches_type(VoiceListResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.usage_reports.voice.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + voice = await response.parse() + assert_matches_type(VoiceListResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.usage_reports.voice.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + voice = await response.parse() + assert_matches_type(VoiceListResponse, voice, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncTelnyx) -> None: + voice = await async_client.legacy.reporting.usage_reports.voice.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(VoiceDeleteResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncTelnyx) -> None: + response = await async_client.legacy.reporting.usage_reports.voice.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + voice = await response.parse() + assert_matches_type(VoiceDeleteResponse, voice, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncTelnyx) -> None: + async with async_client.legacy.reporting.usage_reports.voice.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + voice = await response.parse() + assert_matches_type(VoiceDeleteResponse, voice, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.legacy.reporting.usage_reports.voice.with_raw_response.delete( + "", + ) diff --git a/tests/api_resources/phone_numbers/test_jobs.py b/tests/api_resources/phone_numbers/test_jobs.py index 2e64b4e3..0d66209d 100644 --- a/tests/api_resources/phone_numbers/test_jobs.py +++ b/tests/api_resources/phone_numbers/test_jobs.py @@ -173,6 +173,7 @@ def test_method_update_batch_with_all_params(self, client: Telnyx) -> None: billing_group_id="dc8e4d67-33a0-4cbb-af74-7b58f05bd494", connection_id="dc8e4d67-33a0-4cbb-af74-7b58f05bd494", customer_reference="customer-reference", + deletion_lock_enabled=True, external_pin="123456", hd_voice_enabled=True, tags=["tag"], @@ -199,7 +200,7 @@ def test_method_update_batch_with_all_params(self, client: Telnyx) -> None: "t38_fax_gateway_enabled": True, }, "tech_prefix_enabled": True, - "translated_number": "translated_number", + "translated_number": "+13035559999", "usage_payment_method": "pay-per-minute", }, ) @@ -434,6 +435,7 @@ async def test_method_update_batch_with_all_params(self, async_client: AsyncTeln billing_group_id="dc8e4d67-33a0-4cbb-af74-7b58f05bd494", connection_id="dc8e4d67-33a0-4cbb-af74-7b58f05bd494", customer_reference="customer-reference", + deletion_lock_enabled=True, external_pin="123456", hd_voice_enabled=True, tags=["tag"], @@ -460,7 +462,7 @@ async def test_method_update_batch_with_all_params(self, async_client: AsyncTeln "t38_fax_gateway_enabled": True, }, "tech_prefix_enabled": True, - "translated_number": "translated_number", + "translated_number": "+13035559999", "usage_payment_method": "pay-per-minute", }, ) diff --git a/tests/api_resources/phone_numbers/test_voicemail.py b/tests/api_resources/phone_numbers/test_voicemail.py index 928d32a4..77d429d2 100644 --- a/tests/api_resources/phone_numbers/test_voicemail.py +++ b/tests/api_resources/phone_numbers/test_voicemail.py @@ -77,7 +77,7 @@ def test_path_params_create(self, client: Telnyx) -> None: @parametrize def test_method_retrieve(self, client: Telnyx) -> None: voicemail = client.phone_numbers.voicemail.retrieve( - "phone_number_id", + "123455678900", ) assert_matches_type(VoicemailRetrieveResponse, voicemail, path=["response"]) @@ -85,7 +85,7 @@ def test_method_retrieve(self, client: Telnyx) -> None: @parametrize def test_raw_response_retrieve(self, client: Telnyx) -> None: response = client.phone_numbers.voicemail.with_raw_response.retrieve( - "phone_number_id", + "123455678900", ) assert response.is_closed is True @@ -97,7 +97,7 @@ def test_raw_response_retrieve(self, client: Telnyx) -> None: @parametrize def test_streaming_response_retrieve(self, client: Telnyx) -> None: with client.phone_numbers.voicemail.with_streaming_response.retrieve( - "phone_number_id", + "123455678900", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -229,7 +229,7 @@ async def test_path_params_create(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: voicemail = await async_client.phone_numbers.voicemail.retrieve( - "phone_number_id", + "123455678900", ) assert_matches_type(VoicemailRetrieveResponse, voicemail, path=["response"]) @@ -237,7 +237,7 @@ async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: response = await async_client.phone_numbers.voicemail.with_raw_response.retrieve( - "phone_number_id", + "123455678900", ) assert response.is_closed is True @@ -249,7 +249,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_streaming_response_retrieve(self, async_client: AsyncTelnyx) -> None: async with async_client.phone_numbers.voicemail.with_streaming_response.retrieve( - "phone_number_id", + "123455678900", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/porting_orders/test_phone_number_configurations.py b/tests/api_resources/porting_orders/test_phone_number_configurations.py index 1080111e..8dc9486a 100644 --- a/tests/api_resources/porting_orders/test_phone_number_configurations.py +++ b/tests/api_resources/porting_orders/test_phone_number_configurations.py @@ -72,7 +72,7 @@ def test_method_list(self, client: Telnyx) -> None: def test_method_list_with_all_params(self, client: Telnyx) -> None: phone_number_configuration = client.porting_orders.phone_number_configurations.list( filter={ - "porting_order_status": ["activation-in-progress"], + "porting_order": {"status": ["activation-in-progress"]}, "porting_phone_number": ["5d6f7ede-1961-4717-bfb5-db392c5efc2d"], "user_bundle_id": ["5d6f7ede-1961-4717-bfb5-db392c5efc2d"], }, @@ -164,7 +164,7 @@ async def test_method_list(self, async_client: AsyncTelnyx) -> None: async def test_method_list_with_all_params(self, async_client: AsyncTelnyx) -> None: phone_number_configuration = await async_client.porting_orders.phone_number_configurations.list( filter={ - "porting_order_status": ["activation-in-progress"], + "porting_order": {"status": ["activation-in-progress"]}, "porting_phone_number": ["5d6f7ede-1961-4717-bfb5-db392c5efc2d"], "user_bundle_id": ["5d6f7ede-1961-4717-bfb5-db392c5efc2d"], }, diff --git a/tests/api_resources/storage/buckets/test_ssl_certificate.py b/tests/api_resources/storage/buckets/test_ssl_certificate.py index c76ba281..79a5e8e4 100644 --- a/tests/api_resources/storage/buckets/test_ssl_certificate.py +++ b/tests/api_resources/storage/buckets/test_ssl_certificate.py @@ -77,7 +77,7 @@ def test_path_params_create(self, client: Telnyx) -> None: @parametrize def test_method_retrieve(self, client: Telnyx) -> None: ssl_certificate = client.storage.buckets.ssl_certificate.retrieve( - "bucketName", + "", ) assert_matches_type(SslCertificateRetrieveResponse, ssl_certificate, path=["response"]) @@ -85,7 +85,7 @@ def test_method_retrieve(self, client: Telnyx) -> None: @parametrize def test_raw_response_retrieve(self, client: Telnyx) -> None: response = client.storage.buckets.ssl_certificate.with_raw_response.retrieve( - "bucketName", + "", ) assert response.is_closed is True @@ -97,7 +97,7 @@ def test_raw_response_retrieve(self, client: Telnyx) -> None: @parametrize def test_streaming_response_retrieve(self, client: Telnyx) -> None: with client.storage.buckets.ssl_certificate.with_streaming_response.retrieve( - "bucketName", + "", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -119,7 +119,7 @@ def test_path_params_retrieve(self, client: Telnyx) -> None: @parametrize def test_method_delete(self, client: Telnyx) -> None: ssl_certificate = client.storage.buckets.ssl_certificate.delete( - "bucketName", + "", ) assert_matches_type(SslCertificateDeleteResponse, ssl_certificate, path=["response"]) @@ -127,7 +127,7 @@ def test_method_delete(self, client: Telnyx) -> None: @parametrize def test_raw_response_delete(self, client: Telnyx) -> None: response = client.storage.buckets.ssl_certificate.with_raw_response.delete( - "bucketName", + "", ) assert response.is_closed is True @@ -139,7 +139,7 @@ def test_raw_response_delete(self, client: Telnyx) -> None: @parametrize def test_streaming_response_delete(self, client: Telnyx) -> None: with client.storage.buckets.ssl_certificate.with_streaming_response.delete( - "bucketName", + "", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -219,7 +219,7 @@ async def test_path_params_create(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: ssl_certificate = await async_client.storage.buckets.ssl_certificate.retrieve( - "bucketName", + "", ) assert_matches_type(SslCertificateRetrieveResponse, ssl_certificate, path=["response"]) @@ -227,7 +227,7 @@ async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: response = await async_client.storage.buckets.ssl_certificate.with_raw_response.retrieve( - "bucketName", + "", ) assert response.is_closed is True @@ -239,7 +239,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_streaming_response_retrieve(self, async_client: AsyncTelnyx) -> None: async with async_client.storage.buckets.ssl_certificate.with_streaming_response.retrieve( - "bucketName", + "", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -261,7 +261,7 @@ async def test_path_params_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_method_delete(self, async_client: AsyncTelnyx) -> None: ssl_certificate = await async_client.storage.buckets.ssl_certificate.delete( - "bucketName", + "", ) assert_matches_type(SslCertificateDeleteResponse, ssl_certificate, path=["response"]) @@ -269,7 +269,7 @@ async def test_method_delete(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_raw_response_delete(self, async_client: AsyncTelnyx) -> None: response = await async_client.storage.buckets.ssl_certificate.with_raw_response.delete( - "bucketName", + "", ) assert response.is_closed is True @@ -281,7 +281,7 @@ async def test_raw_response_delete(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_streaming_response_delete(self, async_client: AsyncTelnyx) -> None: async with async_client.storage.buckets.ssl_certificate.with_streaming_response.delete( - "bucketName", + "", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/storage/buckets/test_usage.py b/tests/api_resources/storage/buckets/test_usage.py index d487e399..ceecb0a4 100644 --- a/tests/api_resources/storage/buckets/test_usage.py +++ b/tests/api_resources/storage/buckets/test_usage.py @@ -83,7 +83,7 @@ def test_path_params_get_api_usage(self, client: Telnyx) -> None: @parametrize def test_method_get_bucket_usage(self, client: Telnyx) -> None: usage = client.storage.buckets.usage.get_bucket_usage( - "bucketName", + "", ) assert_matches_type(UsageGetBucketUsageResponse, usage, path=["response"]) @@ -91,7 +91,7 @@ def test_method_get_bucket_usage(self, client: Telnyx) -> None: @parametrize def test_raw_response_get_bucket_usage(self, client: Telnyx) -> None: response = client.storage.buckets.usage.with_raw_response.get_bucket_usage( - "bucketName", + "", ) assert response.is_closed is True @@ -103,7 +103,7 @@ def test_raw_response_get_bucket_usage(self, client: Telnyx) -> None: @parametrize def test_streaming_response_get_bucket_usage(self, client: Telnyx) -> None: with client.storage.buckets.usage.with_streaming_response.get_bucket_usage( - "bucketName", + "", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -189,7 +189,7 @@ async def test_path_params_get_api_usage(self, async_client: AsyncTelnyx) -> Non @parametrize async def test_method_get_bucket_usage(self, async_client: AsyncTelnyx) -> None: usage = await async_client.storage.buckets.usage.get_bucket_usage( - "bucketName", + "", ) assert_matches_type(UsageGetBucketUsageResponse, usage, path=["response"]) @@ -197,7 +197,7 @@ async def test_method_get_bucket_usage(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_raw_response_get_bucket_usage(self, async_client: AsyncTelnyx) -> None: response = await async_client.storage.buckets.usage.with_raw_response.get_bucket_usage( - "bucketName", + "", ) assert response.is_closed is True @@ -209,7 +209,7 @@ async def test_raw_response_get_bucket_usage(self, async_client: AsyncTelnyx) -> @parametrize async def test_streaming_response_get_bucket_usage(self, async_client: AsyncTelnyx) -> None: async with async_client.storage.buckets.usage.with_streaming_response.get_bucket_usage( - "bucketName", + "", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/storage/migrations/test_actions.py b/tests/api_resources/storage/migrations/test_actions.py index 67c18a38..34047059 100644 --- a/tests/api_resources/storage/migrations/test_actions.py +++ b/tests/api_resources/storage/migrations/test_actions.py @@ -21,7 +21,7 @@ class TestActions: @parametrize def test_method_stop(self, client: Telnyx) -> None: action = client.storage.migrations.actions.stop( - "id", + "", ) assert_matches_type(ActionStopResponse, action, path=["response"]) @@ -29,7 +29,7 @@ def test_method_stop(self, client: Telnyx) -> None: @parametrize def test_raw_response_stop(self, client: Telnyx) -> None: response = client.storage.migrations.actions.with_raw_response.stop( - "id", + "", ) assert response.is_closed is True @@ -41,7 +41,7 @@ def test_raw_response_stop(self, client: Telnyx) -> None: @parametrize def test_streaming_response_stop(self, client: Telnyx) -> None: with client.storage.migrations.actions.with_streaming_response.stop( - "id", + "", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -69,7 +69,7 @@ class TestAsyncActions: @parametrize async def test_method_stop(self, async_client: AsyncTelnyx) -> None: action = await async_client.storage.migrations.actions.stop( - "id", + "", ) assert_matches_type(ActionStopResponse, action, path=["response"]) @@ -77,7 +77,7 @@ async def test_method_stop(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_raw_response_stop(self, async_client: AsyncTelnyx) -> None: response = await async_client.storage.migrations.actions.with_raw_response.stop( - "id", + "", ) assert response.is_closed is True @@ -89,7 +89,7 @@ async def test_raw_response_stop(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_streaming_response_stop(self, async_client: AsyncTelnyx) -> None: async with async_client.storage.migrations.actions.with_streaming_response.stop( - "id", + "", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/storage/test_migration_sources.py b/tests/api_resources/storage/test_migration_sources.py index efdce519..f0601ce6 100644 --- a/tests/api_resources/storage/test_migration_sources.py +++ b/tests/api_resources/storage/test_migration_sources.py @@ -80,7 +80,7 @@ def test_streaming_response_create(self, client: Telnyx) -> None: @parametrize def test_method_retrieve(self, client: Telnyx) -> None: migration_source = client.storage.migration_sources.retrieve( - "id", + "", ) assert_matches_type(MigrationSourceRetrieveResponse, migration_source, path=["response"]) @@ -88,7 +88,7 @@ def test_method_retrieve(self, client: Telnyx) -> None: @parametrize def test_raw_response_retrieve(self, client: Telnyx) -> None: response = client.storage.migration_sources.with_raw_response.retrieve( - "id", + "", ) assert response.is_closed is True @@ -100,7 +100,7 @@ def test_raw_response_retrieve(self, client: Telnyx) -> None: @parametrize def test_streaming_response_retrieve(self, client: Telnyx) -> None: with client.storage.migration_sources.with_streaming_response.retrieve( - "id", + "", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -150,7 +150,7 @@ def test_streaming_response_list(self, client: Telnyx) -> None: @parametrize def test_method_delete(self, client: Telnyx) -> None: migration_source = client.storage.migration_sources.delete( - "id", + "", ) assert_matches_type(MigrationSourceDeleteResponse, migration_source, path=["response"]) @@ -158,7 +158,7 @@ def test_method_delete(self, client: Telnyx) -> None: @parametrize def test_raw_response_delete(self, client: Telnyx) -> None: response = client.storage.migration_sources.with_raw_response.delete( - "id", + "", ) assert response.is_closed is True @@ -170,7 +170,7 @@ def test_raw_response_delete(self, client: Telnyx) -> None: @parametrize def test_streaming_response_delete(self, client: Telnyx) -> None: with client.storage.migration_sources.with_streaming_response.delete( - "id", + "", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -252,7 +252,7 @@ async def test_streaming_response_create(self, async_client: AsyncTelnyx) -> Non @parametrize async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: migration_source = await async_client.storage.migration_sources.retrieve( - "id", + "", ) assert_matches_type(MigrationSourceRetrieveResponse, migration_source, path=["response"]) @@ -260,7 +260,7 @@ async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: response = await async_client.storage.migration_sources.with_raw_response.retrieve( - "id", + "", ) assert response.is_closed is True @@ -272,7 +272,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_streaming_response_retrieve(self, async_client: AsyncTelnyx) -> None: async with async_client.storage.migration_sources.with_streaming_response.retrieve( - "id", + "", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -322,7 +322,7 @@ async def test_streaming_response_list(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_method_delete(self, async_client: AsyncTelnyx) -> None: migration_source = await async_client.storage.migration_sources.delete( - "id", + "", ) assert_matches_type(MigrationSourceDeleteResponse, migration_source, path=["response"]) @@ -330,7 +330,7 @@ async def test_method_delete(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_raw_response_delete(self, async_client: AsyncTelnyx) -> None: response = await async_client.storage.migration_sources.with_raw_response.delete( - "id", + "", ) assert response.is_closed is True @@ -342,7 +342,7 @@ async def test_raw_response_delete(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_streaming_response_delete(self, async_client: AsyncTelnyx) -> None: async with async_client.storage.migration_sources.with_streaming_response.delete( - "id", + "", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/storage/test_migrations.py b/tests/api_resources/storage/test_migrations.py index b56b3e80..72e5bb1c 100644 --- a/tests/api_resources/storage/test_migrations.py +++ b/tests/api_resources/storage/test_migrations.py @@ -76,7 +76,7 @@ def test_streaming_response_create(self, client: Telnyx) -> None: @parametrize def test_method_retrieve(self, client: Telnyx) -> None: migration = client.storage.migrations.retrieve( - "id", + "", ) assert_matches_type(MigrationRetrieveResponse, migration, path=["response"]) @@ -84,7 +84,7 @@ def test_method_retrieve(self, client: Telnyx) -> None: @parametrize def test_raw_response_retrieve(self, client: Telnyx) -> None: response = client.storage.migrations.with_raw_response.retrieve( - "id", + "", ) assert response.is_closed is True @@ -96,7 +96,7 @@ def test_raw_response_retrieve(self, client: Telnyx) -> None: @parametrize def test_streaming_response_retrieve(self, client: Telnyx) -> None: with client.storage.migrations.with_streaming_response.retrieve( - "id", + "", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -203,7 +203,7 @@ async def test_streaming_response_create(self, async_client: AsyncTelnyx) -> Non @parametrize async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: migration = await async_client.storage.migrations.retrieve( - "id", + "", ) assert_matches_type(MigrationRetrieveResponse, migration, path=["response"]) @@ -211,7 +211,7 @@ async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: response = await async_client.storage.migrations.with_raw_response.retrieve( - "id", + "", ) assert response.is_closed is True @@ -223,7 +223,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_streaming_response_retrieve(self, async_client: AsyncTelnyx) -> None: async with async_client.storage.migrations.with_streaming_response.retrieve( - "id", + "", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/test_billing_groups.py b/tests/api_resources/test_billing_groups.py index 44988fd5..ada5b0ad 100644 --- a/tests/api_resources/test_billing_groups.py +++ b/tests/api_resources/test_billing_groups.py @@ -63,7 +63,7 @@ def test_streaming_response_create(self, client: Telnyx) -> None: @parametrize def test_method_retrieve(self, client: Telnyx) -> None: billing_group = client.billing_groups.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "f5586561-8ff0-4291-a0ac-84fe544797bd", ) assert_matches_type(BillingGroupRetrieveResponse, billing_group, path=["response"]) @@ -71,7 +71,7 @@ def test_method_retrieve(self, client: Telnyx) -> None: @parametrize def test_raw_response_retrieve(self, client: Telnyx) -> None: response = client.billing_groups.with_raw_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "f5586561-8ff0-4291-a0ac-84fe544797bd", ) assert response.is_closed is True @@ -83,7 +83,7 @@ def test_raw_response_retrieve(self, client: Telnyx) -> None: @parametrize def test_streaming_response_retrieve(self, client: Telnyx) -> None: with client.billing_groups.with_streaming_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "f5586561-8ff0-4291-a0ac-84fe544797bd", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -195,7 +195,7 @@ def test_streaming_response_list(self, client: Telnyx) -> None: @parametrize def test_method_delete(self, client: Telnyx) -> None: billing_group = client.billing_groups.delete( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "f5586561-8ff0-4291-a0ac-84fe544797bd", ) assert_matches_type(BillingGroupDeleteResponse, billing_group, path=["response"]) @@ -203,7 +203,7 @@ def test_method_delete(self, client: Telnyx) -> None: @parametrize def test_raw_response_delete(self, client: Telnyx) -> None: response = client.billing_groups.with_raw_response.delete( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "f5586561-8ff0-4291-a0ac-84fe544797bd", ) assert response.is_closed is True @@ -215,7 +215,7 @@ def test_raw_response_delete(self, client: Telnyx) -> None: @parametrize def test_streaming_response_delete(self, client: Telnyx) -> None: with client.billing_groups.with_streaming_response.delete( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "f5586561-8ff0-4291-a0ac-84fe544797bd", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -279,7 +279,7 @@ async def test_streaming_response_create(self, async_client: AsyncTelnyx) -> Non @parametrize async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: billing_group = await async_client.billing_groups.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "f5586561-8ff0-4291-a0ac-84fe544797bd", ) assert_matches_type(BillingGroupRetrieveResponse, billing_group, path=["response"]) @@ -287,7 +287,7 @@ async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: response = await async_client.billing_groups.with_raw_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "f5586561-8ff0-4291-a0ac-84fe544797bd", ) assert response.is_closed is True @@ -299,7 +299,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_streaming_response_retrieve(self, async_client: AsyncTelnyx) -> None: async with async_client.billing_groups.with_streaming_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "f5586561-8ff0-4291-a0ac-84fe544797bd", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -411,7 +411,7 @@ async def test_streaming_response_list(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_method_delete(self, async_client: AsyncTelnyx) -> None: billing_group = await async_client.billing_groups.delete( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "f5586561-8ff0-4291-a0ac-84fe544797bd", ) assert_matches_type(BillingGroupDeleteResponse, billing_group, path=["response"]) @@ -419,7 +419,7 @@ async def test_method_delete(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_raw_response_delete(self, async_client: AsyncTelnyx) -> None: response = await async_client.billing_groups.with_raw_response.delete( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "f5586561-8ff0-4291-a0ac-84fe544797bd", ) assert response.is_closed is True @@ -431,7 +431,7 @@ async def test_raw_response_delete(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_streaming_response_delete(self, async_client: AsyncTelnyx) -> None: async with async_client.billing_groups.with_streaming_response.delete( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "f5586561-8ff0-4291-a0ac-84fe544797bd", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/test_ledger_billing_group_reports.py b/tests/api_resources/test_ledger_billing_group_reports.py index bafd5dea..a857304c 100644 --- a/tests/api_resources/test_ledger_billing_group_reports.py +++ b/tests/api_resources/test_ledger_billing_group_reports.py @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Telnyx) -> None: @parametrize def test_method_retrieve(self, client: Telnyx) -> None: ledger_billing_group_report = client.ledger_billing_group_reports.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "f5586561-8ff0-4291-a0ac-84fe544797bd", ) assert_matches_type(LedgerBillingGroupReportRetrieveResponse, ledger_billing_group_report, path=["response"]) @@ -69,7 +69,7 @@ def test_method_retrieve(self, client: Telnyx) -> None: @parametrize def test_raw_response_retrieve(self, client: Telnyx) -> None: response = client.ledger_billing_group_reports.with_raw_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "f5586561-8ff0-4291-a0ac-84fe544797bd", ) assert response.is_closed is True @@ -81,7 +81,7 @@ def test_raw_response_retrieve(self, client: Telnyx) -> None: @parametrize def test_streaming_response_retrieve(self, client: Telnyx) -> None: with client.ledger_billing_group_reports.with_streaming_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "f5586561-8ff0-4291-a0ac-84fe544797bd", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -148,7 +148,7 @@ async def test_streaming_response_create(self, async_client: AsyncTelnyx) -> Non @parametrize async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: ledger_billing_group_report = await async_client.ledger_billing_group_reports.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "f5586561-8ff0-4291-a0ac-84fe544797bd", ) assert_matches_type(LedgerBillingGroupReportRetrieveResponse, ledger_billing_group_report, path=["response"]) @@ -156,7 +156,7 @@ async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: response = await async_client.ledger_billing_group_reports.with_raw_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "f5586561-8ff0-4291-a0ac-84fe544797bd", ) assert response.is_closed is True @@ -168,7 +168,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_streaming_response_retrieve(self, async_client: AsyncTelnyx) -> None: async with async_client.ledger_billing_group_reports.with_streaming_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "f5586561-8ff0-4291-a0ac-84fe544797bd", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/test_oauth.py b/tests/api_resources/test_oauth.py new file mode 100644 index 00000000..6cf4780c --- /dev/null +++ b/tests/api_resources/test_oauth.py @@ -0,0 +1,607 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from telnyx import Telnyx, AsyncTelnyx +from tests.utils import assert_matches_type +from telnyx.types import ( + OAuthTokenResponse, + OAuthGrantsResponse, + OAuthRegisterResponse, + OAuthRetrieveResponse, + OAuthIntrospectResponse, + OAuthRetrieveJwksResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestOAuth: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_retrieve(self, client: Telnyx) -> None: + oauth = client.oauth.retrieve( + "consent_token", + ) + assert_matches_type(OAuthRetrieveResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_retrieve(self, client: Telnyx) -> None: + response = client.oauth.with_raw_response.retrieve( + "consent_token", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth = response.parse() + assert_matches_type(OAuthRetrieveResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_retrieve(self, client: Telnyx) -> None: + with client.oauth.with_streaming_response.retrieve( + "consent_token", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth = response.parse() + assert_matches_type(OAuthRetrieveResponse, oauth, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_retrieve(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `consent_token` but received ''"): + client.oauth.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_grants(self, client: Telnyx) -> None: + oauth = client.oauth.grants( + allowed=True, + consent_token="consent_token", + ) + assert_matches_type(OAuthGrantsResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_grants(self, client: Telnyx) -> None: + response = client.oauth.with_raw_response.grants( + allowed=True, + consent_token="consent_token", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth = response.parse() + assert_matches_type(OAuthGrantsResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_grants(self, client: Telnyx) -> None: + with client.oauth.with_streaming_response.grants( + allowed=True, + consent_token="consent_token", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth = response.parse() + assert_matches_type(OAuthGrantsResponse, oauth, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_introspect(self, client: Telnyx) -> None: + oauth = client.oauth.introspect( + token="token", + ) + assert_matches_type(OAuthIntrospectResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_introspect(self, client: Telnyx) -> None: + response = client.oauth.with_raw_response.introspect( + token="token", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth = response.parse() + assert_matches_type(OAuthIntrospectResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_introspect(self, client: Telnyx) -> None: + with client.oauth.with_streaming_response.introspect( + token="token", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth = response.parse() + assert_matches_type(OAuthIntrospectResponse, oauth, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_register(self, client: Telnyx) -> None: + oauth = client.oauth.register() + assert_matches_type(OAuthRegisterResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_register_with_all_params(self, client: Telnyx) -> None: + oauth = client.oauth.register( + client_name="My OAuth Application", + grant_types=["authorization_code"], + logo_uri="https://example.com", + policy_uri="https://example.com", + redirect_uris=["https://example.com/callback"], + response_types=["string"], + scope="admin", + token_endpoint_auth_method="none", + tos_uri="https://example.com", + ) + assert_matches_type(OAuthRegisterResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_register(self, client: Telnyx) -> None: + response = client.oauth.with_raw_response.register() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth = response.parse() + assert_matches_type(OAuthRegisterResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_register(self, client: Telnyx) -> None: + with client.oauth.with_streaming_response.register() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth = response.parse() + assert_matches_type(OAuthRegisterResponse, oauth, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism doesn't properly handle redirects") + @parametrize + def test_method_retrieve_authorize(self, client: Telnyx) -> None: + oauth = client.oauth.retrieve_authorize( + client_id="client_id", + redirect_uri="https://example.com", + response_type="code", + ) + assert oauth is None + + @pytest.mark.skip(reason="Prism doesn't properly handle redirects") + @parametrize + def test_method_retrieve_authorize_with_all_params(self, client: Telnyx) -> None: + oauth = client.oauth.retrieve_authorize( + client_id="client_id", + redirect_uri="https://example.com", + response_type="code", + code_challenge="code_challenge", + code_challenge_method="plain", + scope="scope", + state="state", + ) + assert oauth is None + + @pytest.mark.skip(reason="Prism doesn't properly handle redirects") + @parametrize + def test_raw_response_retrieve_authorize(self, client: Telnyx) -> None: + response = client.oauth.with_raw_response.retrieve_authorize( + client_id="client_id", + redirect_uri="https://example.com", + response_type="code", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth = response.parse() + assert oauth is None + + @pytest.mark.skip(reason="Prism doesn't properly handle redirects") + @parametrize + def test_streaming_response_retrieve_authorize(self, client: Telnyx) -> None: + with client.oauth.with_streaming_response.retrieve_authorize( + client_id="client_id", + redirect_uri="https://example.com", + response_type="code", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth = response.parse() + assert oauth is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_retrieve_jwks(self, client: Telnyx) -> None: + oauth = client.oauth.retrieve_jwks() + assert_matches_type(OAuthRetrieveJwksResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_retrieve_jwks(self, client: Telnyx) -> None: + response = client.oauth.with_raw_response.retrieve_jwks() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth = response.parse() + assert_matches_type(OAuthRetrieveJwksResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_retrieve_jwks(self, client: Telnyx) -> None: + with client.oauth.with_streaming_response.retrieve_jwks() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth = response.parse() + assert_matches_type(OAuthRetrieveJwksResponse, oauth, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_token(self, client: Telnyx) -> None: + oauth = client.oauth.token( + grant_type="client_credentials", + ) + assert_matches_type(OAuthTokenResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_token_with_all_params(self, client: Telnyx) -> None: + oauth = client.oauth.token( + grant_type="client_credentials", + client_id="client_id", + client_secret="client_secret", + code="code", + code_verifier="code_verifier", + redirect_uri="https://example.com", + refresh_token="refresh_token", + scope="admin", + ) + assert_matches_type(OAuthTokenResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_token(self, client: Telnyx) -> None: + response = client.oauth.with_raw_response.token( + grant_type="client_credentials", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth = response.parse() + assert_matches_type(OAuthTokenResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_token(self, client: Telnyx) -> None: + with client.oauth.with_streaming_response.token( + grant_type="client_credentials", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth = response.parse() + assert_matches_type(OAuthTokenResponse, oauth, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncOAuth: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: + oauth = await async_client.oauth.retrieve( + "consent_token", + ) + assert_matches_type(OAuthRetrieveResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: + response = await async_client.oauth.with_raw_response.retrieve( + "consent_token", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth = await response.parse() + assert_matches_type(OAuthRetrieveResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncTelnyx) -> None: + async with async_client.oauth.with_streaming_response.retrieve( + "consent_token", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth = await response.parse() + assert_matches_type(OAuthRetrieveResponse, oauth, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `consent_token` but received ''"): + await async_client.oauth.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_grants(self, async_client: AsyncTelnyx) -> None: + oauth = await async_client.oauth.grants( + allowed=True, + consent_token="consent_token", + ) + assert_matches_type(OAuthGrantsResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_grants(self, async_client: AsyncTelnyx) -> None: + response = await async_client.oauth.with_raw_response.grants( + allowed=True, + consent_token="consent_token", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth = await response.parse() + assert_matches_type(OAuthGrantsResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_grants(self, async_client: AsyncTelnyx) -> None: + async with async_client.oauth.with_streaming_response.grants( + allowed=True, + consent_token="consent_token", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth = await response.parse() + assert_matches_type(OAuthGrantsResponse, oauth, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_introspect(self, async_client: AsyncTelnyx) -> None: + oauth = await async_client.oauth.introspect( + token="token", + ) + assert_matches_type(OAuthIntrospectResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_introspect(self, async_client: AsyncTelnyx) -> None: + response = await async_client.oauth.with_raw_response.introspect( + token="token", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth = await response.parse() + assert_matches_type(OAuthIntrospectResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_introspect(self, async_client: AsyncTelnyx) -> None: + async with async_client.oauth.with_streaming_response.introspect( + token="token", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth = await response.parse() + assert_matches_type(OAuthIntrospectResponse, oauth, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_register(self, async_client: AsyncTelnyx) -> None: + oauth = await async_client.oauth.register() + assert_matches_type(OAuthRegisterResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_register_with_all_params(self, async_client: AsyncTelnyx) -> None: + oauth = await async_client.oauth.register( + client_name="My OAuth Application", + grant_types=["authorization_code"], + logo_uri="https://example.com", + policy_uri="https://example.com", + redirect_uris=["https://example.com/callback"], + response_types=["string"], + scope="admin", + token_endpoint_auth_method="none", + tos_uri="https://example.com", + ) + assert_matches_type(OAuthRegisterResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_register(self, async_client: AsyncTelnyx) -> None: + response = await async_client.oauth.with_raw_response.register() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth = await response.parse() + assert_matches_type(OAuthRegisterResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_register(self, async_client: AsyncTelnyx) -> None: + async with async_client.oauth.with_streaming_response.register() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth = await response.parse() + assert_matches_type(OAuthRegisterResponse, oauth, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism doesn't properly handle redirects") + @parametrize + async def test_method_retrieve_authorize(self, async_client: AsyncTelnyx) -> None: + oauth = await async_client.oauth.retrieve_authorize( + client_id="client_id", + redirect_uri="https://example.com", + response_type="code", + ) + assert oauth is None + + @pytest.mark.skip(reason="Prism doesn't properly handle redirects") + @parametrize + async def test_method_retrieve_authorize_with_all_params(self, async_client: AsyncTelnyx) -> None: + oauth = await async_client.oauth.retrieve_authorize( + client_id="client_id", + redirect_uri="https://example.com", + response_type="code", + code_challenge="code_challenge", + code_challenge_method="plain", + scope="scope", + state="state", + ) + assert oauth is None + + @pytest.mark.skip(reason="Prism doesn't properly handle redirects") + @parametrize + async def test_raw_response_retrieve_authorize(self, async_client: AsyncTelnyx) -> None: + response = await async_client.oauth.with_raw_response.retrieve_authorize( + client_id="client_id", + redirect_uri="https://example.com", + response_type="code", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth = await response.parse() + assert oauth is None + + @pytest.mark.skip(reason="Prism doesn't properly handle redirects") + @parametrize + async def test_streaming_response_retrieve_authorize(self, async_client: AsyncTelnyx) -> None: + async with async_client.oauth.with_streaming_response.retrieve_authorize( + client_id="client_id", + redirect_uri="https://example.com", + response_type="code", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth = await response.parse() + assert oauth is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_retrieve_jwks(self, async_client: AsyncTelnyx) -> None: + oauth = await async_client.oauth.retrieve_jwks() + assert_matches_type(OAuthRetrieveJwksResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_retrieve_jwks(self, async_client: AsyncTelnyx) -> None: + response = await async_client.oauth.with_raw_response.retrieve_jwks() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth = await response.parse() + assert_matches_type(OAuthRetrieveJwksResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_retrieve_jwks(self, async_client: AsyncTelnyx) -> None: + async with async_client.oauth.with_streaming_response.retrieve_jwks() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth = await response.parse() + assert_matches_type(OAuthRetrieveJwksResponse, oauth, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_token(self, async_client: AsyncTelnyx) -> None: + oauth = await async_client.oauth.token( + grant_type="client_credentials", + ) + assert_matches_type(OAuthTokenResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_token_with_all_params(self, async_client: AsyncTelnyx) -> None: + oauth = await async_client.oauth.token( + grant_type="client_credentials", + client_id="client_id", + client_secret="client_secret", + code="code", + code_verifier="code_verifier", + redirect_uri="https://example.com", + refresh_token="refresh_token", + scope="admin", + ) + assert_matches_type(OAuthTokenResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_token(self, async_client: AsyncTelnyx) -> None: + response = await async_client.oauth.with_raw_response.token( + grant_type="client_credentials", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth = await response.parse() + assert_matches_type(OAuthTokenResponse, oauth, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_token(self, async_client: AsyncTelnyx) -> None: + async with async_client.oauth.with_streaming_response.token( + grant_type="client_credentials", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth = await response.parse() + assert_matches_type(OAuthTokenResponse, oauth, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_oauth_clients.py b/tests/api_resources/test_oauth_clients.py new file mode 100644 index 00000000..d39b7e8f --- /dev/null +++ b/tests/api_resources/test_oauth_clients.py @@ -0,0 +1,517 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from telnyx import Telnyx, AsyncTelnyx +from tests.utils import assert_matches_type +from telnyx.types import ( + OAuthClientListResponse, + OAuthClientCreateResponse, + OAuthClientUpdateResponse, + OAuthClientRetrieveResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestOAuthClients: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create(self, client: Telnyx) -> None: + oauth_client = client.oauth_clients.create( + allowed_grant_types=["client_credentials"], + allowed_scopes=["admin"], + client_type="public", + name="My OAuth client", + ) + assert_matches_type(OAuthClientCreateResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: Telnyx) -> None: + oauth_client = client.oauth_clients.create( + allowed_grant_types=["client_credentials"], + allowed_scopes=["admin"], + client_type="public", + name="My OAuth client", + logo_uri="https://example.com", + policy_uri="https://example.com", + redirect_uris=["https://example.com"], + require_pkce=True, + tos_uri="https://example.com", + ) + assert_matches_type(OAuthClientCreateResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_create(self, client: Telnyx) -> None: + response = client.oauth_clients.with_raw_response.create( + allowed_grant_types=["client_credentials"], + allowed_scopes=["admin"], + client_type="public", + name="My OAuth client", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_client = response.parse() + assert_matches_type(OAuthClientCreateResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_create(self, client: Telnyx) -> None: + with client.oauth_clients.with_streaming_response.create( + allowed_grant_types=["client_credentials"], + allowed_scopes=["admin"], + client_type="public", + name="My OAuth client", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_client = response.parse() + assert_matches_type(OAuthClientCreateResponse, oauth_client, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_retrieve(self, client: Telnyx) -> None: + oauth_client = client.oauth_clients.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(OAuthClientRetrieveResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_retrieve(self, client: Telnyx) -> None: + response = client.oauth_clients.with_raw_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_client = response.parse() + assert_matches_type(OAuthClientRetrieveResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_retrieve(self, client: Telnyx) -> None: + with client.oauth_clients.with_streaming_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_client = response.parse() + assert_matches_type(OAuthClientRetrieveResponse, oauth_client, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_retrieve(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.oauth_clients.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_update(self, client: Telnyx) -> None: + oauth_client = client.oauth_clients.update( + id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(OAuthClientUpdateResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_update_with_all_params(self, client: Telnyx) -> None: + oauth_client = client.oauth_clients.update( + id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + allowed_grant_types=["client_credentials"], + allowed_scopes=["admin"], + logo_uri="https://example.com", + name="name", + policy_uri="https://example.com", + redirect_uris=["https://example.com"], + require_pkce=True, + tos_uri="https://example.com", + ) + assert_matches_type(OAuthClientUpdateResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_update(self, client: Telnyx) -> None: + response = client.oauth_clients.with_raw_response.update( + id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_client = response.parse() + assert_matches_type(OAuthClientUpdateResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_update(self, client: Telnyx) -> None: + with client.oauth_clients.with_streaming_response.update( + id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_client = response.parse() + assert_matches_type(OAuthClientUpdateResponse, oauth_client, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_update(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.oauth_clients.with_raw_response.update( + id="", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_list(self, client: Telnyx) -> None: + oauth_client = client.oauth_clients.list() + assert_matches_type(OAuthClientListResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: Telnyx) -> None: + oauth_client = client.oauth_clients.list( + filter_allowed_grant_types_contains="client_credentials", + filter_client_id="filter[client_id]", + filter_client_type="confidential", + filter_name="filter[name]", + filter_name_contains="filter[name][contains]", + filter_verified=True, + page_number=1, + page_size=1, + ) + assert_matches_type(OAuthClientListResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_list(self, client: Telnyx) -> None: + response = client.oauth_clients.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_client = response.parse() + assert_matches_type(OAuthClientListResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_list(self, client: Telnyx) -> None: + with client.oauth_clients.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_client = response.parse() + assert_matches_type(OAuthClientListResponse, oauth_client, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_delete(self, client: Telnyx) -> None: + oauth_client = client.oauth_clients.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert oauth_client is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_delete(self, client: Telnyx) -> None: + response = client.oauth_clients.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_client = response.parse() + assert oauth_client is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: Telnyx) -> None: + with client.oauth_clients.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_client = response.parse() + assert oauth_client is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_delete(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.oauth_clients.with_raw_response.delete( + "", + ) + + +class TestAsyncOAuthClients: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncTelnyx) -> None: + oauth_client = await async_client.oauth_clients.create( + allowed_grant_types=["client_credentials"], + allowed_scopes=["admin"], + client_type="public", + name="My OAuth client", + ) + assert_matches_type(OAuthClientCreateResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncTelnyx) -> None: + oauth_client = await async_client.oauth_clients.create( + allowed_grant_types=["client_credentials"], + allowed_scopes=["admin"], + client_type="public", + name="My OAuth client", + logo_uri="https://example.com", + policy_uri="https://example.com", + redirect_uris=["https://example.com"], + require_pkce=True, + tos_uri="https://example.com", + ) + assert_matches_type(OAuthClientCreateResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncTelnyx) -> None: + response = await async_client.oauth_clients.with_raw_response.create( + allowed_grant_types=["client_credentials"], + allowed_scopes=["admin"], + client_type="public", + name="My OAuth client", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_client = await response.parse() + assert_matches_type(OAuthClientCreateResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncTelnyx) -> None: + async with async_client.oauth_clients.with_streaming_response.create( + allowed_grant_types=["client_credentials"], + allowed_scopes=["admin"], + client_type="public", + name="My OAuth client", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_client = await response.parse() + assert_matches_type(OAuthClientCreateResponse, oauth_client, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: + oauth_client = await async_client.oauth_clients.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(OAuthClientRetrieveResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: + response = await async_client.oauth_clients.with_raw_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_client = await response.parse() + assert_matches_type(OAuthClientRetrieveResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncTelnyx) -> None: + async with async_client.oauth_clients.with_streaming_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_client = await response.parse() + assert_matches_type(OAuthClientRetrieveResponse, oauth_client, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.oauth_clients.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_update(self, async_client: AsyncTelnyx) -> None: + oauth_client = await async_client.oauth_clients.update( + id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(OAuthClientUpdateResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncTelnyx) -> None: + oauth_client = await async_client.oauth_clients.update( + id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + allowed_grant_types=["client_credentials"], + allowed_scopes=["admin"], + logo_uri="https://example.com", + name="name", + policy_uri="https://example.com", + redirect_uris=["https://example.com"], + require_pkce=True, + tos_uri="https://example.com", + ) + assert_matches_type(OAuthClientUpdateResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_update(self, async_client: AsyncTelnyx) -> None: + response = await async_client.oauth_clients.with_raw_response.update( + id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_client = await response.parse() + assert_matches_type(OAuthClientUpdateResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_update(self, async_client: AsyncTelnyx) -> None: + async with async_client.oauth_clients.with_streaming_response.update( + id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_client = await response.parse() + assert_matches_type(OAuthClientUpdateResponse, oauth_client, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_update(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.oauth_clients.with_raw_response.update( + id="", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncTelnyx) -> None: + oauth_client = await async_client.oauth_clients.list() + assert_matches_type(OAuthClientListResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncTelnyx) -> None: + oauth_client = await async_client.oauth_clients.list( + filter_allowed_grant_types_contains="client_credentials", + filter_client_id="filter[client_id]", + filter_client_type="confidential", + filter_name="filter[name]", + filter_name_contains="filter[name][contains]", + filter_verified=True, + page_number=1, + page_size=1, + ) + assert_matches_type(OAuthClientListResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncTelnyx) -> None: + response = await async_client.oauth_clients.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_client = await response.parse() + assert_matches_type(OAuthClientListResponse, oauth_client, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncTelnyx) -> None: + async with async_client.oauth_clients.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_client = await response.parse() + assert_matches_type(OAuthClientListResponse, oauth_client, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncTelnyx) -> None: + oauth_client = await async_client.oauth_clients.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert oauth_client is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncTelnyx) -> None: + response = await async_client.oauth_clients.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_client = await response.parse() + assert oauth_client is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncTelnyx) -> None: + async with async_client.oauth_clients.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_client = await response.parse() + assert oauth_client is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.oauth_clients.with_raw_response.delete( + "", + ) diff --git a/tests/api_resources/test_oauth_grants.py b/tests/api_resources/test_oauth_grants.py new file mode 100644 index 00000000..0dfc4532 --- /dev/null +++ b/tests/api_resources/test_oauth_grants.py @@ -0,0 +1,270 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from telnyx import Telnyx, AsyncTelnyx +from tests.utils import assert_matches_type +from telnyx.types import ( + OAuthGrantListResponse, + OAuthGrantDeleteResponse, + OAuthGrantRetrieveResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestOAuthGrants: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_retrieve(self, client: Telnyx) -> None: + oauth_grant = client.oauth_grants.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(OAuthGrantRetrieveResponse, oauth_grant, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_retrieve(self, client: Telnyx) -> None: + response = client.oauth_grants.with_raw_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_grant = response.parse() + assert_matches_type(OAuthGrantRetrieveResponse, oauth_grant, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_retrieve(self, client: Telnyx) -> None: + with client.oauth_grants.with_streaming_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_grant = response.parse() + assert_matches_type(OAuthGrantRetrieveResponse, oauth_grant, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_retrieve(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.oauth_grants.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_list(self, client: Telnyx) -> None: + oauth_grant = client.oauth_grants.list() + assert_matches_type(OAuthGrantListResponse, oauth_grant, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: Telnyx) -> None: + oauth_grant = client.oauth_grants.list( + page_number=1, + page_size=1, + ) + assert_matches_type(OAuthGrantListResponse, oauth_grant, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_list(self, client: Telnyx) -> None: + response = client.oauth_grants.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_grant = response.parse() + assert_matches_type(OAuthGrantListResponse, oauth_grant, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_list(self, client: Telnyx) -> None: + with client.oauth_grants.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_grant = response.parse() + assert_matches_type(OAuthGrantListResponse, oauth_grant, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_delete(self, client: Telnyx) -> None: + oauth_grant = client.oauth_grants.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(OAuthGrantDeleteResponse, oauth_grant, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_delete(self, client: Telnyx) -> None: + response = client.oauth_grants.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_grant = response.parse() + assert_matches_type(OAuthGrantDeleteResponse, oauth_grant, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: Telnyx) -> None: + with client.oauth_grants.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_grant = response.parse() + assert_matches_type(OAuthGrantDeleteResponse, oauth_grant, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_delete(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.oauth_grants.with_raw_response.delete( + "", + ) + + +class TestAsyncOAuthGrants: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: + oauth_grant = await async_client.oauth_grants.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(OAuthGrantRetrieveResponse, oauth_grant, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: + response = await async_client.oauth_grants.with_raw_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_grant = await response.parse() + assert_matches_type(OAuthGrantRetrieveResponse, oauth_grant, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncTelnyx) -> None: + async with async_client.oauth_grants.with_streaming_response.retrieve( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_grant = await response.parse() + assert_matches_type(OAuthGrantRetrieveResponse, oauth_grant, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.oauth_grants.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncTelnyx) -> None: + oauth_grant = await async_client.oauth_grants.list() + assert_matches_type(OAuthGrantListResponse, oauth_grant, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncTelnyx) -> None: + oauth_grant = await async_client.oauth_grants.list( + page_number=1, + page_size=1, + ) + assert_matches_type(OAuthGrantListResponse, oauth_grant, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncTelnyx) -> None: + response = await async_client.oauth_grants.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_grant = await response.parse() + assert_matches_type(OAuthGrantListResponse, oauth_grant, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncTelnyx) -> None: + async with async_client.oauth_grants.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_grant = await response.parse() + assert_matches_type(OAuthGrantListResponse, oauth_grant, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncTelnyx) -> None: + oauth_grant = await async_client.oauth_grants.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(OAuthGrantDeleteResponse, oauth_grant, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncTelnyx) -> None: + response = await async_client.oauth_grants.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_grant = await response.parse() + assert_matches_type(OAuthGrantDeleteResponse, oauth_grant, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncTelnyx) -> None: + async with async_client.oauth_grants.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_grant = await response.parse() + assert_matches_type(OAuthGrantDeleteResponse, oauth_grant, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.oauth_grants.with_raw_response.delete( + "", + ) diff --git a/tests/api_resources/test_phone_numbers.py b/tests/api_resources/test_phone_numbers.py index 0cb71e23..68814c50 100644 --- a/tests/api_resources/test_phone_numbers.py +++ b/tests/api_resources/test_phone_numbers.py @@ -149,6 +149,7 @@ def test_method_list_with_all_params(self, client: Telnyx) -> None: "starts_with": "test", }, "voice_usage_payment_method": "channel", + "without_tags": "true", }, page={ "number": 1, @@ -415,6 +416,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncTelnyx) -> N "starts_with": "test", }, "voice_usage_payment_method": "channel", + "without_tags": "true", }, page={ "number": 1, diff --git a/tests/api_resources/test_porting_orders.py b/tests/api_resources/test_porting_orders.py index d5f8df72..89ba0bea 100644 --- a/tests/api_resources/test_porting_orders.py +++ b/tests/api_resources/test_porting_orders.py @@ -48,6 +48,7 @@ def test_method_create(self, client: Telnyx) -> None: def test_method_create_with_all_params(self, client: Telnyx) -> None: porting_order = client.porting_orders.create( phone_numbers=["+13035550000", "+13035550001", "+13035550002"], + customer_group_reference="Group-456", customer_reference="Acct 123abc", ) assert_matches_type(PortingOrderCreateResponse, porting_order, path=["response"]) @@ -143,6 +144,7 @@ def test_method_update_with_all_params(self, client: Telnyx) -> None: porting_order = client.porting_orders.update( id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", activation_settings={"foc_datetime_requested": parse_datetime("2021-03-19T10:07:15.527Z")}, + customer_group_reference="customer_group_reference", customer_reference="customer_reference", documents={ "invoice": "ce74b771-d23d-4960-81ec-8741b3862146", @@ -240,19 +242,28 @@ def test_method_list(self, client: Telnyx) -> None: def test_method_list_with_all_params(self, client: Telnyx) -> None: porting_order = client.porting_orders.list( filter={ - "activation_settings_fast_port_eligible": True, - "activation_settings_foc_datetime_requested": { - "gt": "2021-03-25T10:00:00.000Z", - "lt": "2021-03-25T10:00:00.000Z", + "activation_settings": { + "fast_port_eligible": True, + "foc_datetime_requested": { + "gt": "2021-03-25T10:00:00.000Z", + "lt": "2021-03-25T10:00:00.000Z", + }, }, + "customer_group_reference": "customer_group_reference", "customer_reference": "customer_reference", - "end_user_admin_auth_person_name": "end_user.admin.auth_person_name", - "end_user_admin_entity_name": "end_user.admin.entity_name", - "misc_type": "full", + "end_user": { + "admin": { + "auth_person_name": "auth_person_name", + "entity_name": "entity_name", + } + }, + "misc": {"type": "full"}, "parent_support_key": "parent_support_key", - "phone_numbers_carrier_name": "phone_numbers.carrier_name", - "phone_numbers_country_code": "phone_numbers.country_code", - "phone_numbers_phone_number": {"contains": "contains"}, + "phone_numbers": { + "carrier_name": "carrier_name", + "country_code": "country_code", + "phone_number": {"contains": "contains"}, + }, }, include_phone_numbers=True, page={ @@ -583,6 +594,7 @@ async def test_method_create(self, async_client: AsyncTelnyx) -> None: async def test_method_create_with_all_params(self, async_client: AsyncTelnyx) -> None: porting_order = await async_client.porting_orders.create( phone_numbers=["+13035550000", "+13035550001", "+13035550002"], + customer_group_reference="Group-456", customer_reference="Acct 123abc", ) assert_matches_type(PortingOrderCreateResponse, porting_order, path=["response"]) @@ -678,6 +690,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncTelnyx) -> porting_order = await async_client.porting_orders.update( id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", activation_settings={"foc_datetime_requested": parse_datetime("2021-03-19T10:07:15.527Z")}, + customer_group_reference="customer_group_reference", customer_reference="customer_reference", documents={ "invoice": "ce74b771-d23d-4960-81ec-8741b3862146", @@ -775,19 +788,28 @@ async def test_method_list(self, async_client: AsyncTelnyx) -> None: async def test_method_list_with_all_params(self, async_client: AsyncTelnyx) -> None: porting_order = await async_client.porting_orders.list( filter={ - "activation_settings_fast_port_eligible": True, - "activation_settings_foc_datetime_requested": { - "gt": "2021-03-25T10:00:00.000Z", - "lt": "2021-03-25T10:00:00.000Z", + "activation_settings": { + "fast_port_eligible": True, + "foc_datetime_requested": { + "gt": "2021-03-25T10:00:00.000Z", + "lt": "2021-03-25T10:00:00.000Z", + }, }, + "customer_group_reference": "customer_group_reference", "customer_reference": "customer_reference", - "end_user_admin_auth_person_name": "end_user.admin.auth_person_name", - "end_user_admin_entity_name": "end_user.admin.entity_name", - "misc_type": "full", + "end_user": { + "admin": { + "auth_person_name": "auth_person_name", + "entity_name": "entity_name", + } + }, + "misc": {"type": "full"}, "parent_support_key": "parent_support_key", - "phone_numbers_carrier_name": "phone_numbers.carrier_name", - "phone_numbers_country_code": "phone_numbers.country_code", - "phone_numbers_phone_number": {"contains": "contains"}, + "phone_numbers": { + "carrier_name": "carrier_name", + "country_code": "country_code", + "phone_number": {"contains": "contains"}, + }, }, include_phone_numbers=True, page={ diff --git a/tests/api_resources/test_requirement_types.py b/tests/api_resources/test_requirement_types.py index 0e5506b5..5d868c9d 100644 --- a/tests/api_resources/test_requirement_types.py +++ b/tests/api_resources/test_requirement_types.py @@ -21,7 +21,7 @@ class TestRequirementTypes: @parametrize def test_method_retrieve(self, client: Telnyx) -> None: requirement_type = client.requirement_types.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "a38c217a-8019-48f8-bff6-0fdd9939075b", ) assert_matches_type(RequirementTypeRetrieveResponse, requirement_type, path=["response"]) @@ -29,7 +29,7 @@ def test_method_retrieve(self, client: Telnyx) -> None: @parametrize def test_raw_response_retrieve(self, client: Telnyx) -> None: response = client.requirement_types.with_raw_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "a38c217a-8019-48f8-bff6-0fdd9939075b", ) assert response.is_closed is True @@ -41,7 +41,7 @@ def test_raw_response_retrieve(self, client: Telnyx) -> None: @parametrize def test_streaming_response_retrieve(self, client: Telnyx) -> None: with client.requirement_types.with_streaming_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "a38c217a-8019-48f8-bff6-0fdd9939075b", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -106,7 +106,7 @@ class TestAsyncRequirementTypes: @parametrize async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: requirement_type = await async_client.requirement_types.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "a38c217a-8019-48f8-bff6-0fdd9939075b", ) assert_matches_type(RequirementTypeRetrieveResponse, requirement_type, path=["response"]) @@ -114,7 +114,7 @@ async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: response = await async_client.requirement_types.with_raw_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "a38c217a-8019-48f8-bff6-0fdd9939075b", ) assert response.is_closed is True @@ -126,7 +126,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_streaming_response_retrieve(self, async_client: AsyncTelnyx) -> None: async with async_client.requirement_types.with_streaming_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "a38c217a-8019-48f8-bff6-0fdd9939075b", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/test_requirements.py b/tests/api_resources/test_requirements.py index 73a86e0b..c33ee4d9 100644 --- a/tests/api_resources/test_requirements.py +++ b/tests/api_resources/test_requirements.py @@ -21,7 +21,7 @@ class TestRequirements: @parametrize def test_method_retrieve(self, client: Telnyx) -> None: requirement = client.requirements.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "a9dad8d5-fdbd-49d7-aa23-39bb08a5ebaa", ) assert_matches_type(RequirementRetrieveResponse, requirement, path=["response"]) @@ -29,7 +29,7 @@ def test_method_retrieve(self, client: Telnyx) -> None: @parametrize def test_raw_response_retrieve(self, client: Telnyx) -> None: response = client.requirements.with_raw_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "a9dad8d5-fdbd-49d7-aa23-39bb08a5ebaa", ) assert response.is_closed is True @@ -41,7 +41,7 @@ def test_raw_response_retrieve(self, client: Telnyx) -> None: @parametrize def test_streaming_response_retrieve(self, client: Telnyx) -> None: with client.requirements.with_streaming_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "a9dad8d5-fdbd-49d7-aa23-39bb08a5ebaa", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -114,7 +114,7 @@ class TestAsyncRequirements: @parametrize async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: requirement = await async_client.requirements.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "a9dad8d5-fdbd-49d7-aa23-39bb08a5ebaa", ) assert_matches_type(RequirementRetrieveResponse, requirement, path=["response"]) @@ -122,7 +122,7 @@ async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: response = await async_client.requirements.with_raw_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "a9dad8d5-fdbd-49d7-aa23-39bb08a5ebaa", ) assert response.is_closed is True @@ -134,7 +134,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_streaming_response_retrieve(self, async_client: AsyncTelnyx) -> None: async with async_client.requirements.with_streaming_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "a9dad8d5-fdbd-49d7-aa23-39bb08a5ebaa", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/test_sub_number_orders_report.py b/tests/api_resources/test_sub_number_orders_report.py index 16eb5a0d..7bd21bee 100644 --- a/tests/api_resources/test_sub_number_orders_report.py +++ b/tests/api_resources/test_sub_number_orders_report.py @@ -66,7 +66,7 @@ def test_streaming_response_create(self, client: Telnyx) -> None: @parametrize def test_method_retrieve(self, client: Telnyx) -> None: sub_number_orders_report = client.sub_number_orders_report.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "12ade33a-21c0-473b-b055-b3c836e1c293", ) assert_matches_type(SubNumberOrdersReportRetrieveResponse, sub_number_orders_report, path=["response"]) @@ -74,7 +74,7 @@ def test_method_retrieve(self, client: Telnyx) -> None: @parametrize def test_raw_response_retrieve(self, client: Telnyx) -> None: response = client.sub_number_orders_report.with_raw_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "12ade33a-21c0-473b-b055-b3c836e1c293", ) assert response.is_closed is True @@ -86,7 +86,7 @@ def test_raw_response_retrieve(self, client: Telnyx) -> None: @parametrize def test_streaming_response_retrieve(self, client: Telnyx) -> None: with client.sub_number_orders_report.with_streaming_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "12ade33a-21c0-473b-b055-b3c836e1c293", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -108,7 +108,7 @@ def test_path_params_retrieve(self, client: Telnyx) -> None: @parametrize def test_method_download(self, client: Telnyx) -> None: sub_number_orders_report = client.sub_number_orders_report.download( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "12ade33a-21c0-473b-b055-b3c836e1c293", ) assert_matches_type(str, sub_number_orders_report, path=["response"]) @@ -116,7 +116,7 @@ def test_method_download(self, client: Telnyx) -> None: @parametrize def test_raw_response_download(self, client: Telnyx) -> None: response = client.sub_number_orders_report.with_raw_response.download( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "12ade33a-21c0-473b-b055-b3c836e1c293", ) assert response.is_closed is True @@ -128,7 +128,7 @@ def test_raw_response_download(self, client: Telnyx) -> None: @parametrize def test_streaming_response_download(self, client: Telnyx) -> None: with client.sub_number_orders_report.with_streaming_response.download( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "12ade33a-21c0-473b-b055-b3c836e1c293", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -197,7 +197,7 @@ async def test_streaming_response_create(self, async_client: AsyncTelnyx) -> Non @parametrize async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: sub_number_orders_report = await async_client.sub_number_orders_report.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "12ade33a-21c0-473b-b055-b3c836e1c293", ) assert_matches_type(SubNumberOrdersReportRetrieveResponse, sub_number_orders_report, path=["response"]) @@ -205,7 +205,7 @@ async def test_method_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: response = await async_client.sub_number_orders_report.with_raw_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "12ade33a-21c0-473b-b055-b3c836e1c293", ) assert response.is_closed is True @@ -217,7 +217,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_streaming_response_retrieve(self, async_client: AsyncTelnyx) -> None: async with async_client.sub_number_orders_report.with_streaming_response.retrieve( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "12ade33a-21c0-473b-b055-b3c836e1c293", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -239,7 +239,7 @@ async def test_path_params_retrieve(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_method_download(self, async_client: AsyncTelnyx) -> None: sub_number_orders_report = await async_client.sub_number_orders_report.download( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "12ade33a-21c0-473b-b055-b3c836e1c293", ) assert_matches_type(str, sub_number_orders_report, path=["response"]) @@ -247,7 +247,7 @@ async def test_method_download(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_raw_response_download(self, async_client: AsyncTelnyx) -> None: response = await async_client.sub_number_orders_report.with_raw_response.download( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "12ade33a-21c0-473b-b055-b3c836e1c293", ) assert response.is_closed is True @@ -259,7 +259,7 @@ async def test_raw_response_download(self, async_client: AsyncTelnyx) -> None: @parametrize async def test_streaming_response_download(self, async_client: AsyncTelnyx) -> None: async with async_client.sub_number_orders_report.with_streaming_response.download( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "12ade33a-21c0-473b-b055-b3c836e1c293", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/test_verifications.py b/tests/api_resources/test_verifications.py index d7bc4d00..afd39806 100644 --- a/tests/api_resources/test_verifications.py +++ b/tests/api_resources/test_verifications.py @@ -78,6 +78,7 @@ def test_method_trigger_call_with_all_params(self, client: Telnyx) -> None: phone_number="+13035551234", verify_profile_id="12ade33a-21c0-473b-b055-b3c836e1c292", custom_code="43612", + extension="1www2WABCDw9", timeout_secs=300, ) assert_matches_type(CreateVerificationResponse, verification, path=["response"]) @@ -269,6 +270,7 @@ async def test_method_trigger_call_with_all_params(self, async_client: AsyncTeln phone_number="+13035551234", verify_profile_id="12ade33a-21c0-473b-b055-b3c836e1c292", custom_code="43612", + extension="1www2WABCDw9", timeout_secs=300, ) assert_matches_type(CreateVerificationResponse, verification, path=["response"]) diff --git a/tests/api_resources/test_verify_profiles.py b/tests/api_resources/test_verify_profiles.py index 1d952476..806ce59d 100644 --- a/tests/api_resources/test_verify_profiles.py +++ b/tests/api_resources/test_verify_profiles.py @@ -12,6 +12,8 @@ from telnyx.types import ( VerifyProfileData, VerifyProfileListResponse, + VerifyProfileCreateTemplateResponse, + VerifyProfileUpdateTemplateResponse, VerifyProfileRetrieveTemplatesResponse, ) @@ -282,6 +284,40 @@ def test_path_params_delete(self, client: Telnyx) -> None: "", ) + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create_template(self, client: Telnyx) -> None: + verify_profile = client.verify_profiles.create_template( + text="Your {{app_name}} verification code is: {{code}}.", + ) + assert_matches_type(VerifyProfileCreateTemplateResponse, verify_profile, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_create_template(self, client: Telnyx) -> None: + response = client.verify_profiles.with_raw_response.create_template( + text="Your {{app_name}} verification code is: {{code}}.", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + verify_profile = response.parse() + assert_matches_type(VerifyProfileCreateTemplateResponse, verify_profile, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_create_template(self, client: Telnyx) -> None: + with client.verify_profiles.with_streaming_response.create_template( + text="Your {{app_name}} verification code is: {{code}}.", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + verify_profile = response.parse() + assert_matches_type(VerifyProfileCreateTemplateResponse, verify_profile, path=["response"]) + + assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_retrieve_templates(self, client: Telnyx) -> None: @@ -310,6 +346,52 @@ def test_streaming_response_retrieve_templates(self, client: Telnyx) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_update_template(self, client: Telnyx) -> None: + verify_profile = client.verify_profiles.update_template( + template_id="12ade33a-21c0-473b-b055-b3c836e1c292", + text="Your {{app_name}} verification code is: {{code}}.", + ) + assert_matches_type(VerifyProfileUpdateTemplateResponse, verify_profile, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_update_template(self, client: Telnyx) -> None: + response = client.verify_profiles.with_raw_response.update_template( + template_id="12ade33a-21c0-473b-b055-b3c836e1c292", + text="Your {{app_name}} verification code is: {{code}}.", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + verify_profile = response.parse() + assert_matches_type(VerifyProfileUpdateTemplateResponse, verify_profile, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_update_template(self, client: Telnyx) -> None: + with client.verify_profiles.with_streaming_response.update_template( + template_id="12ade33a-21c0-473b-b055-b3c836e1c292", + text="Your {{app_name}} verification code is: {{code}}.", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + verify_profile = response.parse() + assert_matches_type(VerifyProfileUpdateTemplateResponse, verify_profile, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_update_template(self, client: Telnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `template_id` but received ''"): + client.verify_profiles.with_raw_response.update_template( + template_id="", + text="Your {{app_name}} verification code is: {{code}}.", + ) + class TestAsyncVerifyProfiles: parametrize = pytest.mark.parametrize( @@ -577,6 +659,40 @@ async def test_path_params_delete(self, async_client: AsyncTelnyx) -> None: "", ) + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create_template(self, async_client: AsyncTelnyx) -> None: + verify_profile = await async_client.verify_profiles.create_template( + text="Your {{app_name}} verification code is: {{code}}.", + ) + assert_matches_type(VerifyProfileCreateTemplateResponse, verify_profile, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_create_template(self, async_client: AsyncTelnyx) -> None: + response = await async_client.verify_profiles.with_raw_response.create_template( + text="Your {{app_name}} verification code is: {{code}}.", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + verify_profile = await response.parse() + assert_matches_type(VerifyProfileCreateTemplateResponse, verify_profile, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_create_template(self, async_client: AsyncTelnyx) -> None: + async with async_client.verify_profiles.with_streaming_response.create_template( + text="Your {{app_name}} verification code is: {{code}}.", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + verify_profile = await response.parse() + assert_matches_type(VerifyProfileCreateTemplateResponse, verify_profile, path=["response"]) + + assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_retrieve_templates(self, async_client: AsyncTelnyx) -> None: @@ -604,3 +720,49 @@ async def test_streaming_response_retrieve_templates(self, async_client: AsyncTe assert_matches_type(VerifyProfileRetrieveTemplatesResponse, verify_profile, path=["response"]) assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_update_template(self, async_client: AsyncTelnyx) -> None: + verify_profile = await async_client.verify_profiles.update_template( + template_id="12ade33a-21c0-473b-b055-b3c836e1c292", + text="Your {{app_name}} verification code is: {{code}}.", + ) + assert_matches_type(VerifyProfileUpdateTemplateResponse, verify_profile, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_update_template(self, async_client: AsyncTelnyx) -> None: + response = await async_client.verify_profiles.with_raw_response.update_template( + template_id="12ade33a-21c0-473b-b055-b3c836e1c292", + text="Your {{app_name}} verification code is: {{code}}.", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + verify_profile = await response.parse() + assert_matches_type(VerifyProfileUpdateTemplateResponse, verify_profile, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_update_template(self, async_client: AsyncTelnyx) -> None: + async with async_client.verify_profiles.with_streaming_response.update_template( + template_id="12ade33a-21c0-473b-b055-b3c836e1c292", + text="Your {{app_name}} verification code is: {{code}}.", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + verify_profile = await response.parse() + assert_matches_type(VerifyProfileUpdateTemplateResponse, verify_profile, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_update_template(self, async_client: AsyncTelnyx) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `template_id` but received ''"): + await async_client.verify_profiles.with_raw_response.update_template( + template_id="", + text="Your {{app_name}} verification code is: {{code}}.", + ) diff --git a/tests/api_resources/test_well_known.py b/tests/api_resources/test_well_known.py new file mode 100644 index 00000000..67a024b1 --- /dev/null +++ b/tests/api_resources/test_well_known.py @@ -0,0 +1,139 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from telnyx import Telnyx, AsyncTelnyx +from tests.utils import assert_matches_type +from telnyx.types import ( + WellKnownRetrieveProtectedResourceMetadataResponse, + WellKnownRetrieveAuthorizationServerMetadataResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestWellKnown: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_retrieve_authorization_server_metadata(self, client: Telnyx) -> None: + well_known = client.well_known.retrieve_authorization_server_metadata() + assert_matches_type(WellKnownRetrieveAuthorizationServerMetadataResponse, well_known, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_retrieve_authorization_server_metadata(self, client: Telnyx) -> None: + response = client.well_known.with_raw_response.retrieve_authorization_server_metadata() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + well_known = response.parse() + assert_matches_type(WellKnownRetrieveAuthorizationServerMetadataResponse, well_known, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_retrieve_authorization_server_metadata(self, client: Telnyx) -> None: + with client.well_known.with_streaming_response.retrieve_authorization_server_metadata() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + well_known = response.parse() + assert_matches_type(WellKnownRetrieveAuthorizationServerMetadataResponse, well_known, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_retrieve_protected_resource_metadata(self, client: Telnyx) -> None: + well_known = client.well_known.retrieve_protected_resource_metadata() + assert_matches_type(WellKnownRetrieveProtectedResourceMetadataResponse, well_known, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_retrieve_protected_resource_metadata(self, client: Telnyx) -> None: + response = client.well_known.with_raw_response.retrieve_protected_resource_metadata() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + well_known = response.parse() + assert_matches_type(WellKnownRetrieveProtectedResourceMetadataResponse, well_known, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_retrieve_protected_resource_metadata(self, client: Telnyx) -> None: + with client.well_known.with_streaming_response.retrieve_protected_resource_metadata() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + well_known = response.parse() + assert_matches_type(WellKnownRetrieveProtectedResourceMetadataResponse, well_known, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncWellKnown: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_retrieve_authorization_server_metadata(self, async_client: AsyncTelnyx) -> None: + well_known = await async_client.well_known.retrieve_authorization_server_metadata() + assert_matches_type(WellKnownRetrieveAuthorizationServerMetadataResponse, well_known, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_retrieve_authorization_server_metadata(self, async_client: AsyncTelnyx) -> None: + response = await async_client.well_known.with_raw_response.retrieve_authorization_server_metadata() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + well_known = await response.parse() + assert_matches_type(WellKnownRetrieveAuthorizationServerMetadataResponse, well_known, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_retrieve_authorization_server_metadata(self, async_client: AsyncTelnyx) -> None: + async with async_client.well_known.with_streaming_response.retrieve_authorization_server_metadata() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + well_known = await response.parse() + assert_matches_type(WellKnownRetrieveAuthorizationServerMetadataResponse, well_known, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_retrieve_protected_resource_metadata(self, async_client: AsyncTelnyx) -> None: + well_known = await async_client.well_known.retrieve_protected_resource_metadata() + assert_matches_type(WellKnownRetrieveProtectedResourceMetadataResponse, well_known, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_retrieve_protected_resource_metadata(self, async_client: AsyncTelnyx) -> None: + response = await async_client.well_known.with_raw_response.retrieve_protected_resource_metadata() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + well_known = await response.parse() + assert_matches_type(WellKnownRetrieveProtectedResourceMetadataResponse, well_known, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_retrieve_protected_resource_metadata(self, async_client: AsyncTelnyx) -> None: + async with async_client.well_known.with_streaming_response.retrieve_protected_resource_metadata() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + well_known = await response.parse() + assert_matches_type(WellKnownRetrieveProtectedResourceMetadataResponse, well_known, path=["response"]) + + assert cast(Any, response.is_closed) is True