diff --git a/CHANGES.md b/CHANGES.md index 60487c62d..f5063282c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,183 @@ twilio-python Changelog Here you can see the full list of changes between each twilio-python release. +[2026-09-02] Version 9.11.1 +--------------------------- +**Library - Fix** +- [PR #954](https://github.com/twilio/twilio-python/pull/954): Fix tag validation regex in deploy.yml. Thanks to [@kridai](https://github.com/kridai)! + +**Audiences** +- ## 2026-09-01 +- Backticked brace- and angle-bracket-bearing tokens in descriptions for MDX safety. +- Updated a prose reference to the renamed `FetchCohortSnapshot` operation. +- ## 2026-08-26 +- **Removed 5 path(s)**: +- `/preview/Audiences` (AdminListAudiences) +- `/preview/Audiences/{audienceId}` (AdminGetAudience) +- `/preview/Snapshots` (AdminListSnapshots) +- `/preview/Snapshots/{snapshotId}` (AdminGetSnapshot) +- `/preview/Operations/{operationId}` (AdminGetOperation) +- ## 2026-08-25 +- Minor updates (formatting, metadata) +- ## 2026-08-24 +- **Added 1 new path(s)**: +- `/preview/Snapshots/{cohortSnapshotId}/Operations` (AdminListSnapshotOperations) +- **Removed 1 path(s)**: +- `/preview/Snapshots/{snapshotId}/Operations` (ListAdminSnapshotOperations) +- ## 2026-08-20 +- Renamed all 13 operations so the operationId keyword leads (`AdminGetCohort` -> `FetchAdminCohort`) to meet standard. +- Set `info` `libraryVisibility` to `hidden` to exclude this admin spec from generation. +- Added the standard `pageSize`/`pageToken` query parameters to `ListAdminSnapshotOperations`, the only list operation missing them. +- ## 2026-08-19 +- **Added 5 new path(s)**: +- `/preview/Cohorts` (AdminListCohorts) +- `/preview/Cohorts/{cohortId}` (AdminGetCohort) +- `/preview/CohortSnapshots` (AdminListCohortSnapshots) +- `/preview/CohortSnapshots/{cohortSnapshotId}` (AdminGetCohortSnapshot) +- `/preview/CohortOperations/{cohortOperationId}` (AdminGetCohortOperation) +- ## 2026-09-01 +- Renamed 3 `Get*` operations to `Fetch*` to match the operationId standard: `FetchCohort`, `FetchCohortSnapshot`, `FetchCohortOperation`. The transpiler skips operations whose operationId does not start with a standard keyword, which had been dropping all three from generated output. +- Set `libraryVisibility` to `private` (was `hidden`) so the spec is eligible for the private docs pipeline. +- Backticked brace- and angle-bracket-bearing tokens in descriptions for MDX safety. +- ## 2026-08-28 +- **Removed 6 path(s)**: +- `/preview/Audiences` (ListAudiences, CreateAudience) +- `/preview/Audiences/{audienceId}` (FetchAudience, UpdateAudience, DeleteAudience) +- `/preview/Snapshots` (ListSnapshots, CreateSnapshot) +- `/preview/Snapshots/{snapshotId}` (FetchSnapshot, DeleteSnapshot) +- `/preview/Snapshots/{snapshotId}/Profiles` (ListSnapshotProfiles) +- `/preview/Operations/{operationId}` (FetchOperation) +- ## 2026-08-20 +- Renamed 6 `Get*` operations to `Fetch*` to match the operationId standard. +- Hid the deprecated Audiences/Snapshots paths and `/preview/Operations/{operationId}`. +- Backticked 11 brace-bearing tokens in descriptions for MDX safety. + +**Conversations** +- Add `VIDEO` to the Conversations v2 Communication channel enum. + +**Data-ingress** +- # API Changes +- ## 2026-09-01 +- Minor updates (formatting, metadata) +- ## 2026-08-12 +- Minor updates (formatting, metadata) +- ## 2026-08-12 +- Initial release with 13 paths and 13 operations + +**Destinations** +- ## 2026-08-26 +- Minor updates (formatting, metadata) +- ## 2026-08-26 +- Minor updates (formatting, metadata) +- ## 2026-08-25 +- **Content updates**: +- Updated description for `CreateDestination` +- ## 2026-08-12 +- Minor updates (formatting, metadata) +- ## 2026-08-12 +- **Content updates**: +- Added properties to `DestinationType`: releaseStatus +- Removed properties from `DestinationType`: maturity + +**Email** +- # API Changes +- ## 2026-08-28 +- **Content updates**: +- Updated summary for `sendTransactional` +- Added parameter(s) to `sendTransactional`: X-Twilio-Version +- Updated schema description for `SuppressionsGroup` +- Added properties to `SuppressionsGroup`: type +- Removed properties from `SuppressionsGroup`: mode +- Updated schema description for `SuppressionsGlobal` +- Added properties to `SuppressionsGlobal`: type +- Removed properties from `SuppressionsGlobal`: mode +- Updated schema description for `Suppressions` +- Updated schema description for `LongRunningOperationResponse` +- ## 2026-08-27 +- **Content updates**: +- Updated description for `SendEmail` +- Added parameter(s) to `SendEmail`: Content-Encoding, Idempotency-Key +- Updated schema description for `Envelope` +- Updated schema description for `SuppressionsGroup` +- Updated schema description for `SuppressionsGlobal` + +**Iam** +- Added GET /v1/Account/AuthorizedApps/{consentSid} - fetch authorized app details, including allowed permissions, by consent identifier SID +- added container-scoped entitlements endpoint (GET /v2/Container/{containerId}/Entitlements) + +**Knowledge** +- ## 2026-07-20 +- **Content updates**: +- Added new schemas: `KnowledgeErrorInstance`, `KnowledgeErrorGroup` +- Added `errors` field to `WebSourceDetails` for reporting web crawl errors + +**Memory** +- ## 2026-08-18 +- **Breaking change**: +- Removed the deprecated `CSV` and `DATASET` values from the `DataMappingType` enum. +- `INGRESS`, `DATASET_CLOUDAPP`, and `DATASET_WAREHOUSE` are the only valid values now. +- Removed the `DataMappingFromCSV` and `DataMappingFromDataSet` schemas and their +- `oneOf`/discriminator entries on `DataMappingFromTypes`, along with the corresponding +- `CSV`/`DATASET` discriminator mapping keys. +- Any caller still sending `type: CSV` or `type: DATASET` on `AdminListDataMappings` +- (filtering by those values) will get a 400. +- ## 2026-08-10 +- No path changes (updated metadata only) +- `DataMappingType` gains `INGRESS`, `DATASET_CLOUDAPP`, and `DATASET_WAREHOUSE`. +- `CSV` and `DATASET` remain valid and unchanged; they are deprecated aliases and +- will be removed in a follow-up change. +- `DataMappingFromTypes` gains three `oneOf` members and three discriminator keys: +- `DataMappingFromIngress` (renames `DataMappingFromCSV`), +- `DataMappingFromCloudAppDataSet` and `DataMappingFromWarehouseDataSet` +- (both split from `DataMappingFromDataSet`, distinguishing a cloud-app-backed +- TDI dataset from a warehouse-backed one). +- Additive and backwards compatible: existing `CSV` and `DATASET` payloads are +- unaffected. +- ## 2026-08-27 +- **Added 2 new path(s)** for Trait Extraction Strategies: +- `/v1/ControlPlane/TraitExtractionStrategies` (ListTraitExtractionStrategies, CreateTraitExtractionStrategy) +- `/v1/ControlPlane/TraitExtractionStrategies/{traitStrategyId}` (FetchTraitExtractionStrategy, UpdateTraitExtractionStrategy, DeleteTraitExtractionStrategy) +- ## 2026-08-18 +- **Breaking change**: +- Removed the deprecated `CSV` and `DATASET` values from the `DataMappingType` enum. +- `INGRESS`, `DATASET_CLOUDAPP`, and `DATASET_WAREHOUSE` are the only valid values now. +- Removed the `DataMappingFromCSV` and `DataMappingFromDataSet` schemas and their +- `oneOf`/discriminator entries on `DataMappingFromTypes`, along with the corresponding +- `CSV`/`DATASET` discriminator mapping keys. +- Any caller still sending `type: CSV` or `type: DATASET` on `CreateDataMapping` or +- `UpdateDataMapping` (or filtering `ListDataMappings`/`ListDataMappingSuggestions` by +- those values) will get a 400. +- ## 2026-08-10 +- No path changes (updated metadata only) +- `DataMappingType` gains `INGRESS`, `DATASET_CLOUDAPP`, and `DATASET_WAREHOUSE`. +- `CSV` and `DATASET` remain valid and unchanged; they are deprecated aliases and +- will be removed in a follow-up change. +- `DataMappingFromTypes` gains three `oneOf` members and three discriminator keys: +- `DataMappingFromIngress` (renames `DataMappingFromCSV`), +- `DataMappingFromCloudAppDataSet` and `DataMappingFromWarehouseDataSet` +- (both split from `DataMappingFromDataSet`, distinguishing a cloud-app-backed +- TDI dataset from a warehouse-backed one). +- Additive and backwards compatible: existing `CSV` and `DATASET` payloads are +- unaffected. + +**Messaging** +- Add SenderIdentity, SenderType, and SenderRegion filter query parameters to list numbers and senders endpoint (beta) +- Add capabilities field to the numbers and senders response (beta) +- Remove the WhatsApp Senders v1 endpoints (`/v1/Channels/WhatsApp/Senders`) from RestProxy; the sender was routed to the sunsetting `messaging-whatsapp-k8s-orch` downstream. Use the Senders v2 API (`/v2/Channels/Senders`) instead. + +**Verify** +- Add `Templates` optional parameter on Verification creation (a stringified JSON array of `sid`/`substitutions` entries). When provided, `Templates` takes precedence over `TemplateSid`. + +**Voice** +- ## 2026-08-05 +- Added GET /v3/Transcriptions to list and filter transcriptions (status, sourceId, languageCode, createdAfter/createdBefore) with pageSize/pageToken pagination. createdAfter is inclusive and createdBefore exclusive. Returns 422 (error code 17535) when a sourceId's historical item count exceeds the service scan cap + +**Webhooks** +- # API Changes +- ## 2026-08-24 +- **Changed**: Created Webhooks Config API ( https://docs.google.com/document/d/1zkAJD8a8MgoxWifdYDl_d465Az3W6CcD9fuCC2xlSXE/edit?tab=t.0#heading=h.u9e0ry6oe89j ), that includes 7 new resource(s)**: SharedKeys, AuthProfiles, Settings, Rules, Operations, Tests, EdgeZones in /v1/Webhooks referencing webhooks-config downstream. + + [2026-08-11] Version 9.11.0 --------------------------- **Library - Fix** diff --git a/setup.py b/setup.py index c31508371..c131ece07 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setup( name="twilio", - version="9.11.0", + version="9.11.1", description="Twilio API client and TwiML generator", author="Twilio", help_center="https://www.twilio.com/help/contact", diff --git a/twilio/__init__.py b/twilio/__init__.py index 2ef30c7eb..0ab1f74eb 100644 --- a/twilio/__init__.py +++ b/twilio/__init__.py @@ -1,2 +1,2 @@ -__version_info__ = ("9", "11", "0") +__version_info__ = ("9", "11", "1") __version__ = ".".join(__version_info__) diff --git a/twilio/rest/content/v1/content/__init__.py b/twilio/rest/content/v1/content/__init__.py index 3e38e775a..c0673c70a 100644 --- a/twilio/rest/content/v1/content/__init__.py +++ b/twilio/rest/content/v1/content/__init__.py @@ -152,8 +152,13 @@ def __init__(self, payload: Dict[str, Any]): self.title: Optional[str] = payload.get("title") self.body: Optional[str] = payload.get("body") self.media: Optional[str] = payload.get("media") - self.actions: Optional[List[ContentList.CarouselAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CarouselAction]] = ( + [ + ContentList.CarouselAction(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -210,7 +215,11 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.variables: Optional[Dict[str, str]] = payload.get("variables") self.language: Optional[str] = payload.get("language") - self.types: Optional[ContentList.Types] = payload.get("types") + self.types: Optional[ContentList.Types] = ( + ContentList.Types(payload.get("types")) + if payload.get("types") is not None + else None + ) def to_dict(self): return { @@ -233,7 +242,11 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.variables: Optional[Dict[str, str]] = payload.get("variables") self.language: Optional[str] = payload.get("language") - self.types: Optional[ContentList.Types] = payload.get("types") + self.types: Optional[ContentList.Types] = ( + ContentList.Types(payload.get("types")) + if payload.get("types") is not None + else None + ) def to_dict(self): return { @@ -258,8 +271,17 @@ def __init__(self, payload: Dict[str, Any]): self.next_page_id: Optional[str] = payload.get("next_page_id") self.title: Optional[str] = payload.get("title") self.subtitle: Optional[str] = payload.get("subtitle") - self.layout: Optional[List[ContentList.FlowsPageComponent]] = payload.get( - "layout" + self.layout: Optional[List[ContentList.FlowsPageComponent]] = ( + [ + ( + ContentList.FlowsPageComponent(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("layout") + ] + if payload.get("layout") is not None + else None ) def to_dict(self): @@ -343,8 +365,17 @@ class TwilioCallToAction(object): def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") - self.actions: Optional[List[ContentList.CallToActionAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CallToActionAction]] = ( + [ + ( + ContentList.CallToActionAction(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -370,8 +401,13 @@ def __init__(self, payload: Dict[str, Any]): self.title: Optional[str] = payload.get("title") self.subtitle: Optional[str] = payload.get("subtitle") self.media: Optional[List[str]] = payload.get("media") - self.actions: Optional[List[ContentList.CardAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CardAction]] = ( + [ + ContentList.CardAction(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -395,7 +431,14 @@ class TwilioCarousel(object): def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") - self.cards: Optional[List[ContentList.CarouselCard]] = payload.get("cards") + self.cards: Optional[List[ContentList.CarouselCard]] = ( + [ + ContentList.CarouselCard(item) if isinstance(item, dict) else item + for item in payload.get("cards") + ] + if payload.get("cards") is not None + else None + ) def to_dict(self): return { @@ -423,7 +466,14 @@ def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") self.subtitle: Optional[str] = payload.get("subtitle") self.id: Optional[str] = payload.get("id") - self.items: Optional[List[ContentList.CatalogItem]] = payload.get("items") + self.items: Optional[List[ContentList.CatalogItem]] = ( + [ + ContentList.CatalogItem(item) if isinstance(item, dict) else item + for item in payload.get("items") + ] + if payload.get("items") is not None + else None + ) self.dynamic_items: Optional[str] = payload.get("dynamic_items") def to_dict(self): @@ -456,7 +506,14 @@ def __init__(self, payload: Dict[str, Any]): self.button_text: Optional[str] = payload.get("button_text") self.subtitle: Optional[str] = payload.get("subtitle") self.media_url: Optional[str] = payload.get("media_url") - self.pages: Optional[List[ContentList.FlowsPage]] = payload.get("pages") + self.pages: Optional[List[ContentList.FlowsPage]] = ( + [ + ContentList.FlowsPage(item) if isinstance(item, dict) else item + for item in payload.get("pages") + ] + if payload.get("pages") is not None + else None + ) self.type: Optional[str] = payload.get("type") def to_dict(self): @@ -484,7 +541,14 @@ def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") self.button: Optional[str] = payload.get("button") - self.items: Optional[List[ContentList.ListItem]] = payload.get("items") + self.items: Optional[List[ContentList.ListItem]] = ( + [ + ContentList.ListItem(item) if isinstance(item, dict) else item + for item in payload.get("items") + ] + if payload.get("items") is not None + else None + ) def to_dict(self): return { @@ -549,8 +613,17 @@ class TwilioQuickReply(object): def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") - self.actions: Optional[List[ContentList.QuickReplyAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.QuickReplyAction]] = ( + [ + ( + ContentList.QuickReplyAction(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -617,47 +690,79 @@ class Types(object): def __init__(self, payload: Dict[str, Any]): - self.twilio_text: Optional[ContentList.TwilioText] = payload.get( - "twilio/text" + self.twilio_text: Optional[ContentList.TwilioText] = ( + ContentList.TwilioText(payload.get("twilio/text")) + if payload.get("twilio/text") is not None + else None ) - self.twilio_media: Optional[ContentList.TwilioMedia] = payload.get( - "twilio/media" + self.twilio_media: Optional[ContentList.TwilioMedia] = ( + ContentList.TwilioMedia(payload.get("twilio/media")) + if payload.get("twilio/media") is not None + else None ) - self.twilio_location: Optional[ContentList.TwilioLocation] = payload.get( - "twilio/location" + self.twilio_location: Optional[ContentList.TwilioLocation] = ( + ContentList.TwilioLocation(payload.get("twilio/location")) + if payload.get("twilio/location") is not None + else None ) self.twilio_list_picker: Optional[ContentList.TwilioListPicker] = ( - payload.get("twilio/list-picker") + ContentList.TwilioListPicker(payload.get("twilio/list-picker")) + if payload.get("twilio/list-picker") is not None + else None ) self.twilio_call_to_action: Optional[ContentList.TwilioCallToAction] = ( - payload.get("twilio/call-to-action") + ContentList.TwilioCallToAction(payload.get("twilio/call-to-action")) + if payload.get("twilio/call-to-action") is not None + else None ) self.twilio_quick_reply: Optional[ContentList.TwilioQuickReply] = ( - payload.get("twilio/quick-reply") - ) - self.twilio_card: Optional[ContentList.TwilioCard] = payload.get( - "twilio/card" - ) - self.twilio_catalog: Optional[ContentList.TwilioCatalog] = payload.get( - "twilio/catalog" - ) - self.twilio_carousel: Optional[ContentList.TwilioCarousel] = payload.get( - "twilio/carousel" - ) - self.twilio_flows: Optional[ContentList.TwilioFlows] = payload.get( - "twilio/flows" - ) - self.twilio_schedule: Optional[ContentList.TwilioSchedule] = payload.get( - "twilio/schedule" - ) - self.whatsapp_card: Optional[ContentList.WhatsappCard] = payload.get( - "whatsapp/card" + ContentList.TwilioQuickReply(payload.get("twilio/quick-reply")) + if payload.get("twilio/quick-reply") is not None + else None + ) + self.twilio_card: Optional[ContentList.TwilioCard] = ( + ContentList.TwilioCard(payload.get("twilio/card")) + if payload.get("twilio/card") is not None + else None + ) + self.twilio_catalog: Optional[ContentList.TwilioCatalog] = ( + ContentList.TwilioCatalog(payload.get("twilio/catalog")) + if payload.get("twilio/catalog") is not None + else None + ) + self.twilio_carousel: Optional[ContentList.TwilioCarousel] = ( + ContentList.TwilioCarousel(payload.get("twilio/carousel")) + if payload.get("twilio/carousel") is not None + else None + ) + self.twilio_flows: Optional[ContentList.TwilioFlows] = ( + ContentList.TwilioFlows(payload.get("twilio/flows")) + if payload.get("twilio/flows") is not None + else None + ) + self.twilio_schedule: Optional[ContentList.TwilioSchedule] = ( + ContentList.TwilioSchedule(payload.get("twilio/schedule")) + if payload.get("twilio/schedule") is not None + else None + ) + self.whatsapp_card: Optional[ContentList.WhatsappCard] = ( + ContentList.WhatsappCard(payload.get("whatsapp/card")) + if payload.get("whatsapp/card") is not None + else None ) self.whatsapp_authentication: Optional[ ContentList.WhatsappAuthentication - ] = payload.get("whatsapp/authentication") - self.whatsapp_flows: Optional[ContentList.WhatsappFlows] = payload.get( - "whatsapp/flows" + ] = ( + ContentList.WhatsappAuthentication( + payload.get("whatsapp/authentication") + ) + if payload.get("whatsapp/authentication") is not None + else None + ) + self.whatsapp_flows: Optional[ContentList.WhatsappFlows] = ( + ContentList.WhatsappFlows(payload.get("whatsapp/flows")) + if payload.get("whatsapp/flows") is not None + else None ) def to_dict(self): @@ -746,7 +851,16 @@ def __init__(self, payload: Dict[str, Any]): "code_expiration_minutes" ) self.actions: Optional[List[ContentList.AuthenticationAction]] = ( - payload.get("actions") + [ + ( + ContentList.AuthenticationAction(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -775,8 +889,13 @@ def __init__(self, payload: Dict[str, Any]): self.footer: Optional[str] = payload.get("footer") self.media: Optional[List[str]] = payload.get("media") self.header_text: Optional[str] = payload.get("header_text") - self.actions: Optional[List[ContentList.CardAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CardAction]] = ( + [ + ContentList.CardAction(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -1192,8 +1311,13 @@ def __init__(self, payload: Dict[str, Any]): self.title: Optional[str] = payload.get("title") self.body: Optional[str] = payload.get("body") self.media: Optional[str] = payload.get("media") - self.actions: Optional[List[ContentList.CarouselAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CarouselAction]] = ( + [ + ContentList.CarouselAction(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -1250,7 +1374,11 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.variables: Optional[Dict[str, str]] = payload.get("variables") self.language: Optional[str] = payload.get("language") - self.types: Optional[ContentList.Types] = payload.get("types") + self.types: Optional[ContentList.Types] = ( + ContentList.Types(payload.get("types")) + if payload.get("types") is not None + else None + ) def to_dict(self): return { @@ -1273,7 +1401,11 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.variables: Optional[Dict[str, str]] = payload.get("variables") self.language: Optional[str] = payload.get("language") - self.types: Optional[ContentList.Types] = payload.get("types") + self.types: Optional[ContentList.Types] = ( + ContentList.Types(payload.get("types")) + if payload.get("types") is not None + else None + ) def to_dict(self): return { @@ -1298,8 +1430,17 @@ def __init__(self, payload: Dict[str, Any]): self.next_page_id: Optional[str] = payload.get("next_page_id") self.title: Optional[str] = payload.get("title") self.subtitle: Optional[str] = payload.get("subtitle") - self.layout: Optional[List[ContentList.FlowsPageComponent]] = payload.get( - "layout" + self.layout: Optional[List[ContentList.FlowsPageComponent]] = ( + [ + ( + ContentList.FlowsPageComponent(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("layout") + ] + if payload.get("layout") is not None + else None ) def to_dict(self): @@ -1383,8 +1524,17 @@ class TwilioCallToAction(object): def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") - self.actions: Optional[List[ContentList.CallToActionAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CallToActionAction]] = ( + [ + ( + ContentList.CallToActionAction(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -1410,8 +1560,13 @@ def __init__(self, payload: Dict[str, Any]): self.title: Optional[str] = payload.get("title") self.subtitle: Optional[str] = payload.get("subtitle") self.media: Optional[List[str]] = payload.get("media") - self.actions: Optional[List[ContentList.CardAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CardAction]] = ( + [ + ContentList.CardAction(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -1435,7 +1590,14 @@ class TwilioCarousel(object): def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") - self.cards: Optional[List[ContentList.CarouselCard]] = payload.get("cards") + self.cards: Optional[List[ContentList.CarouselCard]] = ( + [ + ContentList.CarouselCard(item) if isinstance(item, dict) else item + for item in payload.get("cards") + ] + if payload.get("cards") is not None + else None + ) def to_dict(self): return { @@ -1463,7 +1625,14 @@ def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") self.subtitle: Optional[str] = payload.get("subtitle") self.id: Optional[str] = payload.get("id") - self.items: Optional[List[ContentList.CatalogItem]] = payload.get("items") + self.items: Optional[List[ContentList.CatalogItem]] = ( + [ + ContentList.CatalogItem(item) if isinstance(item, dict) else item + for item in payload.get("items") + ] + if payload.get("items") is not None + else None + ) self.dynamic_items: Optional[str] = payload.get("dynamic_items") def to_dict(self): @@ -1496,7 +1665,14 @@ def __init__(self, payload: Dict[str, Any]): self.button_text: Optional[str] = payload.get("button_text") self.subtitle: Optional[str] = payload.get("subtitle") self.media_url: Optional[str] = payload.get("media_url") - self.pages: Optional[List[ContentList.FlowsPage]] = payload.get("pages") + self.pages: Optional[List[ContentList.FlowsPage]] = ( + [ + ContentList.FlowsPage(item) if isinstance(item, dict) else item + for item in payload.get("pages") + ] + if payload.get("pages") is not None + else None + ) self.type: Optional[str] = payload.get("type") def to_dict(self): @@ -1524,7 +1700,14 @@ def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") self.button: Optional[str] = payload.get("button") - self.items: Optional[List[ContentList.ListItem]] = payload.get("items") + self.items: Optional[List[ContentList.ListItem]] = ( + [ + ContentList.ListItem(item) if isinstance(item, dict) else item + for item in payload.get("items") + ] + if payload.get("items") is not None + else None + ) def to_dict(self): return { @@ -1589,8 +1772,17 @@ class TwilioQuickReply(object): def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") - self.actions: Optional[List[ContentList.QuickReplyAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.QuickReplyAction]] = ( + [ + ( + ContentList.QuickReplyAction(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -1657,47 +1849,79 @@ class Types(object): def __init__(self, payload: Dict[str, Any]): - self.twilio_text: Optional[ContentList.TwilioText] = payload.get( - "twilio/text" + self.twilio_text: Optional[ContentList.TwilioText] = ( + ContentList.TwilioText(payload.get("twilio/text")) + if payload.get("twilio/text") is not None + else None ) - self.twilio_media: Optional[ContentList.TwilioMedia] = payload.get( - "twilio/media" + self.twilio_media: Optional[ContentList.TwilioMedia] = ( + ContentList.TwilioMedia(payload.get("twilio/media")) + if payload.get("twilio/media") is not None + else None ) - self.twilio_location: Optional[ContentList.TwilioLocation] = payload.get( - "twilio/location" + self.twilio_location: Optional[ContentList.TwilioLocation] = ( + ContentList.TwilioLocation(payload.get("twilio/location")) + if payload.get("twilio/location") is not None + else None ) self.twilio_list_picker: Optional[ContentList.TwilioListPicker] = ( - payload.get("twilio/list-picker") + ContentList.TwilioListPicker(payload.get("twilio/list-picker")) + if payload.get("twilio/list-picker") is not None + else None ) self.twilio_call_to_action: Optional[ContentList.TwilioCallToAction] = ( - payload.get("twilio/call-to-action") + ContentList.TwilioCallToAction(payload.get("twilio/call-to-action")) + if payload.get("twilio/call-to-action") is not None + else None ) self.twilio_quick_reply: Optional[ContentList.TwilioQuickReply] = ( - payload.get("twilio/quick-reply") - ) - self.twilio_card: Optional[ContentList.TwilioCard] = payload.get( - "twilio/card" - ) - self.twilio_catalog: Optional[ContentList.TwilioCatalog] = payload.get( - "twilio/catalog" - ) - self.twilio_carousel: Optional[ContentList.TwilioCarousel] = payload.get( - "twilio/carousel" - ) - self.twilio_flows: Optional[ContentList.TwilioFlows] = payload.get( - "twilio/flows" - ) - self.twilio_schedule: Optional[ContentList.TwilioSchedule] = payload.get( - "twilio/schedule" - ) - self.whatsapp_card: Optional[ContentList.WhatsappCard] = payload.get( - "whatsapp/card" + ContentList.TwilioQuickReply(payload.get("twilio/quick-reply")) + if payload.get("twilio/quick-reply") is not None + else None + ) + self.twilio_card: Optional[ContentList.TwilioCard] = ( + ContentList.TwilioCard(payload.get("twilio/card")) + if payload.get("twilio/card") is not None + else None + ) + self.twilio_catalog: Optional[ContentList.TwilioCatalog] = ( + ContentList.TwilioCatalog(payload.get("twilio/catalog")) + if payload.get("twilio/catalog") is not None + else None + ) + self.twilio_carousel: Optional[ContentList.TwilioCarousel] = ( + ContentList.TwilioCarousel(payload.get("twilio/carousel")) + if payload.get("twilio/carousel") is not None + else None + ) + self.twilio_flows: Optional[ContentList.TwilioFlows] = ( + ContentList.TwilioFlows(payload.get("twilio/flows")) + if payload.get("twilio/flows") is not None + else None + ) + self.twilio_schedule: Optional[ContentList.TwilioSchedule] = ( + ContentList.TwilioSchedule(payload.get("twilio/schedule")) + if payload.get("twilio/schedule") is not None + else None + ) + self.whatsapp_card: Optional[ContentList.WhatsappCard] = ( + ContentList.WhatsappCard(payload.get("whatsapp/card")) + if payload.get("whatsapp/card") is not None + else None ) self.whatsapp_authentication: Optional[ ContentList.WhatsappAuthentication - ] = payload.get("whatsapp/authentication") - self.whatsapp_flows: Optional[ContentList.WhatsappFlows] = payload.get( - "whatsapp/flows" + ] = ( + ContentList.WhatsappAuthentication( + payload.get("whatsapp/authentication") + ) + if payload.get("whatsapp/authentication") is not None + else None + ) + self.whatsapp_flows: Optional[ContentList.WhatsappFlows] = ( + ContentList.WhatsappFlows(payload.get("whatsapp/flows")) + if payload.get("whatsapp/flows") is not None + else None ) def to_dict(self): @@ -1786,7 +2010,16 @@ def __init__(self, payload: Dict[str, Any]): "code_expiration_minutes" ) self.actions: Optional[List[ContentList.AuthenticationAction]] = ( - payload.get("actions") + [ + ( + ContentList.AuthenticationAction(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -1815,8 +2048,13 @@ def __init__(self, payload: Dict[str, Any]): self.footer: Optional[str] = payload.get("footer") self.media: Optional[List[str]] = payload.get("media") self.header_text: Optional[str] = payload.get("header_text") - self.actions: Optional[List[ContentList.CardAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CardAction]] = ( + [ + ContentList.CardAction(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -2324,8 +2562,13 @@ def __init__(self, payload: Dict[str, Any]): self.title: Optional[str] = payload.get("title") self.body: Optional[str] = payload.get("body") self.media: Optional[str] = payload.get("media") - self.actions: Optional[List[ContentList.CarouselAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CarouselAction]] = ( + [ + ContentList.CarouselAction(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -2382,7 +2625,11 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.variables: Optional[Dict[str, str]] = payload.get("variables") self.language: Optional[str] = payload.get("language") - self.types: Optional[ContentList.Types] = payload.get("types") + self.types: Optional[ContentList.Types] = ( + ContentList.Types(payload.get("types")) + if payload.get("types") is not None + else None + ) def to_dict(self): return { @@ -2405,7 +2652,11 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.variables: Optional[Dict[str, str]] = payload.get("variables") self.language: Optional[str] = payload.get("language") - self.types: Optional[ContentList.Types] = payload.get("types") + self.types: Optional[ContentList.Types] = ( + ContentList.Types(payload.get("types")) + if payload.get("types") is not None + else None + ) def to_dict(self): return { @@ -2430,8 +2681,17 @@ def __init__(self, payload: Dict[str, Any]): self.next_page_id: Optional[str] = payload.get("next_page_id") self.title: Optional[str] = payload.get("title") self.subtitle: Optional[str] = payload.get("subtitle") - self.layout: Optional[List[ContentList.FlowsPageComponent]] = payload.get( - "layout" + self.layout: Optional[List[ContentList.FlowsPageComponent]] = ( + [ + ( + ContentList.FlowsPageComponent(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("layout") + ] + if payload.get("layout") is not None + else None ) def to_dict(self): @@ -2515,8 +2775,17 @@ class TwilioCallToAction(object): def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") - self.actions: Optional[List[ContentList.CallToActionAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CallToActionAction]] = ( + [ + ( + ContentList.CallToActionAction(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -2542,8 +2811,13 @@ def __init__(self, payload: Dict[str, Any]): self.title: Optional[str] = payload.get("title") self.subtitle: Optional[str] = payload.get("subtitle") self.media: Optional[List[str]] = payload.get("media") - self.actions: Optional[List[ContentList.CardAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CardAction]] = ( + [ + ContentList.CardAction(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -2567,7 +2841,14 @@ class TwilioCarousel(object): def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") - self.cards: Optional[List[ContentList.CarouselCard]] = payload.get("cards") + self.cards: Optional[List[ContentList.CarouselCard]] = ( + [ + ContentList.CarouselCard(item) if isinstance(item, dict) else item + for item in payload.get("cards") + ] + if payload.get("cards") is not None + else None + ) def to_dict(self): return { @@ -2595,7 +2876,14 @@ def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") self.subtitle: Optional[str] = payload.get("subtitle") self.id: Optional[str] = payload.get("id") - self.items: Optional[List[ContentList.CatalogItem]] = payload.get("items") + self.items: Optional[List[ContentList.CatalogItem]] = ( + [ + ContentList.CatalogItem(item) if isinstance(item, dict) else item + for item in payload.get("items") + ] + if payload.get("items") is not None + else None + ) self.dynamic_items: Optional[str] = payload.get("dynamic_items") def to_dict(self): @@ -2628,7 +2916,14 @@ def __init__(self, payload: Dict[str, Any]): self.button_text: Optional[str] = payload.get("button_text") self.subtitle: Optional[str] = payload.get("subtitle") self.media_url: Optional[str] = payload.get("media_url") - self.pages: Optional[List[ContentList.FlowsPage]] = payload.get("pages") + self.pages: Optional[List[ContentList.FlowsPage]] = ( + [ + ContentList.FlowsPage(item) if isinstance(item, dict) else item + for item in payload.get("pages") + ] + if payload.get("pages") is not None + else None + ) self.type: Optional[str] = payload.get("type") def to_dict(self): @@ -2656,7 +2951,14 @@ def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") self.button: Optional[str] = payload.get("button") - self.items: Optional[List[ContentList.ListItem]] = payload.get("items") + self.items: Optional[List[ContentList.ListItem]] = ( + [ + ContentList.ListItem(item) if isinstance(item, dict) else item + for item in payload.get("items") + ] + if payload.get("items") is not None + else None + ) def to_dict(self): return { @@ -2721,8 +3023,17 @@ class TwilioQuickReply(object): def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") - self.actions: Optional[List[ContentList.QuickReplyAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.QuickReplyAction]] = ( + [ + ( + ContentList.QuickReplyAction(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -2789,47 +3100,79 @@ class Types(object): def __init__(self, payload: Dict[str, Any]): - self.twilio_text: Optional[ContentList.TwilioText] = payload.get( - "twilio/text" + self.twilio_text: Optional[ContentList.TwilioText] = ( + ContentList.TwilioText(payload.get("twilio/text")) + if payload.get("twilio/text") is not None + else None ) - self.twilio_media: Optional[ContentList.TwilioMedia] = payload.get( - "twilio/media" + self.twilio_media: Optional[ContentList.TwilioMedia] = ( + ContentList.TwilioMedia(payload.get("twilio/media")) + if payload.get("twilio/media") is not None + else None ) - self.twilio_location: Optional[ContentList.TwilioLocation] = payload.get( - "twilio/location" + self.twilio_location: Optional[ContentList.TwilioLocation] = ( + ContentList.TwilioLocation(payload.get("twilio/location")) + if payload.get("twilio/location") is not None + else None ) self.twilio_list_picker: Optional[ContentList.TwilioListPicker] = ( - payload.get("twilio/list-picker") + ContentList.TwilioListPicker(payload.get("twilio/list-picker")) + if payload.get("twilio/list-picker") is not None + else None ) self.twilio_call_to_action: Optional[ContentList.TwilioCallToAction] = ( - payload.get("twilio/call-to-action") + ContentList.TwilioCallToAction(payload.get("twilio/call-to-action")) + if payload.get("twilio/call-to-action") is not None + else None ) self.twilio_quick_reply: Optional[ContentList.TwilioQuickReply] = ( - payload.get("twilio/quick-reply") - ) - self.twilio_card: Optional[ContentList.TwilioCard] = payload.get( - "twilio/card" - ) - self.twilio_catalog: Optional[ContentList.TwilioCatalog] = payload.get( - "twilio/catalog" - ) - self.twilio_carousel: Optional[ContentList.TwilioCarousel] = payload.get( - "twilio/carousel" - ) - self.twilio_flows: Optional[ContentList.TwilioFlows] = payload.get( - "twilio/flows" - ) - self.twilio_schedule: Optional[ContentList.TwilioSchedule] = payload.get( - "twilio/schedule" - ) - self.whatsapp_card: Optional[ContentList.WhatsappCard] = payload.get( - "whatsapp/card" + ContentList.TwilioQuickReply(payload.get("twilio/quick-reply")) + if payload.get("twilio/quick-reply") is not None + else None + ) + self.twilio_card: Optional[ContentList.TwilioCard] = ( + ContentList.TwilioCard(payload.get("twilio/card")) + if payload.get("twilio/card") is not None + else None + ) + self.twilio_catalog: Optional[ContentList.TwilioCatalog] = ( + ContentList.TwilioCatalog(payload.get("twilio/catalog")) + if payload.get("twilio/catalog") is not None + else None + ) + self.twilio_carousel: Optional[ContentList.TwilioCarousel] = ( + ContentList.TwilioCarousel(payload.get("twilio/carousel")) + if payload.get("twilio/carousel") is not None + else None + ) + self.twilio_flows: Optional[ContentList.TwilioFlows] = ( + ContentList.TwilioFlows(payload.get("twilio/flows")) + if payload.get("twilio/flows") is not None + else None + ) + self.twilio_schedule: Optional[ContentList.TwilioSchedule] = ( + ContentList.TwilioSchedule(payload.get("twilio/schedule")) + if payload.get("twilio/schedule") is not None + else None + ) + self.whatsapp_card: Optional[ContentList.WhatsappCard] = ( + ContentList.WhatsappCard(payload.get("whatsapp/card")) + if payload.get("whatsapp/card") is not None + else None ) self.whatsapp_authentication: Optional[ ContentList.WhatsappAuthentication - ] = payload.get("whatsapp/authentication") - self.whatsapp_flows: Optional[ContentList.WhatsappFlows] = payload.get( - "whatsapp/flows" + ] = ( + ContentList.WhatsappAuthentication( + payload.get("whatsapp/authentication") + ) + if payload.get("whatsapp/authentication") is not None + else None + ) + self.whatsapp_flows: Optional[ContentList.WhatsappFlows] = ( + ContentList.WhatsappFlows(payload.get("whatsapp/flows")) + if payload.get("whatsapp/flows") is not None + else None ) def to_dict(self): @@ -2918,7 +3261,16 @@ def __init__(self, payload: Dict[str, Any]): "code_expiration_minutes" ) self.actions: Optional[List[ContentList.AuthenticationAction]] = ( - payload.get("actions") + [ + ( + ContentList.AuthenticationAction(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): @@ -2947,8 +3299,13 @@ def __init__(self, payload: Dict[str, Any]): self.footer: Optional[str] = payload.get("footer") self.media: Optional[List[str]] = payload.get("media") self.header_text: Optional[str] = payload.get("header_text") - self.actions: Optional[List[ContentList.CardAction]] = payload.get( - "actions" + self.actions: Optional[List[ContentList.CardAction]] = ( + [ + ContentList.CardAction(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) def to_dict(self): diff --git a/twilio/rest/content/v1/content/approval_create.py b/twilio/rest/content/v1/content/approval_create.py index 2487ec609..cfb7b88bf 100644 --- a/twilio/rest/content/v1/content/approval_create.py +++ b/twilio/rest/content/v1/content/approval_create.py @@ -27,17 +27,20 @@ class ContentApprovalRequest(object): """ :ivar name: Name of the template. :ivar category: A WhatsApp recognized template category. + :ivar send_ttl_seconds: Time-to-live in seconds for attempting to send a message with this Content """ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.category: Optional[str] = payload.get("category") + self.send_ttl_seconds: Optional[int] = payload.get("send_ttl_seconds") def to_dict(self): return { "name": self.name, "category": self.category, + "send_ttl_seconds": self.send_ttl_seconds, } """ @@ -47,6 +50,7 @@ def to_dict(self): :ivar status: :ivar rejection_reason: :ivar allow_category_change: + :ivar send_ttl_seconds: Time-to-live in seconds for attempting to send a message with this Content """ def __init__(self, version: Version, payload: Dict[str, Any], content_sid: str): @@ -60,6 +64,7 @@ def __init__(self, version: Version, payload: Dict[str, Any], content_sid: str): self.allow_category_change: Optional[bool] = payload.get( "allow_category_change" ) + self.send_ttl_seconds: Optional[int] = payload.get("send_ttl_seconds") self._solution = { "content_sid": content_sid, @@ -81,17 +86,20 @@ class ContentApprovalRequest(object): """ :ivar name: Name of the template. :ivar category: A WhatsApp recognized template category. + :ivar send_ttl_seconds: Time-to-live in seconds for attempting to send a message with this Content """ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.category: Optional[str] = payload.get("category") + self.send_ttl_seconds: Optional[int] = payload.get("send_ttl_seconds") def to_dict(self): return { "name": self.name, "category": self.category, + "send_ttl_seconds": self.send_ttl_seconds, } def __init__(self, version: Version, content_sid: str): diff --git a/twilio/rest/conversations/v2/action.py b/twilio/rest/conversations/v2/action.py index 6f907b17d..d1baa8caf 100644 --- a/twilio/rest/conversations/v2/action.py +++ b/twilio/rest/conversations/v2/action.py @@ -37,6 +37,7 @@ class ConversationsV2Channel(object): RCS = "RCS" WHATSAPP = "WHATSAPP" CHAT = "CHAT" + VIDEO = "VIDEO" """ :ivar id: Unique identifier for this Action. @@ -327,13 +328,28 @@ class ConversationsV2SendMessagePayload(object): def __init__(self, payload: Dict[str, Any]): self._from: Optional[ActionList.ConversationsV2SendMessageParticipant] = ( - payload.get("from") + ActionList.ConversationsV2SendMessageParticipant(payload.get("from")) + if payload.get("from") is not None + else None ) self.to: Optional[ List[ActionList.ConversationsV2SendMessageParticipant] - ] = payload.get("to") + ] = ( + [ + ( + ActionList.ConversationsV2SendMessageParticipant(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("to") + ] + if payload.get("to") is not None + else None + ) self.content: Optional[ActionList.ConversationsV2SendMessageContent] = ( - payload.get("content") + ActionList.ConversationsV2SendMessageContent(payload.get("content")) + if payload.get("content") is not None + else None ) self.channel_settings: Optional[Dict[str, object]] = payload.get( "channelSettings" @@ -357,7 +373,9 @@ def __init__(self, payload: Dict[str, Any]): self.type: Optional[str] = payload.get("type") self.payload: Optional[ActionList.ConversationsV2SendMessagePayload] = ( - payload.get("payload") + ActionList.ConversationsV2SendMessagePayload(payload.get("payload")) + if payload.get("payload") is not None + else None ) def to_dict(self): diff --git a/twilio/rest/conversations/v2/communication.py b/twilio/rest/conversations/v2/communication.py index adecbdd95..378058c94 100644 --- a/twilio/rest/conversations/v2/communication.py +++ b/twilio/rest/conversations/v2/communication.py @@ -33,11 +33,13 @@ class ConversationsV2Channel(object): RCS = "RCS" WHATSAPP = "WHATSAPP" CHAT = "CHAT" + VIDEO = "VIDEO" class ConversationsV2RecipientDeliveryStatus(object): INITIATED = "INITIATED" IN_PROGRESS = "IN_PROGRESS" DELIVERED = "DELIVERED" + READ = "READ" COMPLETED = "COMPLETED" FAILED = "FAILED" @@ -337,7 +339,18 @@ def __init__(self, payload: Dict[str, Any]): self.engine: Optional[str] = payload.get("engine") self.words: Optional[ List[ConversationsV2ContentTranscriptionTranscriptionWords] - ] = payload.get("words") + ] = ( + [ + ( + ConversationsV2ContentTranscriptionTranscriptionWords(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("words") + ] + if payload.get("words") is not None + else None + ) def to_dict(self): return { @@ -384,16 +397,41 @@ def __init__(self, payload: Dict[str, Any]): self.author: Optional[ CommunicationList.CreateCommunicationInConversationRequestAuthor - ] = payload.get("author") + ] = ( + CommunicationList.CreateCommunicationInConversationRequestAuthor( + payload.get("author") + ) + if payload.get("author") is not None + else None + ) self.content: Optional[ CommunicationList.CreateCommunicationInConversationRequestContent - ] = payload.get("content") + ] = ( + CommunicationList.CreateCommunicationInConversationRequestContent( + payload.get("content") + ) + if payload.get("content") is not None + else None + ) self.channel_id: Optional[str] = payload.get("channelId") self.recipients: Optional[ List[ CommunicationList.CreateCommunicationInConversationRequestRecipients ] - ] = payload.get("recipients") + ] = ( + [ + ( + CommunicationList.CreateCommunicationInConversationRequestRecipients( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("recipients") + ] + if payload.get("recipients") is not None + else None + ) self.occurred_at: Optional[datetime] = payload.get("occurredAt") def to_dict(self): @@ -442,7 +480,13 @@ def __init__(self, payload: Dict[str, Any]): self.text: Optional[str] = payload.get("text") self.transcription: Optional[ CommunicationList.ContentTranscriptionTranscription - ] = payload.get("transcription") + ] = ( + CommunicationList.ContentTranscriptionTranscription( + payload.get("transcription") + ) + if payload.get("transcription") is not None + else None + ) def to_dict(self): return { diff --git a/twilio/rest/conversations/v2/configuration.py b/twilio/rest/conversations/v2/configuration.py index fb481bcc4..7facd2ef6 100644 --- a/twilio/rest/conversations/v2/configuration.py +++ b/twilio/rest/conversations/v2/configuration.py @@ -707,11 +707,18 @@ class ConversationsV2ChannelSetting(object): def __init__(self, payload: Dict[str, Any]): - self.status_timeouts: Optional[ConversationsV2StatusTimeouts] = payload.get( - "statusTimeouts" + self.status_timeouts: Optional[ConversationsV2StatusTimeouts] = ( + ConversationsV2StatusTimeouts(payload.get("statusTimeouts")) + if payload.get("statusTimeouts") is not None + else None ) self.capture_rules: Optional[List[ConversationsV2CaptureRule]] = ( - payload.get("captureRules") + [ + ConversationsV2CaptureRule(item) if isinstance(item, dict) else item + for item in payload.get("captureRules") + ] + if payload.get("captureRules") is not None + else None ) def to_dict(self): @@ -802,7 +809,20 @@ def __init__(self, payload: Dict[str, Any]): ] = payload.get("channelSettings") self.status_callbacks: Optional[ List[ConfigurationList.CreateConfigurationRequestStatusCallbacks] - ] = payload.get("statusCallbacks") + ] = ( + [ + ( + ConfigurationList.CreateConfigurationRequestStatusCallbacks( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("statusCallbacks") + ] + if payload.get("statusCallbacks") is not None + else None + ) self.intelligence_configuration_ids: Optional[List[str]] = payload.get( "intelligenceConfigurationIds" ) @@ -811,7 +831,13 @@ def __init__(self, payload: Dict[str, Any]): ) self.conversations_v1_bridge: Optional[ ConfigurationList.CreateConfigurationRequestConversationsV1Bridge - ] = payload.get("conversationsV1Bridge") + ] = ( + ConfigurationList.CreateConfigurationRequestConversationsV1Bridge( + payload.get("conversationsV1Bridge") + ) + if payload.get("conversationsV1Bridge") is not None + else None + ) def to_dict(self): return { @@ -851,10 +877,27 @@ def __init__(self, payload: Dict[str, Any]): self.status_timeouts: Optional[ CreateConfigurationRequestChannelSettingsValueStatusTimeouts - ] = payload.get("statusTimeouts") + ] = ( + CreateConfigurationRequestChannelSettingsValueStatusTimeouts( + payload.get("statusTimeouts") + ) + if payload.get("statusTimeouts") is not None + else None + ) self.capture_rules: Optional[ List[CreateConfigurationRequestChannelSettingsValueCaptureRules] - ] = payload.get("captureRules") + ] = ( + [ + ( + CreateConfigurationRequestChannelSettingsValueCaptureRules(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("captureRules") + ] + if payload.get("captureRules") is not None + else None + ) def to_dict(self): return { @@ -964,7 +1007,20 @@ def __init__(self, payload: Dict[str, Any]): ] = payload.get("channelSettings") self.status_callbacks: Optional[ List[ConfigurationList.UpdateConfigurationRequestStatusCallbacks] - ] = payload.get("statusCallbacks") + ] = ( + [ + ( + ConfigurationList.UpdateConfigurationRequestStatusCallbacks( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("statusCallbacks") + ] + if payload.get("statusCallbacks") is not None + else None + ) self.intelligence_configuration_ids: Optional[List[str]] = payload.get( "intelligenceConfigurationIds" ) @@ -973,7 +1029,13 @@ def __init__(self, payload: Dict[str, Any]): ) self.conversations_v1_bridge: Optional[ ConfigurationList.CreateConfigurationRequestConversationsV1Bridge - ] = payload.get("conversationsV1Bridge") + ] = ( + ConfigurationList.CreateConfigurationRequestConversationsV1Bridge( + payload.get("conversationsV1Bridge") + ) + if payload.get("conversationsV1Bridge") is not None + else None + ) def to_dict(self): return { @@ -1013,10 +1075,27 @@ def __init__(self, payload: Dict[str, Any]): self.status_timeouts: Optional[ UpdateConfigurationRequestChannelSettingsValueStatusTimeouts - ] = payload.get("statusTimeouts") + ] = ( + UpdateConfigurationRequestChannelSettingsValueStatusTimeouts( + payload.get("statusTimeouts") + ) + if payload.get("statusTimeouts") is not None + else None + ) self.capture_rules: Optional[ List[UpdateConfigurationRequestChannelSettingsValueCaptureRules] - ] = payload.get("captureRules") + ] = ( + [ + ( + UpdateConfigurationRequestChannelSettingsValueCaptureRules(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("captureRules") + ] + if payload.get("captureRules") is not None + else None + ) def to_dict(self): return { diff --git a/twilio/rest/conversations/v2/conversation.py b/twilio/rest/conversations/v2/conversation.py index 43a44569b..71c5e78e8 100644 --- a/twilio/rest/conversations/v2/conversation.py +++ b/twilio/rest/conversations/v2/conversation.py @@ -33,6 +33,7 @@ class ConversationsV2Channel(object): RCS = "RCS" WHATSAPP = "WHATSAPP" CHAT = "CHAT" + VIDEO = "VIDEO" class ConversationsV2ConversationGroupingType(object): GROUP_BY_PROFILE = "GROUP_BY_PROFILE" @@ -801,7 +802,11 @@ class ConversationsV2Address(object): def __init__(self, payload: Dict[str, Any]): - self.channel: Optional[ConversationsV2Channel] = payload.get("channel") + self.channel: Optional[ConversationsV2Channel] = ( + ConversationsV2Channel(payload.get("channel")) + if payload.get("channel") is not None + else None + ) self.address: Optional[str] = payload.get("address") self.channel_id: Optional[str] = payload.get("channelId") @@ -857,10 +862,29 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.configuration: Optional[ ConversationList.CreateConversationWithConfigRequestConfiguration - ] = payload.get("configuration") + ] = ( + ConversationList.CreateConversationWithConfigRequestConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) self.participants: Optional[ List[ConversationList.CreateConversationWithConfigRequestParticipants] - ] = payload.get("participants") + ] = ( + [ + ( + ConversationList.CreateConversationWithConfigRequestParticipants( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("participants") + ] + if payload.get("participants") is not None + else None + ) def to_dict(self): return { @@ -911,7 +935,20 @@ def __init__(self, payload: Dict[str, Any]): List[ ConversationList.CreateConversationWithConfigRequestParticipantsAddresses ] - ] = payload.get("addresses") + ] = ( + [ + ( + ConversationList.CreateConversationWithConfigRequestParticipantsAddresses( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("addresses") + ] + if payload.get("addresses") is not None + else None + ) def to_dict(self): return { @@ -958,7 +995,13 @@ def __init__(self, payload: Dict[str, Any]): self.status: Optional["ConversationInstance.str"] = payload.get("status") self.configuration: Optional[ ConversationList.PatchConversationByIdRequestConfiguration - ] = payload.get("configuration") + ] = ( + ConversationList.PatchConversationByIdRequestConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) def to_dict(self): return { @@ -980,7 +1023,18 @@ def __init__(self, payload: Dict[str, Any]): self.status_callbacks: Optional[ List[ConversationList.ConversationsV2StatusCallbackConfig] - ] = payload.get("statusCallbacks") + ] = ( + [ + ( + ConversationList.ConversationsV2StatusCallbackConfig(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("statusCallbacks") + ] + if payload.get("statusCallbacks") is not None + else None + ) def to_dict(self): return { diff --git a/twilio/rest/conversations/v2/participant.py b/twilio/rest/conversations/v2/participant.py index 63daceda0..0e5bd16e4 100644 --- a/twilio/rest/conversations/v2/participant.py +++ b/twilio/rest/conversations/v2/participant.py @@ -33,6 +33,7 @@ class ConversationsV2Channel(object): RCS = "RCS" WHATSAPP = "WHATSAPP" CHAT = "CHAT" + VIDEO = "VIDEO" class ConversationsV2ParticipantType(object): HUMAN_AGENT = "HUMAN_AGENT" @@ -543,7 +544,20 @@ def __init__(self, payload: Dict[str, Any]): List[ ParticipantList.CreateConversationWithConfigRequestParticipantsAddresses ] - ] = payload.get("addresses") + ] = ( + [ + ( + ParticipantList.CreateConversationWithConfigRequestParticipantsAddresses( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("addresses") + ] + if payload.get("addresses") is not None + else None + ) def to_dict(self): return { @@ -574,7 +588,20 @@ def __init__(self, payload: Dict[str, Any]): List[ ParticipantList.CreateConversationWithConfigRequestParticipantsAddresses ] - ] = payload.get("addresses") + ] = ( + [ + ( + ParticipantList.CreateConversationWithConfigRequestParticipantsAddresses( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("addresses") + ] + if payload.get("addresses") is not None + else None + ) def to_dict(self): return { diff --git a/twilio/rest/iam/v1/o_auth_app.py b/twilio/rest/iam/v1/o_auth_app.py index 14d069bce..ba3ae62c9 100644 --- a/twilio/rest/iam/v1/o_auth_app.py +++ b/twilio/rest/iam/v1/o_auth_app.py @@ -48,7 +48,13 @@ def __init__(self, payload: Dict[str, Any]): ) self.policy: Optional[ OAuthAppList.IamV1OrganizationVendoroauthappPolicy - ] = payload.get("policy") + ] = ( + OAuthAppList.IamV1OrganizationVendoroauthappPolicy( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") def to_dict(self): @@ -79,7 +85,13 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.policy: Optional[ OAuthAppList.IamV1OrganizationVendorOauthAppUpdateRequestPolicy - ] = payload.get("policy") + ] = ( + OAuthAppList.IamV1OrganizationVendorOauthAppUpdateRequestPolicy( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") def to_dict(self): @@ -319,7 +331,13 @@ def __init__(self, payload: Dict[str, Any]): ) self.policy: Optional[ OAuthAppList.IamV1OrganizationVendoroauthappPolicy - ] = payload.get("policy") + ] = ( + OAuthAppList.IamV1OrganizationVendoroauthappPolicy( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") def to_dict(self): @@ -350,7 +368,13 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.policy: Optional[ OAuthAppList.IamV1OrganizationVendorOauthAppUpdateRequestPolicy - ] = payload.get("policy") + ] = ( + OAuthAppList.IamV1OrganizationVendorOauthAppUpdateRequestPolicy( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") def to_dict(self): @@ -629,7 +653,13 @@ def __init__(self, payload: Dict[str, Any]): ) self.policy: Optional[ OAuthAppList.IamV1OrganizationVendoroauthappPolicy - ] = payload.get("policy") + ] = ( + OAuthAppList.IamV1OrganizationVendoroauthappPolicy( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") def to_dict(self): @@ -660,7 +690,13 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.policy: Optional[ OAuthAppList.IamV1OrganizationVendorOauthAppUpdateRequestPolicy - ] = payload.get("policy") + ] = ( + OAuthAppList.IamV1OrganizationVendorOauthAppUpdateRequestPolicy( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") def to_dict(self): diff --git a/twilio/rest/insights/v2/__init__.py b/twilio/rest/insights/v2/__init__.py index 9f2e26d1f..5ebe7481d 100644 --- a/twilio/rest/insights/v2/__init__.py +++ b/twilio/rest/insights/v2/__init__.py @@ -16,7 +16,9 @@ from twilio.base.version import Version from twilio.base.domain import Domain from twilio.rest.insights.v2.inbound import InboundList +from twilio.rest.insights.v2.inbound_report import InboundReportList from twilio.rest.insights.v2.outbound import OutboundList +from twilio.rest.insights.v2.outbound_report import OutboundReportList from twilio.rest.insights.v2.report import ReportList @@ -29,6 +31,8 @@ def __init__(self, domain: Domain): :param domain: The Twilio.insights domain """ super().__init__(domain, "v2") + self._inbound_reports: Optional[InboundReportList] = None + self._outbound_reports: Optional[OutboundReportList] = None self._reports: Optional[ReportList] = None def inbound(self, report_id: str, inbound_id: str = None): @@ -45,6 +49,12 @@ def inbound(self, report_id: str, inbound_id: str = None): return list_instance(inbound_id) return list_instance + @property + def inbound_reports(self) -> InboundReportList: + if self._inbound_reports is None: + self._inbound_reports = InboundReportList(self) + return self._inbound_reports + def outbound(self, report_id: str, outbound_id: str = None): """ Access the OutboundList resource @@ -59,6 +69,12 @@ def outbound(self, report_id: str, outbound_id: str = None): return list_instance(outbound_id) return list_instance + @property + def outbound_reports(self) -> OutboundReportList: + if self._outbound_reports is None: + self._outbound_reports = OutboundReportList(self) + return self._outbound_reports + @property def reports(self) -> ReportList: if self._reports is None: diff --git a/twilio/rest/insights/v2/inbound.py b/twilio/rest/insights/v2/inbound.py index 47bf2a026..b46c4e9d2 100644 --- a/twilio/rest/insights/v2/inbound.py +++ b/twilio/rest/insights/v2/inbound.py @@ -12,11 +12,10 @@ Do not edit the class manually. """ -from datetime import datetime from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, values from twilio.base.api_response import ApiResponse -from twilio.base.instance_context import InstanceContext + from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.version import Version @@ -24,103 +23,11 @@ class InboundInstance(InstanceResource): - - class InsightsV2CreatePhoneNumbersReportRequest(object): - """ - :ivar time_range: - :ivar filters: - :ivar size: The number of max available top Phone Numbers to generate. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.time_range: Optional[ - InboundList.InsightsV2CreatePhoneNumbersReportRequestTimeRange - ] = payload.get("time_range") - self.filters: Optional[List[InboundList.PhoneNumberReportFilter]] = ( - payload.get("filters") - ) - self.size: Optional[int] = payload.get("size") - - def to_dict(self): - return { - "time_range": ( - self.time_range.to_dict() if self.time_range is not None else None - ), - "filters": ( - [filters.to_dict() for filters in self.filters] - if self.filters is not None - else None - ), - "size": self.size, - } - - class InsightsV2CreatePhoneNumbersReportRequestTimeRange(object): - """ - :ivar start_datetime: Start date time of the report - :ivar end_datetime: End date time of the report - """ - - def __init__(self, payload: Dict[str, Any]): - - self.start_datetime: Optional[datetime] = payload.get("start_datetime") - self.end_datetime: Optional[datetime] = payload.get("end_datetime") - - def to_dict(self): - return { - "start_datetime": self.start_datetime, - "end_datetime": self.end_datetime, - } - - class PhoneNumberReportFilter(object): - """ - :ivar key: The name of the filter - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - class ReportFilter(object): - """ - :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - class ReportStatus(object): - CREATED = "created" - RUNNING = "running" - COMPLETED = "completed" - """ - :ivar account_sid: The unique SID identifier of the Account. - :ivar report_id: The report identifier as Voice Insights Report TTID. - :ivar status: - :ivar request_meta: - :ivar url: The URL of this resource. :ivar handle: Inbound phone number handle represented in the report. :ivar total_calls: Total number of calls made with the given handle during the report period. - :ivar call_answer_score: The call answer score measures customers behavior to the delivered calls. The score is a value between 0 and 100, where 100 indicates that all calls were successfully answered. - :ivar call_state_percentage: + :ivar call_answer_score: The call answer score measures customers behavior to the delivered calls. The score is a value between 0 and 100, where 100 indicates that all calls were successfully answered. + :ivar call_state_percentage: :ivar silent_calls_percentage: Percentage of inbound calls with silence tags over total outbound calls. A silent tag is indicative of a connectivity issue or muted audio. """ @@ -129,11 +36,6 @@ def __init__( ): super().__init__(version) - self.account_sid: Optional[str] = payload.get("account_sid") - self.report_id: Optional[str] = payload.get("report_id") - self.status: Optional["InboundInstance.str"] = payload.get("status") - self.request_meta: Optional[str] = payload.get("request_meta") - self.url: Optional[str] = payload.get("url") self.handle: Optional[str] = payload.get("handle") self.total_calls: Optional[int] = deserialize.integer( payload.get("total_calls") @@ -148,91 +50,6 @@ def __init__( "report_id": report_id or self.report_id, } - self._context: Optional[InboundContext] = None - - @property - def _proxy(self) -> "InboundContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: InboundContext for this InboundInstance - """ - if self._context is None: - self._context = InboundContext( - self._version, - report_id=self._solution["report_id"], - ) - return self._context - - def create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> "InboundInstance": - """ - Create the InboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created InboundInstance - """ - return self._proxy.create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request, - ) - - async def create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> "InboundInstance": - """ - Asynchronous coroutine to create the InboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created InboundInstance - """ - return await self._proxy.create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request, - ) - - def create_with_http_info( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Create the InboundInstance with HTTP info - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - return self._proxy.create_with_http_info( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request, - ) - - async def create_with_http_info_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronous coroutine to create the InboundInstance with HTTP info - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - return await self._proxy.create_with_http_info_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request, - ) - def __repr__(self) -> str: """ Provide a friendly representation @@ -243,244 +60,6 @@ def __repr__(self) -> str: return "".format(context) -class InboundContext(InstanceContext): - - class InsightsV2CreatePhoneNumbersReportRequest(object): - """ - :ivar time_range: - :ivar filters: - :ivar size: The number of max available top Phone Numbers to generate. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.time_range: Optional[ - InboundList.InsightsV2CreatePhoneNumbersReportRequestTimeRange - ] = payload.get("time_range") - self.filters: Optional[List[InboundList.PhoneNumberReportFilter]] = ( - payload.get("filters") - ) - self.size: Optional[int] = payload.get("size") - - def to_dict(self): - return { - "time_range": ( - self.time_range.to_dict() if self.time_range is not None else None - ), - "filters": ( - [filters.to_dict() for filters in self.filters] - if self.filters is not None - else None - ), - "size": self.size, - } - - class InsightsV2CreatePhoneNumbersReportRequestTimeRange(object): - """ - :ivar start_datetime: Start date time of the report - :ivar end_datetime: End date time of the report - """ - - def __init__(self, payload: Dict[str, Any]): - - self.start_datetime: Optional[datetime] = payload.get("start_datetime") - self.end_datetime: Optional[datetime] = payload.get("end_datetime") - - def to_dict(self): - return { - "start_datetime": self.start_datetime, - "end_datetime": self.end_datetime, - } - - class PhoneNumberReportFilter(object): - """ - :ivar key: The name of the filter - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - class ReportFilter(object): - """ - :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - def __init__(self, version: Version, report_id: str): - """ - Initialize the InboundContext - - :param version: Version that contains the resource - :param report_id: A unique Report Id. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "report_id": report_id, - } - self._uri = "/Voice/Reports/PhoneNumbers/Inbound".format(**self._solution) - - def _create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_phone_numbers_report_request.to_dict() - - headers = values.of({}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return self._version.create_with_response_info( - method="POST", uri=self._uri, data=data, headers=headers - ) - - def create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> InboundInstance: - """ - Create the InboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created InboundInstance - """ - payload, _, _ = self._create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - return InboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - def create_with_http_info( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Create the InboundInstance and return response metadata - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - instance = InboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal async helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_phone_numbers_report_request.to_dict() - - headers = values.of({}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - async def create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> InboundInstance: - """ - Asynchronous coroutine to create the InboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created InboundInstance - """ - payload, _, _ = await self._create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - return InboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - async def create_with_http_info_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronous coroutine to create the InboundInstance and return response metadata - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - instance = InboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - class InboundPage(Page): def get_instance(self, payload: Dict[str, Any]) -> InboundInstance: @@ -505,87 +84,6 @@ def __repr__(self) -> str: class InboundList(ListResource): - class InsightsV2CreatePhoneNumbersReportRequest(object): - """ - :ivar time_range: - :ivar filters: - :ivar size: The number of max available top Phone Numbers to generate. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.time_range: Optional[ - InboundList.InsightsV2CreatePhoneNumbersReportRequestTimeRange - ] = payload.get("time_range") - self.filters: Optional[List[InboundList.PhoneNumberReportFilter]] = ( - payload.get("filters") - ) - self.size: Optional[int] = payload.get("size") - - def to_dict(self): - return { - "time_range": ( - self.time_range.to_dict() if self.time_range is not None else None - ), - "filters": ( - [filters.to_dict() for filters in self.filters] - if self.filters is not None - else None - ), - "size": self.size, - } - - class InsightsV2CreatePhoneNumbersReportRequestTimeRange(object): - """ - :ivar start_datetime: Start date time of the report - :ivar end_datetime: End date time of the report - """ - - def __init__(self, payload: Dict[str, Any]): - - self.start_datetime: Optional[datetime] = payload.get("start_datetime") - self.end_datetime: Optional[datetime] = payload.get("end_datetime") - - def to_dict(self): - return { - "start_datetime": self.start_datetime, - "end_datetime": self.end_datetime, - } - - class PhoneNumberReportFilter(object): - """ - :ivar key: The name of the filter - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - class ReportFilter(object): - """ - :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - def __init__(self, version: Version, report_id: str): """ Initialize the InboundList @@ -604,136 +102,6 @@ def __init__(self, version: Version, report_id: str): **self._solution ) - def _create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_phone_numbers_report_request.to_dict() - - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return self._version.create_with_response_info( - method="POST", uri=self._uri, data=data, headers=headers - ) - - def create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> InboundInstance: - """ - Create the InboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created InboundInstance - """ - payload, _, _ = self._create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - return InboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - def create_with_http_info( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Create the InboundInstance and return response metadata - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - instance = InboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal async helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_phone_numbers_report_request.to_dict() - - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - async def create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> InboundInstance: - """ - Asynchronously create the InboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created InboundInstance - """ - payload, _, _ = await self._create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - return InboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - async def create_with_http_info_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronously create the InboundInstance and return response metadata - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - instance = InboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - def stream( self, limit: Optional[int] = None, @@ -1099,22 +467,6 @@ async def get_page_async(self, target_url: str) -> InboundPage: response = await self._version.domain.twilio.request_async("GET", target_url) return InboundPage(self._version, response, solution=self._solution) - def get(self, report_id: str) -> InboundContext: - """ - Constructs a InboundContext - - :param report_id: A unique Report Id. - """ - return InboundContext(self._version, report_id=report_id) - - def __call__(self, report_id: str) -> InboundContext: - """ - Constructs a InboundContext - - :param report_id: A unique Report Id. - """ - return InboundContext(self._version, report_id=report_id) - def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/insights/v2/inbound_report.py b/twilio/rest/insights/v2/inbound_report.py new file mode 100644 index 000000000..ca159da54 --- /dev/null +++ b/twilio/rest/insights/v2/inbound_report.py @@ -0,0 +1,392 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Sample/reference Twilio API. + This is the reference API for the rest-proxy server. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, List, Optional, Union +from twilio.base import values +from twilio.base.api_response import ApiResponse + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class InboundReportInstance(InstanceResource): + + class InsightsV2CreatePhoneNumbersReportRequest(object): + """ + :ivar time_range: + :ivar filters: + :ivar size: The number of max available top Phone Numbers to generate. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.time_range: Optional[ + InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange + ] = ( + InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange( + payload.get("time_range") + ) + if payload.get("time_range") is not None + else None + ) + self.filters: Optional[List[InboundReportList.PhoneNumberReportFilter]] = ( + [ + ( + InboundReportList.PhoneNumberReportFilter(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("filters") + ] + if payload.get("filters") is not None + else None + ) + self.size: Optional[int] = payload.get("size") + + def to_dict(self): + return { + "time_range": ( + self.time_range.to_dict() if self.time_range is not None else None + ), + "filters": ( + [filters.to_dict() for filters in self.filters] + if self.filters is not None + else None + ), + "size": self.size, + } + + class InsightsV2CreatePhoneNumbersReportRequestTimeRange(object): + """ + :ivar start_datetime: Start date time of the report + :ivar end_datetime: End date time of the report + """ + + def __init__(self, payload: Dict[str, Any]): + + self.start_datetime: Optional[datetime] = payload.get("start_datetime") + self.end_datetime: Optional[datetime] = payload.get("end_datetime") + + def to_dict(self): + return { + "start_datetime": self.start_datetime, + "end_datetime": self.end_datetime, + } + + class PhoneNumberReportFilter(object): + """ + :ivar key: The name of the filter + :ivar values: List of supported filter values for the field name + """ + + def __init__(self, payload: Dict[str, Any]): + + self.key: Optional[str] = payload.get("key") + self.values: Optional[List[str]] = payload.get("values") + + def to_dict(self): + return { + "key": self.key, + "values": self.values, + } + + class ReportFilter(object): + """ + :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' + :ivar values: List of supported filter values for the field name + """ + + def __init__(self, payload: Dict[str, Any]): + + self.key: Optional[str] = payload.get("key") + self.values: Optional[List[str]] = payload.get("values") + + def to_dict(self): + return { + "key": self.key, + "values": self.values, + } + + class ReportStatus(object): + CREATED = "created" + RUNNING = "running" + COMPLETED = "completed" + + """ + :ivar account_sid: The unique SID identifier of the Account. + :ivar report_id: The report identifier as Voice Insights Report TTID. + :ivar status: + :ivar request_meta: + :ivar url: The URL of this resource. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.report_id: Optional[str] = payload.get("report_id") + self.status: Optional["InboundReportInstance.str"] = payload.get("status") + self.request_meta: Optional[str] = payload.get("request_meta") + self.url: Optional[str] = payload.get("url") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class InboundReportList(ListResource): + + class InsightsV2CreatePhoneNumbersReportRequest(object): + """ + :ivar time_range: + :ivar filters: + :ivar size: The number of max available top Phone Numbers to generate. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.time_range: Optional[ + InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange + ] = ( + InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange( + payload.get("time_range") + ) + if payload.get("time_range") is not None + else None + ) + self.filters: Optional[List[InboundReportList.PhoneNumberReportFilter]] = ( + [ + ( + InboundReportList.PhoneNumberReportFilter(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("filters") + ] + if payload.get("filters") is not None + else None + ) + self.size: Optional[int] = payload.get("size") + + def to_dict(self): + return { + "time_range": ( + self.time_range.to_dict() if self.time_range is not None else None + ), + "filters": ( + [filters.to_dict() for filters in self.filters] + if self.filters is not None + else None + ), + "size": self.size, + } + + class InsightsV2CreatePhoneNumbersReportRequestTimeRange(object): + """ + :ivar start_datetime: Start date time of the report + :ivar end_datetime: End date time of the report + """ + + def __init__(self, payload: Dict[str, Any]): + + self.start_datetime: Optional[datetime] = payload.get("start_datetime") + self.end_datetime: Optional[datetime] = payload.get("end_datetime") + + def to_dict(self): + return { + "start_datetime": self.start_datetime, + "end_datetime": self.end_datetime, + } + + class PhoneNumberReportFilter(object): + """ + :ivar key: The name of the filter + :ivar values: List of supported filter values for the field name + """ + + def __init__(self, payload: Dict[str, Any]): + + self.key: Optional[str] = payload.get("key") + self.values: Optional[List[str]] = payload.get("values") + + def to_dict(self): + return { + "key": self.key, + "values": self.values, + } + + class ReportFilter(object): + """ + :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' + :ivar values: List of supported filter values for the field name + """ + + def __init__(self, payload: Dict[str, Any]): + + self.key: Optional[str] = payload.get("key") + self.values: Optional[List[str]] = payload.get("values") + + def to_dict(self): + return { + "key": self.key, + "values": self.values, + } + + def __init__(self, version: Version): + """ + Initialize the InboundReportList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Voice/Reports/PhoneNumbers/Inbound" + + def _create( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = insights_v2_create_phone_numbers_report_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return self._version.create_with_response_info( + method="POST", uri=self._uri, data=data, headers=headers + ) + + def create( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> InboundReportInstance: + """ + Create the InboundReportInstance + + :param insights_v2_create_phone_numbers_report_request: + + :returns: The created InboundReportInstance + """ + payload, _, _ = self._create( + insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request + ) + return InboundReportInstance(self._version, payload) + + def create_with_http_info( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Create the InboundReportInstance and return response metadata + + :param insights_v2_create_phone_numbers_report_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create( + insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request + ) + instance = InboundReportInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = insights_v2_create_phone_numbers_report_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return await self._version.create_with_response_info_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + async def create_async( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> InboundReportInstance: + """ + Asynchronously create the InboundReportInstance + + :param insights_v2_create_phone_numbers_report_request: + + :returns: The created InboundReportInstance + """ + payload, _, _ = await self._create_async( + insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request + ) + return InboundReportInstance(self._version, payload) + + async def create_with_http_info_async( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronously create the InboundReportInstance and return response metadata + + :param insights_v2_create_phone_numbers_report_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async( + insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request + ) + instance = InboundReportInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/insights/v2/outbound.py b/twilio/rest/insights/v2/outbound.py index 2774a09d0..e880b1f23 100644 --- a/twilio/rest/insights/v2/outbound.py +++ b/twilio/rest/insights/v2/outbound.py @@ -12,11 +12,10 @@ Do not edit the class manually. """ -from datetime import datetime from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, values from twilio.base.api_response import ApiResponse -from twilio.base.instance_context import InstanceContext + from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.version import Version @@ -24,136 +23,19 @@ class OutboundInstance(InstanceResource): - - class CountyCarrierValueCarriers(object): - """ - :ivar carrier: The name of the carrier. - :ivar total_calls: Total number of outbound calls for the carrier in the country. - :ivar blocked_calls: Total number of blocked outbound calls for the carrier in the country. - :ivar blocked_calls_percentage: Percentage of blocked outbound calls for the carrier in the country. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.carrier: Optional[str] = payload.get("carrier") - self.total_calls: Optional[int] = payload.get("total_calls") - self.blocked_calls: Optional[int] = payload.get("blocked_calls") - self.blocked_calls_percentage: Optional[float] = payload.get( - "blocked_calls_percentage" - ) - - def to_dict(self): - return { - "carrier": self.carrier, - "total_calls": self.total_calls, - "blocked_calls": self.blocked_calls, - "blocked_calls_percentage": self.blocked_calls_percentage, - } - - class InsightsV2CreatePhoneNumbersReportRequest(object): - """ - :ivar time_range: - :ivar filters: - :ivar size: The number of max available top Phone Numbers to generate. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.time_range: Optional[ - InboundList.InsightsV2CreatePhoneNumbersReportRequestTimeRange - ] = payload.get("time_range") - self.filters: Optional[List[InboundList.PhoneNumberReportFilter]] = ( - payload.get("filters") - ) - self.size: Optional[int] = payload.get("size") - - def to_dict(self): - return { - "time_range": ( - self.time_range.to_dict() if self.time_range is not None else None - ), - "filters": ( - [filters.to_dict() for filters in self.filters] - if self.filters is not None - else None - ), - "size": self.size, - } - - class InsightsV2CreatePhoneNumbersReportRequestTimeRange(object): - """ - :ivar start_datetime: Start date time of the report - :ivar end_datetime: End date time of the report - """ - - def __init__(self, payload: Dict[str, Any]): - - self.start_datetime: Optional[datetime] = payload.get("start_datetime") - self.end_datetime: Optional[datetime] = payload.get("end_datetime") - - def to_dict(self): - return { - "start_datetime": self.start_datetime, - "end_datetime": self.end_datetime, - } - - class PhoneNumberReportFilter(object): - """ - :ivar key: The name of the filter - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - class ReportFilter(object): - """ - :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - class ReportStatus(object): - CREATED = "created" - RUNNING = "running" - COMPLETED = "completed" - """ - :ivar account_sid: The unique SID identifier of the Account. - :ivar report_id: The report identifier as Voice Insights Report TTID. - :ivar status: - :ivar request_meta: - :ivar url: The URL of this resource. - :ivar handle: Inbound phone number handle represented in the report. - :ivar total_calls: Total number of calls made with the given handle during the report period. - :ivar call_answer_score: The call answer score measures customers behavior to the delivered calls. The score is a value between 0 and 100, where 100 indicates that all calls were successfully answered. - :ivar call_state_percentage: - :ivar silent_calls_percentage: Percentage of inbound calls with silence tags over total outbound calls. A silent tag is indicative of a connectivity issue or muted audio. - :ivar calls_by_device_type: Number of calls made with each device type. `voip`, `mobile`, `landline`, `unknown` - :ivar answer_rate_device_type: Answer rate for each device type. `voip`, `mobile`, `landline`, `unknown` + :ivar handle: The outbound phone number handle. + :ivar total_calls: Total number of outbound calls made with the given handle during the report period. + :ivar call_answer_score: The call answer score measures customers behavior to the delivered calls. The score is a value between 0 and 100, where 100 indicates that all calls were successfully answered. + :ivar calls_by_device_type: Number of calls made with each device type. `voip`, `mobile`, `landline`, `unknown` + :ivar answer_rate_device_type: Answer rate for each device type. `voip`, `mobile`, `landline`, `unknown` + :ivar call_state_percentage: :ivar blocked_calls_by_carrier: Percentage of blocked calls by carrier per country. + :ivar silent_calls_percentage: Percentage of calls with silence tags over total calls. A silent tag is indicative of a connectivity issue or muted audio. :ivar short_duration_calls_percentage: Percentage of completed outbound calls under 10 seconds (PSTN Short call tags); More than 15% is typically low trust measured. :ivar long_duration_calls_percentage: Percentage of long duration calls ( >= 60 seconds) :ivar potential_robocalls_percentage: Percentage of completed outbound calls to unassigned or unallocated phone numbers. - :ivar answering_machine_detection: + :ivar answering_machine_detection: """ def __init__( @@ -161,29 +43,24 @@ def __init__( ): super().__init__(version) - self.account_sid: Optional[str] = payload.get("account_sid") - self.report_id: Optional[str] = payload.get("report_id") - self.status: Optional["InboundInstance.str"] = payload.get("status") - self.request_meta: Optional[str] = payload.get("request_meta") - self.url: Optional[str] = payload.get("url") self.handle: Optional[str] = payload.get("handle") self.total_calls: Optional[int] = deserialize.integer( payload.get("total_calls") ) self.call_answer_score: Optional[float] = payload.get("call_answer_score") - self.call_state_percentage: Optional[str] = payload.get("call_state_percentage") - self.silent_calls_percentage: Optional[float] = payload.get( - "silent_calls_percentage" - ) self.calls_by_device_type: Optional[Dict[str, int]] = payload.get( "calls_by_device_type" ) self.answer_rate_device_type: Optional[Dict[str, float]] = payload.get( "answer_rate_device_type" ) + self.call_state_percentage: Optional[str] = payload.get("call_state_percentage") self.blocked_calls_by_carrier: Optional[List[str]] = payload.get( "blocked_calls_by_carrier" ) + self.silent_calls_percentage: Optional[float] = payload.get( + "silent_calls_percentage" + ) self.short_duration_calls_percentage: Optional[float] = payload.get( "short_duration_calls_percentage" ) @@ -201,91 +78,6 @@ def __init__( "report_id": report_id or self.report_id, } - self._context: Optional[OutboundContext] = None - - @property - def _proxy(self) -> "OutboundContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: OutboundContext for this OutboundInstance - """ - if self._context is None: - self._context = OutboundContext( - self._version, - report_id=self._solution["report_id"], - ) - return self._context - - def create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> "OutboundInstance": - """ - Create the OutboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created OutboundInstance - """ - return self._proxy.create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request, - ) - - async def create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> "OutboundInstance": - """ - Asynchronous coroutine to create the OutboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created OutboundInstance - """ - return await self._proxy.create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request, - ) - - def create_with_http_info( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Create the OutboundInstance with HTTP info - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - return self._proxy.create_with_http_info( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request, - ) - - async def create_with_http_info_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronous coroutine to create the OutboundInstance with HTTP info - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - return await self._proxy.create_with_http_info_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request, - ) - def __repr__(self) -> str: """ Provide a friendly representation @@ -296,269 +88,6 @@ def __repr__(self) -> str: return "".format(context) -class OutboundContext(InstanceContext): - - class CountyCarrierValueCarriers(object): - """ - :ivar carrier: The name of the carrier. - :ivar total_calls: Total number of outbound calls for the carrier in the country. - :ivar blocked_calls: Total number of blocked outbound calls for the carrier in the country. - :ivar blocked_calls_percentage: Percentage of blocked outbound calls for the carrier in the country. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.carrier: Optional[str] = payload.get("carrier") - self.total_calls: Optional[int] = payload.get("total_calls") - self.blocked_calls: Optional[int] = payload.get("blocked_calls") - self.blocked_calls_percentage: Optional[float] = payload.get( - "blocked_calls_percentage" - ) - - def to_dict(self): - return { - "carrier": self.carrier, - "total_calls": self.total_calls, - "blocked_calls": self.blocked_calls, - "blocked_calls_percentage": self.blocked_calls_percentage, - } - - class InsightsV2CreatePhoneNumbersReportRequest(object): - """ - :ivar time_range: - :ivar filters: - :ivar size: The number of max available top Phone Numbers to generate. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.time_range: Optional[ - InboundList.InsightsV2CreatePhoneNumbersReportRequestTimeRange - ] = payload.get("time_range") - self.filters: Optional[List[InboundList.PhoneNumberReportFilter]] = ( - payload.get("filters") - ) - self.size: Optional[int] = payload.get("size") - - def to_dict(self): - return { - "time_range": ( - self.time_range.to_dict() if self.time_range is not None else None - ), - "filters": ( - [filters.to_dict() for filters in self.filters] - if self.filters is not None - else None - ), - "size": self.size, - } - - class InsightsV2CreatePhoneNumbersReportRequestTimeRange(object): - """ - :ivar start_datetime: Start date time of the report - :ivar end_datetime: End date time of the report - """ - - def __init__(self, payload: Dict[str, Any]): - - self.start_datetime: Optional[datetime] = payload.get("start_datetime") - self.end_datetime: Optional[datetime] = payload.get("end_datetime") - - def to_dict(self): - return { - "start_datetime": self.start_datetime, - "end_datetime": self.end_datetime, - } - - class PhoneNumberReportFilter(object): - """ - :ivar key: The name of the filter - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - class ReportFilter(object): - """ - :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - def __init__(self, version: Version, report_id: str): - """ - Initialize the OutboundContext - - :param version: Version that contains the resource - :param report_id: A unique Report Id. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "report_id": report_id, - } - self._uri = "/Voice/Reports/PhoneNumbers/Outbound".format(**self._solution) - - def _create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_phone_numbers_report_request.to_dict() - - headers = values.of({}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return self._version.create_with_response_info( - method="POST", uri=self._uri, data=data, headers=headers - ) - - def create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> OutboundInstance: - """ - Create the OutboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created OutboundInstance - """ - payload, _, _ = self._create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - return OutboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - def create_with_http_info( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Create the OutboundInstance and return response metadata - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - instance = OutboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal async helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_phone_numbers_report_request.to_dict() - - headers = values.of({}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - async def create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> OutboundInstance: - """ - Asynchronous coroutine to create the OutboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created OutboundInstance - """ - payload, _, _ = await self._create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - return OutboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - async def create_with_http_info_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronous coroutine to create the OutboundInstance and return response metadata - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - instance = OutboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - class OutboundPage(Page): def get_instance(self, payload: Dict[str, Any]) -> OutboundInstance: @@ -583,112 +112,6 @@ def __repr__(self) -> str: class OutboundList(ListResource): - class CountyCarrierValueCarriers(object): - """ - :ivar carrier: The name of the carrier. - :ivar total_calls: Total number of outbound calls for the carrier in the country. - :ivar blocked_calls: Total number of blocked outbound calls for the carrier in the country. - :ivar blocked_calls_percentage: Percentage of blocked outbound calls for the carrier in the country. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.carrier: Optional[str] = payload.get("carrier") - self.total_calls: Optional[int] = payload.get("total_calls") - self.blocked_calls: Optional[int] = payload.get("blocked_calls") - self.blocked_calls_percentage: Optional[float] = payload.get( - "blocked_calls_percentage" - ) - - def to_dict(self): - return { - "carrier": self.carrier, - "total_calls": self.total_calls, - "blocked_calls": self.blocked_calls, - "blocked_calls_percentage": self.blocked_calls_percentage, - } - - class InsightsV2CreatePhoneNumbersReportRequest(object): - """ - :ivar time_range: - :ivar filters: - :ivar size: The number of max available top Phone Numbers to generate. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.time_range: Optional[ - InboundList.InsightsV2CreatePhoneNumbersReportRequestTimeRange - ] = payload.get("time_range") - self.filters: Optional[List[InboundList.PhoneNumberReportFilter]] = ( - payload.get("filters") - ) - self.size: Optional[int] = payload.get("size") - - def to_dict(self): - return { - "time_range": ( - self.time_range.to_dict() if self.time_range is not None else None - ), - "filters": ( - [filters.to_dict() for filters in self.filters] - if self.filters is not None - else None - ), - "size": self.size, - } - - class InsightsV2CreatePhoneNumbersReportRequestTimeRange(object): - """ - :ivar start_datetime: Start date time of the report - :ivar end_datetime: End date time of the report - """ - - def __init__(self, payload: Dict[str, Any]): - - self.start_datetime: Optional[datetime] = payload.get("start_datetime") - self.end_datetime: Optional[datetime] = payload.get("end_datetime") - - def to_dict(self): - return { - "start_datetime": self.start_datetime, - "end_datetime": self.end_datetime, - } - - class PhoneNumberReportFilter(object): - """ - :ivar key: The name of the filter - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - - class ReportFilter(object): - """ - :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' - :ivar values: List of supported filter values for the field name - """ - - def __init__(self, payload: Dict[str, Any]): - - self.key: Optional[str] = payload.get("key") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "key": self.key, - "values": self.values, - } - def __init__(self, version: Version, report_id: str): """ Initialize the OutboundList @@ -707,136 +130,6 @@ def __init__(self, version: Version, report_id: str): **self._solution ) - def _create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_phone_numbers_report_request.to_dict() - - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return self._version.create_with_response_info( - method="POST", uri=self._uri, data=data, headers=headers - ) - - def create( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> OutboundInstance: - """ - Create the OutboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created OutboundInstance - """ - payload, _, _ = self._create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - return OutboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - def create_with_http_info( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Create the OutboundInstance and return response metadata - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - instance = OutboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal async helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_phone_numbers_report_request.to_dict() - - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - async def create_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> OutboundInstance: - """ - Asynchronously create the OutboundInstance - - :param insights_v2_create_phone_numbers_report_request: - - :returns: The created OutboundInstance - """ - payload, _, _ = await self._create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - return OutboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - async def create_with_http_info_async( - self, - insights_v2_create_phone_numbers_report_request: Union[ - InsightsV2CreatePhoneNumbersReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronously create the OutboundInstance and return response metadata - - :param insights_v2_create_phone_numbers_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async( - insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request - ) - instance = OutboundInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - def stream( self, limit: Optional[int] = None, @@ -1202,22 +495,6 @@ async def get_page_async(self, target_url: str) -> OutboundPage: response = await self._version.domain.twilio.request_async("GET", target_url) return OutboundPage(self._version, response, solution=self._solution) - def get(self, report_id: str) -> OutboundContext: - """ - Constructs a OutboundContext - - :param report_id: A unique Report Id. - """ - return OutboundContext(self._version, report_id=report_id) - - def __call__(self, report_id: str) -> OutboundContext: - """ - Constructs a OutboundContext - - :param report_id: A unique Report Id. - """ - return OutboundContext(self._version, report_id=report_id) - def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/insights/v2/outbound_report.py b/twilio/rest/insights/v2/outbound_report.py new file mode 100644 index 000000000..65f68568e --- /dev/null +++ b/twilio/rest/insights/v2/outbound_report.py @@ -0,0 +1,323 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Sample/reference Twilio API. + This is the reference API for the rest-proxy server. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, List, Optional, Union +from twilio.base import values +from twilio.base.api_response import ApiResponse + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class OutboundReportInstance(InstanceResource): + + class InsightsV2CreatePhoneNumbersReportRequest(object): + """ + :ivar time_range: + :ivar filters: + :ivar size: The number of max available top Phone Numbers to generate. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.time_range: Optional[ + InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange + ] = ( + InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange( + payload.get("time_range") + ) + if payload.get("time_range") is not None + else None + ) + self.filters: Optional[List[InboundReportList.PhoneNumberReportFilter]] = ( + [ + ( + InboundReportList.PhoneNumberReportFilter(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("filters") + ] + if payload.get("filters") is not None + else None + ) + self.size: Optional[int] = payload.get("size") + + def to_dict(self): + return { + "time_range": ( + self.time_range.to_dict() if self.time_range is not None else None + ), + "filters": ( + [filters.to_dict() for filters in self.filters] + if self.filters is not None + else None + ), + "size": self.size, + } + + class ReportFilter(object): + """ + :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' + :ivar values: List of supported filter values for the field name + """ + + def __init__(self, payload: Dict[str, Any]): + + self.key: Optional[str] = payload.get("key") + self.values: Optional[List[str]] = payload.get("values") + + def to_dict(self): + return { + "key": self.key, + "values": self.values, + } + + class ReportStatus(object): + CREATED = "created" + RUNNING = "running" + COMPLETED = "completed" + + """ + :ivar account_sid: The unique SID identifier of the Account. + :ivar report_id: The report identifier as Voice Insights Report TTID. + :ivar status: + :ivar request_meta: + :ivar url: The URL of this resource. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.report_id: Optional[str] = payload.get("report_id") + self.status: Optional["InboundReportInstance.str"] = payload.get("status") + self.request_meta: Optional[str] = payload.get("request_meta") + self.url: Optional[str] = payload.get("url") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class OutboundReportList(ListResource): + + class InsightsV2CreatePhoneNumbersReportRequest(object): + """ + :ivar time_range: + :ivar filters: + :ivar size: The number of max available top Phone Numbers to generate. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.time_range: Optional[ + InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange + ] = ( + InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange( + payload.get("time_range") + ) + if payload.get("time_range") is not None + else None + ) + self.filters: Optional[List[InboundReportList.PhoneNumberReportFilter]] = ( + [ + ( + InboundReportList.PhoneNumberReportFilter(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("filters") + ] + if payload.get("filters") is not None + else None + ) + self.size: Optional[int] = payload.get("size") + + def to_dict(self): + return { + "time_range": ( + self.time_range.to_dict() if self.time_range is not None else None + ), + "filters": ( + [filters.to_dict() for filters in self.filters] + if self.filters is not None + else None + ), + "size": self.size, + } + + class ReportFilter(object): + """ + :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent' + :ivar values: List of supported filter values for the field name + """ + + def __init__(self, payload: Dict[str, Any]): + + self.key: Optional[str] = payload.get("key") + self.values: Optional[List[str]] = payload.get("values") + + def to_dict(self): + return { + "key": self.key, + "values": self.values, + } + + def __init__(self, version: Version): + """ + Initialize the OutboundReportList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Voice/Reports/PhoneNumbers/Outbound" + + def _create( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = insights_v2_create_phone_numbers_report_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return self._version.create_with_response_info( + method="POST", uri=self._uri, data=data, headers=headers + ) + + def create( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> OutboundReportInstance: + """ + Create the OutboundReportInstance + + :param insights_v2_create_phone_numbers_report_request: + + :returns: The created OutboundReportInstance + """ + payload, _, _ = self._create( + insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request + ) + return OutboundReportInstance(self._version, payload) + + def create_with_http_info( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Create the OutboundReportInstance and return response metadata + + :param insights_v2_create_phone_numbers_report_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create( + insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request + ) + instance = OutboundReportInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = insights_v2_create_phone_numbers_report_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return await self._version.create_with_response_info_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + async def create_async( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> OutboundReportInstance: + """ + Asynchronously create the OutboundReportInstance + + :param insights_v2_create_phone_numbers_report_request: + + :returns: The created OutboundReportInstance + """ + payload, _, _ = await self._create_async( + insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request + ) + return OutboundReportInstance(self._version, payload) + + async def create_with_http_info_async( + self, + insights_v2_create_phone_numbers_report_request: Union[ + InsightsV2CreatePhoneNumbersReportRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronously create the OutboundReportInstance and return response metadata + + :param insights_v2_create_phone_numbers_report_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async( + insights_v2_create_phone_numbers_report_request=insights_v2_create_phone_numbers_report_request + ) + instance = OutboundReportInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/insights/v2/report.py b/twilio/rest/insights/v2/report.py index fb7df212e..5f02058a8 100644 --- a/twilio/rest/insights/v2/report.py +++ b/twilio/rest/insights/v2/report.py @@ -14,7 +14,7 @@ from datetime import datetime from typing import Any, Dict, List, Optional, Union -from twilio.base import deserialize, values +from twilio.base import values from twilio.base.api_response import ApiResponse from twilio.base.instance_context import InstanceContext from twilio.base.instance_resource import InstanceResource @@ -126,7 +126,13 @@ def __init__(self, payload: Dict[str, Any]): self.outbound_carrier_calling: Optional[ AccountReportKYTOutboundCarrierCalling - ] = payload.get("outbound_carrier_calling") + ] = ( + AccountReportKYTOutboundCarrierCalling( + payload.get("outbound_carrier_calling") + ) + if payload.get("outbound_carrier_calling") is not None + else None + ) def to_dict(self): return { @@ -159,7 +165,12 @@ def __init__(self, payload: Dict[str, Any]): "unique_called_numbers" ) self.blocked_calls_by_carrier: Optional[List[CountyCarrierValue]] = ( - payload.get("blocked_calls_by_carrier") + [ + CountyCarrierValue(item) if isinstance(item, dict) else item + for item in payload.get("blocked_calls_by_carrier") + ] + if payload.get("blocked_calls_by_carrier") is not None + else None ) self.short_duration_calls_percentage: Optional[float] = payload.get( "short_duration_calls_percentage" @@ -170,13 +181,21 @@ def __init__(self, payload: Dict[str, Any]): self.potential_robocalls_percentage: Optional[float] = payload.get( "potential_robocalls_percentage" ) - self.branded_calling: Optional[BrandedCalling] = payload.get( - "branded_calling" + self.branded_calling: Optional[BrandedCalling] = ( + BrandedCalling(payload.get("branded_calling")) + if payload.get("branded_calling") is not None + else None + ) + self.voice_integrity: Optional[VoiceIntegrity] = ( + VoiceIntegrity(payload.get("voice_integrity")) + if payload.get("voice_integrity") is not None + else None ) - self.voice_integrity: Optional[VoiceIntegrity] = payload.get( - "voice_integrity" + self.stir_shaken: Optional[StirShaken] = ( + StirShaken(payload.get("stir_shaken")) + if payload.get("stir_shaken") is not None + else None ) - self.stir_shaken: Optional[StirShaken] = payload.get("stir_shaken") def to_dict(self): return { @@ -216,9 +235,15 @@ class AccountReportNetworkIssues(object): def __init__(self, payload: Dict[str, Any]): - self.sdk: Optional[AccountReportNetworkIssuesSdk] = payload.get("sdk") + self.sdk: Optional[AccountReportNetworkIssuesSdk] = ( + AccountReportNetworkIssuesSdk(payload.get("sdk")) + if payload.get("sdk") is not None + else None + ) self.twilio_gateway: Optional[AccountReportNetworkIssuesTwilioGateway] = ( - payload.get("twilio_gateway") + AccountReportNetworkIssuesTwilioGateway(payload.get("twilio_gateway")) + if payload.get("twilio_gateway") is not None + else None ) def to_dict(self): @@ -307,8 +332,13 @@ def __init__(self, payload: Dict[str, Any]): self.answer_rate: Optional[float] = payload.get("answer_rate") self.human_answer_rate: Optional[float] = payload.get("human_answer_rate") self.engagement_rate: Optional[float] = payload.get("engagement_rate") - self.by_use_case: Optional[List[BrandedUseCaseDetail]] = payload.get( - "by_use_case" + self.by_use_case: Optional[List[BrandedUseCaseDetail]] = ( + [ + BrandedUseCaseDetail(item) if isinstance(item, dict) else item + for item in payload.get("by_use_case") + ] + if payload.get("by_use_case") is not None + else None ) def to_dict(self): @@ -391,9 +421,20 @@ def __init__(self, payload: Dict[str, Any]): self.time_range: Optional[ ReportList.InsightsV2CreateAccountReportRequestTimeRange - ] = payload.get("time_range") - self.filters: Optional[List[ReportList.ReportFilter]] = payload.get( - "filters" + ] = ( + ReportList.InsightsV2CreateAccountReportRequestTimeRange( + payload.get("time_range") + ) + if payload.get("time_range") is not None + else None + ) + self.filters: Optional[List[ReportList.ReportFilter]] = ( + [ + ReportList.ReportFilter(item) if isinstance(item, dict) else item + for item in payload.get("filters") + ] + if payload.get("filters") is not None + else None ) def to_dict(self): @@ -451,10 +492,20 @@ class StirShaken(object): def __init__(self, payload: Dict[str, Any]): - self.call_count: Optional[StirShakenCallCount] = payload.get("call_count") - self.percentage: Optional[StirShakenPercentage] = payload.get("percentage") - self.answer_rate: Optional[StirShakenAnswerRate] = payload.get( - "answer_rate" + self.call_count: Optional[StirShakenCallCount] = ( + StirShakenCallCount(payload.get("call_count")) + if payload.get("call_count") is not None + else None + ) + self.percentage: Optional[StirShakenPercentage] = ( + StirShakenPercentage(payload.get("percentage")) + if payload.get("percentage") is not None + else None + ) + self.answer_rate: Optional[StirShakenAnswerRate] = ( + StirShakenAnswerRate(payload.get("answer_rate")) + if payload.get("answer_rate") is not None + else None ) def to_dict(self): @@ -542,7 +593,16 @@ def __init__(self, payload: Dict[str, Any]): self.enabled_calls: Optional[int] = payload.get("enabled_calls") self.enabled_percentage: Optional[float] = payload.get("enabled_percentage") self.calls_per_bundle: Optional[List[VoiceIntegrityCallsPerBundle]] = ( - payload.get("calls_per_bundle") + [ + ( + VoiceIntegrityCallsPerBundle(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("calls_per_bundle") + ] + if payload.get("calls_per_bundle") is not None + else None ) def to_dict(self): @@ -598,18 +658,6 @@ class ReportStatus(object): :ivar status: :ivar request_meta: :ivar url: The URL of this resource. - :ivar handle: Inbound phone number handle represented in the report. - :ivar total_calls: Total number of calls made with the given handle during the report period. - :ivar call_answer_score: The call answer score measures customers behavior to the delivered calls. The score is a value between 0 and 100, where 100 indicates that all calls were successfully answered. - :ivar call_state_percentage: - :ivar silent_calls_percentage: Percentage of inbound calls with silence tags over total outbound calls. A silent tag is indicative of a connectivity issue or muted audio. - :ivar calls_by_device_type: Number of calls made with each device type. `voip`, `mobile`, `landline`, `unknown` - :ivar answer_rate_device_type: Answer rate for each device type. `voip`, `mobile`, `landline`, `unknown` - :ivar blocked_calls_by_carrier: Percentage of blocked calls by carrier per country. - :ivar short_duration_calls_percentage: Percentage of completed outbound calls under 10 seconds (PSTN Short call tags); More than 15% is typically low trust measured. - :ivar long_duration_calls_percentage: Percentage of long duration calls ( >= 60 seconds) - :ivar potential_robocalls_percentage: Percentage of completed outbound calls to unassigned or unallocated phone numbers. - :ivar answering_machine_detection: :ivar report: """ @@ -620,39 +668,9 @@ def __init__( self.account_sid: Optional[str] = payload.get("account_sid") self.report_id: Optional[str] = payload.get("report_id") - self.status: Optional["InboundInstance.str"] = payload.get("status") + self.status: Optional["InboundReportInstance.str"] = payload.get("status") self.request_meta: Optional[str] = payload.get("request_meta") self.url: Optional[str] = payload.get("url") - self.handle: Optional[str] = payload.get("handle") - self.total_calls: Optional[int] = deserialize.integer( - payload.get("total_calls") - ) - self.call_answer_score: Optional[float] = payload.get("call_answer_score") - self.call_state_percentage: Optional[str] = payload.get("call_state_percentage") - self.silent_calls_percentage: Optional[float] = payload.get( - "silent_calls_percentage" - ) - self.calls_by_device_type: Optional[Dict[str, int]] = payload.get( - "calls_by_device_type" - ) - self.answer_rate_device_type: Optional[Dict[str, float]] = payload.get( - "answer_rate_device_type" - ) - self.blocked_calls_by_carrier: Optional[List[str]] = payload.get( - "blocked_calls_by_carrier" - ) - self.short_duration_calls_percentage: Optional[float] = payload.get( - "short_duration_calls_percentage" - ) - self.long_duration_calls_percentage: Optional[float] = payload.get( - "long_duration_calls_percentage" - ) - self.potential_robocalls_percentage: Optional[float] = payload.get( - "potential_robocalls_percentage" - ) - self.answering_machine_detection: Optional[str] = payload.get( - "answering_machine_detection" - ) self.report: Optional[str] = payload.get("report") self._solution = { @@ -676,74 +694,6 @@ def _proxy(self) -> "ReportContext": ) return self._context - def create( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> "ReportInstance": - """ - Create the ReportInstance - - :param insights_v2_create_account_report_request: - - :returns: The created ReportInstance - """ - return self._proxy.create( - insights_v2_create_account_report_request=insights_v2_create_account_report_request, - ) - - async def create_async( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> "ReportInstance": - """ - Asynchronous coroutine to create the ReportInstance - - :param insights_v2_create_account_report_request: - - :returns: The created ReportInstance - """ - return await self._proxy.create_async( - insights_v2_create_account_report_request=insights_v2_create_account_report_request, - ) - - def create_with_http_info( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Create the ReportInstance with HTTP info - - :param insights_v2_create_account_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - return self._proxy.create_with_http_info( - insights_v2_create_account_report_request=insights_v2_create_account_report_request, - ) - - async def create_with_http_info_async( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronous coroutine to create the ReportInstance with HTTP info - - :param insights_v2_create_account_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - return await self._proxy.create_with_http_info_async( - insights_v2_create_account_report_request=insights_v2_create_account_report_request, - ) - def fetch(self) -> "ReportInstance": """ Fetch the ReportInstance @@ -894,7 +844,13 @@ def __init__(self, payload: Dict[str, Any]): self.outbound_carrier_calling: Optional[ AccountReportKYTOutboundCarrierCalling - ] = payload.get("outbound_carrier_calling") + ] = ( + AccountReportKYTOutboundCarrierCalling( + payload.get("outbound_carrier_calling") + ) + if payload.get("outbound_carrier_calling") is not None + else None + ) def to_dict(self): return { @@ -927,7 +883,12 @@ def __init__(self, payload: Dict[str, Any]): "unique_called_numbers" ) self.blocked_calls_by_carrier: Optional[List[CountyCarrierValue]] = ( - payload.get("blocked_calls_by_carrier") + [ + CountyCarrierValue(item) if isinstance(item, dict) else item + for item in payload.get("blocked_calls_by_carrier") + ] + if payload.get("blocked_calls_by_carrier") is not None + else None ) self.short_duration_calls_percentage: Optional[float] = payload.get( "short_duration_calls_percentage" @@ -938,13 +899,21 @@ def __init__(self, payload: Dict[str, Any]): self.potential_robocalls_percentage: Optional[float] = payload.get( "potential_robocalls_percentage" ) - self.branded_calling: Optional[BrandedCalling] = payload.get( - "branded_calling" + self.branded_calling: Optional[BrandedCalling] = ( + BrandedCalling(payload.get("branded_calling")) + if payload.get("branded_calling") is not None + else None ) - self.voice_integrity: Optional[VoiceIntegrity] = payload.get( - "voice_integrity" + self.voice_integrity: Optional[VoiceIntegrity] = ( + VoiceIntegrity(payload.get("voice_integrity")) + if payload.get("voice_integrity") is not None + else None + ) + self.stir_shaken: Optional[StirShaken] = ( + StirShaken(payload.get("stir_shaken")) + if payload.get("stir_shaken") is not None + else None ) - self.stir_shaken: Optional[StirShaken] = payload.get("stir_shaken") def to_dict(self): return { @@ -984,9 +953,15 @@ class AccountReportNetworkIssues(object): def __init__(self, payload: Dict[str, Any]): - self.sdk: Optional[AccountReportNetworkIssuesSdk] = payload.get("sdk") + self.sdk: Optional[AccountReportNetworkIssuesSdk] = ( + AccountReportNetworkIssuesSdk(payload.get("sdk")) + if payload.get("sdk") is not None + else None + ) self.twilio_gateway: Optional[AccountReportNetworkIssuesTwilioGateway] = ( - payload.get("twilio_gateway") + AccountReportNetworkIssuesTwilioGateway(payload.get("twilio_gateway")) + if payload.get("twilio_gateway") is not None + else None ) def to_dict(self): @@ -1075,8 +1050,13 @@ def __init__(self, payload: Dict[str, Any]): self.answer_rate: Optional[float] = payload.get("answer_rate") self.human_answer_rate: Optional[float] = payload.get("human_answer_rate") self.engagement_rate: Optional[float] = payload.get("engagement_rate") - self.by_use_case: Optional[List[BrandedUseCaseDetail]] = payload.get( - "by_use_case" + self.by_use_case: Optional[List[BrandedUseCaseDetail]] = ( + [ + BrandedUseCaseDetail(item) if isinstance(item, dict) else item + for item in payload.get("by_use_case") + ] + if payload.get("by_use_case") is not None + else None ) def to_dict(self): @@ -1159,9 +1139,20 @@ def __init__(self, payload: Dict[str, Any]): self.time_range: Optional[ ReportList.InsightsV2CreateAccountReportRequestTimeRange - ] = payload.get("time_range") - self.filters: Optional[List[ReportList.ReportFilter]] = payload.get( - "filters" + ] = ( + ReportList.InsightsV2CreateAccountReportRequestTimeRange( + payload.get("time_range") + ) + if payload.get("time_range") is not None + else None + ) + self.filters: Optional[List[ReportList.ReportFilter]] = ( + [ + ReportList.ReportFilter(item) if isinstance(item, dict) else item + for item in payload.get("filters") + ] + if payload.get("filters") is not None + else None ) def to_dict(self): @@ -1219,10 +1210,20 @@ class StirShaken(object): def __init__(self, payload: Dict[str, Any]): - self.call_count: Optional[StirShakenCallCount] = payload.get("call_count") - self.percentage: Optional[StirShakenPercentage] = payload.get("percentage") - self.answer_rate: Optional[StirShakenAnswerRate] = payload.get( - "answer_rate" + self.call_count: Optional[StirShakenCallCount] = ( + StirShakenCallCount(payload.get("call_count")) + if payload.get("call_count") is not None + else None + ) + self.percentage: Optional[StirShakenPercentage] = ( + StirShakenPercentage(payload.get("percentage")) + if payload.get("percentage") is not None + else None + ) + self.answer_rate: Optional[StirShakenAnswerRate] = ( + StirShakenAnswerRate(payload.get("answer_rate")) + if payload.get("answer_rate") is not None + else None ) def to_dict(self): @@ -1310,7 +1311,16 @@ def __init__(self, payload: Dict[str, Any]): self.enabled_calls: Optional[int] = payload.get("enabled_calls") self.enabled_percentage: Optional[float] = payload.get("enabled_percentage") self.calls_per_bundle: Optional[List[VoiceIntegrityCallsPerBundle]] = ( - payload.get("calls_per_bundle") + [ + ( + VoiceIntegrityCallsPerBundle(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("calls_per_bundle") + ] + if payload.get("calls_per_bundle") is not None + else None ) def to_dict(self): @@ -1370,136 +1380,6 @@ def __init__(self, version: Version, report_id: str): } self._uri = "/Voice/Reports/{report_id}".format(**self._solution) - def _create( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_account_report_request.to_dict() - - headers = values.of({}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return self._version.create_with_response_info( - method="POST", uri=self._uri, data=data, headers=headers - ) - - def create( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> ReportInstance: - """ - Create the ReportInstance - - :param insights_v2_create_account_report_request: - - :returns: The created ReportInstance - """ - payload, _, _ = self._create( - insights_v2_create_account_report_request=insights_v2_create_account_report_request - ) - return ReportInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - def create_with_http_info( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Create the ReportInstance and return response metadata - - :param insights_v2_create_account_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create( - insights_v2_create_account_report_request=insights_v2_create_account_report_request - ) - instance = ReportInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _create_async( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal async helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_v2_create_account_report_request.to_dict() - - headers = values.of({}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - async def create_async( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> ReportInstance: - """ - Asynchronous coroutine to create the ReportInstance - - :param insights_v2_create_account_report_request: - - :returns: The created ReportInstance - """ - payload, _, _ = await self._create_async( - insights_v2_create_account_report_request=insights_v2_create_account_report_request - ) - return ReportInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - - async def create_with_http_info_async( - self, - insights_v2_create_account_report_request: Union[ - InsightsV2CreateAccountReportRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronous coroutine to create the ReportInstance and return response metadata - - :param insights_v2_create_account_report_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async( - insights_v2_create_account_report_request=insights_v2_create_account_report_request - ) - instance = ReportInstance( - self._version, payload, report_id=self._solution["report_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - def _fetch(self) -> tuple: """ Internal helper for fetch operation @@ -1704,7 +1584,13 @@ def __init__(self, payload: Dict[str, Any]): self.outbound_carrier_calling: Optional[ AccountReportKYTOutboundCarrierCalling - ] = payload.get("outbound_carrier_calling") + ] = ( + AccountReportKYTOutboundCarrierCalling( + payload.get("outbound_carrier_calling") + ) + if payload.get("outbound_carrier_calling") is not None + else None + ) def to_dict(self): return { @@ -1737,7 +1623,12 @@ def __init__(self, payload: Dict[str, Any]): "unique_called_numbers" ) self.blocked_calls_by_carrier: Optional[List[CountyCarrierValue]] = ( - payload.get("blocked_calls_by_carrier") + [ + CountyCarrierValue(item) if isinstance(item, dict) else item + for item in payload.get("blocked_calls_by_carrier") + ] + if payload.get("blocked_calls_by_carrier") is not None + else None ) self.short_duration_calls_percentage: Optional[float] = payload.get( "short_duration_calls_percentage" @@ -1748,13 +1639,21 @@ def __init__(self, payload: Dict[str, Any]): self.potential_robocalls_percentage: Optional[float] = payload.get( "potential_robocalls_percentage" ) - self.branded_calling: Optional[BrandedCalling] = payload.get( - "branded_calling" + self.branded_calling: Optional[BrandedCalling] = ( + BrandedCalling(payload.get("branded_calling")) + if payload.get("branded_calling") is not None + else None ) - self.voice_integrity: Optional[VoiceIntegrity] = payload.get( - "voice_integrity" + self.voice_integrity: Optional[VoiceIntegrity] = ( + VoiceIntegrity(payload.get("voice_integrity")) + if payload.get("voice_integrity") is not None + else None + ) + self.stir_shaken: Optional[StirShaken] = ( + StirShaken(payload.get("stir_shaken")) + if payload.get("stir_shaken") is not None + else None ) - self.stir_shaken: Optional[StirShaken] = payload.get("stir_shaken") def to_dict(self): return { @@ -1794,9 +1693,15 @@ class AccountReportNetworkIssues(object): def __init__(self, payload: Dict[str, Any]): - self.sdk: Optional[AccountReportNetworkIssuesSdk] = payload.get("sdk") + self.sdk: Optional[AccountReportNetworkIssuesSdk] = ( + AccountReportNetworkIssuesSdk(payload.get("sdk")) + if payload.get("sdk") is not None + else None + ) self.twilio_gateway: Optional[AccountReportNetworkIssuesTwilioGateway] = ( - payload.get("twilio_gateway") + AccountReportNetworkIssuesTwilioGateway(payload.get("twilio_gateway")) + if payload.get("twilio_gateway") is not None + else None ) def to_dict(self): @@ -1885,8 +1790,13 @@ def __init__(self, payload: Dict[str, Any]): self.answer_rate: Optional[float] = payload.get("answer_rate") self.human_answer_rate: Optional[float] = payload.get("human_answer_rate") self.engagement_rate: Optional[float] = payload.get("engagement_rate") - self.by_use_case: Optional[List[BrandedUseCaseDetail]] = payload.get( - "by_use_case" + self.by_use_case: Optional[List[BrandedUseCaseDetail]] = ( + [ + BrandedUseCaseDetail(item) if isinstance(item, dict) else item + for item in payload.get("by_use_case") + ] + if payload.get("by_use_case") is not None + else None ) def to_dict(self): @@ -1969,9 +1879,20 @@ def __init__(self, payload: Dict[str, Any]): self.time_range: Optional[ ReportList.InsightsV2CreateAccountReportRequestTimeRange - ] = payload.get("time_range") - self.filters: Optional[List[ReportList.ReportFilter]] = payload.get( - "filters" + ] = ( + ReportList.InsightsV2CreateAccountReportRequestTimeRange( + payload.get("time_range") + ) + if payload.get("time_range") is not None + else None + ) + self.filters: Optional[List[ReportList.ReportFilter]] = ( + [ + ReportList.ReportFilter(item) if isinstance(item, dict) else item + for item in payload.get("filters") + ] + if payload.get("filters") is not None + else None ) def to_dict(self): @@ -2029,10 +1950,20 @@ class StirShaken(object): def __init__(self, payload: Dict[str, Any]): - self.call_count: Optional[StirShakenCallCount] = payload.get("call_count") - self.percentage: Optional[StirShakenPercentage] = payload.get("percentage") - self.answer_rate: Optional[StirShakenAnswerRate] = payload.get( - "answer_rate" + self.call_count: Optional[StirShakenCallCount] = ( + StirShakenCallCount(payload.get("call_count")) + if payload.get("call_count") is not None + else None + ) + self.percentage: Optional[StirShakenPercentage] = ( + StirShakenPercentage(payload.get("percentage")) + if payload.get("percentage") is not None + else None + ) + self.answer_rate: Optional[StirShakenAnswerRate] = ( + StirShakenAnswerRate(payload.get("answer_rate")) + if payload.get("answer_rate") is not None + else None ) def to_dict(self): @@ -2120,7 +2051,16 @@ def __init__(self, payload: Dict[str, Any]): self.enabled_calls: Optional[int] = payload.get("enabled_calls") self.enabled_percentage: Optional[float] = payload.get("enabled_percentage") self.calls_per_bundle: Optional[List[VoiceIntegrityCallsPerBundle]] = ( - payload.get("calls_per_bundle") + [ + ( + VoiceIntegrityCallsPerBundle(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("calls_per_bundle") + ] + if payload.get("calls_per_bundle") is not None + else None ) def to_dict(self): @@ -2174,6 +2114,130 @@ def __init__(self, version: Version): """ super().__init__(version) + self._uri = "/Voice/Reports" + + def _create( + self, + insights_v2_create_account_report_request: Union[ + InsightsV2CreateAccountReportRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = insights_v2_create_account_report_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return self._version.create_with_response_info( + method="POST", uri=self._uri, data=data, headers=headers + ) + + def create( + self, + insights_v2_create_account_report_request: Union[ + InsightsV2CreateAccountReportRequest, object + ] = values.unset, + ) -> ReportInstance: + """ + Create the ReportInstance + + :param insights_v2_create_account_report_request: + + :returns: The created ReportInstance + """ + payload, _, _ = self._create( + insights_v2_create_account_report_request=insights_v2_create_account_report_request + ) + return ReportInstance(self._version, payload) + + def create_with_http_info( + self, + insights_v2_create_account_report_request: Union[ + InsightsV2CreateAccountReportRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Create the ReportInstance and return response metadata + + :param insights_v2_create_account_report_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create( + insights_v2_create_account_report_request=insights_v2_create_account_report_request + ) + instance = ReportInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async( + self, + insights_v2_create_account_report_request: Union[ + InsightsV2CreateAccountReportRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = insights_v2_create_account_report_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return await self._version.create_with_response_info_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + async def create_async( + self, + insights_v2_create_account_report_request: Union[ + InsightsV2CreateAccountReportRequest, object + ] = values.unset, + ) -> ReportInstance: + """ + Asynchronously create the ReportInstance + + :param insights_v2_create_account_report_request: + + :returns: The created ReportInstance + """ + payload, _, _ = await self._create_async( + insights_v2_create_account_report_request=insights_v2_create_account_report_request + ) + return ReportInstance(self._version, payload) + + async def create_with_http_info_async( + self, + insights_v2_create_account_report_request: Union[ + InsightsV2CreateAccountReportRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronously create the ReportInstance and return response metadata + + :param insights_v2_create_account_report_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async( + insights_v2_create_account_report_request=insights_v2_create_account_report_request + ) + instance = ReportInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + def get(self, report_id: str) -> ReportContext: """ Constructs a ReportContext diff --git a/twilio/rest/insights/v3/__init__.py b/twilio/rest/insights/v3/__init__.py index 293980816..8562e01d7 100644 --- a/twilio/rest/insights/v3/__init__.py +++ b/twilio/rest/insights/v3/__init__.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio - Insights - Insights Domain V3 API. Includes synchronous Query, Metadata, and Async Query (long-running operation) endpoints. + The Twilio Insights v3 API provides semantic query access to Conversations analytics data. Resources include synchronous Query, Metadata, and asynchronous QueryJobs for long-running queries. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech @@ -17,7 +17,6 @@ from twilio.base.domain import Domain from twilio.rest.insights.v3.metadata import MetadataList from twilio.rest.insights.v3.query import QueryList -from twilio.rest.insights.v3.query_job import QueryJobList class V3(Version): @@ -31,7 +30,6 @@ def __init__(self, domain: Domain): super().__init__(domain, "v3") self._metadata: Optional[MetadataList] = None self._query: Optional[QueryList] = None - self._query_jobs: Optional[QueryJobList] = None @property def metadata(self) -> MetadataList: @@ -45,12 +43,6 @@ def query(self) -> QueryList: self._query = QueryList(self) return self._query - @property - def query_jobs(self) -> QueryJobList: - if self._query_jobs is None: - self._query_jobs = QueryJobList(self) - return self._query_jobs - def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/insights/v3/metadata.py b/twilio/rest/insights/v3/metadata.py index 30e8d8f11..93857fd90 100644 --- a/twilio/rest/insights/v3/metadata.py +++ b/twilio/rest/insights/v3/metadata.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio - Insights - Insights Domain V3 API. Includes synchronous Query, Metadata, and Async Query (long-running operation) endpoints. + The Twilio Insights v3 API provides semantic query access to Conversations analytics data. Resources include synchronous Query, Metadata, and asynchronous QueryJobs for long-running queries. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech diff --git a/twilio/rest/insights/v3/query.py b/twilio/rest/insights/v3/query.py index b65b0aaec..e4c95921a 100644 --- a/twilio/rest/insights/v3/query.py +++ b/twilio/rest/insights/v3/query.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio - Insights - Insights Domain V3 API. Includes synchronous Query, Metadata, and Async Query (long-running operation) endpoints. + The Twilio Insights v3 API provides semantic query access to Conversations analytics data. Resources include synchronous Query, Metadata, and asynchronous QueryJobs for long-running queries. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech @@ -58,7 +58,11 @@ class InsightsQueryRequest(object): def __init__(self, payload: Dict[str, Any]): self.domain: Optional[str] = payload.get("domain") - self.query: Optional[QueryList.QueryDefinition] = payload.get("query") + self.query: Optional[QueryList.QueryDefinition] = ( + QueryList.QueryDefinition(payload.get("query")) + if payload.get("query") is not None + else None + ) def to_dict(self): return { @@ -79,10 +83,28 @@ def __init__(self, payload: Dict[str, Any]): self.measures: Optional[List[str]] = payload.get("measures") self.dimensions: Optional[List[str]] = payload.get("dimensions") self.filters: Optional[List[QueryList.QueryDefinitionFilters]] = ( - payload.get("filters") + [ + ( + QueryList.QueryDefinitionFilters(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("filters") + ] + if payload.get("filters") is not None + else None ) self.order_by: Optional[List[QueryList.QueryDefinitionOrderBy]] = ( - payload.get("orderBy") + [ + ( + QueryList.QueryDefinitionOrderBy(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("orderBy") + ] + if payload.get("orderBy") is not None + else None ) def to_dict(self): @@ -112,7 +134,18 @@ def __init__(self, payload: Dict[str, Any]): self.op: Optional["QueryInstance.str"] = payload.get("op") self.expressions: Optional[ List[QueryList.QueryDefinitionFiltersExpressions] - ] = payload.get("expressions") + ] = ( + [ + ( + QueryList.QueryDefinitionFiltersExpressions(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("expressions") + ] + if payload.get("expressions") is not None + else None + ) def to_dict(self): return { diff --git a/twilio/rest/insights/v3/query_job.py b/twilio/rest/insights/v3/query_job.py deleted file mode 100644 index 893dce976..000000000 --- a/twilio/rest/insights/v3/query_job.py +++ /dev/null @@ -1,1004 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Insights - Insights Domain V3 API. Includes synchronous Query, Metadata, and Async Query (long-running operation) endpoints. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - -from __future__ import annotations - -from datetime import datetime -from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator -from twilio.base import deserialize, values -from twilio.base.api_response import ApiResponse -from twilio.base.instance_context import InstanceContext -from twilio.base.instance_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version -from twilio.base.token_pagination import TokenPagination - - -class QueryJobInstance(InstanceResource): - - class LongRunningOperationStatus(object): - PENDING = "PENDING" - RUNNING = "RUNNING" - CANCELLED = "CANCELLED" - COMPLETED = "COMPLETED" - FAILED = "FAILED" - - """ - :ivar operation_id: - :ivar status: - :ivar status_url: - :ivar created_at: - :ivar completed_at: When the operation reached a terminal state. - :ivar error: Error details. Present only when status is FAILED. - :ivar result_url: URL to retrieve query results. Present only when status is COMPLETED. Supports pagination via pageSize and pageToken query parameters. - :ivar result_retention_period: ISO 8601 duration for how long results are retained. - """ - - def __init__( - self, - version: Version, - payload: ResponseResource, - operation_id: Optional[str] = None, - ): - super().__init__(version) - - self.operation_id: Optional[str] = payload.get("operationId") - self.status: Optional["QueryJobInstance.LongRunningOperationStatus"] = ( - payload.get("status") - ) - self.status_url: Optional[str] = payload.get("statusUrl") - self.created_at: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("createdAt") - ) - self.completed_at: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("completedAt") - ) - self.error: Optional[OperationError] = payload.get("error") - self.result_url: Optional[str] = payload.get("resultUrl") - self.result_retention_period: Optional[str] = payload.get( - "resultRetentionPeriod" - ) - - # Only set _solution if path params are provided (not None) - if operation_id is not None: - self._solution = { - "operation_id": operation_id, - } - - self._context: Optional[QueryJobContext] = None - - @property - def _proxy(self) -> "QueryJobContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: QueryJobContext for this QueryJobInstance - """ - if self._context is None: - self._context = QueryJobContext( - self._version, - operation_id=self._solution["operation_id"], - ) - return self._context - - def fetch(self) -> "QueryJobInstance": - """ - Fetch the QueryJobInstance - - - :returns: The fetched QueryJobInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "QueryJobInstance": - """ - Asynchronous coroutine to fetch the QueryJobInstance - - - :returns: The fetched QueryJobInstance - """ - return await self._proxy.fetch_async() - - def fetch_with_http_info(self) -> ApiResponse: - """ - Fetch the QueryJobInstance with HTTP info - - - :returns: ApiResponse with instance, status code, and headers - """ - return self._proxy.fetch_with_http_info() - - async def fetch_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine to fetch the QueryJobInstance with HTTP info - - - :returns: ApiResponse with instance, status code, and headers - """ - return await self._proxy.fetch_with_http_info_async() - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class QueryJobContext(InstanceContext): - - def __init__(self, version: Version, operation_id: str): - """ - Initialize the QueryJobContext - - :param version: Version that contains the resource - :param operation_id: The unique identifier for the async query operation (TTID format). - """ - super().__init__(version) - - # Path Solution - self._solution = { - "operation_id": operation_id, - } - self._uri = "/InsightsDomains/Conversations/QueryJobs/{operation_id}".format( - **self._solution - ) - - def _fetch(self) -> tuple: - """ - Internal helper for fetch operation - - Returns: - tuple: (payload, status_code, headers) - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - return self._version.fetch_with_response_info( - method="GET", uri=self._uri, headers=headers - ) - - def fetch(self) -> QueryJobInstance: - """ - Fetch the QueryJobInstance - - - :returns: The fetched QueryJobInstance - """ - payload, _, _ = self._fetch() - return QueryJobInstance( - self._version, - payload, - operation_id=self._solution["operation_id"], - ) - - def fetch_with_http_info(self) -> ApiResponse: - """ - Fetch the QueryJobInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._fetch() - instance = QueryJobInstance( - self._version, - payload, - operation_id=self._solution["operation_id"], - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _fetch_async(self) -> tuple: - """ - Internal async helper for fetch operation - - Returns: - tuple: (payload, status_code, headers) - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - return await self._version.fetch_with_response_info_async( - method="GET", uri=self._uri, headers=headers - ) - - async def fetch_async(self) -> QueryJobInstance: - """ - Asynchronous coroutine to fetch the QueryJobInstance - - - :returns: The fetched QueryJobInstance - """ - payload, _, _ = await self._fetch_async() - return QueryJobInstance( - self._version, - payload, - operation_id=self._solution["operation_id"], - ) - - async def fetch_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine to fetch the QueryJobInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._fetch_async() - instance = QueryJobInstance( - self._version, - payload, - operation_id=self._solution["operation_id"], - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class QueryJobPage(TokenPagination): - - def get_instance(self, payload: Dict[str, Any]) -> QueryJobInstance: - """ - Build an instance of QueryJobInstance - - :param payload: Payload response from the API - """ - - return QueryJobInstance(self._version, payload) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class QueryJobList(ListResource): - - class InsightsQueryRequest(object): - """ - :ivar domain: The business domain to execute the query against - :ivar query: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.domain: Optional[str] = payload.get("domain") - self.query: Optional[QueryList.QueryDefinition] = payload.get("query") - - def to_dict(self): - return { - "domain": self.domain, - "query": self.query.to_dict() if self.query is not None else None, - } - - class OperationError(object): - """ - :ivar code: Twilio-specific error code - :ivar message: A human readable error message - :ivar http_status_code: HTTP status code that would have been returned for a synchronous failure - :ivar detail: Additional context about the failure - """ - - def __init__(self, payload: Dict[str, Any]): - - self.code: Optional[int] = payload.get("code") - self.message: Optional[str] = payload.get("message") - self.http_status_code: Optional[int] = payload.get("httpStatusCode") - self.detail: Optional[str] = payload.get("detail") - - def to_dict(self): - return { - "code": self.code, - "message": self.message, - "httpStatusCode": self.http_status_code, - "detail": self.detail, - } - - class QueryDefinition(object): - """ - :ivar measures: Array of measures to retrieve, representing quantitative values or metrics to be calculated - :ivar dimensions: Array of dimensions to retrieve, representing categorical attributes for grouping and organizing data - :ivar filters: Nested filter conditions. Always use `op` and `expressions`. - :ivar order_by: Specifications for sorting the query results by specific fields in ascending or descending order - """ - - def __init__(self, payload: Dict[str, Any]): - - self.measures: Optional[List[str]] = payload.get("measures") - self.dimensions: Optional[List[str]] = payload.get("dimensions") - self.filters: Optional[List[QueryList.QueryDefinitionFilters]] = ( - payload.get("filters") - ) - self.order_by: Optional[List[QueryList.QueryDefinitionOrderBy]] = ( - payload.get("orderBy") - ) - - def to_dict(self): - return { - "measures": self.measures, - "dimensions": self.dimensions, - "filters": ( - [filters.to_dict() for filters in self.filters] - if self.filters is not None - else None - ), - "orderBy": ( - [order_by.to_dict() for order_by in self.order_by] - if self.order_by is not None - else None - ), - } - - class QueryDefinitionFilters(object): - """ - :ivar op: - :ivar expressions: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.op: Optional["QueryInstance.str"] = payload.get("op") - self.expressions: Optional[ - List[QueryList.QueryDefinitionFiltersExpressions] - ] = payload.get("expressions") - - def to_dict(self): - return { - "op": self.op, - "expressions": ( - [expressions.to_dict() for expressions in self.expressions] - if self.expressions is not None - else None - ), - } - - class QueryDefinitionFiltersExpressions(object): - """ - :ivar op: - :ivar field: - :ivar values: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.op: Optional["QueryInstance.str"] = payload.get("op") - self.field: Optional[str] = payload.get("field") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "op": self.op, - "field": self.field, - "values": self.values, - } - - class QueryDefinitionOrderBy(object): - """ - :ivar field: Dimension or measure to order by - :ivar direction: Sort order direction, ascending or descending - """ - - def __init__(self, payload: Dict[str, Any]): - - self.field: Optional[str] = payload.get("field") - self.direction: Optional["QueryInstance.str"] = payload.get("direction") - - def to_dict(self): - return { - "field": self.field, - "direction": self.direction, - } - - def __init__(self, version: Version): - """ - Initialize the QueryJobList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/InsightsDomains/Conversations/QueryJobs" - - def _create( - self, - insights_query_request: InsightsQueryRequest, - idempotency_key: Union[str, object] = values.unset, - ) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_query_request.to_dict() - - headers = values.of( - { - "Idempotency-Key": idempotency_key, - "Content-Type": "application/x-www-form-urlencoded", - } - ) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return self._version.create_with_response_info( - method="POST", uri=self._uri, data=data, headers=headers - ) - - def create( - self, - insights_query_request: InsightsQueryRequest, - idempotency_key: Union[str, object] = values.unset, - ) -> QueryJobInstance: - """ - Create the QueryJobInstance - - :param insights_query_request: - :param idempotency_key: Client-generated UUIDv7 key to ensure idempotent behavior. Submitting the same key for identical requests returns the same operation without re-execution. Scoped to Account + Region. Retained for 24 hours. - - :returns: The created QueryJobInstance - """ - payload, _, _ = self._create( - insights_query_request=insights_query_request, - idempotency_key=idempotency_key, - ) - return QueryJobInstance(self._version, payload) - - def create_with_http_info( - self, - insights_query_request: InsightsQueryRequest, - idempotency_key: Union[str, object] = values.unset, - ) -> ApiResponse: - """ - Create the QueryJobInstance and return response metadata - - :param insights_query_request: - :param idempotency_key: Client-generated UUIDv7 key to ensure idempotent behavior. Submitting the same key for identical requests returns the same operation without re-execution. Scoped to Account + Region. Retained for 24 hours. - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create( - insights_query_request=insights_query_request, - idempotency_key=idempotency_key, - ) - instance = QueryJobInstance(self._version, payload) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _create_async( - self, - insights_query_request: InsightsQueryRequest, - idempotency_key: Union[str, object] = values.unset, - ) -> tuple: - """ - Internal async helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_query_request.to_dict() - - headers = values.of( - { - "Idempotency-Key": idempotency_key, - "Content-Type": "application/x-www-form-urlencoded", - } - ) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - async def create_async( - self, - insights_query_request: InsightsQueryRequest, - idempotency_key: Union[str, object] = values.unset, - ) -> QueryJobInstance: - """ - Asynchronously create the QueryJobInstance - - :param insights_query_request: - :param idempotency_key: Client-generated UUIDv7 key to ensure idempotent behavior. Submitting the same key for identical requests returns the same operation without re-execution. Scoped to Account + Region. Retained for 24 hours. - - :returns: The created QueryJobInstance - """ - payload, _, _ = await self._create_async( - insights_query_request=insights_query_request, - idempotency_key=idempotency_key, - ) - return QueryJobInstance(self._version, payload) - - async def create_with_http_info_async( - self, - insights_query_request: InsightsQueryRequest, - idempotency_key: Union[str, object] = values.unset, - ) -> ApiResponse: - """ - Asynchronously create the QueryJobInstance and return response metadata - - :param insights_query_request: - :param idempotency_key: Client-generated UUIDv7 key to ensure idempotent behavior. Submitting the same key for identical requests returns the same operation without re-execution. Scoped to Account + Region. Retained for 24 hours. - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async( - insights_query_request=insights_query_request, - idempotency_key=idempotency_key, - ) - instance = QueryJobInstance(self._version, payload) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def stream( - self, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[QueryJobInstance]: - """ - Streams QueryJobInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = self.page( - page_token=page_token, status=status, page_size=limits["page_size"] - ) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[QueryJobInstance]: - """ - Asynchronously streams QueryJobInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = await self.page_async( - page_token=page_token, status=status, page_size=limits["page_size"] - ) - - return self._version.stream_async(page, limits["limit"]) - - def stream_with_http_info( - self, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Streams QueryJobInstance and returns headers from first page - - - :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: tuple of (generator, status_code, headers) where generator yields instances - """ - limits = self._version.read_limits(limit, page_size) - page_response = self.page_with_http_info( - page_token=page_token, status=status, page_size=limits["page_size"] - ) - - generator = self._version.stream(page_response.data, limits["limit"]) - return (generator, page_response.status_code, page_response.headers) - - async def stream_with_http_info_async( - self, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Asynchronously streams QueryJobInstance and returns headers from first page - - - :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: tuple of (generator, status_code, headers) where generator yields instances - """ - limits = self._version.read_limits(limit, page_size) - page_response = await self.page_with_http_info_async( - page_token=page_token, status=status, page_size=limits["page_size"] - ) - - generator = self._version.stream_async(page_response.data, limits["limit"]) - return (generator, page_response.status_code, page_response.headers) - - def list( - self, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[QueryJobInstance]: - """ - Lists QueryJobInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - - return list( - self.stream( - page_token=page_token, - status=status, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[QueryJobInstance]: - """ - Asynchronously lists QueryJobInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - - return [ - record - async for record in await self.stream_async( - page_token=page_token, - status=status, - limit=limit, - page_size=page_size, - ) - ] - - def list_with_http_info( - self, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Lists QueryJobInstance and returns headers from first page - - - :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: ApiResponse with list of instances, status code, and headers - """ - generator, status_code, headers = self.stream_with_http_info( - page_token=page_token, - status=status, - limit=limit, - page_size=page_size, - ) - items = list(generator) - return ApiResponse(data=items, status_code=status_code, headers=headers) - - async def list_with_http_info_async( - self, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Asynchronously lists QueryJobInstance and returns headers from first page - - - :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: ApiResponse with list of instances, status code, and headers - """ - generator, status_code, headers = await self.stream_with_http_info_async( - page_token=page_token, - status=status, - limit=limit, - page_size=page_size, - ) - items = [record async for record in generator] - return ApiResponse(data=items, status_code=status_code, headers=headers) - - def page( - self, - page_size: Union[int, object] = values.unset, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - ) -> QueryJobPage: - """ - Retrieve a single page of QueryJobInstance records from the API. - Request is executed immediately - - :param page_size: The maximum number of resources to return - :param page_token: Token for pagination - :param status: Filter by operation status. - :returns: Page of QueryJobInstance - """ - data = values.of( - { - "pageSize": page_size, - "pageToken": page_token, - "status": status, - } - ) - - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - headers["Accept"] = "application/json" - - response = self._version.page( - method="GET", uri=self._uri, params=data, headers=headers - ) - return QueryJobPage(self._version, response, uri=self._uri, params=data) - - async def page_async( - self, - page_size: Union[int, object] = values.unset, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - ) -> QueryJobPage: - """ - Asynchronously retrieve a single page of QueryJobInstance records from the API. - Request is executed immediately - - :param page_size: The maximum number of resources to return - :param page_token: Token for pagination - :param status: Filter by operation status. - :returns: Page of QueryJobInstance - """ - data = values.of( - { - "pageSize": page_size, - "pageToken": page_token, - "status": status, - } - ) - - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - headers["Accept"] = "application/json" - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data, headers=headers - ) - return QueryJobPage(self._version, response, uri=self._uri, params=data) - - def page_with_http_info( - self, - status: Union[LongRunningOperationStatus, object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> ApiResponse: - """ - Retrieve a single page with response metadata - - - :param page_token: Token for pagination - :param status: Filter by operation status. - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: ApiResponse with QueryJobPage, status code, and headers - """ - data = values.of( - { - "pageToken": page_token, - "status": status, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - headers["Accept"] = "application/json" - - response, status_code, response_headers = self._version.page_with_response_info( - method="GET", uri=self._uri, params=data, headers=headers - ) - page = QueryJobPage(self._version, response, uri=self._uri) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - async def page_with_http_info_async( - self, - status: Union[LongRunningOperationStatus, object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> ApiResponse: - """ - Asynchronously retrieve a single page with response metadata - - - :param page_token: Token for pagination - :param status: Filter by operation status. - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: ApiResponse with QueryJobPage, status code, and headers - """ - data = values.of( - { - "pageToken": page_token, - "status": status, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - headers["Accept"] = "application/json" - - response, status_code, response_headers = ( - await self._version.page_with_response_info_async( - method="GET", uri=self._uri, params=data, headers=headers - ) - ) - page = QueryJobPage(self._version, response) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - def get_page(self, target_url: str) -> QueryJobPage: - """ - Retrieve a specific page of QueryJobInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of QueryJobInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return QueryJobPage(self._version, response) - - async def get_page_async(self, target_url: str) -> QueryJobPage: - """ - Asynchronously retrieve a specific page of QueryJobInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of QueryJobInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return QueryJobPage(self._version, response) - - def get(self, operation_id: str) -> QueryJobContext: - """ - Constructs a QueryJobContext - - :param operation_id: The unique identifier for the async query operation (TTID format). - """ - return QueryJobContext(self._version, operation_id=operation_id) - - def __call__(self, operation_id: str) -> QueryJobContext: - """ - Constructs a QueryJobContext - - :param operation_id: The unique identifier for the async query operation (TTID format). - """ - return QueryJobContext(self._version, operation_id=operation_id) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/insights/v3/result.py b/twilio/rest/insights/v3/result.py deleted file mode 100644 index 239c7208d..000000000 --- a/twilio/rest/insights/v3/result.py +++ /dev/null @@ -1,208 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Insights - Insights Domain V3 API. Includes synchronous Query, Metadata, and Async Query (long-running operation) endpoints. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - -from __future__ import annotations - -from typing import Any, Dict, List, Optional, Union -from twilio.base import values -from twilio.base.api_response import ApiResponse - -from twilio.base.instance_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version - - -class ResultInstance(InstanceResource): - """ - :ivar domain: Indicates the business domain the query was executed against - :ivar items: Array of result objects containing the query results. Each object contains properties matching the requested measures and dimensions. - :ivar meta: - """ - - def __init__(self, version: Version, payload: Dict[str, Any], operation_id: str): - super().__init__(version) - - self.domain: Optional[str] = payload.get("domain") - self.items: Optional[List[Dict[str, object]]] = payload.get("items") - self.meta: Optional[str] = payload.get("meta") - - # Only set _solution if path params are provided (not None) - if operation_id is not None: - self._solution = { - "operation_id": operation_id, - } - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class ResultList(ListResource): - - def __init__(self, version: Version, operation_id: str): - """ - Initialize the ResultList - - :param version: Version that contains the resource - :param operation_id: The unique identifier for the async query operation. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "operation_id": operation_id, - } - self._uri = ( - "/InsightsDomains/Conversations/QueryJobs/{operation_id}/Results".format( - **self._solution - ) - ) - - def _fetch( - self, - page_size: Union[int, object] = values.unset, - page_token: Union[str, object] = values.unset, - ) -> tuple: - """ - Internal helper for fetch operation - - Returns: - tuple: (payload, status_code, headers) - """ - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - headers["Accept"] = "application/json" - - params = values.of( - { - "pageSize": page_size, - "pageToken": page_token, - } - ) - - return self._version.fetch_with_response_info( - method="GET", uri=self._uri, headers=headers, params=params - ) - - def fetch( - self, - page_size: Union[int, object] = values.unset, - page_token: Union[str, object] = values.unset, - ) -> ResultInstance: - """ - Fetch the ResultInstance - - :param page_size: The maximum number of resources to return:param page_token: Token for pagination - :returns: The fetched ResultInstance - """ - payload, _, _ = self._fetch(page_size=page_size, page_token=page_token) - return ResultInstance( - self._version, payload, operation_id=self._solution["operation_id"] - ) - - def fetch_with_http_info( - self, - page_size: Union[int, object] = values.unset, - page_token: Union[str, object] = values.unset, - ) -> ApiResponse: - """ - Fetch the ResultInstance and return response metadata - - :param page_size: The maximum number of resources to return:param page_token: Token for pagination - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._fetch( - page_size=page_size, page_token=page_token - ) - instance = ResultInstance( - self._version, payload, operation_id=self._solution["operation_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _fetch_async( - self, - page_size: Union[int, object] = values.unset, - page_token: Union[str, object] = values.unset, - ) -> tuple: - """ - Internal async helper for fetch operation - - Returns: - tuple: (payload, status_code, headers) - """ - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - headers["Accept"] = "application/json" - - params = values.of( - { - "pageSize": page_size, - "pageToken": page_token, - } - ) - - return await self._version.fetch_with_response_info_async( - method="GET", uri=self._uri, headers=headers, params=params - ) - - async def fetch_async( - self, - page_size: Union[int, object] = values.unset, - page_token: Union[str, object] = values.unset, - ) -> ResultInstance: - """ - Asynchronously fetch the ResultInstance - - :param page_size: The maximum number of resources to return:param page_token: Token for pagination - :returns: The fetched ResultInstance - """ - payload, _, _ = await self._fetch_async( - page_size=page_size, page_token=page_token - ) - return ResultInstance( - self._version, payload, operation_id=self._solution["operation_id"] - ) - - async def fetch_with_http_info_async( - self, - page_size: Union[int, object] = values.unset, - page_token: Union[str, object] = values.unset, - ) -> ApiResponse: - """ - Asynchronously fetch the ResultInstance and return response metadata - - :param page_size: The maximum number of resources to return:param page_token: Token for pagination - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._fetch_async( - page_size=page_size, page_token=page_token - ) - instance = ResultInstance( - self._version, payload, operation_id=self._solution["operation_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/intelligence/v3/configuration.py b/twilio/rest/intelligence/v3/configuration.py index d67f2057b..e2760e79f 100644 --- a/twilio/rest/intelligence/v3/configuration.py +++ b/twilio/rest/intelligence/v3/configuration.py @@ -573,11 +573,15 @@ class Context(object): def __init__(self, payload: Dict[str, Any]): - self.memory: Optional[ConfigurationList.ContextMemory] = payload.get( - "memory" + self.memory: Optional[ConfigurationList.ContextMemory] = ( + ConfigurationList.ContextMemory(payload.get("memory")) + if payload.get("memory") is not None + else None ) - self.knowledge: Optional[ConfigurationList.ContextKnowledge] = payload.get( - "knowledge" + self.knowledge: Optional[ConfigurationList.ContextKnowledge] = ( + ConfigurationList.ContextKnowledge(payload.get("knowledge")) + if payload.get("knowledge") is not None + else None ) def to_dict(self): @@ -628,7 +632,16 @@ def __init__(self, payload: Dict[str, Any]): self.display_name: Optional[str] = payload.get("displayName") self.description: Optional[str] = payload.get("description") self.rules: Optional[List[ConfigurationList.RuleCreationRequestPayload]] = ( - payload.get("rules") + [ + ( + ConfigurationList.RuleCreationRequestPayload(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("rules") + ] + if payload.get("rules") is not None + else None ) def to_dict(self): @@ -672,16 +685,35 @@ class RuleCreationRequestPayload(object): def __init__(self, payload: Dict[str, Any]): - self.operators: Optional[List[ConfigurationList.Operator]] = payload.get( - "operators" + self.operators: Optional[List[ConfigurationList.Operator]] = ( + [ + ConfigurationList.Operator(item) if isinstance(item, dict) else item + for item in payload.get("operators") + ] + if payload.get("operators") is not None + else None ) - self.triggers: Optional[List[ConfigurationList.Trigger]] = payload.get( - "triggers" + self.triggers: Optional[List[ConfigurationList.Trigger]] = ( + [ + ConfigurationList.Trigger(item) if isinstance(item, dict) else item + for item in payload.get("triggers") + ] + if payload.get("triggers") is not None + else None ) - self.actions: Optional[List[ConfigurationList.Action]] = payload.get( - "actions" + self.actions: Optional[List[ConfigurationList.Action]] = ( + [ + ConfigurationList.Action(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None + ) + self.context: Optional[ConfigurationList.Context] = ( + ConfigurationList.Context(payload.get("context")) + if payload.get("context") is not None + else None ) - self.context: Optional[ConfigurationList.Context] = payload.get("context") def to_dict(self): return { @@ -715,16 +747,35 @@ class RuleUpdateRequestPayload(object): def __init__(self, payload: Dict[str, Any]): self.id: Optional[str] = payload.get("id") - self.operators: Optional[List[ConfigurationList.Operator]] = payload.get( - "operators" + self.operators: Optional[List[ConfigurationList.Operator]] = ( + [ + ConfigurationList.Operator(item) if isinstance(item, dict) else item + for item in payload.get("operators") + ] + if payload.get("operators") is not None + else None + ) + self.triggers: Optional[List[ConfigurationList.Trigger]] = ( + [ + ConfigurationList.Trigger(item) if isinstance(item, dict) else item + for item in payload.get("triggers") + ] + if payload.get("triggers") is not None + else None ) - self.triggers: Optional[List[ConfigurationList.Trigger]] = payload.get( - "triggers" + self.actions: Optional[List[ConfigurationList.Action]] = ( + [ + ConfigurationList.Action(item) if isinstance(item, dict) else item + for item in payload.get("actions") + ] + if payload.get("actions") is not None + else None ) - self.actions: Optional[List[ConfigurationList.Action]] = payload.get( - "actions" + self.context: Optional[ConfigurationList.Context] = ( + ConfigurationList.Context(payload.get("context")) + if payload.get("context") is not None + else None ) - self.context: Optional[ConfigurationList.Context] = payload.get("context") def to_dict(self): return { @@ -757,7 +808,9 @@ def __init__(self, payload: Dict[str, Any]): self.on: Optional["ConfigurationInstance.str"] = payload.get("on") self.parameters: Optional[ConfigurationList.TriggerParameters] = ( - payload.get("parameters") + ConfigurationList.TriggerParameters(payload.get("parameters")) + if payload.get("parameters") is not None + else None ) def to_dict(self): @@ -794,7 +847,16 @@ def __init__(self, payload: Dict[str, Any]): self.display_name: Optional[str] = payload.get("displayName") self.description: Optional[str] = payload.get("description") self.rules: Optional[List[ConfigurationList.RuleUpdateRequestPayload]] = ( - payload.get("rules") + [ + ( + ConfigurationList.RuleUpdateRequestPayload(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("rules") + ] + if payload.get("rules") is not None + else None ) def to_dict(self): diff --git a/twilio/rest/intelligence/v3/operator.py b/twilio/rest/intelligence/v3/operator.py index cbd7499a5..47c698be3 100644 --- a/twilio/rest/intelligence/v3/operator.py +++ b/twilio/rest/intelligence/v3/operator.py @@ -631,9 +631,22 @@ def __init__(self, payload: Dict[str, Any]): ) self.training_examples: Optional[ List[OperatorList.OperatorTrainingExample] - ] = payload.get("trainingExamples") - self.context: Optional[OperatorList.OperatorContext] = payload.get( - "context" + ] = ( + [ + ( + OperatorList.OperatorTrainingExample(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("trainingExamples") + ] + if payload.get("trainingExamples") is not None + else None + ) + self.context: Optional[OperatorList.OperatorContext] = ( + OperatorList.OperatorContext(payload.get("context")) + if payload.get("context") is not None + else None ) self.parameters: Optional[Dict[str, OperatorParameter]] = payload.get( "parameters" @@ -673,11 +686,15 @@ class OperatorContext(object): def __init__(self, payload: Dict[str, Any]): - self.memory: Optional[OperatorList.OperatorContextMemory] = payload.get( - "memory" + self.memory: Optional[OperatorList.OperatorContextMemory] = ( + OperatorList.OperatorContextMemory(payload.get("memory")) + if payload.get("memory") is not None + else None ) self.knowledge: Optional[OperatorList.OperatorContextKnowledge] = ( - payload.get("knowledge") + OperatorList.OperatorContextKnowledge(payload.get("knowledge")) + if payload.get("knowledge") is not None + else None ) def to_dict(self): diff --git a/twilio/rest/knowledge/v1/knowledge/__init__.py b/twilio/rest/knowledge/v1/knowledge/__init__.py index 55395f073..568850ebc 100644 --- a/twilio/rest/knowledge/v1/knowledge/__init__.py +++ b/twilio/rest/knowledge/v1/knowledge/__init__.py @@ -46,7 +46,13 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.policy: Optional[ KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest - ] = payload.get("policy") + ] = ( + KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -107,7 +113,13 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.policy: Optional[ KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest - ] = payload.get("policy") + ] = ( + KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -364,7 +376,13 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.policy: Optional[ KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest - ] = payload.get("policy") + ] = ( + KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -425,7 +443,13 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.policy: Optional[ KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest - ] = payload.get("policy") + ] = ( + KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -812,7 +836,13 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.policy: Optional[ KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest - ] = payload.get("policy") + ] = ( + KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -873,7 +903,13 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.policy: Optional[ KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest - ] = payload.get("policy") + ] = ( + KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( + payload.get("policy") + ) + if payload.get("policy") is not None + else None + ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") diff --git a/twilio/rest/knowledge/v2/knowledge.py b/twilio/rest/knowledge/v2/knowledge.py index dc40d54a9..393c64e79 100644 --- a/twilio/rest/knowledge/v2/knowledge.py +++ b/twilio/rest/knowledge/v2/knowledge.py @@ -630,8 +630,10 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.description: Optional[str] = payload.get("description") - self.source: Optional[KnowledgeList.KnowledgeSourceTypes] = payload.get( - "source" + self.source: Optional[KnowledgeList.KnowledgeSourceTypes] = ( + KnowledgeList.KnowledgeSourceTypes(payload.get("source")) + if payload.get("source") is not None + else None ) def to_dict(self): @@ -641,6 +643,61 @@ def to_dict(self): "source": self.source.to_dict() if self.source is not None else None, } + class KnowledgeErrorGroup(object): + """ + :ivar title: The error type or reason (e.g., \"404 Not Found\", \"500 Internal Server Error\"). + :ivar instances: Array of error instances for this error title. Required when an error group is present. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.title: Optional[str] = payload.get("title") + self.instances: Optional[List[KnowledgeList.KnowledgeErrorInstance]] = ( + [ + ( + KnowledgeList.KnowledgeErrorInstance(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("instances") + ] + if payload.get("instances") is not None + else None + ) + + def to_dict(self): + return { + "title": self.title, + "instances": ( + [instances.to_dict() for instances in self.instances] + if self.instances is not None + else None + ), + } + + class KnowledgeErrorInstance(object): + """ + :ivar type: A URI reference identifying the problem type, resolving to human-readable documentation (e.g., https://www.twilio.com/docs/api/errors/420018). + :ivar code: Twilio-specific numeric error code for programmatic handling. + :ivar instance: The specific URL or resource that caused the error. + :ivar detail: Detailed explanation of the error. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.type: Optional[str] = payload.get("type") + self.code: Optional[int] = payload.get("code") + self.instance: Optional[str] = payload.get("instance") + self.detail: Optional[str] = payload.get("detail") + + def to_dict(self): + return { + "type": self.type, + "code": self.code, + "instance": self.instance, + "detail": self.detail, + } + class KnowledgeSourceTypes(object): """ :ivar type: Raw text knowledge sources @@ -648,6 +705,7 @@ class KnowledgeSourceTypes(object): :ivar url: The URL to crawl for web content :ivar crawl_depth: The maximum depth to crawl from the source URL :ivar crawl_period: Frequency of re-crawling the website for updated content + :ivar errors: Processing errors encountered during web crawling, grouped by title. Array of error groups, where each group has a title and list of error instances. Only present when crawl errors occurred. :ivar file_name: Name of the file to be uploaded :ivar file_size: Expected size of the file in bytes :ivar mime_type: @@ -664,6 +722,18 @@ def __init__(self, payload: Dict[str, Any]): self.crawl_period: Optional["KnowledgeInstance.str"] = payload.get( "crawlPeriod" ) + self.errors: Optional[List[KnowledgeList.KnowledgeErrorGroup]] = ( + [ + ( + KnowledgeList.KnowledgeErrorGroup(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("errors") + ] + if payload.get("errors") is not None + else None + ) self.file_name: Optional[str] = payload.get("fileName") self.file_size: Optional[int] = payload.get("fileSize") self.mime_type: Optional["KnowledgeInstance.SupportedFileMimeType"] = ( @@ -679,6 +749,11 @@ def to_dict(self): "url": self.url, "crawlDepth": self.crawl_depth, "crawlPeriod": self.crawl_period, + "errors": ( + [errors.to_dict() for errors in self.errors] + if self.errors is not None + else None + ), "fileName": self.file_name, "fileSize": self.file_size, "mimeType": self.mime_type, diff --git a/twilio/rest/lookups/v2/query.py b/twilio/rest/lookups/v2/query.py index 1bb3ff6cc..6b25d7e07 100644 --- a/twilio/rest/lookups/v2/query.py +++ b/twilio/rest/lookups/v2/query.py @@ -107,13 +107,19 @@ def __init__(self, payload: Dict[str, Any]): self.fields: Optional[List[Enumstr]] = payload.get("fields") self.country_code: Optional[str] = payload.get("country_code") self.identity_match: Optional[QueryList.IdentityMatchParameters] = ( - payload.get("identity_match") + QueryList.IdentityMatchParameters(payload.get("identity_match")) + if payload.get("identity_match") is not None + else None ) self.reassigned_number: Optional[QueryList.ReassignedNumberParameters] = ( - payload.get("reassigned_number") + QueryList.ReassignedNumberParameters(payload.get("reassigned_number")) + if payload.get("reassigned_number") is not None + else None ) - self.sms_pumping_risk: Optional[QueryList.RiskParameters] = payload.get( - "sms_pumping_risk" + self.sms_pumping_risk: Optional[QueryList.RiskParameters] = ( + QueryList.RiskParameters(payload.get("sms_pumping_risk")) + if payload.get("sms_pumping_risk") is not None + else None ) def to_dict(self): @@ -147,7 +153,16 @@ class LookupRequest(object): def __init__(self, payload: Dict[str, Any]): self.phone_numbers: Optional[List[QueryList.LookupBatchRequest]] = ( - payload.get("phone_numbers") + [ + ( + QueryList.LookupBatchRequest(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("phone_numbers") + ] + if payload.get("phone_numbers") is not None + else None ) def to_dict(self): @@ -291,13 +306,19 @@ def __init__(self, payload: Dict[str, Any]): self.fields: Optional[List[Enumstr]] = payload.get("fields") self.country_code: Optional[str] = payload.get("country_code") self.identity_match: Optional[QueryList.IdentityMatchParameters] = ( - payload.get("identity_match") + QueryList.IdentityMatchParameters(payload.get("identity_match")) + if payload.get("identity_match") is not None + else None ) self.reassigned_number: Optional[QueryList.ReassignedNumberParameters] = ( - payload.get("reassigned_number") + QueryList.ReassignedNumberParameters(payload.get("reassigned_number")) + if payload.get("reassigned_number") is not None + else None ) - self.sms_pumping_risk: Optional[QueryList.RiskParameters] = payload.get( - "sms_pumping_risk" + self.sms_pumping_risk: Optional[QueryList.RiskParameters] = ( + QueryList.RiskParameters(payload.get("sms_pumping_risk")) + if payload.get("sms_pumping_risk") is not None + else None ) def to_dict(self): @@ -331,7 +352,16 @@ class LookupRequest(object): def __init__(self, payload: Dict[str, Any]): self.phone_numbers: Optional[List[QueryList.LookupBatchRequest]] = ( - payload.get("phone_numbers") + [ + ( + QueryList.LookupBatchRequest(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("phone_numbers") + ] + if payload.get("phone_numbers") is not None + else None ) def to_dict(self): diff --git a/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_usage.py b/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_usage.py index 9a2a66844..cf615ac8d 100644 --- a/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_usage.py +++ b/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_usage.py @@ -38,7 +38,20 @@ def __init__(self, payload: Dict[str, Any]): List[ InstalledAddOnUsageList.MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems ] - ] = payload.get("billable_items") + ] = ( + [ + ( + InstalledAddOnUsageList.MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("billable_items") + ] + if payload.get("billable_items") is not None + else None + ) def to_dict(self): return { @@ -83,9 +96,11 @@ def __init__( self.total_submitted: Optional[float] = deserialize.decimal( payload.get("total_submitted") ) - self.billable_items: Optional[List[InstalledAddOnUsageList.str]] = payload.get( - "billable_items" - ) + self.billable_items: Optional[ + List[ + InstalledAddOnUsageList.MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems + ] + ] = payload.get("billable_items") self._solution = { "installed_add_on_sid": installed_add_on_sid, @@ -118,7 +133,20 @@ def __init__(self, payload: Dict[str, Any]): List[ InstalledAddOnUsageList.MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems ] - ] = payload.get("billable_items") + ] = ( + [ + ( + InstalledAddOnUsageList.MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("billable_items") + ] + if payload.get("billable_items") is not None + else None + ) def to_dict(self): return { diff --git a/twilio/rest/memory/v1/bulk.py b/twilio/rest/memory/v1/bulk.py index eb7794584..62d552937 100644 --- a/twilio/rest/memory/v1/bulk.py +++ b/twilio/rest/memory/v1/bulk.py @@ -72,8 +72,13 @@ class UpdateProfilesBulkRequest(object): def __init__(self, payload: Dict[str, Any]): - self.profiles: Optional[List[BulkList.ProfileData]] = payload.get( - "profiles" + self.profiles: Optional[List[BulkList.ProfileData]] = ( + [ + BulkList.ProfileData(item) if isinstance(item, dict) else item + for item in payload.get("profiles") + ] + if payload.get("profiles") is not None + else None ) def to_dict(self): diff --git a/twilio/rest/memory/v1/conversation_summary.py b/twilio/rest/memory/v1/conversation_summary.py index 7f95b1beb..fc6eefaab 100644 --- a/twilio/rest/memory/v1/conversation_summary.py +++ b/twilio/rest/memory/v1/conversation_summary.py @@ -557,7 +557,16 @@ class CreateSummariesRequest(object): def __init__(self, payload: Dict[str, Any]): self.summaries: Optional[List[ConversationSummaryList.SummaryCore]] = ( - payload.get("summaries") + [ + ( + ConversationSummaryList.SummaryCore(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("summaries") + ] + if payload.get("summaries") is not None + else None ) def to_dict(self): diff --git a/twilio/rest/memory/v1/data_mapping.py b/twilio/rest/memory/v1/data_mapping.py index 8cefd6789..570cf6429 100644 --- a/twilio/rest/memory/v1/data_mapping.py +++ b/twilio/rest/memory/v1/data_mapping.py @@ -28,8 +28,9 @@ class DataMappingInstance(InstanceResource): class DataMappingType(object): - CSV = "CSV" - DATASET = "DATASET" + INGRESS = "INGRESS" + DATASET_CLOUDAPP = "DATASET_CLOUDAPP" + DATASET_WAREHOUSE = "DATASET_WAREHOUSE" """ :ivar message: @@ -601,10 +602,14 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.is_enabled: Optional[bool] = payload.get("isEnabled") self.mapping_to: Optional[DataMappingList.DataMappingToTraits] = ( - payload.get("mappingTo") + DataMappingList.DataMappingToTraits(payload.get("mappingTo")) + if payload.get("mappingTo") is not None + else None ) self.mapping_from: Optional[DataMappingList.DataMappingFromTypes] = ( - payload.get("mappingFrom") + DataMappingList.DataMappingFromTypes(payload.get("mappingFrom")) + if payload.get("mappingFrom") is not None + else None ) def to_dict(self): @@ -636,7 +641,9 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.is_enabled: Optional[bool] = payload.get("isEnabled") self.mapping_to: Optional[DataMappingList.DataMappingToTraits] = ( - payload.get("mappingTo") + DataMappingList.DataMappingToTraits(payload.get("mappingTo")) + if payload.get("mappingTo") is not None + else None ) def to_dict(self): @@ -652,7 +659,7 @@ def to_dict(self): class DataMappingFromTypes(object): """ :ivar type: The source data type, which determines the source of the data and the required configuration parameters. - :ivar columns: The list of CSV column names that serve as the source fields. + :ivar columns: The list of ingress column names that serve as the source fields. :ivar dataset_id: The unique identifier of the TDI dataset to connect. """ @@ -679,7 +686,16 @@ def __init__(self, payload: Dict[str, Any]): self.type: Optional["DataMappingInstance.str"] = payload.get("type") self.mappings: Optional[List[DataMappingList.MappingTraitItem]] = ( - payload.get("mappings") + [ + ( + DataMappingList.MappingTraitItem(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("mappings") + ] + if payload.get("mappings") is not None + else None ) def to_dict(self): diff --git a/twilio/rest/memory/v1/identity_resolution_setting.py b/twilio/rest/memory/v1/identity_resolution_setting.py index 6c1ea4439..09294a418 100644 --- a/twilio/rest/memory/v1/identity_resolution_setting.py +++ b/twilio/rest/memory/v1/identity_resolution_setting.py @@ -107,7 +107,18 @@ def __init__(self, payload: Dict[str, Any]): self.identifier_configs: Optional[ List[IdentityResolutionSettingList.IdentifierConfig] - ] = payload.get("identifierConfigs") + ] = ( + [ + ( + IdentityResolutionSettingList.IdentifierConfig(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("identifierConfigs") + ] + if payload.get("identifierConfigs") is not None + else None + ) self.matching_rules: Optional[List[str]] = payload.get("matchingRules") def to_dict(self): diff --git a/twilio/rest/memory/v1/import_.py b/twilio/rest/memory/v1/import_.py index 3c30af4c5..9c2c0d20e 100644 --- a/twilio/rest/memory/v1/import_.py +++ b/twilio/rest/memory/v1/import_.py @@ -319,7 +319,16 @@ def __init__(self, payload: Dict[str, Any]): self.filename: Optional[str] = payload.get("filename") self.file_size: Optional[int] = payload.get("fileSize") self.column_mappings: Optional[List[ImportList.ColumnMappingItem]] = ( - payload.get("columnMappings") + [ + ( + ImportList.ColumnMappingItem(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("columnMappings") + ] + if payload.get("columnMappings") is not None + else None ) def to_dict(self): diff --git a/twilio/rest/memory/v1/observation.py b/twilio/rest/memory/v1/observation.py index 3f61682c7..99095a19a 100644 --- a/twilio/rest/memory/v1/observation.py +++ b/twilio/rest/memory/v1/observation.py @@ -552,7 +552,18 @@ def __init__(self, payload: Dict[str, Any]): self.observations: Optional[ List[ObservationList.ObservationCreateRequest] - ] = payload.get("observations") + ] = ( + [ + ( + ObservationList.ObservationCreateRequest(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("observations") + ] + if payload.get("observations") is not None + else None + ) def to_dict(self): return { diff --git a/twilio/rest/memory/v1/recall.py b/twilio/rest/memory/v1/recall.py index ff759be74..d04f56a39 100644 --- a/twilio/rest/memory/v1/recall.py +++ b/twilio/rest/memory/v1/recall.py @@ -98,7 +98,11 @@ def __init__(self, payload: Dict[str, Any]): self.id: Optional[str] = payload.get("id") self.name: Optional[str] = payload.get("name") - self.type: Optional[ParticipantType] = payload.get("type") + self.type: Optional[ParticipantType] = ( + ParticipantType(payload.get("type")) + if payload.get("type") is not None + else None + ) self.profile_id: Optional[str] = payload.get("profileId") self.address: Optional[str] = payload.get("address") self.channel: Optional[str] = payload.get("channel") @@ -168,7 +172,11 @@ def __init__(self, payload: Dict[str, Any]): self.id: Optional[str] = payload.get("id") self.name: Optional[str] = payload.get("name") - self.type: Optional[ParticipantType] = payload.get("type") + self.type: Optional[ParticipantType] = ( + ParticipantType(payload.get("type")) + if payload.get("type") is not None + else None + ) self.profile_id: Optional[str] = payload.get("profileId") self.address: Optional[str] = payload.get("address") self.channel: Optional[str] = payload.get("channel") diff --git a/twilio/rest/memory/v1/trait_group.py b/twilio/rest/memory/v1/trait_group.py index 1412ffc70..602884c7e 100644 --- a/twilio/rest/memory/v1/trait_group.py +++ b/twilio/rest/memory/v1/trait_group.py @@ -776,8 +776,10 @@ def __init__(self, payload: Dict[str, Any]): self.data_type: Optional[str] = payload.get("dataType") self.description: Optional[str] = payload.get("description") - self.validation_rule: Optional[ValidationRule] = payload.get( - "validationRule" + self.validation_rule: Optional[ValidationRule] = ( + ValidationRule(payload.get("validationRule")) + if payload.get("validationRule") is not None + else None ) self.id_type_promotion: Optional[str] = payload.get("idTypePromotion") @@ -834,8 +836,10 @@ def __init__(self, payload: Dict[str, Any]): self.data_type: Optional[str] = payload.get("dataType") self.description: Optional[str] = payload.get("description") - self.validation_rule: Optional[ValidationRule] = payload.get( - "validationRule" + self.validation_rule: Optional[ValidationRule] = ( + ValidationRule(payload.get("validationRule")) + if payload.get("validationRule") is not None + else None ) self.id_type_promotion: Optional[str] = payload.get("idTypePromotion") @@ -889,8 +893,10 @@ def __init__(self, payload: Dict[str, Any]): self.data_type: Optional[str] = payload.get("dataType") self.description: Optional[str] = payload.get("description") - self.validation_rule: Optional[ValidationRule] = payload.get( - "validationRule" + self.validation_rule: Optional[ValidationRule] = ( + ValidationRule(payload.get("validationRule")) + if payload.get("validationRule") is not None + else None ) self.id_type_promotion: Optional[str] = payload.get("idTypePromotion") diff --git a/twilio/rest/messaging/v2/channels_sender.py b/twilio/rest/messaging/v2/channels_sender.py index 603a4c7ed..711b84625 100644 --- a/twilio/rest/messaging/v2/channels_sender.py +++ b/twilio/rest/messaging/v2/channels_sender.py @@ -181,13 +181,31 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.configuration: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderConfiguration - ] = payload.get("configuration") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook - ] = payload.get("webhook") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderWebhook( + payload.get("webhook") + ) + if payload.get("webhook") is not None + else None + ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile - ] = payload.get("profile") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderProfile( + payload.get("profile") + ) + if payload.get("profile") is not None + else None + ) def to_dict(self): return { @@ -215,13 +233,31 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.configuration: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderConfiguration - ] = payload.get("configuration") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook - ] = payload.get("webhook") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderWebhook( + payload.get("webhook") + ) + if payload.get("webhook") is not None + else None + ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile - ] = payload.get("profile") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderProfile( + payload.get("profile") + ) + if payload.get("profile") is not None + else None + ) def to_dict(self): return { @@ -279,7 +315,11 @@ class MessagingV2RcsCarrier(object): def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") - self.status: Optional[MessagingV2RcsCarrierStatus] = payload.get("status") + self.status: Optional[MessagingV2RcsCarrierStatus] = ( + MessagingV2RcsCarrierStatus(payload.get("status")) + if payload.get("status") is not None + else None + ) def to_dict(self): return { @@ -299,9 +339,18 @@ def __init__(self, payload: Dict[str, Any]): self.country: Optional[str] = payload.get("country") self.registration_sid: Optional[str] = payload.get("registration_sid") - self.status: Optional[MessagingV2RcsCountryStatus] = payload.get("status") - self.carriers: Optional[List[MessagingV2RcsCarrier]] = payload.get( - "carriers" + self.status: Optional[MessagingV2RcsCountryStatus] = ( + MessagingV2RcsCountryStatus(payload.get("status")) + if payload.get("status") is not None + else None + ) + self.carriers: Optional[List[MessagingV2RcsCarrier]] = ( + [ + MessagingV2RcsCarrier(item) if isinstance(item, dict) else item + for item in payload.get("carriers") + ] + if payload.get("carriers") is not None + else None ) def to_dict(self): @@ -702,13 +751,31 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.configuration: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderConfiguration - ] = payload.get("configuration") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook - ] = payload.get("webhook") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderWebhook( + payload.get("webhook") + ) + if payload.get("webhook") is not None + else None + ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile - ] = payload.get("profile") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderProfile( + payload.get("profile") + ) + if payload.get("profile") is not None + else None + ) def to_dict(self): return { @@ -736,13 +803,31 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.configuration: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderConfiguration - ] = payload.get("configuration") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook - ] = payload.get("webhook") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderWebhook( + payload.get("webhook") + ) + if payload.get("webhook") is not None + else None + ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile - ] = payload.get("profile") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderProfile( + payload.get("profile") + ) + if payload.get("profile") is not None + else None + ) def to_dict(self): return { @@ -800,7 +885,11 @@ class MessagingV2RcsCarrier(object): def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") - self.status: Optional[MessagingV2RcsCarrierStatus] = payload.get("status") + self.status: Optional[MessagingV2RcsCarrierStatus] = ( + MessagingV2RcsCarrierStatus(payload.get("status")) + if payload.get("status") is not None + else None + ) def to_dict(self): return { @@ -820,9 +909,18 @@ def __init__(self, payload: Dict[str, Any]): self.country: Optional[str] = payload.get("country") self.registration_sid: Optional[str] = payload.get("registration_sid") - self.status: Optional[MessagingV2RcsCountryStatus] = payload.get("status") - self.carriers: Optional[List[MessagingV2RcsCarrier]] = payload.get( - "carriers" + self.status: Optional[MessagingV2RcsCountryStatus] = ( + MessagingV2RcsCountryStatus(payload.get("status")) + if payload.get("status") is not None + else None + ) + self.carriers: Optional[List[MessagingV2RcsCarrier]] = ( + [ + MessagingV2RcsCarrier(item) if isinstance(item, dict) else item + for item in payload.get("carriers") + ] + if payload.get("carriers") is not None + else None ) def to_dict(self): @@ -1325,13 +1423,31 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.configuration: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderConfiguration - ] = payload.get("configuration") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook - ] = payload.get("webhook") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderWebhook( + payload.get("webhook") + ) + if payload.get("webhook") is not None + else None + ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile - ] = payload.get("profile") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderProfile( + payload.get("profile") + ) + if payload.get("profile") is not None + else None + ) def to_dict(self): return { @@ -1359,13 +1475,31 @@ def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.configuration: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderConfiguration - ] = payload.get("configuration") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook - ] = payload.get("webhook") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderWebhook( + payload.get("webhook") + ) + if payload.get("webhook") is not None + else None + ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile - ] = payload.get("profile") + ] = ( + ChannelsSenderList.MessagingV2ChannelsSenderProfile( + payload.get("profile") + ) + if payload.get("profile") is not None + else None + ) def to_dict(self): return { @@ -1423,7 +1557,11 @@ class MessagingV2RcsCarrier(object): def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") - self.status: Optional[MessagingV2RcsCarrierStatus] = payload.get("status") + self.status: Optional[MessagingV2RcsCarrierStatus] = ( + MessagingV2RcsCarrierStatus(payload.get("status")) + if payload.get("status") is not None + else None + ) def to_dict(self): return { @@ -1443,9 +1581,18 @@ def __init__(self, payload: Dict[str, Any]): self.country: Optional[str] = payload.get("country") self.registration_sid: Optional[str] = payload.get("registration_sid") - self.status: Optional[MessagingV2RcsCountryStatus] = payload.get("status") - self.carriers: Optional[List[MessagingV2RcsCarrier]] = payload.get( - "carriers" + self.status: Optional[MessagingV2RcsCountryStatus] = ( + MessagingV2RcsCountryStatus(payload.get("status")) + if payload.get("status") is not None + else None + ) + self.carriers: Optional[List[MessagingV2RcsCarrier]] = ( + [ + MessagingV2RcsCarrier(item) if isinstance(item, dict) else item + for item in payload.get("carriers") + ] + if payload.get("carriers") is not None + else None ) def to_dict(self): diff --git a/twilio/rest/numbers/v1/__init__.py b/twilio/rest/numbers/v1/__init__.py index a3f3cc084..59dd3d522 100644 --- a/twilio/rest/numbers/v1/__init__.py +++ b/twilio/rest/numbers/v1/__init__.py @@ -34,6 +34,10 @@ from twilio.rest.numbers.v1.signing_request_configuration import ( SigningRequestConfigurationList, ) +from twilio.rest.numbers.v1.sms_verification import SmsVerificationList +from twilio.rest.numbers.v1.sms_verification_check import SmsVerificationCheckList +from twilio.rest.numbers.v1.voice_verification import VoiceVerificationList +from twilio.rest.numbers.v1.voice_verification_check import VoiceVerificationCheckList from twilio.rest.numbers.v1.webhook import WebhookList @@ -64,6 +68,10 @@ def __init__(self, domain: Domain): self._signing_request_configurations: Optional[ SigningRequestConfigurationList ] = None + self._sms_verifications: Optional[SmsVerificationList] = None + self._sms_verification_checks: Optional[SmsVerificationCheckList] = None + self._voice_verifications: Optional[VoiceVerificationList] = None + self._voice_verification_checks: Optional[VoiceVerificationCheckList] = None self._webhook: Optional[WebhookList] = None @property @@ -144,6 +152,30 @@ def signing_request_configurations(self) -> SigningRequestConfigurationList: self._signing_request_configurations = SigningRequestConfigurationList(self) return self._signing_request_configurations + @property + def sms_verifications(self) -> SmsVerificationList: + if self._sms_verifications is None: + self._sms_verifications = SmsVerificationList(self) + return self._sms_verifications + + @property + def sms_verification_checks(self) -> SmsVerificationCheckList: + if self._sms_verification_checks is None: + self._sms_verification_checks = SmsVerificationCheckList(self) + return self._sms_verification_checks + + @property + def voice_verifications(self) -> VoiceVerificationList: + if self._voice_verifications is None: + self._voice_verifications = VoiceVerificationList(self) + return self._voice_verifications + + @property + def voice_verification_checks(self) -> VoiceVerificationCheckList: + if self._voice_verification_checks is None: + self._voice_verification_checks = VoiceVerificationCheckList(self) + return self._voice_verification_checks + @property def webhook(self) -> WebhookList: if self._webhook is None: diff --git a/twilio/rest/numbers/v1/porting_port_in.py b/twilio/rest/numbers/v1/porting_port_in.py index 53400a5fd..c27b053e4 100644 --- a/twilio/rest/numbers/v1/porting_port_in.py +++ b/twilio/rest/numbers/v1/porting_port_in.py @@ -78,7 +78,9 @@ def __init__(self, payload: Dict[str, Any]): ) self.address_sid: Optional[str] = payload.get("address_sid") self.address: Optional[PortingPortInList.NumbersV1PortingAddress] = ( - payload.get("address") + PortingPortInList.NumbersV1PortingAddress(payload.get("address")) + if payload.get("address") is not None + else None ) self.authorized_representative: Optional[str] = payload.get( "authorized_representative" @@ -133,10 +135,27 @@ def __init__(self, payload: Dict[str, Any]): self.documents: Optional[List[str]] = payload.get("documents") self.phone_numbers: Optional[ List[PortingPortInList.NumbersV1PortingPortInCreatePhoneNumbers] - ] = payload.get("phone_numbers") + ] = ( + [ + ( + PortingPortInList.NumbersV1PortingPortInCreatePhoneNumbers(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("phone_numbers") + ] + if payload.get("phone_numbers") is not None + else None + ) self.losing_carrier_information: Optional[ PortingPortInList.NumbersV1PortingLosingCarrierInformation - ] = payload.get("losing_carrier_information") + ] = ( + PortingPortInList.NumbersV1PortingLosingCarrierInformation( + payload.get("losing_carrier_information") + ) + if payload.get("losing_carrier_information") is not None + else None + ) self.notification_emails: Optional[List[str]] = payload.get( "notification_emails" ) @@ -426,7 +445,9 @@ def __init__(self, payload: Dict[str, Any]): ) self.address_sid: Optional[str] = payload.get("address_sid") self.address: Optional[PortingPortInList.NumbersV1PortingAddress] = ( - payload.get("address") + PortingPortInList.NumbersV1PortingAddress(payload.get("address")) + if payload.get("address") is not None + else None ) self.authorized_representative: Optional[str] = payload.get( "authorized_representative" @@ -481,10 +502,27 @@ def __init__(self, payload: Dict[str, Any]): self.documents: Optional[List[str]] = payload.get("documents") self.phone_numbers: Optional[ List[PortingPortInList.NumbersV1PortingPortInCreatePhoneNumbers] - ] = payload.get("phone_numbers") + ] = ( + [ + ( + PortingPortInList.NumbersV1PortingPortInCreatePhoneNumbers(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("phone_numbers") + ] + if payload.get("phone_numbers") is not None + else None + ) self.losing_carrier_information: Optional[ PortingPortInList.NumbersV1PortingLosingCarrierInformation - ] = payload.get("losing_carrier_information") + ] = ( + PortingPortInList.NumbersV1PortingLosingCarrierInformation( + payload.get("losing_carrier_information") + ) + if payload.get("losing_carrier_information") is not None + else None + ) self.notification_emails: Optional[List[str]] = payload.get( "notification_emails" ) @@ -784,7 +822,9 @@ def __init__(self, payload: Dict[str, Any]): ) self.address_sid: Optional[str] = payload.get("address_sid") self.address: Optional[PortingPortInList.NumbersV1PortingAddress] = ( - payload.get("address") + PortingPortInList.NumbersV1PortingAddress(payload.get("address")) + if payload.get("address") is not None + else None ) self.authorized_representative: Optional[str] = payload.get( "authorized_representative" @@ -839,10 +879,27 @@ def __init__(self, payload: Dict[str, Any]): self.documents: Optional[List[str]] = payload.get("documents") self.phone_numbers: Optional[ List[PortingPortInList.NumbersV1PortingPortInCreatePhoneNumbers] - ] = payload.get("phone_numbers") + ] = ( + [ + ( + PortingPortInList.NumbersV1PortingPortInCreatePhoneNumbers(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("phone_numbers") + ] + if payload.get("phone_numbers") is not None + else None + ) self.losing_carrier_information: Optional[ PortingPortInList.NumbersV1PortingLosingCarrierInformation - ] = payload.get("losing_carrier_information") + ] = ( + PortingPortInList.NumbersV1PortingLosingCarrierInformation( + payload.get("losing_carrier_information") + ) + if payload.get("losing_carrier_information") is not None + else None + ) self.notification_emails: Optional[List[str]] = payload.get( "notification_emails" ) diff --git a/twilio/rest/numbers/v1/sms_verification.py b/twilio/rest/numbers/v1/sms_verification.py new file mode 100644 index 000000000..71d0d2215 --- /dev/null +++ b/twilio/rest/numbers/v1/sms_verification.py @@ -0,0 +1,141 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Numbers + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, List, Optional +from twilio.base import values +from twilio.base.api_response import ApiResponse + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class SmsVerificationInstance(InstanceResource): + """ + :ivar to: The phone number being verified in E.164 format. + :ivar verification_sid: The unique SID of this verification resource. + :ivar send_code_attempts: An array of verification attempt objects. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.to: Optional[str] = payload.get("to") + self.verification_sid: Optional[str] = payload.get("verificationSid") + self.send_code_attempts: Optional[List[str]] = payload.get("sendCodeAttempts") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class SmsVerificationList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the SmsVerificationList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/CallerIds/SmsVerifications" + + def _create(self) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + return self._version.create_with_response_info( + method="POST", uri=self._uri, headers=headers + ) + + def create(self) -> SmsVerificationInstance: + """ + Create the SmsVerificationInstance + + + :returns: The created SmsVerificationInstance + """ + payload, _, _ = self._create() + return SmsVerificationInstance(self._version, payload) + + def create_with_http_info(self) -> ApiResponse: + """ + Create the SmsVerificationInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create() + instance = SmsVerificationInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async(self) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + return await self._version.create_with_response_info_async( + method="POST", uri=self._uri, headers=headers + ) + + async def create_async(self) -> SmsVerificationInstance: + """ + Asynchronously create the SmsVerificationInstance + + + :returns: The created SmsVerificationInstance + """ + payload, _, _ = await self._create_async() + return SmsVerificationInstance(self._version, payload) + + async def create_with_http_info_async(self) -> ApiResponse: + """ + Asynchronously create the SmsVerificationInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async() + instance = SmsVerificationInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v1/sms_verification_check.py b/twilio/rest/numbers/v1/sms_verification_check.py new file mode 100644 index 000000000..f57035319 --- /dev/null +++ b/twilio/rest/numbers/v1/sms_verification_check.py @@ -0,0 +1,143 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Numbers + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, Optional +from twilio.base import values +from twilio.base.api_response import ApiResponse + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class SmsVerificationCheckInstance(InstanceResource): + """ + :ivar to: The phone number that was verified in E.164 format. + :ivar verification_sid: The unique SID of this verification resource. + :ivar status: The status of the verification (pending, approved, canceled). + :ivar caller_id_sid: The Caller ID SID created upon successful verification. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.to: Optional[str] = payload.get("to") + self.verification_sid: Optional[str] = payload.get("verificationSid") + self.status: Optional[str] = payload.get("status") + self.caller_id_sid: Optional[str] = payload.get("callerIdSid") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class SmsVerificationCheckList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the SmsVerificationCheckList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/CallerIds/SmsVerificationChecks" + + def _create(self) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + return self._version.create_with_response_info( + method="POST", uri=self._uri, headers=headers + ) + + def create(self) -> SmsVerificationCheckInstance: + """ + Create the SmsVerificationCheckInstance + + + :returns: The created SmsVerificationCheckInstance + """ + payload, _, _ = self._create() + return SmsVerificationCheckInstance(self._version, payload) + + def create_with_http_info(self) -> ApiResponse: + """ + Create the SmsVerificationCheckInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create() + instance = SmsVerificationCheckInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async(self) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + return await self._version.create_with_response_info_async( + method="POST", uri=self._uri, headers=headers + ) + + async def create_async(self) -> SmsVerificationCheckInstance: + """ + Asynchronously create the SmsVerificationCheckInstance + + + :returns: The created SmsVerificationCheckInstance + """ + payload, _, _ = await self._create_async() + return SmsVerificationCheckInstance(self._version, payload) + + async def create_with_http_info_async(self) -> ApiResponse: + """ + Asynchronously create the SmsVerificationCheckInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async() + instance = SmsVerificationCheckInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v1/voice_verification.py b/twilio/rest/numbers/v1/voice_verification.py new file mode 100644 index 000000000..5e41647d7 --- /dev/null +++ b/twilio/rest/numbers/v1/voice_verification.py @@ -0,0 +1,145 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Numbers + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, Optional +from twilio.base import values +from twilio.base.api_response import ApiResponse + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class VoiceVerificationInstance(InstanceResource): + """ + :ivar account_sid: The Account SID that owns this verification. + :ivar phone_number: The phone number being verified in E.164 format. + :ivar friendly_name: A human-readable name for this caller ID. + :ivar validation_code: The 6-digit validation code to be entered during the call. + :ivar call_sid: The Call SID for the verification call. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("accountSid") + self.phone_number: Optional[str] = payload.get("phoneNumber") + self.friendly_name: Optional[str] = payload.get("friendlyName") + self.validation_code: Optional[str] = payload.get("validationCode") + self.call_sid: Optional[str] = payload.get("callSid") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class VoiceVerificationList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the VoiceVerificationList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/CallerIds/VoiceVerifications" + + def _create(self) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + return self._version.create_with_response_info( + method="POST", uri=self._uri, headers=headers + ) + + def create(self) -> VoiceVerificationInstance: + """ + Create the VoiceVerificationInstance + + + :returns: The created VoiceVerificationInstance + """ + payload, _, _ = self._create() + return VoiceVerificationInstance(self._version, payload) + + def create_with_http_info(self) -> ApiResponse: + """ + Create the VoiceVerificationInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create() + instance = VoiceVerificationInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async(self) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + return await self._version.create_with_response_info_async( + method="POST", uri=self._uri, headers=headers + ) + + async def create_async(self) -> VoiceVerificationInstance: + """ + Asynchronously create the VoiceVerificationInstance + + + :returns: The created VoiceVerificationInstance + """ + payload, _, _ = await self._create_async() + return VoiceVerificationInstance(self._version, payload) + + async def create_with_http_info_async(self) -> ApiResponse: + """ + Asynchronously create the VoiceVerificationInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async() + instance = VoiceVerificationInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v1/voice_verification_check.py b/twilio/rest/numbers/v1/voice_verification_check.py new file mode 100644 index 000000000..28d201e55 --- /dev/null +++ b/twilio/rest/numbers/v1/voice_verification_check.py @@ -0,0 +1,139 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Numbers + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, Optional +from twilio.base import values +from twilio.base.api_response import ApiResponse + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class VoiceVerificationCheckInstance(InstanceResource): + """ + :ivar to: The phone number that was verified in E.164 format. + :ivar caller_id_sid: The Caller ID SID created upon successful verification. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.to: Optional[str] = payload.get("to") + self.caller_id_sid: Optional[str] = payload.get("callerIdSid") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class VoiceVerificationCheckList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the VoiceVerificationCheckList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/CallerIds/VoiceVerificationChecks" + + def _create(self) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + return self._version.create_with_response_info( + method="POST", uri=self._uri, headers=headers + ) + + def create(self) -> VoiceVerificationCheckInstance: + """ + Create the VoiceVerificationCheckInstance + + + :returns: The created VoiceVerificationCheckInstance + """ + payload, _, _ = self._create() + return VoiceVerificationCheckInstance(self._version, payload) + + def create_with_http_info(self) -> ApiResponse: + """ + Create the VoiceVerificationCheckInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create() + instance = VoiceVerificationCheckInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async(self) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + return await self._version.create_with_response_info_async( + method="POST", uri=self._uri, headers=headers + ) + + async def create_async(self) -> VoiceVerificationCheckInstance: + """ + Asynchronously create the VoiceVerificationCheckInstance + + + :returns: The created VoiceVerificationCheckInstance + """ + payload, _, _ = await self._create_async() + return VoiceVerificationCheckInstance(self._version, payload) + + async def create_with_http_info_async(self) -> ApiResponse: + """ + Asynchronously create the VoiceVerificationCheckInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async() + instance = VoiceVerificationCheckInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v2/application.py b/twilio/rest/numbers/v2/application.py index 1381c1d7a..a6d30030b 100644 --- a/twilio/rest/numbers/v2/application.py +++ b/twilio/rest/numbers/v2/application.py @@ -39,10 +39,22 @@ def __init__(self, payload: Dict[str, Any]): self.iso_country: Optional[str] = payload.get("iso_country") self.business_information: Optional[ ApplicationList.CreateShortCodeApplicationRequestBusinessInformation - ] = payload.get("business_information") + ] = ( + ApplicationList.CreateShortCodeApplicationRequestBusinessInformation( + payload.get("business_information") + ) + if payload.get("business_information") is not None + else None + ) self.setup: Optional[ ApplicationList.CreateShortCodeApplicationRequestSetup - ] = payload.get("setup") + ] = ( + ApplicationList.CreateShortCodeApplicationRequestSetup( + payload.get("setup") + ) + if payload.get("setup") is not None + else None + ) def to_dict(self): return { @@ -230,10 +242,22 @@ def __init__(self, payload: Dict[str, Any]): self.iso_country: Optional[str] = payload.get("iso_country") self.business_information: Optional[ ApplicationList.CreateShortCodeApplicationRequestBusinessInformation - ] = payload.get("business_information") + ] = ( + ApplicationList.CreateShortCodeApplicationRequestBusinessInformation( + payload.get("business_information") + ) + if payload.get("business_information") is not None + else None + ) self.setup: Optional[ ApplicationList.CreateShortCodeApplicationRequestSetup - ] = payload.get("setup") + ] = ( + ApplicationList.CreateShortCodeApplicationRequestSetup( + payload.get("setup") + ) + if payload.get("setup") is not None + else None + ) def to_dict(self): return { @@ -428,10 +452,22 @@ def __init__(self, payload: Dict[str, Any]): self.iso_country: Optional[str] = payload.get("iso_country") self.business_information: Optional[ ApplicationList.CreateShortCodeApplicationRequestBusinessInformation - ] = payload.get("business_information") + ] = ( + ApplicationList.CreateShortCodeApplicationRequestBusinessInformation( + payload.get("business_information") + ) + if payload.get("business_information") is not None + else None + ) self.setup: Optional[ ApplicationList.CreateShortCodeApplicationRequestSetup - ] = payload.get("setup") + ] = ( + ApplicationList.CreateShortCodeApplicationRequestSetup( + payload.get("setup") + ) + if payload.get("setup") is not None + else None + ) def to_dict(self): return { diff --git a/twilio/rest/oauth/v1/oauth_authorization_server.py b/twilio/rest/oauth/v2/oauth_authorization_server.py similarity index 96% rename from twilio/rest/oauth/v1/oauth_authorization_server.py rename to twilio/rest/oauth/v2/oauth_authorization_server.py index 4fcdd357c..758831a4b 100644 --- a/twilio/rest/oauth/v1/oauth_authorization_server.py +++ b/twilio/rest/oauth/v2/oauth_authorization_server.py @@ -4,8 +4,8 @@ | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - Twilio - Oauth - This is the public Twilio REST API. + User OAuth API + User OAuth API NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech @@ -60,7 +60,7 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" class OauthAuthorizationServerList(ListResource): @@ -154,4 +154,4 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" diff --git a/twilio/rest/oauth/v2/token.py b/twilio/rest/oauth/v2/token.py index 07bff732c..35e1f9ef1 100644 --- a/twilio/rest/oauth/v2/token.py +++ b/twilio/rest/oauth/v2/token.py @@ -64,8 +64,8 @@ def __init__(self, version: Version): def _create( self, + grant_type: str, account_sid: Union[str, object] = values.unset, - grant_type: Union[str, object] = values.unset, client_id: Union[str, object] = values.unset, client_secret: Union[str, object] = values.unset, code: Union[str, object] = values.unset, @@ -113,8 +113,8 @@ def _create( def create( self, + grant_type: str, account_sid: Union[str, object] = values.unset, - grant_type: Union[str, object] = values.unset, client_id: Union[str, object] = values.unset, client_secret: Union[str, object] = values.unset, code: Union[str, object] = values.unset, @@ -127,8 +127,8 @@ def create( """ Create the TokenInstance - :param account_sid: Optional Account SID to perform on behalf of requests. :param grant_type: Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + :param account_sid: Optional Account SID to perform on behalf of requests. :param client_id: A 34 character string that uniquely identifies this OAuth App. :param client_secret: The credential for confidential OAuth App. :param code: JWT token related to the authorization code grant type. @@ -141,8 +141,8 @@ def create( :returns: The created TokenInstance """ payload, _, _ = self._create( - account_sid=account_sid, grant_type=grant_type, + account_sid=account_sid, client_id=client_id, client_secret=client_secret, code=code, @@ -156,8 +156,8 @@ def create( def create_with_http_info( self, + grant_type: str, account_sid: Union[str, object] = values.unset, - grant_type: Union[str, object] = values.unset, client_id: Union[str, object] = values.unset, client_secret: Union[str, object] = values.unset, code: Union[str, object] = values.unset, @@ -170,8 +170,8 @@ def create_with_http_info( """ Create the TokenInstance and return response metadata - :param account_sid: Optional Account SID to perform on behalf of requests. :param grant_type: Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + :param account_sid: Optional Account SID to perform on behalf of requests. :param client_id: A 34 character string that uniquely identifies this OAuth App. :param client_secret: The credential for confidential OAuth App. :param code: JWT token related to the authorization code grant type. @@ -184,8 +184,8 @@ def create_with_http_info( :returns: ApiResponse with instance, status code, and headers """ payload, status_code, headers = self._create( - account_sid=account_sid, grant_type=grant_type, + account_sid=account_sid, client_id=client_id, client_secret=client_secret, code=code, @@ -200,8 +200,8 @@ def create_with_http_info( async def _create_async( self, + grant_type: str, account_sid: Union[str, object] = values.unset, - grant_type: Union[str, object] = values.unset, client_id: Union[str, object] = values.unset, client_secret: Union[str, object] = values.unset, code: Union[str, object] = values.unset, @@ -249,8 +249,8 @@ async def _create_async( async def create_async( self, + grant_type: str, account_sid: Union[str, object] = values.unset, - grant_type: Union[str, object] = values.unset, client_id: Union[str, object] = values.unset, client_secret: Union[str, object] = values.unset, code: Union[str, object] = values.unset, @@ -263,8 +263,8 @@ async def create_async( """ Asynchronously create the TokenInstance - :param account_sid: Optional Account SID to perform on behalf of requests. :param grant_type: Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + :param account_sid: Optional Account SID to perform on behalf of requests. :param client_id: A 34 character string that uniquely identifies this OAuth App. :param client_secret: The credential for confidential OAuth App. :param code: JWT token related to the authorization code grant type. @@ -277,8 +277,8 @@ async def create_async( :returns: The created TokenInstance """ payload, _, _ = await self._create_async( - account_sid=account_sid, grant_type=grant_type, + account_sid=account_sid, client_id=client_id, client_secret=client_secret, code=code, @@ -292,8 +292,8 @@ async def create_async( async def create_with_http_info_async( self, + grant_type: str, account_sid: Union[str, object] = values.unset, - grant_type: Union[str, object] = values.unset, client_id: Union[str, object] = values.unset, client_secret: Union[str, object] = values.unset, code: Union[str, object] = values.unset, @@ -306,8 +306,8 @@ async def create_with_http_info_async( """ Asynchronously create the TokenInstance and return response metadata - :param account_sid: Optional Account SID to perform on behalf of requests. :param grant_type: Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + :param account_sid: Optional Account SID to perform on behalf of requests. :param client_id: A 34 character string that uniquely identifies this OAuth App. :param client_secret: The credential for confidential OAuth App. :param code: JWT token related to the authorization code grant type. @@ -320,8 +320,8 @@ async def create_with_http_info_async( :returns: ApiResponse with instance, status code, and headers """ payload, status_code, headers = await self._create_async( - account_sid=account_sid, grant_type=grant_type, + account_sid=account_sid, client_id=client_id, client_secret=client_secret, code=code, diff --git a/twilio/rest/preview_iam/versionless/organization/user.py b/twilio/rest/preview_iam/versionless/organization/user.py index 8299913b2..055aaba00 100644 --- a/twilio/rest/preview_iam/versionless/organization/user.py +++ b/twilio/rest/preview_iam/versionless/organization/user.py @@ -114,8 +114,17 @@ class ScimPatchRequest(object): def __init__(self, payload: Dict[str, Any]): self.schemas: Optional[List[str]] = payload.get("schemas") - self.operations: Optional[List[UserList.ScimPatchOperation]] = payload.get( - "Operations" + self.operations: Optional[List[UserList.ScimPatchOperation]] = ( + [ + ( + UserList.ScimPatchOperation(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("Operations") + ] + if payload.get("Operations") is not None + else None ) def to_dict(self): @@ -154,15 +163,28 @@ def __init__(self, payload: Dict[str, Any]): self.external_id: Optional[str] = payload.get("externalId") self.user_name: Optional[str] = payload.get("userName") self.display_name: Optional[str] = payload.get("displayName") - self.name: Optional[UserList.ScimName] = payload.get("name") - self.emails: Optional[List[UserList.ScimEmailAddress]] = payload.get( - "emails" + self.name: Optional[UserList.ScimName] = ( + UserList.ScimName(payload.get("name")) + if payload.get("name") is not None + else None + ) + self.emails: Optional[List[UserList.ScimEmailAddress]] = ( + [ + UserList.ScimEmailAddress(item) if isinstance(item, dict) else item + for item in payload.get("emails") + ] + if payload.get("emails") is not None + else None ) self.active: Optional[bool] = payload.get("active") self.locale: Optional[str] = payload.get("locale") self.timezone: Optional[str] = payload.get("timezone") self.schemas: Optional[List[str]] = payload.get("schemas") - self.meta: Optional[UserList.ScimMeta] = payload.get("meta") + self.meta: Optional[UserList.ScimMeta] = ( + UserList.ScimMeta(payload.get("meta")) + if payload.get("meta") is not None + else None + ) self.detail: Optional[str] = payload.get("detail") self.scim_type: Optional["UserInstance.str"] = payload.get("scimType") self.status: Optional[str] = payload.get("status") @@ -225,13 +247,13 @@ def __init__( self.external_id: Optional[str] = payload.get("externalId") self.user_name: Optional[str] = payload.get("userName") self.display_name: Optional[str] = payload.get("displayName") - self.name: Optional[UserList.str] = payload.get("name") - self.emails: Optional[List[UserList.str]] = payload.get("emails") + self.name: Optional[UserList.ScimName] = payload.get("name") + self.emails: Optional[List[UserList.ScimEmailAddress]] = payload.get("emails") self.active: Optional[bool] = payload.get("active") self.locale: Optional[str] = payload.get("locale") self.timezone: Optional[str] = payload.get("timezone") self.schemas: Optional[List[str]] = payload.get("schemas") - self.meta: Optional[UserList.str] = payload.get("meta") + self.meta: Optional[UserList.ScimMeta] = payload.get("meta") self.detail: Optional[str] = payload.get("detail") self.scim_type: Optional["UserInstance.str"] = payload.get("scimType") self.status: Optional[str] = payload.get("status") @@ -534,8 +556,17 @@ class ScimPatchRequest(object): def __init__(self, payload: Dict[str, Any]): self.schemas: Optional[List[str]] = payload.get("schemas") - self.operations: Optional[List[UserList.ScimPatchOperation]] = payload.get( - "Operations" + self.operations: Optional[List[UserList.ScimPatchOperation]] = ( + [ + ( + UserList.ScimPatchOperation(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("Operations") + ] + if payload.get("Operations") is not None + else None ) def to_dict(self): @@ -574,15 +605,28 @@ def __init__(self, payload: Dict[str, Any]): self.external_id: Optional[str] = payload.get("externalId") self.user_name: Optional[str] = payload.get("userName") self.display_name: Optional[str] = payload.get("displayName") - self.name: Optional[UserList.ScimName] = payload.get("name") - self.emails: Optional[List[UserList.ScimEmailAddress]] = payload.get( - "emails" + self.name: Optional[UserList.ScimName] = ( + UserList.ScimName(payload.get("name")) + if payload.get("name") is not None + else None + ) + self.emails: Optional[List[UserList.ScimEmailAddress]] = ( + [ + UserList.ScimEmailAddress(item) if isinstance(item, dict) else item + for item in payload.get("emails") + ] + if payload.get("emails") is not None + else None ) self.active: Optional[bool] = payload.get("active") self.locale: Optional[str] = payload.get("locale") self.timezone: Optional[str] = payload.get("timezone") self.schemas: Optional[List[str]] = payload.get("schemas") - self.meta: Optional[UserList.ScimMeta] = payload.get("meta") + self.meta: Optional[UserList.ScimMeta] = ( + UserList.ScimMeta(payload.get("meta")) + if payload.get("meta") is not None + else None + ) self.detail: Optional[str] = payload.get("detail") self.scim_type: Optional["UserInstance.str"] = payload.get("scimType") self.status: Optional[str] = payload.get("status") @@ -1211,8 +1255,17 @@ class ScimPatchRequest(object): def __init__(self, payload: Dict[str, Any]): self.schemas: Optional[List[str]] = payload.get("schemas") - self.operations: Optional[List[UserList.ScimPatchOperation]] = payload.get( - "Operations" + self.operations: Optional[List[UserList.ScimPatchOperation]] = ( + [ + ( + UserList.ScimPatchOperation(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("Operations") + ] + if payload.get("Operations") is not None + else None ) def to_dict(self): @@ -1251,15 +1304,28 @@ def __init__(self, payload: Dict[str, Any]): self.external_id: Optional[str] = payload.get("externalId") self.user_name: Optional[str] = payload.get("userName") self.display_name: Optional[str] = payload.get("displayName") - self.name: Optional[UserList.ScimName] = payload.get("name") - self.emails: Optional[List[UserList.ScimEmailAddress]] = payload.get( - "emails" + self.name: Optional[UserList.ScimName] = ( + UserList.ScimName(payload.get("name")) + if payload.get("name") is not None + else None + ) + self.emails: Optional[List[UserList.ScimEmailAddress]] = ( + [ + UserList.ScimEmailAddress(item) if isinstance(item, dict) else item + for item in payload.get("emails") + ] + if payload.get("emails") is not None + else None ) self.active: Optional[bool] = payload.get("active") self.locale: Optional[str] = payload.get("locale") self.timezone: Optional[str] = payload.get("timezone") self.schemas: Optional[List[str]] = payload.get("schemas") - self.meta: Optional[UserList.ScimMeta] = payload.get("meta") + self.meta: Optional[UserList.ScimMeta] = ( + UserList.ScimMeta(payload.get("meta")) + if payload.get("meta") is not None + else None + ) self.detail: Optional[str] = payload.get("detail") self.scim_type: Optional["UserInstance.str"] = payload.get("scimType") self.status: Optional[str] = payload.get("status") diff --git a/twilio/rest/verify/v2/service/approve_challenge.py b/twilio/rest/verify/v2/service/approve_challenge.py index 52af951f0..5064004c1 100644 --- a/twilio/rest/verify/v2/service/approve_challenge.py +++ b/twilio/rest/verify/v2/service/approve_challenge.py @@ -43,7 +43,13 @@ def __init__(self, payload: Dict[str, Any]): self.type: Optional["ApproveChallengeInstance.str"] = payload.get("type") self.response: Optional[ ApproveChallengeList.ApprovePasskeysChallengeRequestResponse - ] = payload.get("response") + ] = ( + ApproveChallengeList.ApprovePasskeysChallengeRequestResponse( + payload.get("response") + ) + if payload.get("response") is not None + else None + ) def to_dict(self): return { @@ -171,7 +177,13 @@ def __init__(self, payload: Dict[str, Any]): self.type: Optional["ApproveChallengeInstance.str"] = payload.get("type") self.response: Optional[ ApproveChallengeList.ApprovePasskeysChallengeRequestResponse - ] = payload.get("response") + ] = ( + ApproveChallengeList.ApprovePasskeysChallengeRequestResponse( + payload.get("response") + ) + if payload.get("response") is not None + else None + ) def to_dict(self): return { diff --git a/twilio/rest/verify/v2/service/new_challenge.py b/twilio/rest/verify/v2/service/new_challenge.py index 74107dd04..1d9001088 100644 --- a/twilio/rest/verify/v2/service/new_challenge.py +++ b/twilio/rest/verify/v2/service/new_challenge.py @@ -13,7 +13,7 @@ """ from datetime import datetime -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, Union from twilio.base import deserialize, values from twilio.base.api_response import ApiResponse from twilio.base.instance_context import InstanceContext @@ -120,7 +120,10 @@ def _proxy(self) -> "NewChallengeContext": return self._context def create( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> "NewChallengeInstance": """ Create the NewChallengeInstance @@ -130,11 +133,14 @@ def create( :returns: The created NewChallengeInstance """ return self._proxy.create( - create_passkeys_challenge_request, + create_passkeys_challenge_request=create_passkeys_challenge_request, ) async def create_async( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> "NewChallengeInstance": """ Asynchronous coroutine to create the NewChallengeInstance @@ -144,11 +150,14 @@ async def create_async( :returns: The created NewChallengeInstance """ return await self._proxy.create_async( - create_passkeys_challenge_request, + create_passkeys_challenge_request=create_passkeys_challenge_request, ) def create_with_http_info( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> ApiResponse: """ Create the NewChallengeInstance with HTTP info @@ -158,11 +167,14 @@ def create_with_http_info( :returns: ApiResponse with instance, status code, and headers """ return self._proxy.create_with_http_info( - create_passkeys_challenge_request, + create_passkeys_challenge_request=create_passkeys_challenge_request, ) async def create_with_http_info_async( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> ApiResponse: """ Asynchronous coroutine to create the NewChallengeInstance with HTTP info @@ -172,7 +184,7 @@ async def create_with_http_info_async( :returns: ApiResponse with instance, status code, and headers """ return await self._proxy.create_with_http_info_async( - create_passkeys_challenge_request, + create_passkeys_challenge_request=create_passkeys_challenge_request, ) def __repr__(self) -> str: @@ -222,7 +234,10 @@ def __init__(self, version: Version, service_sid: str): ) def _create( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> tuple: """ Internal helper for create operation @@ -243,7 +258,10 @@ def _create( ) def create( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> NewChallengeInstance: """ Create the NewChallengeInstance @@ -260,7 +278,10 @@ def create( ) def create_with_http_info( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> ApiResponse: """ Create the NewChallengeInstance and return response metadata @@ -278,7 +299,10 @@ def create_with_http_info( return ApiResponse(data=instance, status_code=status_code, headers=headers) async def _create_async( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> tuple: """ Internal async helper for create operation @@ -299,7 +323,10 @@ async def _create_async( ) async def create_async( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> NewChallengeInstance: """ Asynchronous coroutine to create the NewChallengeInstance @@ -316,7 +343,10 @@ async def create_async( ) async def create_with_http_info_async( - self, create_passkeys_challenge_request: CreatePasskeysChallengeRequest + self, + create_passkeys_challenge_request: Union[ + CreatePasskeysChallengeRequest, object + ] = values.unset, ) -> ApiResponse: """ Asynchronous coroutine to create the NewChallengeInstance and return response metadata diff --git a/twilio/rest/verify/v2/service/new_factor.py b/twilio/rest/verify/v2/service/new_factor.py index b5595bca5..4008195a2 100644 --- a/twilio/rest/verify/v2/service/new_factor.py +++ b/twilio/rest/verify/v2/service/new_factor.py @@ -37,7 +37,13 @@ def __init__(self, payload: Dict[str, Any]): self.identity: Optional[str] = payload.get("identity") self.config: Optional[ NewFactorList.CreateNewPasskeysFactorRequestConfig - ] = payload.get("config") + ] = ( + NewFactorList.CreateNewPasskeysFactorRequestConfig( + payload.get("config") + ) + if payload.get("config") is not None + else None + ) def to_dict(self): return { @@ -58,7 +64,13 @@ def __init__(self, payload: Dict[str, Any]): self.relying_party: Optional[ NewFactorList.CreateNewPasskeysFactorRequestConfigRelyingParty - ] = payload.get("relying_party") + ] = ( + NewFactorList.CreateNewPasskeysFactorRequestConfigRelyingParty( + payload.get("relying_party") + ) + if payload.get("relying_party") is not None + else None + ) self.authenticator_attachment: Optional["NewFactorInstance.str"] = ( payload.get("authenticator_attachment") ) @@ -171,7 +183,13 @@ def __init__(self, payload: Dict[str, Any]): self.identity: Optional[str] = payload.get("identity") self.config: Optional[ NewFactorList.CreateNewPasskeysFactorRequestConfig - ] = payload.get("config") + ] = ( + NewFactorList.CreateNewPasskeysFactorRequestConfig( + payload.get("config") + ) + if payload.get("config") is not None + else None + ) def to_dict(self): return { @@ -192,7 +210,13 @@ def __init__(self, payload: Dict[str, Any]): self.relying_party: Optional[ NewFactorList.CreateNewPasskeysFactorRequestConfigRelyingParty - ] = payload.get("relying_party") + ] = ( + NewFactorList.CreateNewPasskeysFactorRequestConfigRelyingParty( + payload.get("relying_party") + ) + if payload.get("relying_party") is not None + else None + ) self.authenticator_attachment: Optional["NewFactorInstance.str"] = ( payload.get("authenticator_attachment") ) diff --git a/twilio/rest/verify/v2/service/new_verify_factor.py b/twilio/rest/verify/v2/service/new_verify_factor.py index 703eabd3b..cd138d0c4 100644 --- a/twilio/rest/verify/v2/service/new_verify_factor.py +++ b/twilio/rest/verify/v2/service/new_verify_factor.py @@ -43,7 +43,13 @@ def __init__(self, payload: Dict[str, Any]): self.type: Optional["NewVerifyFactorInstance.str"] = payload.get("type") self.response: Optional[ NewVerifyFactorList.VerifyPasskeysFactorRequestResponse - ] = payload.get("response") + ] = ( + NewVerifyFactorList.VerifyPasskeysFactorRequestResponse( + payload.get("response") + ) + if payload.get("response") is not None + else None + ) def to_dict(self): return { @@ -150,7 +156,13 @@ def __init__(self, payload: Dict[str, Any]): self.type: Optional["NewVerifyFactorInstance.str"] = payload.get("type") self.response: Optional[ NewVerifyFactorList.VerifyPasskeysFactorRequestResponse - ] = payload.get("response") + ] = ( + NewVerifyFactorList.VerifyPasskeysFactorRequestResponse( + payload.get("response") + ) + if payload.get("response") is not None + else None + ) def to_dict(self): return { diff --git a/twilio/rest/verify/v2/service/verification.py b/twilio/rest/verify/v2/service/verification.py index 88ae5cb75..428ea80e7 100644 --- a/twilio/rest/verify/v2/service/verification.py +++ b/twilio/rest/verify/v2/service/verification.py @@ -488,6 +488,7 @@ def _create( app_hash: Union[str, object] = values.unset, template_sid: Union[str, object] = values.unset, template_custom_substitutions: Union[str, object] = values.unset, + templates: Union[str, object] = values.unset, device_ip: Union[str, object] = values.unset, enable_sna_client_token: Union[bool, object] = values.unset, risk_check: Union["VerificationInstance.RiskCheck", object] = values.unset, @@ -516,6 +517,7 @@ def _create( "AppHash": app_hash, "TemplateSid": template_sid, "TemplateCustomSubstitutions": template_custom_substitutions, + "Templates": templates, "DeviceIp": device_ip, "EnableSnaClientToken": serialize.boolean_to_string( enable_sna_client_token @@ -550,6 +552,7 @@ def create( app_hash: Union[str, object] = values.unset, template_sid: Union[str, object] = values.unset, template_custom_substitutions: Union[str, object] = values.unset, + templates: Union[str, object] = values.unset, device_ip: Union[str, object] = values.unset, enable_sna_client_token: Union[bool, object] = values.unset, risk_check: Union["VerificationInstance.RiskCheck", object] = values.unset, @@ -570,8 +573,9 @@ def create( :param rate_limits: The custom key-value pairs of Programmable Rate Limits. Keys correspond to `unique_name` fields defined when [creating your Rate Limit](https://www.twilio.com/docs/verify/api/service-rate-limits). Associated value pairs represent values in the request that you are rate limiting on. You may include multiple Rate Limit values in each request. :param channel_configuration: [`email`](https://www.twilio.com/docs/verify/email) channel configuration in json format. The fields 'from' and 'from_name' are optional but if included the 'from' field must have a valid email address. :param app_hash: Your [App Hash](https://developers.google.com/identity/sms-retriever/verify#computing_your_apps_hash_string) to be appended at the end of your verification SMS body. Applies only to SMS. Example SMS body: `<#> Your AppName verification code is: 1234 He42w354ol9`. - :param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. + :param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. If the `Templates` parameter is also provided, `Templates` takes precedence over this parameter. :param template_custom_substitutions: A stringified JSON object in which the keys are the template's special variables and the values are the variables substitutions. + :param templates: A stringified JSON array of template entries, ordered by preference. Each entry is an object with the following fields: `sid` (string, required, matching `^HJ[0-9a-fA-F]{32}$`) — the SID of the message [template](https://www.twilio.com/docs/verify/api/templates) to apply; and `substitutions` (object, optional) — a key-value map in which the keys are the template's special variables and the values are their substitution values. The array may contain up to 10 entries. If provided, `Templates` takes precedence over `TemplateSid` and `TemplateCustomSubstitutions`. :param device_ip: Strongly encouraged if using the auto channel. The IP address of the client's device. If provided, it has to be a valid IPv4 or IPv6 address. :param enable_sna_client_token: An optional Boolean value to indicate the requirement of sna client token in the SNA URL invocation response for added security. This token must match in the Verification Check request to confirm phone number verification. :param risk_check: @@ -594,6 +598,7 @@ def create( app_hash=app_hash, template_sid=template_sid, template_custom_substitutions=template_custom_substitutions, + templates=templates, device_ip=device_ip, enable_sna_client_token=enable_sna_client_token, risk_check=risk_check, @@ -619,6 +624,7 @@ def create_with_http_info( app_hash: Union[str, object] = values.unset, template_sid: Union[str, object] = values.unset, template_custom_substitutions: Union[str, object] = values.unset, + templates: Union[str, object] = values.unset, device_ip: Union[str, object] = values.unset, enable_sna_client_token: Union[bool, object] = values.unset, risk_check: Union["VerificationInstance.RiskCheck", object] = values.unset, @@ -639,8 +645,9 @@ def create_with_http_info( :param rate_limits: The custom key-value pairs of Programmable Rate Limits. Keys correspond to `unique_name` fields defined when [creating your Rate Limit](https://www.twilio.com/docs/verify/api/service-rate-limits). Associated value pairs represent values in the request that you are rate limiting on. You may include multiple Rate Limit values in each request. :param channel_configuration: [`email`](https://www.twilio.com/docs/verify/email) channel configuration in json format. The fields 'from' and 'from_name' are optional but if included the 'from' field must have a valid email address. :param app_hash: Your [App Hash](https://developers.google.com/identity/sms-retriever/verify#computing_your_apps_hash_string) to be appended at the end of your verification SMS body. Applies only to SMS. Example SMS body: `<#> Your AppName verification code is: 1234 He42w354ol9`. - :param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. + :param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. If the `Templates` parameter is also provided, `Templates` takes precedence over this parameter. :param template_custom_substitutions: A stringified JSON object in which the keys are the template's special variables and the values are the variables substitutions. + :param templates: A stringified JSON array of template entries, ordered by preference. Each entry is an object with the following fields: `sid` (string, required, matching `^HJ[0-9a-fA-F]{32}$`) — the SID of the message [template](https://www.twilio.com/docs/verify/api/templates) to apply; and `substitutions` (object, optional) — a key-value map in which the keys are the template's special variables and the values are their substitution values. The array may contain up to 10 entries. If provided, `Templates` takes precedence over `TemplateSid` and `TemplateCustomSubstitutions`. :param device_ip: Strongly encouraged if using the auto channel. The IP address of the client's device. If provided, it has to be a valid IPv4 or IPv6 address. :param enable_sna_client_token: An optional Boolean value to indicate the requirement of sna client token in the SNA URL invocation response for added security. This token must match in the Verification Check request to confirm phone number verification. :param risk_check: @@ -663,6 +670,7 @@ def create_with_http_info( app_hash=app_hash, template_sid=template_sid, template_custom_substitutions=template_custom_substitutions, + templates=templates, device_ip=device_ip, enable_sna_client_token=enable_sna_client_token, risk_check=risk_check, @@ -689,6 +697,7 @@ async def _create_async( app_hash: Union[str, object] = values.unset, template_sid: Union[str, object] = values.unset, template_custom_substitutions: Union[str, object] = values.unset, + templates: Union[str, object] = values.unset, device_ip: Union[str, object] = values.unset, enable_sna_client_token: Union[bool, object] = values.unset, risk_check: Union["VerificationInstance.RiskCheck", object] = values.unset, @@ -717,6 +726,7 @@ async def _create_async( "AppHash": app_hash, "TemplateSid": template_sid, "TemplateCustomSubstitutions": template_custom_substitutions, + "Templates": templates, "DeviceIp": device_ip, "EnableSnaClientToken": serialize.boolean_to_string( enable_sna_client_token @@ -751,6 +761,7 @@ async def create_async( app_hash: Union[str, object] = values.unset, template_sid: Union[str, object] = values.unset, template_custom_substitutions: Union[str, object] = values.unset, + templates: Union[str, object] = values.unset, device_ip: Union[str, object] = values.unset, enable_sna_client_token: Union[bool, object] = values.unset, risk_check: Union["VerificationInstance.RiskCheck", object] = values.unset, @@ -771,8 +782,9 @@ async def create_async( :param rate_limits: The custom key-value pairs of Programmable Rate Limits. Keys correspond to `unique_name` fields defined when [creating your Rate Limit](https://www.twilio.com/docs/verify/api/service-rate-limits). Associated value pairs represent values in the request that you are rate limiting on. You may include multiple Rate Limit values in each request. :param channel_configuration: [`email`](https://www.twilio.com/docs/verify/email) channel configuration in json format. The fields 'from' and 'from_name' are optional but if included the 'from' field must have a valid email address. :param app_hash: Your [App Hash](https://developers.google.com/identity/sms-retriever/verify#computing_your_apps_hash_string) to be appended at the end of your verification SMS body. Applies only to SMS. Example SMS body: `<#> Your AppName verification code is: 1234 He42w354ol9`. - :param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. + :param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. If the `Templates` parameter is also provided, `Templates` takes precedence over this parameter. :param template_custom_substitutions: A stringified JSON object in which the keys are the template's special variables and the values are the variables substitutions. + :param templates: A stringified JSON array of template entries, ordered by preference. Each entry is an object with the following fields: `sid` (string, required, matching `^HJ[0-9a-fA-F]{32}$`) — the SID of the message [template](https://www.twilio.com/docs/verify/api/templates) to apply; and `substitutions` (object, optional) — a key-value map in which the keys are the template's special variables and the values are their substitution values. The array may contain up to 10 entries. If provided, `Templates` takes precedence over `TemplateSid` and `TemplateCustomSubstitutions`. :param device_ip: Strongly encouraged if using the auto channel. The IP address of the client's device. If provided, it has to be a valid IPv4 or IPv6 address. :param enable_sna_client_token: An optional Boolean value to indicate the requirement of sna client token in the SNA URL invocation response for added security. This token must match in the Verification Check request to confirm phone number verification. :param risk_check: @@ -795,6 +807,7 @@ async def create_async( app_hash=app_hash, template_sid=template_sid, template_custom_substitutions=template_custom_substitutions, + templates=templates, device_ip=device_ip, enable_sna_client_token=enable_sna_client_token, risk_check=risk_check, @@ -820,6 +833,7 @@ async def create_with_http_info_async( app_hash: Union[str, object] = values.unset, template_sid: Union[str, object] = values.unset, template_custom_substitutions: Union[str, object] = values.unset, + templates: Union[str, object] = values.unset, device_ip: Union[str, object] = values.unset, enable_sna_client_token: Union[bool, object] = values.unset, risk_check: Union["VerificationInstance.RiskCheck", object] = values.unset, @@ -840,8 +854,9 @@ async def create_with_http_info_async( :param rate_limits: The custom key-value pairs of Programmable Rate Limits. Keys correspond to `unique_name` fields defined when [creating your Rate Limit](https://www.twilio.com/docs/verify/api/service-rate-limits). Associated value pairs represent values in the request that you are rate limiting on. You may include multiple Rate Limit values in each request. :param channel_configuration: [`email`](https://www.twilio.com/docs/verify/email) channel configuration in json format. The fields 'from' and 'from_name' are optional but if included the 'from' field must have a valid email address. :param app_hash: Your [App Hash](https://developers.google.com/identity/sms-retriever/verify#computing_your_apps_hash_string) to be appended at the end of your verification SMS body. Applies only to SMS. Example SMS body: `<#> Your AppName verification code is: 1234 He42w354ol9`. - :param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. + :param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. If the `Templates` parameter is also provided, `Templates` takes precedence over this parameter. :param template_custom_substitutions: A stringified JSON object in which the keys are the template's special variables and the values are the variables substitutions. + :param templates: A stringified JSON array of template entries, ordered by preference. Each entry is an object with the following fields: `sid` (string, required, matching `^HJ[0-9a-fA-F]{32}$`) — the SID of the message [template](https://www.twilio.com/docs/verify/api/templates) to apply; and `substitutions` (object, optional) — a key-value map in which the keys are the template's special variables and the values are their substitution values. The array may contain up to 10 entries. If provided, `Templates` takes precedence over `TemplateSid` and `TemplateCustomSubstitutions`. :param device_ip: Strongly encouraged if using the auto channel. The IP address of the client's device. If provided, it has to be a valid IPv4 or IPv6 address. :param enable_sna_client_token: An optional Boolean value to indicate the requirement of sna client token in the SNA URL invocation response for added security. This token must match in the Verification Check request to confirm phone number verification. :param risk_check: @@ -864,6 +879,7 @@ async def create_with_http_info_async( app_hash=app_hash, template_sid=template_sid, template_custom_substitutions=template_custom_substitutions, + templates=templates, device_ip=device_ip, enable_sna_client_token=enable_sna_client_token, risk_check=risk_check, diff --git a/twilio/rest/voice/v2/recording.py b/twilio/rest/voice/v2/recording.py index 0ae6ac1ac..e71c1ab08 100644 --- a/twilio/rest/voice/v2/recording.py +++ b/twilio/rest/voice/v2/recording.py @@ -60,16 +60,45 @@ def __init__(self, payload: Dict[str, Any]): ) self.composition_policy: Optional[ RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy - ] = payload.get("compositionPolicy") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy( + payload.get("compositionPolicy") + ) + if payload.get("compositionPolicy") is not None + else None + ) self.call_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback - ] = payload.get("callRecordingStatusCallback") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingStatusCallback( + payload.get("callRecordingStatusCallback") + ) + if payload.get("callRecordingStatusCallback") is not None + else None + ) self.conference_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback - ] = payload.get("conferenceRecordingStatusCallback") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingStatusCallback( + payload.get("conferenceRecordingStatusCallback") + ) + if payload.get("conferenceRecordingStatusCallback") is not None + else None + ) self.features: Optional[ List[RecordingList.VoiceV2ConfigurationRecordingFeature] - ] = payload.get("features") + ] = ( + [ + ( + RecordingList.VoiceV2ConfigurationRecordingFeature(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("features") + ] + if payload.get("features") is not None + else None + ) def to_dict(self): return { @@ -129,7 +158,13 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.configuration: Optional[ RecordingList.VoiceV2ConfigurationRecordingConfiguration - ] = payload.get("configuration") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) def to_dict(self): return { @@ -409,16 +444,45 @@ def __init__(self, payload: Dict[str, Any]): ) self.composition_policy: Optional[ RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy - ] = payload.get("compositionPolicy") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy( + payload.get("compositionPolicy") + ) + if payload.get("compositionPolicy") is not None + else None + ) self.call_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback - ] = payload.get("callRecordingStatusCallback") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingStatusCallback( + payload.get("callRecordingStatusCallback") + ) + if payload.get("callRecordingStatusCallback") is not None + else None + ) self.conference_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback - ] = payload.get("conferenceRecordingStatusCallback") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingStatusCallback( + payload.get("conferenceRecordingStatusCallback") + ) + if payload.get("conferenceRecordingStatusCallback") is not None + else None + ) self.features: Optional[ List[RecordingList.VoiceV2ConfigurationRecordingFeature] - ] = payload.get("features") + ] = ( + [ + ( + RecordingList.VoiceV2ConfigurationRecordingFeature(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("features") + ] + if payload.get("features") is not None + else None + ) def to_dict(self): return { @@ -478,7 +542,13 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.configuration: Optional[ RecordingList.VoiceV2ConfigurationRecordingConfiguration - ] = payload.get("configuration") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) def to_dict(self): return { @@ -876,16 +946,45 @@ def __init__(self, payload: Dict[str, Any]): ) self.composition_policy: Optional[ RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy - ] = payload.get("compositionPolicy") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy( + payload.get("compositionPolicy") + ) + if payload.get("compositionPolicy") is not None + else None + ) self.call_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback - ] = payload.get("callRecordingStatusCallback") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingStatusCallback( + payload.get("callRecordingStatusCallback") + ) + if payload.get("callRecordingStatusCallback") is not None + else None + ) self.conference_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback - ] = payload.get("conferenceRecordingStatusCallback") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingStatusCallback( + payload.get("conferenceRecordingStatusCallback") + ) + if payload.get("conferenceRecordingStatusCallback") is not None + else None + ) self.features: Optional[ List[RecordingList.VoiceV2ConfigurationRecordingFeature] - ] = payload.get("features") + ] = ( + [ + ( + RecordingList.VoiceV2ConfigurationRecordingFeature(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("features") + ] + if payload.get("features") is not None + else None + ) def to_dict(self): return { @@ -945,7 +1044,13 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.configuration: Optional[ RecordingList.VoiceV2ConfigurationRecordingConfiguration - ] = payload.get("configuration") + ] = ( + RecordingList.VoiceV2ConfigurationRecordingConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) def to_dict(self): return { diff --git a/twilio/rest/voice/v2/transcription.py b/twilio/rest/voice/v2/transcription.py index d76c1f421..6a99da14e 100644 --- a/twilio/rest/voice/v2/transcription.py +++ b/twilio/rest/voice/v2/transcription.py @@ -47,7 +47,13 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.transcription_status_callback: Optional[ TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback - ] = payload.get("transcriptionStatusCallback") + ] = ( + TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback( + payload.get("transcriptionStatusCallback") + ) + if payload.get("transcriptionStatusCallback") is not None + else None + ) self.conversation_configuration_id: Optional[str] = payload.get( "conversationConfigurationId" ) @@ -55,7 +61,20 @@ def __init__(self, payload: Dict[str, Any]): List[ TranscriptionList.VoiceV2ConfigurationTranscriptionParticipantDefault ] - ] = payload.get("participantDefaults") + ] = ( + [ + ( + TranscriptionList.VoiceV2ConfigurationTranscriptionParticipantDefault( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("participantDefaults") + ] + if payload.get("participantDefaults") is not None + else None + ) def to_dict(self): return { @@ -109,7 +128,13 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.configuration: Optional[ TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration - ] = payload.get("configuration") + ] = ( + TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) def to_dict(self): return { @@ -373,7 +398,13 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.transcription_status_callback: Optional[ TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback - ] = payload.get("transcriptionStatusCallback") + ] = ( + TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback( + payload.get("transcriptionStatusCallback") + ) + if payload.get("transcriptionStatusCallback") is not None + else None + ) self.conversation_configuration_id: Optional[str] = payload.get( "conversationConfigurationId" ) @@ -381,7 +412,20 @@ def __init__(self, payload: Dict[str, Any]): List[ TranscriptionList.VoiceV2ConfigurationTranscriptionParticipantDefault ] - ] = payload.get("participantDefaults") + ] = ( + [ + ( + TranscriptionList.VoiceV2ConfigurationTranscriptionParticipantDefault( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("participantDefaults") + ] + if payload.get("participantDefaults") is not None + else None + ) def to_dict(self): return { @@ -435,7 +479,13 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.configuration: Optional[ TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration - ] = payload.get("configuration") + ] = ( + TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) def to_dict(self): return { @@ -817,7 +867,13 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.transcription_status_callback: Optional[ TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback - ] = payload.get("transcriptionStatusCallback") + ] = ( + TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback( + payload.get("transcriptionStatusCallback") + ) + if payload.get("transcriptionStatusCallback") is not None + else None + ) self.conversation_configuration_id: Optional[str] = payload.get( "conversationConfigurationId" ) @@ -825,7 +881,20 @@ def __init__(self, payload: Dict[str, Any]): List[ TranscriptionList.VoiceV2ConfigurationTranscriptionParticipantDefault ] - ] = payload.get("participantDefaults") + ] = ( + [ + ( + TranscriptionList.VoiceV2ConfigurationTranscriptionParticipantDefault( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("participantDefaults") + ] + if payload.get("participantDefaults") is not None + else None + ) def to_dict(self): return { @@ -879,7 +948,13 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.configuration: Optional[ TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration - ] = payload.get("configuration") + ] = ( + TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration( + payload.get("configuration") + ) + if payload.get("configuration") is not None + else None + ) def to_dict(self): return { diff --git a/twilio/rest/voice/v3/transcription.py b/twilio/rest/voice/v3/transcription.py index 5ade4ce6f..08aa0c93e 100644 --- a/twilio/rest/voice/v3/transcription.py +++ b/twilio/rest/voice/v3/transcription.py @@ -15,21 +15,35 @@ from __future__ import annotations from datetime import datetime -from typing import Any, Dict, List, Optional, Union -from twilio.base import values +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import deserialize, serialize, values from twilio.base.api_response import ApiResponse from twilio.base.instance_context import InstanceContext from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.version import Version +from twilio.base.token_pagination import TokenPagination class TranscriptionInstance(InstanceResource): """ - :ivar operation_id: Unique identifier for the transcription operation. - :ivar status: Current status of the transcription operation. PENDING: accepted but not yet started. RUNNING: currently in progress. COMPLETED: successfully completed. FAILED: failed and cannot be completed. - :ivar status_url: URL to poll for the latest operation status. + :ivar id: Unique identifier for a Transcription. This is also the transcriptionId returned in the LRO 202 response. + :ivar account_id: Twilio Account SID + :ivar status: The current status of the transcription operation + :ivar transcription_configuration_id: Unique identifier for a Transcription configuration. + :ivar media_url: The third party media URL + :ivar source_id: The source ID (recording ID) - used for tracking only + :ivar audio_started_at: The call/recording start time. When the transcription was created using a sourceId, this value is inferred from the recording resource's start time. When created using a mediaUrl, this reflects the value supplied by the caller. + :ivar conversation_id: Maestro conversation ID, populated once the transcription has been stored in Maestro. + :ivar participants: Array of participants in the conversation + :ivar duration: Audio duration in seconds + :ivar resolved_configuration: + :ivar created_at: When this transcript was created + :ivar updated_at: When this transcript was last updated + :ivar url: The URL of this resource + :ivar status_url: URI to poll for operation status. Mirrors the Location response header. Provided as a body field for programmatic access by JSON-parsing clients (RFC 9110 Section 15.3.3). :ivar transcription: + :ivar operation_id: Unique identifier for the transcription operation. """ def __init__( @@ -40,12 +54,35 @@ def __init__( ): super().__init__(version) - self.operation_id: Optional[str] = payload.get("operationId") + self.id: Optional[str] = payload.get("id") + self.account_id: Optional[str] = payload.get("accountId") self.status: Optional["TranscriptionInstance.str"] = payload.get("status") - self.status_url: Optional[str] = payload.get("statusUrl") - self.transcription: Optional[VoiceV3TranscriptionTranscription] = payload.get( - "transcription" + self.transcription_configuration_id: Optional[str] = payload.get( + "transcriptionConfigurationId" + ) + self.media_url: Optional[str] = payload.get("mediaUrl") + self.source_id: Optional[str] = payload.get("sourceId") + self.audio_started_at: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("audioStartedAt") ) + self.conversation_id: Optional[str] = payload.get("conversationId") + self.participants: Optional[List[VoiceV3TranscriptionParticipant]] = ( + payload.get("participants") + ) + self.duration: Optional[int] = deserialize.integer(payload.get("duration")) + self.resolved_configuration: Optional[ + VoiceV3TranscriptionResolvedConfiguration + ] = payload.get("resolvedConfiguration") + self.created_at: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("createdAt") + ) + self.updated_at: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("updatedAt") + ) + self.url: Optional[str] = payload.get("url") + self.status_url: Optional[str] = payload.get("statusUrl") + self.transcription: Optional[str] = payload.get("transcription") + self.operation_id: Optional[str] = payload.get("operationId") # Only set _solution if path params are provided (not None) if transcription_id is not None: @@ -233,6 +270,26 @@ def __repr__(self) -> str: return "".format(context) +class TranscriptionPage(TokenPagination): + + def get_instance(self, payload: Dict[str, Any]) -> TranscriptionInstance: + """ + Build an instance of TranscriptionInstance + + :param payload: Payload response from the API + """ + + return TranscriptionInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + class TranscriptionList(ListResource): class CreateV3TranscriptionsRequest(object): @@ -256,7 +313,18 @@ def __init__(self, payload: Dict[str, Any]): self.source_id: Optional[str] = payload.get("sourceId") self.participants: Optional[ List[TranscriptionList.VoiceV3TranscriptionParticipant] - ] = payload.get("participants") + ] = ( + [ + ( + TranscriptionList.VoiceV3TranscriptionParticipant(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("participants") + ] + if payload.get("participants") is not None + else None + ) self.media_url: Optional[str] = payload.get("mediaUrl") self.audio_started_at: Optional[datetime] = payload.get("audioStartedAt") @@ -316,13 +384,32 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.transcription_status_callback: Optional[ VoiceV3TranscriptionTranscriptionStatusCallback - ] = payload.get("transcriptionStatusCallback") + ] = ( + VoiceV3TranscriptionTranscriptionStatusCallback( + payload.get("transcriptionStatusCallback") + ) + if payload.get("transcriptionStatusCallback") is not None + else None + ) self.conversation_configuration_id: Optional[str] = payload.get( "conversationConfigurationId" ) self.participant_defaults: Optional[ List[VoiceV3TranscriptionResolvedConfigurationParticipantDefaults] - ] = payload.get("participantDefaults") + ] = ( + [ + ( + VoiceV3TranscriptionResolvedConfigurationParticipantDefaults( + item + ) + if isinstance(item, dict) + else item + ) + for item in payload.get("participantDefaults") + ] + if payload.get("participantDefaults") is not None + else None + ) def to_dict(self): return { @@ -527,6 +614,577 @@ async def create_with_http_info_async( instance = TranscriptionInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) + def stream( + self, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[TranscriptionInstance]: + """ + Streams TranscriptionInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param datetime created_after: Only include transcriptions created at or after this time (inclusive) + :param datetime created_before: Only include transcriptions created strictly before this time (exclusive) + :param str language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param str source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param str status: Only include transcriptions in this status + :param str page_token: Opaque cursor for retrieving the next or previous page of results + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = self.page( + created_after=created_after, + created_before=created_before, + language_code=language_code, + source_id=source_id, + status=status, + page_token=page_token, + page_size=limits["page_size"], + ) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[TranscriptionInstance]: + """ + Asynchronously streams TranscriptionInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param datetime created_after: Only include transcriptions created at or after this time (inclusive) + :param datetime created_before: Only include transcriptions created strictly before this time (exclusive) + :param str language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param str source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param str status: Only include transcriptions in this status + :param str page_token: Opaque cursor for retrieving the next or previous page of results + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = await self.page_async( + created_after=created_after, + created_before=created_before, + language_code=language_code, + source_id=source_id, + status=status, + page_token=page_token, + page_size=limits["page_size"], + ) + + return self._version.stream_async(page, limits["limit"]) + + def stream_with_http_info( + self, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> tuple: + """ + Streams TranscriptionInstance and returns headers from first page + + + :param datetime created_after: Only include transcriptions created at or after this time (inclusive) + :param datetime created_before: Only include transcriptions created strictly before this time (exclusive) + :param str language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param str source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param str status: Only include transcriptions in this status + :param str page_token: Opaque cursor for retrieving the next or previous page of results + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: tuple of (generator, status_code, headers) where generator yields instances + """ + limits = self._version.read_limits(limit, page_size) + page_response = self.page_with_http_info( + created_after=created_after, + created_before=created_before, + language_code=language_code, + source_id=source_id, + status=status, + page_token=page_token, + page_size=limits["page_size"], + ) + + generator = self._version.stream(page_response.data, limits["limit"]) + return (generator, page_response.status_code, page_response.headers) + + async def stream_with_http_info_async( + self, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> tuple: + """ + Asynchronously streams TranscriptionInstance and returns headers from first page + + + :param datetime created_after: Only include transcriptions created at or after this time (inclusive) + :param datetime created_before: Only include transcriptions created strictly before this time (exclusive) + :param str language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param str source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param str status: Only include transcriptions in this status + :param str page_token: Opaque cursor for retrieving the next or previous page of results + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: tuple of (generator, status_code, headers) where generator yields instances + """ + limits = self._version.read_limits(limit, page_size) + page_response = await self.page_with_http_info_async( + created_after=created_after, + created_before=created_before, + language_code=language_code, + source_id=source_id, + status=status, + page_token=page_token, + page_size=limits["page_size"], + ) + + generator = self._version.stream_async(page_response.data, limits["limit"]) + return (generator, page_response.status_code, page_response.headers) + + def list( + self, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[TranscriptionInstance]: + """ + Lists TranscriptionInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param datetime created_after: Only include transcriptions created at or after this time (inclusive) + :param datetime created_before: Only include transcriptions created strictly before this time (exclusive) + :param str language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param str source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param str status: Only include transcriptions in this status + :param str page_token: Opaque cursor for retrieving the next or previous page of results + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + + return list( + self.stream( + created_after=created_after, + created_before=created_before, + language_code=language_code, + source_id=source_id, + status=status, + page_token=page_token, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[TranscriptionInstance]: + """ + Asynchronously lists TranscriptionInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param datetime created_after: Only include transcriptions created at or after this time (inclusive) + :param datetime created_before: Only include transcriptions created strictly before this time (exclusive) + :param str language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param str source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param str status: Only include transcriptions in this status + :param str page_token: Opaque cursor for retrieving the next or previous page of results + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + + return [ + record + async for record in await self.stream_async( + created_after=created_after, + created_before=created_before, + language_code=language_code, + source_id=source_id, + status=status, + page_token=page_token, + limit=limit, + page_size=page_size, + ) + ] + + def list_with_http_info( + self, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ApiResponse: + """ + Lists TranscriptionInstance and returns headers from first page + + + :param datetime created_after: Only include transcriptions created at or after this time (inclusive) + :param datetime created_before: Only include transcriptions created strictly before this time (exclusive) + :param str language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param str source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param str status: Only include transcriptions in this status + :param str page_token: Opaque cursor for retrieving the next or previous page of results + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: ApiResponse with list of instances, status code, and headers + """ + generator, status_code, headers = self.stream_with_http_info( + created_after=created_after, + created_before=created_before, + language_code=language_code, + source_id=source_id, + status=status, + page_token=page_token, + limit=limit, + page_size=page_size, + ) + items = list(generator) + return ApiResponse(data=items, status_code=status_code, headers=headers) + + async def list_with_http_info_async( + self, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ApiResponse: + """ + Asynchronously lists TranscriptionInstance and returns headers from first page + + + :param datetime created_after: Only include transcriptions created at or after this time (inclusive) + :param datetime created_before: Only include transcriptions created strictly before this time (exclusive) + :param str language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param str source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param str status: Only include transcriptions in this status + :param str page_token: Opaque cursor for retrieving the next or previous page of results + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: ApiResponse with list of instances, status code, and headers + """ + generator, status_code, headers = await self.stream_with_http_info_async( + created_after=created_after, + created_before=created_before, + language_code=language_code, + source_id=source_id, + status=status, + page_token=page_token, + limit=limit, + page_size=page_size, + ) + items = [record async for record in generator] + return ApiResponse(data=items, status_code=status_code, headers=headers) + + def page( + self, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_size: Union[int, object] = values.unset, + page_token: Union[str, object] = values.unset, + ) -> TranscriptionPage: + """ + Retrieve a single page of TranscriptionInstance records from the API. + Request is executed immediately + + :param created_after: Only include transcriptions created at or after this time (inclusive) + :param created_before: Only include transcriptions created strictly before this time (exclusive) + :param language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param status: Only include transcriptions in this status + :param page_size: Number of results per page. This endpoint caps at 100, which is lower than the shared pagination component's ceiling and matches what the service enforces. + :param page_token: Opaque cursor for retrieving the next or previous page of results + :returns: Page of TranscriptionInstance + """ + data = values.of( + { + "createdAfter": serialize.iso8601_datetime(created_after), + "createdBefore": serialize.iso8601_datetime(created_before), + "languageCode": language_code, + "sourceId": source_id, + "status": status, + "pageSize": page_size, + "pageToken": page_token, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return TranscriptionPage(self._version, response, uri=self._uri, params=data) + + async def page_async( + self, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_size: Union[int, object] = values.unset, + page_token: Union[str, object] = values.unset, + ) -> TranscriptionPage: + """ + Asynchronously retrieve a single page of TranscriptionInstance records from the API. + Request is executed immediately + + :param created_after: Only include transcriptions created at or after this time (inclusive) + :param created_before: Only include transcriptions created strictly before this time (exclusive) + :param language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param status: Only include transcriptions in this status + :param page_size: Number of results per page. This endpoint caps at 100, which is lower than the shared pagination component's ceiling and matches what the service enforces. + :param page_token: Opaque cursor for retrieving the next or previous page of results + :returns: Page of TranscriptionInstance + """ + data = values.of( + { + "createdAfter": serialize.iso8601_datetime(created_after), + "createdBefore": serialize.iso8601_datetime(created_before), + "languageCode": language_code, + "sourceId": source_id, + "status": status, + "pageSize": page_size, + "pageToken": page_token, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return TranscriptionPage(self._version, response, uri=self._uri, params=data) + + def page_with_http_info( + self, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> ApiResponse: + """ + Retrieve a single page with response metadata + + + :param created_after: Only include transcriptions created at or after this time (inclusive) + :param created_before: Only include transcriptions created strictly before this time (exclusive) + :param language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param status: Only include transcriptions in this status + :param page_token: Opaque cursor for retrieving the next or previous page of results + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: ApiResponse with TranscriptionPage, status code, and headers + """ + data = values.of( + { + "createdAfter": serialize.iso8601_datetime(created_after), + "createdBefore": serialize.iso8601_datetime(created_before), + "languageCode": language_code, + "sourceId": source_id, + "status": status, + "pageToken": page_token, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response, status_code, response_headers = self._version.page_with_response_info( + method="GET", uri=self._uri, params=data, headers=headers + ) + page = TranscriptionPage(self._version, response, uri=self._uri) + return ApiResponse(data=page, status_code=status_code, headers=response_headers) + + async def page_with_http_info_async( + self, + created_after: Union[datetime, object] = values.unset, + created_before: Union[datetime, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_id: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> ApiResponse: + """ + Asynchronously retrieve a single page with response metadata + + + :param created_after: Only include transcriptions created at or after this time (inclusive) + :param created_before: Only include transcriptions created strictly before this time (exclusive) + :param language_code: Only include transcriptions whose resolved language matches this value exactly. The comparison is case sensitive, so use the stored form, for example en-US. + :param source_id: Only include transcriptions for this source audio. Must be a Recording SID in lowercase hex; anything else is rejected with a 400. + :param status: Only include transcriptions in this status + :param page_token: Opaque cursor for retrieving the next or previous page of results + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: ApiResponse with TranscriptionPage, status code, and headers + """ + data = values.of( + { + "createdAfter": serialize.iso8601_datetime(created_after), + "createdBefore": serialize.iso8601_datetime(created_before), + "languageCode": language_code, + "sourceId": source_id, + "status": status, + "pageToken": page_token, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response, status_code, response_headers = ( + await self._version.page_with_response_info_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + ) + page = TranscriptionPage(self._version, response) + return ApiResponse(data=page, status_code=status_code, headers=response_headers) + + def get_page(self, target_url: str) -> TranscriptionPage: + """ + Retrieve a specific page of TranscriptionInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of TranscriptionInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return TranscriptionPage(self._version, response) + + async def get_page_async(self, target_url: str) -> TranscriptionPage: + """ + Asynchronously retrieve a specific page of TranscriptionInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of TranscriptionInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return TranscriptionPage(self._version, response) + def get(self, transcription_id: str) -> TranscriptionContext: """ Constructs a TranscriptionContext