From 40a12bffbc5ad9d22407390845cdb1635ed53bab Mon Sep 17 00:00:00 2001 From: Twilio Date: Tue, 11 Aug 2026 15:28:28 +0530 Subject: [PATCH 1/2] [Librarian] Regenerated @ f443c9dfa233e41d0e61c9ed6ca2b162467a08b5 89762bc866ded0b2ca596431610a8ad4bc2b215c --- CHANGES.md | 228 +++ twilio/rest/__init__.py | 30 - .../rest/accounts/v1/auth_token_promotion.py | 104 +- .../rest/accounts/v1/secondary_auth_token.py | 204 ++- .../rest/api/v2010/account/call/__init__.py | 16 + .../v2010/account/conference/participant.py | 144 ++ twilio/rest/assistants/AssistantsBase.py | 44 - twilio/rest/assistants/__init__.py | 56 - twilio/rest/assistants/v1/__init__.py | 75 - .../rest/assistants/v1/assistant/__init__.py | 1499 ----------------- .../v1/assistant/assistants_knowledge.py | 871 ---------- .../v1/assistant/assistants_tool.py | 869 ---------- .../rest/assistants/v1/assistant/feedback.py | 638 ------- .../rest/assistants/v1/assistant/message.py | 247 --- .../rest/assistants/v1/knowledge/__init__.py | 1443 ---------------- twilio/rest/assistants/v1/knowledge/chunk.py | 471 ------ .../v1/knowledge/knowledge_status.py | 264 --- twilio/rest/assistants/v1/policy.py | 540 ------ twilio/rest/assistants/v1/session/__init__.py | 680 -------- twilio/rest/assistants/v1/session/message.py | 483 ------ twilio/rest/assistants/v1/tool.py | 1397 --------------- twilio/rest/content/v1/content/__init__.py | 1 + .../v1/conversation/message/__init__.py | 48 +- .../service/conversation/message/__init__.py | 48 +- twilio/rest/conversations/v2/__init__.py | 12 +- twilio/rest/conversations/v2/action.py | 23 +- twilio/rest/conversations/v2/communication.py | 120 +- twilio/rest/conversations/v2/configuration.py | 106 +- twilio/rest/conversations/v2/conversation.py | 105 +- twilio/rest/conversations/v2/operation.py | 48 +- twilio/rest/conversations/v2/participant.py | 159 +- twilio/rest/iam/IamBase.py | 13 + twilio/rest/iam/v1/new_api_key.py | 24 +- twilio/rest/iam/v1/o_auth_app.py | 17 + twilio/rest/insights/v1/call/call_summary.py | 10 + twilio/rest/insights/v1/call/event.py | 4 + twilio/rest/insights/v1/call_summaries.py | 10 + twilio/rest/insights/v3/__init__.py | 10 +- twilio/rest/insights/v3/metadata.py | 2 +- twilio/rest/insights/v3/query.py | 2 +- twilio/rest/insights/v3/query_job.py | 1004 +++++++++++ twilio/rest/insights/v3/result.py | 208 +++ twilio/rest/intelligence/v3/__init__.py | 8 + twilio/rest/intelligence/v3/conversation.py | 48 +- twilio/rest/intelligence/v3/operator.py | 14 +- twilio/rest/intelligence/v3/rule_execution.py | 199 +++ twilio/rest/knowledge/v2/__init__.py | 6 +- twilio/rest/knowledge/v2/chunk.py | 10 + twilio/rest/knowledge/v2/knowledge.py | 3 +- twilio/rest/knowledge/v2/knowledge_basis.py | 4 +- twilio/rest/knowledge/v2/search.py | 167 +- twilio/rest/memory/v1/__init__.py | 31 +- twilio/rest/memory/v1/bulk.py | 185 +- twilio/rest/memory/v1/conversation_summary.py | 38 +- twilio/rest/memory/v1/data_mapping.py | 15 +- twilio/rest/memory/v1/event.py | 315 ---- twilio/rest/memory/v1/identifier.py | 2 +- .../memory/v1/identity_resolution_setting.py | 342 +--- twilio/rest/memory/v1/import_.py | 270 ++- twilio/rest/memory/v1/lookup.py | 2 +- twilio/rest/memory/v1/observation.py | 117 +- twilio/rest/memory/v1/operation.py | 2 +- twilio/rest/memory/v1/profile.py | 40 +- twilio/rest/memory/v1/recall.py | 2 +- twilio/rest/memory/v1/revision.py | 2 +- twilio/rest/memory/v1/store.py | 4 +- twilio/rest/memory/v1/trait.py | 2 +- twilio/rest/memory/v1/trait_group.py | 52 +- twilio/rest/messaging/v2/channels_sender.py | 20 + twilio/rest/messaging/v3/typing_indicator.py | 16 +- .../oauth/v1/oauth_authorization_server.py | 157 ++ twilio/rest/oauth/v2/authorize.py | 32 +- twilio/rest/oauth/v2/token.py | 16 + twilio/rest/routes/RoutesBase.py | 11 + twilio/rest/routes/v3/__init__.py | 43 + twilio/rest/routes/v3/phone_number.py | 521 ++++++ .../serverless/v1/service/build/__init__.py | 1 + twilio/rest/trusthub/v1/__init__.py | 84 + .../trusthub/v1/a2_p_brand_registration.py | 436 +++++ ...2_p_brand_registration_embedded_session.py | 164 ++ .../trusthub/v1/a2_p_campaign_registration.py | 402 +++++ ..._campaign_registration_embedded_session.py | 164 ++ .../v1/customer_profiles_provisional_copy.py | 423 +++++ .../v1/trust_products_provisional_copy.py | 421 +++++ twilio/rest/voice/VoiceBase.py | 11 + twilio/rest/voice/v2/__init__.py | 79 + .../voice/v2/account_default_configuration.py | 838 +++++++++ .../rest/voice/v2/configuration/__init__.py | 432 +++++ twilio/rest/voice/v2/configuration/default.py | 320 ++++ twilio/rest/voice/v2/recording.py | 1136 +++++++++++++ twilio/rest/voice/v2/transcription.py | 1067 ++++++++++++ twilio/rest/voice/v2/type.py | 683 ++++++++ twilio/twiml/voice_response.py | 143 +- 93 files changed, 10657 insertions(+), 11120 deletions(-) delete mode 100644 twilio/rest/assistants/AssistantsBase.py delete mode 100644 twilio/rest/assistants/__init__.py delete mode 100644 twilio/rest/assistants/v1/__init__.py delete mode 100644 twilio/rest/assistants/v1/assistant/__init__.py delete mode 100644 twilio/rest/assistants/v1/assistant/assistants_knowledge.py delete mode 100644 twilio/rest/assistants/v1/assistant/assistants_tool.py delete mode 100644 twilio/rest/assistants/v1/assistant/feedback.py delete mode 100644 twilio/rest/assistants/v1/assistant/message.py delete mode 100644 twilio/rest/assistants/v1/knowledge/__init__.py delete mode 100644 twilio/rest/assistants/v1/knowledge/chunk.py delete mode 100644 twilio/rest/assistants/v1/knowledge/knowledge_status.py delete mode 100644 twilio/rest/assistants/v1/policy.py delete mode 100644 twilio/rest/assistants/v1/session/__init__.py delete mode 100644 twilio/rest/assistants/v1/session/message.py delete mode 100644 twilio/rest/assistants/v1/tool.py create mode 100644 twilio/rest/insights/v3/query_job.py create mode 100644 twilio/rest/insights/v3/result.py create mode 100644 twilio/rest/intelligence/v3/rule_execution.py delete mode 100644 twilio/rest/memory/v1/event.py create mode 100644 twilio/rest/oauth/v1/oauth_authorization_server.py create mode 100644 twilio/rest/routes/v3/__init__.py create mode 100644 twilio/rest/routes/v3/phone_number.py create mode 100644 twilio/rest/trusthub/v1/a2_p_brand_registration.py create mode 100644 twilio/rest/trusthub/v1/a2_p_brand_registration_embedded_session.py create mode 100644 twilio/rest/trusthub/v1/a2_p_campaign_registration.py create mode 100644 twilio/rest/trusthub/v1/a2_p_campaign_registration_embedded_session.py create mode 100644 twilio/rest/trusthub/v1/customer_profiles_provisional_copy.py create mode 100644 twilio/rest/trusthub/v1/trust_products_provisional_copy.py create mode 100644 twilio/rest/voice/v2/__init__.py create mode 100644 twilio/rest/voice/v2/account_default_configuration.py create mode 100644 twilio/rest/voice/v2/configuration/__init__.py create mode 100644 twilio/rest/voice/v2/configuration/default.py create mode 100644 twilio/rest/voice/v2/recording.py create mode 100644 twilio/rest/voice/v2/transcription.py create mode 100644 twilio/rest/voice/v2/type.py diff --git a/CHANGES.md b/CHANGES.md index 5ac12d5bb4..60487c62da 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,234 @@ twilio-python Changelog Here you can see the full list of changes between each twilio-python release. +[2026-08-11] Version 9.11.0 +--------------------------- +**Library - Fix** +- [PR #929](https://github.com/twilio/twilio-python/pull/929): mock HTTP session in TestUserAgentClients to avoid live network calls. Thanks to [@shrutiburman](https://github.com/shrutiburman)! + +**Twiml** +- Remove `` noun from `` verb as part of the AI Assistants deprecation **(breaking change)** +- Add `passports` attribute to `` verb for SHAKEN/STIR passport passthrough + +**Accounts** +- Add `SuppressEmailNotification` parameter to the Secondary Auth Token and Auth Token promotion endpoints. Set it to `true` to suppress the email notification sent to account owners and administrators. Defaults to `false`, preserving existing behavior. +- Add SMS Pumping Protection GET and POST API + +**Ai** +- Removing ai workbench apis + +**Api** +- Add missing `uri` property to the `twiml_session` resource + +**Data-ingress** +- ## 2026-08-07 +- **Removed 1 API path**: +- `/v1/DataQuery` (Realtime DataQuery) +- ## 2026-07-07 +- **Added 1 new API path (data plane)**: +- `/v1/DataQuery` (Realtime DataQuery) +- ## 2026-06-17 +- **Content updates**: +- Added properties to `OAuthJWTBearerCredentials`: privateKey, privateKeyPassphrase +- ## 2026-06-12 +- **Added 16 new path(s)**: +- `/v1/DataSyncs/{syncId}` (FetchDataSync) +- `/v1/CloudAppSources/{sourceId}/Objects` (ListCloudAppObjects) +- `/v1/WarehouseSources/{sourceId}/Preview` (CreateWarehousePreview) +- `/v1/WarehouseSources/{sourceId}/Preview/{operationId}` (FetchWarehousePreview) +- `/v1/DataSample/{operationId}` (FetchDataSample) +- `/v1/ControlPlane/CloudAppSources/{sourceId}` (FetchCloudAppSource, PatchCloudAppSource, DeleteCloudAppSource) +- `/v1/ControlPlane/CloudAppSources/{sourceId}/Datasets` (ListCloudAppDatasets, CreateCloudAppDataset) +- `/v1/ControlPlane/CloudAppSources/{sourceId}/Datasets/{datasetId}` (FetchCloudAppDataset, PatchCloudAppDataset, DeleteCloudAppDataset) +- `/v1/ControlPlane/WarehouseSources/{sourceId}` (FetchWarehouseSource, PatchWarehouseSource, DeleteWarehouseSource) +- `/v1/ControlPlane/WarehouseSources/{sourceId}/Datasets` (ListWarehouseDatasets, CreateWarehouseDataset) +- ...and 6 more paths +- **Removed 16 path(s)**: +- `/v1/DataSyncs/{SyncId}` (FetchDataSync) +- `/v1/CloudAppSources/{SourceId}/Objects` (ListCloudAppObjects) +- `/v1/WarehouseSources/{SourceId}/Preview` (CreateWarehousePreview) +- `/v1/WarehouseSources/{SourceId}/Preview/{OperationId}` (FetchWarehousePreview) +- `/v1/DataSample/{OperationId}` (FetchDataSample) +- `/v1/ControlPlane/CloudAppSources/{SourceId}` (FetchCloudAppSource, PatchCloudAppSource, DeleteCloudAppSource) +- `/v1/ControlPlane/CloudAppSources/{SourceId}/Datasets` (ListCloudAppDatasets, CreateCloudAppDataset) +- `/v1/ControlPlane/CloudAppSources/{SourceId}/Datasets/{DatasetId}` (FetchCloudAppDataset, PatchCloudAppDataset, DeleteCloudAppDataset) +- `/v1/ControlPlane/WarehouseSources/{SourceId}` (FetchWarehouseSource, PatchWarehouseSource, DeleteWarehouseSource) +- `/v1/ControlPlane/WarehouseSources/{SourceId}/Datasets` (ListWarehouseDatasets, CreateWarehouseDataset) +- ...and 6 more paths +- ## 2026-06-11 +- **Added 3 new Signal API path(s) for public exposure (data plane)**: +- `/v1/EventSources/{sourceId}/Signals` (ListSignals) +- `/v1/EventSources/{sourceId}/Signals/{signalKey}` (GetSignalBySignalKey) +- `/v1/EventSources/{sourceId}/SignalStats` (ListSignalStats) +- **Added new Signal API schemas**: +- Signal, SignalListResponse, HourlyStats, SignalStatsResponse +- ## 2026-05-26 +- **Added 12 new path(s) for public exposure**: +- `/v1/ControlPlane/EventSources` (CreateEventSource, ListEventSources) +- `/v1/ControlPlane/EventSources/{SourceId}` (FetchEventSource, PatchEventSource, DeleteEventSource) +- `/v1/ControlPlane/EventSources/{SourceId}/WriteKeys` (CreateWriteKey, ListWriteKeys) +- `/v1/ControlPlane/EventSources/{SourceId}/WriteKeys/{WriteKey}` (DeleteWriteKey) +- `/v1/ControlPlane/EventSources/{SourceId}/Datasets` (CreateEventSourceDataset, ListEventSourceDatasets) +- `/v1/ControlPlane/EventSources/{SourceId}/Datasets/{DatasetId}` (FetchEventSourceDataset, PatchEventSourceDataset, DeleteEventSourceDataset) +- `/v1/ControlPlane/EventSources/{SourceId}/EventSchemas` (CreateEventSchema, ListEventSchemas) +- `/v1/ControlPlane/EventSources/{SourceId}/EventSchemas/{SchemaId}` (FetchEventSchema, PatchEventSchema, DeleteEventSchema) +- `/v1/ControlPlane/AutoInstrumentationRule` (CreateAutoInstrumentationRule, ListAutoInstrumentationRules) +- `/v1/ControlPlane/AutoInstrumentationRule/{AutoInstrumentationRuleId}` (FetchAutoInstrumentationRule, PatchAutoInstrumentationRule, DeleteAutoInstrumentationRule) +- `/v1/ControlPlane/AutoInstrumentationRule/{AutoInstrumentationRuleId}/Versions` (ListAutoInstrumentationRuleVersions) +- `/v1/ControlPlane/AutoInstrumentationRule/{AutoInstrumentationRuleId}/Versions/{Version}` (FetchAutoInstrumentationRuleVersion) +- **Added new schemas**: +- EventSource, EventSourceCreate, EventSourceUpdate +- WriteKey, WriteKeyCreate +- EventSourceDataset, EventSourceDatasetCreate, EventSourceDatasetUpdate +- EventSchema, EventSchemaCreate, EventSchemaUpdate, EventSchemaField, EventSchemaProperty +- AutoInstrumentationRule, AutoInstrumentationRuleCreate, AutoInstrumentationRuleUpdate +- AutoInstrumentationRuleVersion, AutoInstrumentationRuleVersionsResponse +- ## 2026-06-12 +- **Added 16 new path(s)**: +- `/v1/DataSyncs/{syncId}` (FetchDataSync) +- `/v1/CloudAppSources/{sourceId}/Objects` (ListCloudAppObjects) +- `/v1/WarehouseSources/{sourceId}/Preview` (CreateWarehousePreview) +- `/v1/WarehouseSources/{sourceId}/Preview/{operationId}` (FetchWarehousePreview) +- `/v1/DataSample/{operationId}` (FetchDataSample) +- `/v1/ControlPlane/CloudAppSources/{sourceId}` (FetchCloudAppSource, PatchCloudAppSource, DeleteCloudAppSource) +- `/v1/ControlPlane/CloudAppSources/{sourceId}/Datasets` (ListCloudAppDatasets, CreateCloudAppDataset) +- `/v1/ControlPlane/CloudAppSources/{sourceId}/Datasets/{datasetId}` (FetchCloudAppDataset, PatchCloudAppDataset, DeleteCloudAppDataset) +- `/v1/ControlPlane/WarehouseSources/{sourceId}` (FetchWarehouseSource, PatchWarehouseSource, DeleteWarehouseSource) +- `/v1/ControlPlane/WarehouseSources/{sourceId}/Datasets` (ListWarehouseDatasets, CreateWarehouseDataset) +- ...and 6 more paths +- **Removed 16 path(s)**: +- `/v1/DataSyncs/{SyncId}` (FetchDataSync) +- `/v1/CloudAppSources/{SourceId}/Objects` (ListCloudAppObjects) +- `/v1/WarehouseSources/{SourceId}/Preview` (CreateWarehousePreview) +- `/v1/WarehouseSources/{SourceId}/Preview/{OperationId}` (FetchWarehousePreview) +- `/v1/DataSample/{OperationId}` (FetchDataSample) +- `/v1/ControlPlane/CloudAppSources/{SourceId}` (FetchCloudAppSource, PatchCloudAppSource, DeleteCloudAppSource) +- `/v1/ControlPlane/CloudAppSources/{SourceId}/Datasets` (ListCloudAppDatasets, CreateCloudAppDataset) +- `/v1/ControlPlane/CloudAppSources/{SourceId}/Datasets/{DatasetId}` (FetchCloudAppDataset, PatchCloudAppDataset, DeleteCloudAppDataset) +- `/v1/ControlPlane/WarehouseSources/{SourceId}` (FetchWarehouseSource, PatchWarehouseSource, DeleteWarehouseSource) +- `/v1/ControlPlane/WarehouseSources/{SourceId}/Datasets` (ListWarehouseDatasets, CreateWarehouseDataset) +- ...and 6 more paths + +**Deletions** +- # API Changes +- ## 2026-06-23 +- Initial public Rest Proxy registration for the User Data Deletions API +- (`POST` / `GET /v1/UserDataDeletions`, `GET /v1/UserDataDeletions/{deletionId}`, +- `GET /v1/Operations/{operationId}`). +- A single request may mix identifier formats: E.164 phone numbers, email +- addresses, and profile IDs. + +**Destinations** +- # API Changes +- ## 2026-08-07 +- **Content updates**: +- Updated summary for `ListDestinationSupportedEventTypes` +- ## 2026-08-07 +- **Content updates**: +- Updated summary for `ListDestinationSupportedEventTypes` +- ## 2026-08-07 +- **Added 3 new path(s)**: +- `/v1/Catalog/DestinationSupportedEventTypes` (ListDestinationSupportedEventTypes) +- `/v1/ControlPlane/Subscriptions/{subscriptionId}/EventTypes` (ListSubscribedEvents, CreateSubscribedEvent) +- `/v1/ControlPlane/Subscriptions/{subscriptionId}/EventTypes/{eventType}` (GetSubscribedEvent, UpdateSubscribedEvent, DeleteSubscribedEvent) +- **Removed 3 path(s)**: +- `/v1/ControlPlane/Subscriptions/{subscriptionId}/SubscribedEvents` (ListSubscribedEvents, CreateSubscribedEvent) +- `/v1/ControlPlane/Subscriptions/{subscriptionId}/SubscribedEvents/{eventType}` (GetSubscribedEvent, UpdateSubscribedEvent, DeleteSubscribedEvent) +- `/v1/Catalog/DestinationEventTypes` (ListDestinationEventTypes) +- ## 2026-08-04 +- Minor updates (formatting, metadata) +- ## 2026-08-04 +- Minor updates (formatting, metadata) +- ## 2026-08-04 +- Minor updates (formatting, metadata) +- ## 2026-08-04 +- Minor updates (formatting, metadata) +- ## 2026-08-04 +- **Content updates**: +- Added properties to `SubscriptionResponse`: eventTypes +- ## 2026-08-03 +- **Content updates**: +- Added properties to `DestinationType`: documentationUrl, maturity, tier, categories +- ## 2026-07-27 +- Minor updates (formatting, metadata) +- ## 2026-07-23 +- **Content updates**: +- `meta` is now a required property in the response of `ListDestinations`, `ListSubscriptions`, and `ListSubscribedEvents` +- `CreateSubscribedEvent` request body schema consolidated onto `SubscribedEventInput` (previously `SubscribedEventCreate`, a duplicate schema) +- Added response examples for `ListDestinations`, `ListSubscriptions`, and `ListSubscribedEvents` +- ## 2026-07-23 +- **Added 1 new path(s)**: +- `/v1/Catalog/DestinationEventTypes` (ListDestinationEventTypes) +- ## 2026-07-22 +- **Content updates**: +- Added parameter(s) to `ListDestinations`: namePrefix +- Updated description for `UpdateSubscription` +- Added properties to `SubscriptionUpdate`: eventTypes +- ## 2026-07-16 +- Initial release with 9 paths and 18 operations + +**Events** +- Add `stage-ie1` realm support for EventTypes and Schemas endpoints (datataps-catalog) + +**Memory** +- ## 2026-08-10 +- Removed `Events` endpoints from the spec, as they were hidden, never implemented, and are not part of the public API +- ## 2026-08-07 +- **New functionality**: +- Added `pageSize`, `pageToken`, and `orderBy` query parameters to `ListProfileImportsV2`, plus a `meta` object in its response, to support pagination. +- **Content updates**: +- Updated the `ListProfileImportsV2` description to document the new pagination behavior. +- Corrected the example presigned upload URL on `CreateProfilesImportV2` to match the real S3 bucket naming convention. +- Corrected the `meta.key` example on `ListProfileTraits`'s response (was `profiles`, now `traits`) to accurately describe which response field it points to. +- ## 2026-08-07 +- **Content updates**: +- Updated `matchingRules` description in `IdentityResolutionSettingsCore` to remove compound `AND` rule documentation +- ## 2026-07-30 +- **Content updates**: +- Increased the maximum value for the Twilio error `code` from `99999` to `999999` +- ## 2026-07-28 +- **Content updates**: +- Updated the `pageSize` description on the pagination `Meta` schema to clarify it reflects the number of items actually returned, not the requested or default page size. +- ## 2026-07-13 +- **Content updates**: +- Renamed `ListProfiles` response schema references from `ProfileID`/`ProfilesMeta` to `IdentityProfileID`/`IdentityProfilesMeta` (new `IdentityProfilesMeta` schema added; `ProfileID`/`ProfilesMeta` retained for other operations). +- ## 2026-07-08 +- **Content updates**: +- Updated description for `CreateDataMappingSuggestion` +- Updated description for `FetchDataMappingSuggestion` +- ## 2026-07-06 +- **Added 2 new path(s)**: +- `/v1/ControlPlane/Stores/{storeId}/DataMappings/Suggestions` (ListDataMappingSuggestions, CreateDataMappingSuggestion) +- `/v1/ControlPlane/Stores/{storeId}/DataMappings/Suggestions/{suggestionId}` (FetchDataMappingSuggestion) +- ## 2026-06-26 +- **Content updates**: +- Minor updates (formatting, metadata) +- Updated x-twilio location parameter from `instance` to `list` for all endpoints that don't end with a /{param} +- Updated description for `UpdateProfileTraits` +- Updated summary for `UpdateProfileTraits` +- Removed properties from `MappingTraitItem`: fieldName +- Removed `additionalProperties` from `allof` schemas since it isn't supported and causes invalid lint errors on example blocks. +- matruity ga and libraryVisibility public +- ## 2026-06-24 +- **Content updates**: +- Add ConversationID as an optional query parameter for ListObservations and ListConversationSummaries +- ## 2026-05-01 +- **Content updates**: +- Updated description & summary for `UpdateProfileTraits` +- Updated description for `FetchIdentityResolutionSettings` +- Removed properties from `MappingTraitItem`: fieldName +- Updated patch Observations to not require `occurredAt`, `content`, or `source` +- ## 2026-04-28 +- **Content updates**: +- Updated description for `UpdateProfileTraits` +- Updated summary for `UpdateProfileTraits` +- Added properties to `TraitDefinition`: validationRule +- Removed properties from `MappingTraitItem`: fieldName + +**Messaging_admin** +- Add Intelligent Alerts endpoints at `/v1/Messaging/IntelligentAlertsEvents/*`, routing to intelligent-alerts-api via messaging-monkey-backend. Account SID is a required query parameter (`accountSid`) on all three endpoints. + + [2026-05-07] Version 9.10.9 --------------------------- **Conversations** diff --git a/twilio/rest/__init__.py b/twilio/rest/__init__.py index fe898b2095..fe422a931b 100644 --- a/twilio/rest/__init__.py +++ b/twilio/rest/__init__.py @@ -16,7 +16,6 @@ if TYPE_CHECKING: from twilio.rest.accounts import Accounts from twilio.rest.api import Api - from twilio.rest.assistants import Assistants from twilio.rest.bulkexports import Bulkexports from twilio.rest.chat import Chat from twilio.rest.content import Content @@ -26,7 +25,6 @@ from twilio.rest.frontline_api import FrontlineApi from twilio.rest.preview_iam import PreviewIam from twilio.rest.iam import Iam - from twilio.rest.iam import Iam from twilio.rest.insights import Insights from twilio.rest.intelligence import Intelligence from twilio.rest.ip_messaging import IpMessaging @@ -131,7 +129,6 @@ def __init__( # Domains self._accounts: Optional["Accounts"] = None self._api: Optional["Api"] = None - self._assistants: Optional["Assistants"] = None self._bulkexports: Optional["Bulkexports"] = None self._chat: Optional["Chat"] = None self._content: Optional["Content"] = None @@ -141,7 +138,6 @@ def __init__( self._frontline_api: Optional["FrontlineApi"] = None self._preview_iam: Optional["PreviewIam"] = None self._iam: Optional["Iam"] = None - self._iam: Optional["Iam"] = None self._insights: Optional["Insights"] = None self._intelligence: Optional["Intelligence"] = None self._ip_messaging: Optional["IpMessaging"] = None @@ -196,19 +192,6 @@ def api(self) -> "Api": self._api = Api(self) return self._api - @property - def assistants(self) -> "Assistants": - """ - Access the Assistants Twilio Domain - - :returns: Assistants Twilio Domain - """ - if self._assistants is None: - from twilio.rest.assistants import Assistants - - self._assistants = Assistants(self) - return self._assistants - @property def bulkexports(self) -> "Bulkexports": """ @@ -326,19 +309,6 @@ def iam(self) -> "Iam": self._iam = Iam(self) return self._iam - @property - def iam(self) -> "Iam": - """ - Access the Iam Twilio Domain - - :returns: Iam Twilio Domain - """ - if self._iam is None: - from twilio.rest.iam import Iam - - self._iam = Iam(self) - return self._iam - @property def insights(self) -> "Insights": """ diff --git a/twilio/rest/accounts/v1/auth_token_promotion.py b/twilio/rest/accounts/v1/auth_token_promotion.py index c60ea48baa..e8679fd724 100644 --- a/twilio/rest/accounts/v1/auth_token_promotion.py +++ b/twilio/rest/accounts/v1/auth_token_promotion.py @@ -13,8 +13,8 @@ """ from datetime import datetime -from typing import Any, Dict, Optional -from twilio.base import deserialize, values +from typing import Any, Dict, Optional, Union +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 @@ -60,41 +60,61 @@ def _proxy(self) -> "AuthTokenPromotionContext": ) return self._context - def update(self) -> "AuthTokenPromotionInstance": + def update( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> "AuthTokenPromotionInstance": """ Update the AuthTokenPromotionInstance + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: The updated AuthTokenPromotionInstance """ - return self._proxy.update() + return self._proxy.update( + suppress_email_notification=suppress_email_notification, + ) - async def update_async(self) -> "AuthTokenPromotionInstance": + async def update_async( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> "AuthTokenPromotionInstance": """ Asynchronous coroutine to update the AuthTokenPromotionInstance + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: The updated AuthTokenPromotionInstance """ - return await self._proxy.update_async() + return await self._proxy.update_async( + suppress_email_notification=suppress_email_notification, + ) - def update_with_http_info(self) -> ApiResponse: + def update_with_http_info( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> ApiResponse: """ Update the AuthTokenPromotionInstance with HTTP info + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: ApiResponse with instance, status code, and headers """ - return self._proxy.update_with_http_info() + return self._proxy.update_with_http_info( + suppress_email_notification=suppress_email_notification, + ) - async def update_with_http_info_async(self) -> ApiResponse: + async def update_with_http_info_async( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> ApiResponse: """ Asynchronous coroutine to update the AuthTokenPromotionInstance with HTTP info + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: ApiResponse with instance, status code, and headers """ - return await self._proxy.update_with_http_info_async() + return await self._proxy.update_with_http_info_async( + suppress_email_notification=suppress_email_notification, + ) def __repr__(self) -> str: """ @@ -118,7 +138,9 @@ def __init__(self, version: Version): self._uri = "/AuthTokens/Promote" - def _update(self) -> tuple: + def _update( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> tuple: """ Internal helper for update operation @@ -126,37 +148,57 @@ def _update(self) -> tuple: tuple: (payload, status_code, headers) """ - data = values.of({}) + data = values.of( + { + "SuppressEmailNotification": serialize.boolean_to_string( + suppress_email_notification + ), + } + ) headers = values.of({}) + headers["Content-Type"] = "application/x-www-form-urlencoded" + headers["Accept"] = "application/json" return self._version.update_with_response_info( method="POST", uri=self._uri, data=data, headers=headers ) - def update(self) -> AuthTokenPromotionInstance: + def update( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> AuthTokenPromotionInstance: """ Update the AuthTokenPromotionInstance + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: The updated AuthTokenPromotionInstance """ - payload, _, _ = self._update() + payload, _, _ = self._update( + suppress_email_notification=suppress_email_notification + ) return AuthTokenPromotionInstance(self._version, payload) - def update_with_http_info(self) -> ApiResponse: + def update_with_http_info( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> ApiResponse: """ Update the AuthTokenPromotionInstance and return response metadata + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: ApiResponse with instance, status code, and headers """ - payload, status_code, headers = self._update() + payload, status_code, headers = self._update( + suppress_email_notification=suppress_email_notification + ) instance = AuthTokenPromotionInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) - async def _update_async(self) -> tuple: + async def _update_async( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> tuple: """ Internal async helper for update operation @@ -164,33 +206,51 @@ async def _update_async(self) -> tuple: tuple: (payload, status_code, headers) """ - data = values.of({}) + data = values.of( + { + "SuppressEmailNotification": serialize.boolean_to_string( + suppress_email_notification + ), + } + ) headers = values.of({}) + headers["Content-Type"] = "application/x-www-form-urlencoded" + headers["Accept"] = "application/json" return await self._version.update_with_response_info_async( method="POST", uri=self._uri, data=data, headers=headers ) - async def update_async(self) -> AuthTokenPromotionInstance: + async def update_async( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> AuthTokenPromotionInstance: """ Asynchronous coroutine to update the AuthTokenPromotionInstance + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: The updated AuthTokenPromotionInstance """ - payload, _, _ = await self._update_async() + payload, _, _ = await self._update_async( + suppress_email_notification=suppress_email_notification + ) return AuthTokenPromotionInstance(self._version, payload) - async def update_with_http_info_async(self) -> ApiResponse: + async def update_with_http_info_async( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> ApiResponse: """ Asynchronous coroutine to update the AuthTokenPromotionInstance and return response metadata + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: ApiResponse with instance, status code, and headers """ - payload, status_code, headers = await self._update_async() + payload, status_code, headers = await self._update_async( + suppress_email_notification=suppress_email_notification + ) instance = AuthTokenPromotionInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) diff --git a/twilio/rest/accounts/v1/secondary_auth_token.py b/twilio/rest/accounts/v1/secondary_auth_token.py index 9d79a739d7..c50297211d 100644 --- a/twilio/rest/accounts/v1/secondary_auth_token.py +++ b/twilio/rest/accounts/v1/secondary_auth_token.py @@ -13,8 +13,8 @@ """ from datetime import datetime -from typing import Any, Dict, Optional -from twilio.base import deserialize, values +from typing import Any, Dict, Optional, Union +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 @@ -60,77 +60,117 @@ def _proxy(self) -> "SecondaryAuthTokenContext": ) return self._context - def create(self) -> "SecondaryAuthTokenInstance": + def create( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> "SecondaryAuthTokenInstance": """ Create the SecondaryAuthTokenInstance + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: The created SecondaryAuthTokenInstance """ - return self._proxy.create() + return self._proxy.create( + suppress_email_notification=suppress_email_notification, + ) - async def create_async(self) -> "SecondaryAuthTokenInstance": + async def create_async( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> "SecondaryAuthTokenInstance": """ Asynchronous coroutine to create the SecondaryAuthTokenInstance + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: The created SecondaryAuthTokenInstance """ - return await self._proxy.create_async() + return await self._proxy.create_async( + suppress_email_notification=suppress_email_notification, + ) - def create_with_http_info(self) -> ApiResponse: + def create_with_http_info( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> ApiResponse: """ Create the SecondaryAuthTokenInstance with HTTP info + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: ApiResponse with instance, status code, and headers """ - return self._proxy.create_with_http_info() + return self._proxy.create_with_http_info( + suppress_email_notification=suppress_email_notification, + ) - async def create_with_http_info_async(self) -> ApiResponse: + async def create_with_http_info_async( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> ApiResponse: """ Asynchronous coroutine to create the SecondaryAuthTokenInstance with HTTP info + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: ApiResponse with instance, status code, and headers """ - return await self._proxy.create_with_http_info_async() + return await self._proxy.create_with_http_info_async( + suppress_email_notification=suppress_email_notification, + ) - def delete(self) -> bool: + def delete( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> bool: """ Deletes the SecondaryAuthTokenInstance + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: True if delete succeeds, False otherwise """ - return self._proxy.delete() + return self._proxy.delete( + suppress_email_notification=suppress_email_notification, + ) - async def delete_async(self) -> bool: + async def delete_async( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> bool: """ Asynchronous coroutine that deletes the SecondaryAuthTokenInstance + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: True if delete succeeds, False otherwise """ - return await self._proxy.delete_async() + return await self._proxy.delete_async( + suppress_email_notification=suppress_email_notification, + ) - def delete_with_http_info(self) -> ApiResponse: + def delete_with_http_info( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> ApiResponse: """ Deletes the SecondaryAuthTokenInstance with HTTP info + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: ApiResponse with success boolean, status code, and headers """ - return self._proxy.delete_with_http_info() + return self._proxy.delete_with_http_info( + suppress_email_notification=suppress_email_notification, + ) - async def delete_with_http_info_async(self) -> ApiResponse: + async def delete_with_http_info_async( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> ApiResponse: """ Asynchronous coroutine that deletes the SecondaryAuthTokenInstance with HTTP info + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: ApiResponse with success boolean, status code, and headers """ - return await self._proxy.delete_with_http_info_async() + return await self._proxy.delete_with_http_info_async( + suppress_email_notification=suppress_email_notification, + ) def __repr__(self) -> str: """ @@ -154,7 +194,9 @@ def __init__(self, version: Version): self._uri = "/AuthTokens/Secondary" - def _create(self) -> tuple: + def _create( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> tuple: """ Internal helper for create operation @@ -162,37 +204,57 @@ def _create(self) -> tuple: tuple: (payload, status_code, headers) """ - data = values.of({}) + data = values.of( + { + "SuppressEmailNotification": serialize.boolean_to_string( + suppress_email_notification + ), + } + ) headers = values.of({}) + headers["Content-Type"] = "application/x-www-form-urlencoded" + headers["Accept"] = "application/json" return self._version.create_with_response_info( method="POST", uri=self._uri, data=data, headers=headers ) - def create(self) -> SecondaryAuthTokenInstance: + def create( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> SecondaryAuthTokenInstance: """ Create the SecondaryAuthTokenInstance + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: The created SecondaryAuthTokenInstance """ - payload, _, _ = self._create() + payload, _, _ = self._create( + suppress_email_notification=suppress_email_notification + ) return SecondaryAuthTokenInstance(self._version, payload) - def create_with_http_info(self) -> ApiResponse: + def create_with_http_info( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> ApiResponse: """ Create the SecondaryAuthTokenInstance and return response metadata + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: ApiResponse with instance, status code, and headers """ - payload, status_code, headers = self._create() + payload, status_code, headers = self._create( + suppress_email_notification=suppress_email_notification + ) instance = SecondaryAuthTokenInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) - async def _create_async(self) -> tuple: + async def _create_async( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> tuple: """ Internal async helper for create operation @@ -200,37 +262,57 @@ async def _create_async(self) -> tuple: tuple: (payload, status_code, headers) """ - data = values.of({}) + data = values.of( + { + "SuppressEmailNotification": serialize.boolean_to_string( + suppress_email_notification + ), + } + ) headers = values.of({}) + headers["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, data=data, headers=headers ) - async def create_async(self) -> SecondaryAuthTokenInstance: + async def create_async( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> SecondaryAuthTokenInstance: """ Asynchronous coroutine to create the SecondaryAuthTokenInstance + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: The created SecondaryAuthTokenInstance """ - payload, _, _ = await self._create_async() + payload, _, _ = await self._create_async( + suppress_email_notification=suppress_email_notification + ) return SecondaryAuthTokenInstance(self._version, payload) - async def create_with_http_info_async(self) -> ApiResponse: + async def create_with_http_info_async( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> ApiResponse: """ Asynchronous coroutine to create the SecondaryAuthTokenInstance and return response metadata + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: ApiResponse with instance, status code, and headers """ - payload, status_code, headers = await self._create_async() + payload, status_code, headers = await self._create_async( + suppress_email_notification=suppress_email_notification + ) instance = SecondaryAuthTokenInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) - def _delete(self) -> tuple: + def _delete( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> tuple: """ Internal helper for delete operation @@ -240,31 +322,51 @@ def _delete(self) -> tuple: headers = values.of({}) + params = values.of( + { + "SuppressEmailNotification": serialize.boolean_to_string( + suppress_email_notification + ), + } + ) + return self._version.delete_with_response_info( - method="DELETE", uri=self._uri, headers=headers + method="DELETE", uri=self._uri, headers=headers, params=params ) - def delete(self) -> bool: + def delete( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> bool: """ Deletes the SecondaryAuthTokenInstance + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: True if delete succeeds, False otherwise """ - success, _, _ = self._delete() + success, _, _ = self._delete( + suppress_email_notification=suppress_email_notification + ) return success - def delete_with_http_info(self) -> ApiResponse: + def delete_with_http_info( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> ApiResponse: """ Deletes the SecondaryAuthTokenInstance and return response metadata + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: ApiResponse with success boolean, status code, and headers """ - success, status_code, headers = self._delete() + success, status_code, headers = self._delete( + suppress_email_notification=suppress_email_notification + ) return ApiResponse(data=success, status_code=status_code, headers=headers) - async def _delete_async(self) -> tuple: + async def _delete_async( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> tuple: """ Internal async helper for delete operation @@ -274,28 +376,46 @@ async def _delete_async(self) -> tuple: headers = values.of({}) + params = values.of( + { + "SuppressEmailNotification": serialize.boolean_to_string( + suppress_email_notification + ), + } + ) + return await self._version.delete_with_response_info_async( - method="DELETE", uri=self._uri, headers=headers + method="DELETE", uri=self._uri, headers=headers, params=params ) - async def delete_async(self) -> bool: + async def delete_async( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> bool: """ Asynchronous coroutine that deletes the SecondaryAuthTokenInstance + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: True if delete succeeds, False otherwise """ - success, _, _ = await self._delete_async() + success, _, _ = await self._delete_async( + suppress_email_notification=suppress_email_notification + ) return success - async def delete_with_http_info_async(self) -> ApiResponse: + async def delete_with_http_info_async( + self, suppress_email_notification: Union[bool, object] = values.unset + ) -> ApiResponse: """ Asynchronous coroutine that deletes the SecondaryAuthTokenInstance and return response metadata + :param suppress_email_notification: Whether to suppress the email notification that Twilio sends to the owners and administrators of the account about this Auth Token change. Defaults to `false`, so Twilio sends the email. Set to `true` when rotating Auth Tokens across many subaccounts. :returns: ApiResponse with success boolean, status code, and headers """ - success, status_code, headers = await self._delete_async() + success, status_code, headers = await self._delete_async( + suppress_email_notification=suppress_email_notification + ) return ApiResponse(data=success, status_code=status_code, headers=headers) def __repr__(self) -> str: diff --git a/twilio/rest/api/v2010/account/call/__init__.py b/twilio/rest/api/v2010/account/call/__init__.py index 23b0121ee4..6cba76bf52 100644 --- a/twilio/rest/api/v2010/account/call/__init__.py +++ b/twilio/rest/api/v2010/account/call/__init__.py @@ -1109,6 +1109,7 @@ def _create( async_amd: Union[str, object] = values.unset, async_amd_status_callback: Union[str, object] = values.unset, async_amd_status_callback_method: Union[str, object] = values.unset, + passports: Union[str, object] = values.unset, byoc: Union[str, object] = values.unset, call_reason: Union[str, object] = values.unset, call_token: Union[str, object] = values.unset, @@ -1160,6 +1161,7 @@ def _create( "AsyncAmd": async_amd, "AsyncAmdStatusCallback": async_amd_status_callback, "AsyncAmdStatusCallbackMethod": async_amd_status_callback_method, + "Passports": passports, "Byoc": byoc, "CallReason": call_reason, "CallToken": call_token, @@ -1211,6 +1213,7 @@ def create( async_amd: Union[str, object] = values.unset, async_amd_status_callback: Union[str, object] = values.unset, async_amd_status_callback_method: Union[str, object] = values.unset, + passports: Union[str, object] = values.unset, byoc: Union[str, object] = values.unset, call_reason: Union[str, object] = values.unset, call_token: Union[str, object] = values.unset, @@ -1252,6 +1255,7 @@ def create( :param async_amd: Select whether to perform answering machine detection in the background. Default, blocks the execution of the call until Answering Machine Detection is completed. Can be: `true` or `false`. :param async_amd_status_callback: The URL that we should call using the `async_amd_status_callback_method` to notify customer application whether the call was answered by human, machine or fax. :param async_amd_status_callback_method: The HTTP method we should use when calling the `async_amd_status_callback` URL. Can be: `GET` or `POST` and the default is `POST`. + :param passports: The STIR/SHAKEN passport for this call, provided as a base64 encoded string. Multiple passports (at max 5) are comma separated and provided as base64 encoded string :param byoc: The SID of a BYOC (Bring Your Own Carrier) trunk to route this call with. Note that `byoc` is only meaningful when `to` is a phone number; it will otherwise be ignored. (Beta) :param call_reason: The Reason for the outgoing call. Use it to specify the purpose of the call that is presented on the called party's phone. (Branded Calls Beta) :param call_token: A token string needed to invoke a forwarded call. A call_token is generated when an incoming call is received on a Twilio number. Pass an incoming call's call_token value to a forwarded call via the call_token parameter when creating a new call. A forwarded call should bear the same CallerID of the original incoming call. @@ -1293,6 +1297,7 @@ def create( async_amd=async_amd, async_amd_status_callback=async_amd_status_callback, async_amd_status_callback_method=async_amd_status_callback_method, + passports=passports, byoc=byoc, call_reason=call_reason, call_token=call_token, @@ -1337,6 +1342,7 @@ def create_with_http_info( async_amd: Union[str, object] = values.unset, async_amd_status_callback: Union[str, object] = values.unset, async_amd_status_callback_method: Union[str, object] = values.unset, + passports: Union[str, object] = values.unset, byoc: Union[str, object] = values.unset, call_reason: Union[str, object] = values.unset, call_token: Union[str, object] = values.unset, @@ -1378,6 +1384,7 @@ def create_with_http_info( :param async_amd: Select whether to perform answering machine detection in the background. Default, blocks the execution of the call until Answering Machine Detection is completed. Can be: `true` or `false`. :param async_amd_status_callback: The URL that we should call using the `async_amd_status_callback_method` to notify customer application whether the call was answered by human, machine or fax. :param async_amd_status_callback_method: The HTTP method we should use when calling the `async_amd_status_callback` URL. Can be: `GET` or `POST` and the default is `POST`. + :param passports: The STIR/SHAKEN passport for this call, provided as a base64 encoded string. Multiple passports (at max 5) are comma separated and provided as base64 encoded string :param byoc: The SID of a BYOC (Bring Your Own Carrier) trunk to route this call with. Note that `byoc` is only meaningful when `to` is a phone number; it will otherwise be ignored. (Beta) :param call_reason: The Reason for the outgoing call. Use it to specify the purpose of the call that is presented on the called party's phone. (Branded Calls Beta) :param call_token: A token string needed to invoke a forwarded call. A call_token is generated when an incoming call is received on a Twilio number. Pass an incoming call's call_token value to a forwarded call via the call_token parameter when creating a new call. A forwarded call should bear the same CallerID of the original incoming call. @@ -1419,6 +1426,7 @@ def create_with_http_info( async_amd=async_amd, async_amd_status_callback=async_amd_status_callback, async_amd_status_callback_method=async_amd_status_callback_method, + passports=passports, byoc=byoc, call_reason=call_reason, call_token=call_token, @@ -1464,6 +1472,7 @@ async def _create_async( async_amd: Union[str, object] = values.unset, async_amd_status_callback: Union[str, object] = values.unset, async_amd_status_callback_method: Union[str, object] = values.unset, + passports: Union[str, object] = values.unset, byoc: Union[str, object] = values.unset, call_reason: Union[str, object] = values.unset, call_token: Union[str, object] = values.unset, @@ -1515,6 +1524,7 @@ async def _create_async( "AsyncAmd": async_amd, "AsyncAmdStatusCallback": async_amd_status_callback, "AsyncAmdStatusCallbackMethod": async_amd_status_callback_method, + "Passports": passports, "Byoc": byoc, "CallReason": call_reason, "CallToken": call_token, @@ -1566,6 +1576,7 @@ async def create_async( async_amd: Union[str, object] = values.unset, async_amd_status_callback: Union[str, object] = values.unset, async_amd_status_callback_method: Union[str, object] = values.unset, + passports: Union[str, object] = values.unset, byoc: Union[str, object] = values.unset, call_reason: Union[str, object] = values.unset, call_token: Union[str, object] = values.unset, @@ -1607,6 +1618,7 @@ async def create_async( :param async_amd: Select whether to perform answering machine detection in the background. Default, blocks the execution of the call until Answering Machine Detection is completed. Can be: `true` or `false`. :param async_amd_status_callback: The URL that we should call using the `async_amd_status_callback_method` to notify customer application whether the call was answered by human, machine or fax. :param async_amd_status_callback_method: The HTTP method we should use when calling the `async_amd_status_callback` URL. Can be: `GET` or `POST` and the default is `POST`. + :param passports: The STIR/SHAKEN passport for this call, provided as a base64 encoded string. Multiple passports (at max 5) are comma separated and provided as base64 encoded string :param byoc: The SID of a BYOC (Bring Your Own Carrier) trunk to route this call with. Note that `byoc` is only meaningful when `to` is a phone number; it will otherwise be ignored. (Beta) :param call_reason: The Reason for the outgoing call. Use it to specify the purpose of the call that is presented on the called party's phone. (Branded Calls Beta) :param call_token: A token string needed to invoke a forwarded call. A call_token is generated when an incoming call is received on a Twilio number. Pass an incoming call's call_token value to a forwarded call via the call_token parameter when creating a new call. A forwarded call should bear the same CallerID of the original incoming call. @@ -1648,6 +1660,7 @@ async def create_async( async_amd=async_amd, async_amd_status_callback=async_amd_status_callback, async_amd_status_callback_method=async_amd_status_callback_method, + passports=passports, byoc=byoc, call_reason=call_reason, call_token=call_token, @@ -1692,6 +1705,7 @@ async def create_with_http_info_async( async_amd: Union[str, object] = values.unset, async_amd_status_callback: Union[str, object] = values.unset, async_amd_status_callback_method: Union[str, object] = values.unset, + passports: Union[str, object] = values.unset, byoc: Union[str, object] = values.unset, call_reason: Union[str, object] = values.unset, call_token: Union[str, object] = values.unset, @@ -1733,6 +1747,7 @@ async def create_with_http_info_async( :param async_amd: Select whether to perform answering machine detection in the background. Default, blocks the execution of the call until Answering Machine Detection is completed. Can be: `true` or `false`. :param async_amd_status_callback: The URL that we should call using the `async_amd_status_callback_method` to notify customer application whether the call was answered by human, machine or fax. :param async_amd_status_callback_method: The HTTP method we should use when calling the `async_amd_status_callback` URL. Can be: `GET` or `POST` and the default is `POST`. + :param passports: The STIR/SHAKEN passport for this call, provided as a base64 encoded string. Multiple passports (at max 5) are comma separated and provided as base64 encoded string :param byoc: The SID of a BYOC (Bring Your Own Carrier) trunk to route this call with. Note that `byoc` is only meaningful when `to` is a phone number; it will otherwise be ignored. (Beta) :param call_reason: The Reason for the outgoing call. Use it to specify the purpose of the call that is presented on the called party's phone. (Branded Calls Beta) :param call_token: A token string needed to invoke a forwarded call. A call_token is generated when an incoming call is received on a Twilio number. Pass an incoming call's call_token value to a forwarded call via the call_token parameter when creating a new call. A forwarded call should bear the same CallerID of the original incoming call. @@ -1774,6 +1789,7 @@ async def create_with_http_info_async( async_amd=async_amd, async_amd_status_callback=async_amd_status_callback, async_amd_status_callback_method=async_amd_status_callback_method, + passports=passports, byoc=byoc, call_reason=call_reason, call_token=call_token, diff --git a/twilio/rest/api/v2010/account/conference/participant.py b/twilio/rest/api/v2010/account/conference/participant.py index 616cad578a..1839657705 100644 --- a/twilio/rest/api/v2010/account/conference/participant.py +++ b/twilio/rest/api/v2010/account/conference/participant.py @@ -1007,8 +1007,17 @@ def _create( amd_status_callback_method: Union[str, object] = values.unset, trim: Union[str, object] = values.unset, call_token: Union[str, object] = values.unset, + passports: Union[str, object] = values.unset, client_notification_url: Union[str, object] = values.unset, caller_display_name: Union[str, object] = values.unset, + emergency_caller_position: Union[str, object] = values.unset, + emergency_caller_location: Union[str, object] = values.unset, + emergency_name: Union[str, object] = values.unset, + emergency_address: Union[str, object] = values.unset, + emergency_zip_code: Union[str, object] = values.unset, + emergency_city: Union[str, object] = values.unset, + emergency_state: Union[str, object] = values.unset, + emergency_country: Union[str, object] = values.unset, ) -> tuple: """ Internal helper for create operation @@ -1080,8 +1089,17 @@ def _create( "AmdStatusCallbackMethod": amd_status_callback_method, "Trim": trim, "CallToken": call_token, + "Passports": passports, "ClientNotificationUrl": client_notification_url, "CallerDisplayName": caller_display_name, + "EmergencyCallerPosition": emergency_caller_position, + "EmergencyCallerLocation": emergency_caller_location, + "EmergencyName": emergency_name, + "EmergencyAddress": emergency_address, + "EmergencyZipCode": emergency_zip_code, + "EmergencyCity": emergency_city, + "EmergencyState": emergency_state, + "EmergencyCountry": emergency_country, } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) @@ -1147,8 +1165,17 @@ def create( amd_status_callback_method: Union[str, object] = values.unset, trim: Union[str, object] = values.unset, call_token: Union[str, object] = values.unset, + passports: Union[str, object] = values.unset, client_notification_url: Union[str, object] = values.unset, caller_display_name: Union[str, object] = values.unset, + emergency_caller_position: Union[str, object] = values.unset, + emergency_caller_location: Union[str, object] = values.unset, + emergency_name: Union[str, object] = values.unset, + emergency_address: Union[str, object] = values.unset, + emergency_zip_code: Union[str, object] = values.unset, + emergency_city: Union[str, object] = values.unset, + emergency_state: Union[str, object] = values.unset, + emergency_country: Union[str, object] = values.unset, ) -> ParticipantInstance: """ Create the ParticipantInstance @@ -1202,8 +1229,17 @@ def create( :param amd_status_callback_method: The HTTP method we should use when calling the `amd_status_callback` URL. Can be: `GET` or `POST` and the default is `POST`. :param trim: Whether to trim any leading and trailing silence from the participant recording. Can be: `trim-silence` or `do-not-trim` and the default is `trim-silence`. :param call_token: A token string needed to invoke a forwarded call. A call_token is generated when an incoming call is received on a Twilio number. Pass an incoming call's call_token value to a forwarded call via the call_token parameter when creating a new call. A forwarded call should bear the same CallerID of the original incoming call. + :param passports: The STIR/SHAKEN passport for this call, provided as a base64 encoded string. Multiple passports (at max 5) are comma separated and provided as base64 encoded string :param client_notification_url: The URL that we should use to deliver `push call notification`. :param caller_display_name: The name that populates the display name in the From header. Must be between 2 and 255 characters. Only applicable for calls to sip address. + :param emergency_caller_position: The emergency caller's GPS coordinates in decimal degrees format. Format: \\\"latitude longitude\\\" (space-separated) - Latitude: decimal degrees, range -90.0 to +90.0 (negative for South, positive for North) - Longitude: decimal degrees, range -180.0 to +180.0 (negative for West, positive for East) - Precision: up to 6 decimal places recommended for meter-level accuracy Note: If the value exceeds 150 characters, only the first 150 characters will be used. + :param emergency_caller_location: The emergency caller's physical location description within a building or facility. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_name: The emergency caller's organization or entity name. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_address: The emergency caller's street address including street number and street name. Note: If the value exceeds 60 characters, only the first 60 characters will be used. + :param emergency_zip_code: The emergency caller's postal code or ZIP code. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_city: The emergency caller's city or municipality name. Should be the official city name as recognized by local authorities. Used in combination with state and country for emergency call routing. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_state: The emergency caller's state or province. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_country: The emergency caller's country. Currently supported US and CA only. Note: If the value exceeds 20 characters, only the first 20 characters will be used. :returns: The created ParticipantInstance """ @@ -1257,8 +1293,17 @@ def create( amd_status_callback_method=amd_status_callback_method, trim=trim, call_token=call_token, + passports=passports, client_notification_url=client_notification_url, caller_display_name=caller_display_name, + emergency_caller_position=emergency_caller_position, + emergency_caller_location=emergency_caller_location, + emergency_name=emergency_name, + emergency_address=emergency_address, + emergency_zip_code=emergency_zip_code, + emergency_city=emergency_city, + emergency_state=emergency_state, + emergency_country=emergency_country, ) return ParticipantInstance( self._version, @@ -1320,8 +1365,17 @@ def create_with_http_info( amd_status_callback_method: Union[str, object] = values.unset, trim: Union[str, object] = values.unset, call_token: Union[str, object] = values.unset, + passports: Union[str, object] = values.unset, client_notification_url: Union[str, object] = values.unset, caller_display_name: Union[str, object] = values.unset, + emergency_caller_position: Union[str, object] = values.unset, + emergency_caller_location: Union[str, object] = values.unset, + emergency_name: Union[str, object] = values.unset, + emergency_address: Union[str, object] = values.unset, + emergency_zip_code: Union[str, object] = values.unset, + emergency_city: Union[str, object] = values.unset, + emergency_state: Union[str, object] = values.unset, + emergency_country: Union[str, object] = values.unset, ) -> ApiResponse: """ Create the ParticipantInstance and return response metadata @@ -1375,8 +1429,17 @@ def create_with_http_info( :param amd_status_callback_method: The HTTP method we should use when calling the `amd_status_callback` URL. Can be: `GET` or `POST` and the default is `POST`. :param trim: Whether to trim any leading and trailing silence from the participant recording. Can be: `trim-silence` or `do-not-trim` and the default is `trim-silence`. :param call_token: A token string needed to invoke a forwarded call. A call_token is generated when an incoming call is received on a Twilio number. Pass an incoming call's call_token value to a forwarded call via the call_token parameter when creating a new call. A forwarded call should bear the same CallerID of the original incoming call. + :param passports: The STIR/SHAKEN passport for this call, provided as a base64 encoded string. Multiple passports (at max 5) are comma separated and provided as base64 encoded string :param client_notification_url: The URL that we should use to deliver `push call notification`. :param caller_display_name: The name that populates the display name in the From header. Must be between 2 and 255 characters. Only applicable for calls to sip address. + :param emergency_caller_position: The emergency caller's GPS coordinates in decimal degrees format. Format: \\\"latitude longitude\\\" (space-separated) - Latitude: decimal degrees, range -90.0 to +90.0 (negative for South, positive for North) - Longitude: decimal degrees, range -180.0 to +180.0 (negative for West, positive for East) - Precision: up to 6 decimal places recommended for meter-level accuracy Note: If the value exceeds 150 characters, only the first 150 characters will be used. + :param emergency_caller_location: The emergency caller's physical location description within a building or facility. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_name: The emergency caller's organization or entity name. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_address: The emergency caller's street address including street number and street name. Note: If the value exceeds 60 characters, only the first 60 characters will be used. + :param emergency_zip_code: The emergency caller's postal code or ZIP code. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_city: The emergency caller's city or municipality name. Should be the official city name as recognized by local authorities. Used in combination with state and country for emergency call routing. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_state: The emergency caller's state or province. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_country: The emergency caller's country. Currently supported US and CA only. Note: If the value exceeds 20 characters, only the first 20 characters will be used. :returns: ApiResponse with instance, status code, and headers """ @@ -1430,8 +1493,17 @@ def create_with_http_info( amd_status_callback_method=amd_status_callback_method, trim=trim, call_token=call_token, + passports=passports, client_notification_url=client_notification_url, caller_display_name=caller_display_name, + emergency_caller_position=emergency_caller_position, + emergency_caller_location=emergency_caller_location, + emergency_name=emergency_name, + emergency_address=emergency_address, + emergency_zip_code=emergency_zip_code, + emergency_city=emergency_city, + emergency_state=emergency_state, + emergency_country=emergency_country, ) instance = ParticipantInstance( self._version, @@ -1494,8 +1566,17 @@ async def _create_async( amd_status_callback_method: Union[str, object] = values.unset, trim: Union[str, object] = values.unset, call_token: Union[str, object] = values.unset, + passports: Union[str, object] = values.unset, client_notification_url: Union[str, object] = values.unset, caller_display_name: Union[str, object] = values.unset, + emergency_caller_position: Union[str, object] = values.unset, + emergency_caller_location: Union[str, object] = values.unset, + emergency_name: Union[str, object] = values.unset, + emergency_address: Union[str, object] = values.unset, + emergency_zip_code: Union[str, object] = values.unset, + emergency_city: Union[str, object] = values.unset, + emergency_state: Union[str, object] = values.unset, + emergency_country: Union[str, object] = values.unset, ) -> tuple: """ Internal async helper for create operation @@ -1567,8 +1648,17 @@ async def _create_async( "AmdStatusCallbackMethod": amd_status_callback_method, "Trim": trim, "CallToken": call_token, + "Passports": passports, "ClientNotificationUrl": client_notification_url, "CallerDisplayName": caller_display_name, + "EmergencyCallerPosition": emergency_caller_position, + "EmergencyCallerLocation": emergency_caller_location, + "EmergencyName": emergency_name, + "EmergencyAddress": emergency_address, + "EmergencyZipCode": emergency_zip_code, + "EmergencyCity": emergency_city, + "EmergencyState": emergency_state, + "EmergencyCountry": emergency_country, } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) @@ -1634,8 +1724,17 @@ async def create_async( amd_status_callback_method: Union[str, object] = values.unset, trim: Union[str, object] = values.unset, call_token: Union[str, object] = values.unset, + passports: Union[str, object] = values.unset, client_notification_url: Union[str, object] = values.unset, caller_display_name: Union[str, object] = values.unset, + emergency_caller_position: Union[str, object] = values.unset, + emergency_caller_location: Union[str, object] = values.unset, + emergency_name: Union[str, object] = values.unset, + emergency_address: Union[str, object] = values.unset, + emergency_zip_code: Union[str, object] = values.unset, + emergency_city: Union[str, object] = values.unset, + emergency_state: Union[str, object] = values.unset, + emergency_country: Union[str, object] = values.unset, ) -> ParticipantInstance: """ Asynchronously create the ParticipantInstance @@ -1689,8 +1788,17 @@ async def create_async( :param amd_status_callback_method: The HTTP method we should use when calling the `amd_status_callback` URL. Can be: `GET` or `POST` and the default is `POST`. :param trim: Whether to trim any leading and trailing silence from the participant recording. Can be: `trim-silence` or `do-not-trim` and the default is `trim-silence`. :param call_token: A token string needed to invoke a forwarded call. A call_token is generated when an incoming call is received on a Twilio number. Pass an incoming call's call_token value to a forwarded call via the call_token parameter when creating a new call. A forwarded call should bear the same CallerID of the original incoming call. + :param passports: The STIR/SHAKEN passport for this call, provided as a base64 encoded string. Multiple passports (at max 5) are comma separated and provided as base64 encoded string :param client_notification_url: The URL that we should use to deliver `push call notification`. :param caller_display_name: The name that populates the display name in the From header. Must be between 2 and 255 characters. Only applicable for calls to sip address. + :param emergency_caller_position: The emergency caller's GPS coordinates in decimal degrees format. Format: \\\"latitude longitude\\\" (space-separated) - Latitude: decimal degrees, range -90.0 to +90.0 (negative for South, positive for North) - Longitude: decimal degrees, range -180.0 to +180.0 (negative for West, positive for East) - Precision: up to 6 decimal places recommended for meter-level accuracy Note: If the value exceeds 150 characters, only the first 150 characters will be used. + :param emergency_caller_location: The emergency caller's physical location description within a building or facility. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_name: The emergency caller's organization or entity name. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_address: The emergency caller's street address including street number and street name. Note: If the value exceeds 60 characters, only the first 60 characters will be used. + :param emergency_zip_code: The emergency caller's postal code or ZIP code. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_city: The emergency caller's city or municipality name. Should be the official city name as recognized by local authorities. Used in combination with state and country for emergency call routing. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_state: The emergency caller's state or province. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_country: The emergency caller's country. Currently supported US and CA only. Note: If the value exceeds 20 characters, only the first 20 characters will be used. :returns: The created ParticipantInstance """ @@ -1744,8 +1852,17 @@ async def create_async( amd_status_callback_method=amd_status_callback_method, trim=trim, call_token=call_token, + passports=passports, client_notification_url=client_notification_url, caller_display_name=caller_display_name, + emergency_caller_position=emergency_caller_position, + emergency_caller_location=emergency_caller_location, + emergency_name=emergency_name, + emergency_address=emergency_address, + emergency_zip_code=emergency_zip_code, + emergency_city=emergency_city, + emergency_state=emergency_state, + emergency_country=emergency_country, ) return ParticipantInstance( self._version, @@ -1807,8 +1924,17 @@ async def create_with_http_info_async( amd_status_callback_method: Union[str, object] = values.unset, trim: Union[str, object] = values.unset, call_token: Union[str, object] = values.unset, + passports: Union[str, object] = values.unset, client_notification_url: Union[str, object] = values.unset, caller_display_name: Union[str, object] = values.unset, + emergency_caller_position: Union[str, object] = values.unset, + emergency_caller_location: Union[str, object] = values.unset, + emergency_name: Union[str, object] = values.unset, + emergency_address: Union[str, object] = values.unset, + emergency_zip_code: Union[str, object] = values.unset, + emergency_city: Union[str, object] = values.unset, + emergency_state: Union[str, object] = values.unset, + emergency_country: Union[str, object] = values.unset, ) -> ApiResponse: """ Asynchronously create the ParticipantInstance and return response metadata @@ -1862,8 +1988,17 @@ async def create_with_http_info_async( :param amd_status_callback_method: The HTTP method we should use when calling the `amd_status_callback` URL. Can be: `GET` or `POST` and the default is `POST`. :param trim: Whether to trim any leading and trailing silence from the participant recording. Can be: `trim-silence` or `do-not-trim` and the default is `trim-silence`. :param call_token: A token string needed to invoke a forwarded call. A call_token is generated when an incoming call is received on a Twilio number. Pass an incoming call's call_token value to a forwarded call via the call_token parameter when creating a new call. A forwarded call should bear the same CallerID of the original incoming call. + :param passports: The STIR/SHAKEN passport for this call, provided as a base64 encoded string. Multiple passports (at max 5) are comma separated and provided as base64 encoded string :param client_notification_url: The URL that we should use to deliver `push call notification`. :param caller_display_name: The name that populates the display name in the From header. Must be between 2 and 255 characters. Only applicable for calls to sip address. + :param emergency_caller_position: The emergency caller's GPS coordinates in decimal degrees format. Format: \\\"latitude longitude\\\" (space-separated) - Latitude: decimal degrees, range -90.0 to +90.0 (negative for South, positive for North) - Longitude: decimal degrees, range -180.0 to +180.0 (negative for West, positive for East) - Precision: up to 6 decimal places recommended for meter-level accuracy Note: If the value exceeds 150 characters, only the first 150 characters will be used. + :param emergency_caller_location: The emergency caller's physical location description within a building or facility. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_name: The emergency caller's organization or entity name. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_address: The emergency caller's street address including street number and street name. Note: If the value exceeds 60 characters, only the first 60 characters will be used. + :param emergency_zip_code: The emergency caller's postal code or ZIP code. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_city: The emergency caller's city or municipality name. Should be the official city name as recognized by local authorities. Used in combination with state and country for emergency call routing. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_state: The emergency caller's state or province. Note: If the value exceeds 20 characters, only the first 20 characters will be used. + :param emergency_country: The emergency caller's country. Currently supported US and CA only. Note: If the value exceeds 20 characters, only the first 20 characters will be used. :returns: ApiResponse with instance, status code, and headers """ @@ -1917,8 +2052,17 @@ async def create_with_http_info_async( amd_status_callback_method=amd_status_callback_method, trim=trim, call_token=call_token, + passports=passports, client_notification_url=client_notification_url, caller_display_name=caller_display_name, + emergency_caller_position=emergency_caller_position, + emergency_caller_location=emergency_caller_location, + emergency_name=emergency_name, + emergency_address=emergency_address, + emergency_zip_code=emergency_zip_code, + emergency_city=emergency_city, + emergency_state=emergency_state, + emergency_country=emergency_country, ) instance = ParticipantInstance( self._version, diff --git a/twilio/rest/assistants/AssistantsBase.py b/twilio/rest/assistants/AssistantsBase.py deleted file mode 100644 index a9c9e9afcd..0000000000 --- a/twilio/rest/assistants/AssistantsBase.py +++ /dev/null @@ -1,44 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - -from typing import Optional - -from twilio.base.domain import Domain -from twilio.rest import Client -from twilio.rest.assistants.v1 import V1 - - -class AssistantsBase(Domain): - - def __init__(self, twilio: Client): - """ - Initialize the Assistants Domain - - :returns: Domain for Assistants - """ - super().__init__(twilio, "https://assistants.twilio.com") - self._v1: Optional[V1] = None - - @property - def v1(self) -> V1: - """ - :returns: Versions v1 of Assistants - """ - if self._v1 is None: - self._v1 = V1(self) - return self._v1 - - def __repr__(self) -> str: - """ - Provide a friendly representation - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/assistants/__init__.py b/twilio/rest/assistants/__init__.py deleted file mode 100644 index 889daf9d29..0000000000 --- a/twilio/rest/assistants/__init__.py +++ /dev/null @@ -1,56 +0,0 @@ -from warnings import warn - -from twilio.rest.assistants.AssistantsBase import AssistantsBase -from twilio.rest.assistants.v1.assistant import AssistantList -from twilio.rest.assistants.v1.knowledge import KnowledgeList -from twilio.rest.assistants.v1.policy import PolicyList -from twilio.rest.assistants.v1.session import SessionList -from twilio.rest.assistants.v1.tool import ToolList - - -class Assistants(AssistantsBase): - - @property - def assistants(self) -> AssistantList: - warn( - "assistants is deprecated. Use v1.assistants instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.v1.assistants - - @property - def knowledge(self) -> KnowledgeList: - warn( - "knowledge is deprecated. Use v1.knowledge instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.v1.knowledge - - @property - def policies(self) -> PolicyList: - warn( - "policies is deprecated. Use v1.policies instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.v1.policies - - @property - def sessions(self) -> SessionList: - warn( - "sessions is deprecated. Use v1.sessions instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.v1.sessions - - @property - def tools(self) -> ToolList: - warn( - "tools is deprecated. Use v1.tools instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.v1.tools diff --git a/twilio/rest/assistants/v1/__init__.py b/twilio/rest/assistants/v1/__init__.py deleted file mode 100644 index 546ad14554..0000000000 --- a/twilio/rest/assistants/v1/__init__.py +++ /dev/null @@ -1,75 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Assistants - 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 Optional -from twilio.base.version import Version -from twilio.base.domain import Domain -from twilio.rest.assistants.v1.assistant import AssistantList -from twilio.rest.assistants.v1.knowledge import KnowledgeList -from twilio.rest.assistants.v1.policy import PolicyList -from twilio.rest.assistants.v1.session import SessionList -from twilio.rest.assistants.v1.tool import ToolList - - -class V1(Version): - - def __init__(self, domain: Domain): - """ - Initialize the V1 version of Assistants - - :param domain: The Twilio.assistants domain - """ - super().__init__(domain, "v1") - self._assistants: Optional[AssistantList] = None - self._knowledge: Optional[KnowledgeList] = None - self._policies: Optional[PolicyList] = None - self._sessions: Optional[SessionList] = None - self._tools: Optional[ToolList] = None - - @property - def assistants(self) -> AssistantList: - if self._assistants is None: - self._assistants = AssistantList(self) - return self._assistants - - @property - def knowledge(self) -> KnowledgeList: - if self._knowledge is None: - self._knowledge = KnowledgeList(self) - return self._knowledge - - @property - def policies(self) -> PolicyList: - if self._policies is None: - self._policies = PolicyList(self) - return self._policies - - @property - def sessions(self) -> SessionList: - if self._sessions is None: - self._sessions = SessionList(self) - return self._sessions - - @property - def tools(self) -> ToolList: - if self._tools is None: - self._tools = ToolList(self) - return self._tools - - def __repr__(self) -> str: - """ - Provide a friendly representation - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/assistants/v1/assistant/__init__.py b/twilio/rest/assistants/v1/assistant/__init__.py deleted file mode 100644 index aa3c171f63..0000000000 --- a/twilio/rest/assistants/v1/assistant/__init__.py +++ /dev/null @@ -1,1499 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Assistants - 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 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.page import Page -from twilio.rest.assistants.v1.assistant.assistants_knowledge import ( - AssistantsKnowledgeList, -) -from twilio.rest.assistants.v1.assistant.assistants_tool import AssistantsToolList -from twilio.rest.assistants.v1.assistant.feedback import FeedbackList -from twilio.rest.assistants.v1.assistant.message import MessageList - - -class AssistantInstance(InstanceResource): - - class AssistantsV1ServiceCreateAssistantRequest(object): - """ - :ivar customer_ai: - :ivar name: The name of the assistant. - :ivar owner: The owner/company of the assistant. - :ivar personality_prompt: The personality prompt to be used for assistant. - :ivar segment_credential: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.customer_ai: Optional[AssistantList.AssistantsV1ServiceCustomerAi] = ( - payload.get("customer_ai") - ) - self.name: Optional[str] = payload.get("name") - self.owner: Optional[str] = payload.get("owner") - self.personality_prompt: Optional[str] = payload.get("personality_prompt") - self.segment_credential: Optional[ - AssistantList.AssistantsV1ServiceSegmentCredential - ] = payload.get("segment_credential") - - def to_dict(self): - return { - "customer_ai": ( - self.customer_ai.to_dict() if self.customer_ai is not None else None - ), - "name": self.name, - "owner": self.owner, - "personality_prompt": self.personality_prompt, - "segment_credential": ( - self.segment_credential.to_dict() - if self.segment_credential is not None - else None - ), - } - - class AssistantsV1ServiceCustomerAi(object): - """ - :ivar perception_engine_enabled: True if the perception engine is enabled. - :ivar personalization_engine_enabled: True if the personalization engine is enabled. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.perception_engine_enabled: Optional[bool] = payload.get( - "perception_engine_enabled" - ) - self.personalization_engine_enabled: Optional[bool] = payload.get( - "personalization_engine_enabled" - ) - - def to_dict(self): - return { - "perception_engine_enabled": self.perception_engine_enabled, - "personalization_engine_enabled": self.personalization_engine_enabled, - } - - class AssistantsV1ServiceSegmentCredential(object): - """ - :ivar profile_api_key: The profile API key. - :ivar space_id: The space ID. - :ivar write_key: The write key. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.profile_api_key: Optional[str] = payload.get("profile_api_key") - self.space_id: Optional[str] = payload.get("space_id") - self.write_key: Optional[str] = payload.get("write_key") - - def to_dict(self): - return { - "profile_api_key": self.profile_api_key, - "space_id": self.space_id, - "write_key": self.write_key, - } - - class AssistantsV1ServiceUpdateAssistantRequest(object): - """ - :ivar customer_ai: - :ivar name: The name of the assistant. - :ivar owner: The owner/company of the assistant. - :ivar personality_prompt: The personality prompt to be used for assistant. - :ivar segment_credential: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.customer_ai: Optional[AssistantList.AssistantsV1ServiceCustomerAi] = ( - payload.get("customer_ai") - ) - self.name: Optional[str] = payload.get("name") - self.owner: Optional[str] = payload.get("owner") - self.personality_prompt: Optional[str] = payload.get("personality_prompt") - self.segment_credential: Optional[ - AssistantList.AssistantsV1ServiceSegmentCredential - ] = payload.get("segment_credential") - - def to_dict(self): - return { - "customer_ai": ( - self.customer_ai.to_dict() if self.customer_ai is not None else None - ), - "name": self.name, - "owner": self.owner, - "personality_prompt": self.personality_prompt, - "segment_credential": ( - self.segment_credential.to_dict() - if self.segment_credential is not None - else None - ), - } - - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Assistant resource. - :ivar customer_ai: The Personalization and Perception Engine settings. - :ivar id: The Assistant ID. - :ivar model: The default model used by the assistant. - :ivar name: The name of the assistant. - :ivar owner: The owner/company of the assistant. - :ivar url: The url of the assistant resource. - :ivar personality_prompt: The personality prompt to be used for assistant. - :ivar date_created: The date and time in GMT when the Assistant was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - :ivar date_updated: The date and time in GMT when the Assistant was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - :ivar knowledge: The list of knowledge sources associated with the assistant. - :ivar tools: The list of tools associated with the assistant. - """ - - def __init__( - self, version: Version, payload: Dict[str, Any], id: Optional[str] = None - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.customer_ai: Optional[Dict[str, object]] = payload.get("customer_ai") - self.id: Optional[str] = payload.get("id") - self.model: Optional[str] = payload.get("model") - self.name: Optional[str] = payload.get("name") - self.owner: Optional[str] = payload.get("owner") - self.url: Optional[str] = payload.get("url") - self.personality_prompt: Optional[str] = payload.get("personality_prompt") - self.date_created: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_created") - ) - self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_updated") - ) - self.knowledge: Optional[List[str]] = payload.get("knowledge") - self.tools: Optional[List[str]] = payload.get("tools") - - self._solution = { - "id": id or self.id, - } - - self._context: Optional[AssistantContext] = None - - @property - def _proxy(self) -> "AssistantContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: AssistantContext for this AssistantInstance - """ - if self._context is None: - self._context = AssistantContext( - self._version, - id=self._solution["id"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the AssistantInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the AssistantInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def delete_with_http_info(self) -> ApiResponse: - """ - Deletes the AssistantInstance with HTTP info - - - :returns: ApiResponse with success boolean, status code, and headers - """ - return self._proxy.delete_with_http_info() - - async def delete_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine that deletes the AssistantInstance with HTTP info - - - :returns: ApiResponse with success boolean, status code, and headers - """ - return await self._proxy.delete_with_http_info_async() - - def fetch(self) -> "AssistantInstance": - """ - Fetch the AssistantInstance - - - :returns: The fetched AssistantInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "AssistantInstance": - """ - Asynchronous coroutine to fetch the AssistantInstance - - - :returns: The fetched AssistantInstance - """ - return await self._proxy.fetch_async() - - def fetch_with_http_info(self) -> ApiResponse: - """ - Fetch the AssistantInstance 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 AssistantInstance with HTTP info - - - :returns: ApiResponse with instance, status code, and headers - """ - return await self._proxy.fetch_with_http_info_async() - - def update( - self, - assistants_v1_service_update_assistant_request: Union[ - AssistantsV1ServiceUpdateAssistantRequest, object - ] = values.unset, - ) -> "AssistantInstance": - """ - Update the AssistantInstance - - :param assistants_v1_service_update_assistant_request: - - :returns: The updated AssistantInstance - """ - return self._proxy.update( - assistants_v1_service_update_assistant_request=assistants_v1_service_update_assistant_request, - ) - - async def update_async( - self, - assistants_v1_service_update_assistant_request: Union[ - AssistantsV1ServiceUpdateAssistantRequest, object - ] = values.unset, - ) -> "AssistantInstance": - """ - Asynchronous coroutine to update the AssistantInstance - - :param assistants_v1_service_update_assistant_request: - - :returns: The updated AssistantInstance - """ - return await self._proxy.update_async( - assistants_v1_service_update_assistant_request=assistants_v1_service_update_assistant_request, - ) - - def update_with_http_info( - self, - assistants_v1_service_update_assistant_request: Union[ - AssistantsV1ServiceUpdateAssistantRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Update the AssistantInstance with HTTP info - - :param assistants_v1_service_update_assistant_request: - - :returns: ApiResponse with instance, status code, and headers - """ - return self._proxy.update_with_http_info( - assistants_v1_service_update_assistant_request=assistants_v1_service_update_assistant_request, - ) - - async def update_with_http_info_async( - self, - assistants_v1_service_update_assistant_request: Union[ - AssistantsV1ServiceUpdateAssistantRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronous coroutine to update the AssistantInstance with HTTP info - - :param assistants_v1_service_update_assistant_request: - - :returns: ApiResponse with instance, status code, and headers - """ - return await self._proxy.update_with_http_info_async( - assistants_v1_service_update_assistant_request=assistants_v1_service_update_assistant_request, - ) - - @property - def assistants_knowledge(self) -> AssistantsKnowledgeList: - """ - Access the assistants_knowledge - """ - return self._proxy.assistants_knowledge - - @property - def assistants_tools(self) -> AssistantsToolList: - """ - Access the assistants_tools - """ - return self._proxy.assistants_tools - - @property - def feedbacks(self) -> FeedbackList: - """ - Access the feedbacks - """ - return self._proxy.feedbacks - - @property - def messages(self) -> MessageList: - """ - Access the messages - """ - return self._proxy.messages - - 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 AssistantContext(InstanceContext): - - class AssistantsV1ServiceCreateAssistantRequest(object): - """ - :ivar customer_ai: - :ivar name: The name of the assistant. - :ivar owner: The owner/company of the assistant. - :ivar personality_prompt: The personality prompt to be used for assistant. - :ivar segment_credential: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.customer_ai: Optional[AssistantList.AssistantsV1ServiceCustomerAi] = ( - payload.get("customer_ai") - ) - self.name: Optional[str] = payload.get("name") - self.owner: Optional[str] = payload.get("owner") - self.personality_prompt: Optional[str] = payload.get("personality_prompt") - self.segment_credential: Optional[ - AssistantList.AssistantsV1ServiceSegmentCredential - ] = payload.get("segment_credential") - - def to_dict(self): - return { - "customer_ai": ( - self.customer_ai.to_dict() if self.customer_ai is not None else None - ), - "name": self.name, - "owner": self.owner, - "personality_prompt": self.personality_prompt, - "segment_credential": ( - self.segment_credential.to_dict() - if self.segment_credential is not None - else None - ), - } - - class AssistantsV1ServiceCustomerAi(object): - """ - :ivar perception_engine_enabled: True if the perception engine is enabled. - :ivar personalization_engine_enabled: True if the personalization engine is enabled. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.perception_engine_enabled: Optional[bool] = payload.get( - "perception_engine_enabled" - ) - self.personalization_engine_enabled: Optional[bool] = payload.get( - "personalization_engine_enabled" - ) - - def to_dict(self): - return { - "perception_engine_enabled": self.perception_engine_enabled, - "personalization_engine_enabled": self.personalization_engine_enabled, - } - - class AssistantsV1ServiceSegmentCredential(object): - """ - :ivar profile_api_key: The profile API key. - :ivar space_id: The space ID. - :ivar write_key: The write key. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.profile_api_key: Optional[str] = payload.get("profile_api_key") - self.space_id: Optional[str] = payload.get("space_id") - self.write_key: Optional[str] = payload.get("write_key") - - def to_dict(self): - return { - "profile_api_key": self.profile_api_key, - "space_id": self.space_id, - "write_key": self.write_key, - } - - class AssistantsV1ServiceUpdateAssistantRequest(object): - """ - :ivar customer_ai: - :ivar name: The name of the assistant. - :ivar owner: The owner/company of the assistant. - :ivar personality_prompt: The personality prompt to be used for assistant. - :ivar segment_credential: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.customer_ai: Optional[AssistantList.AssistantsV1ServiceCustomerAi] = ( - payload.get("customer_ai") - ) - self.name: Optional[str] = payload.get("name") - self.owner: Optional[str] = payload.get("owner") - self.personality_prompt: Optional[str] = payload.get("personality_prompt") - self.segment_credential: Optional[ - AssistantList.AssistantsV1ServiceSegmentCredential - ] = payload.get("segment_credential") - - def to_dict(self): - return { - "customer_ai": ( - self.customer_ai.to_dict() if self.customer_ai is not None else None - ), - "name": self.name, - "owner": self.owner, - "personality_prompt": self.personality_prompt, - "segment_credential": ( - self.segment_credential.to_dict() - if self.segment_credential is not None - else None - ), - } - - def __init__(self, version: Version, id: str): - """ - Initialize the AssistantContext - - :param version: Version that contains the resource - :param id: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "id": id, - } - self._uri = "/Assistants/{id}".format(**self._solution) - - self._assistants_knowledge: Optional[AssistantsKnowledgeList] = None - self._assistants_tools: Optional[AssistantsToolList] = None - self._feedbacks: Optional[FeedbackList] = None - self._messages: Optional[MessageList] = None - - def _delete(self) -> tuple: - """ - Internal helper for delete operation - - Returns: - tuple: (success_boolean, status_code, headers) - """ - - headers = values.of({}) - - return self._version.delete_with_response_info( - method="DELETE", uri=self._uri, headers=headers - ) - - def delete(self) -> bool: - """ - Deletes the AssistantInstance - - - :returns: True if delete succeeds, False otherwise - """ - success, _, _ = self._delete() - return success - - def delete_with_http_info(self) -> ApiResponse: - """ - Deletes the AssistantInstance and return response metadata - - - :returns: ApiResponse with success boolean, status code, and headers - """ - success, status_code, headers = self._delete() - return ApiResponse(data=success, status_code=status_code, headers=headers) - - async def _delete_async(self) -> tuple: - """ - Internal async helper for delete operation - - Returns: - tuple: (success_boolean, status_code, headers) - """ - - headers = values.of({}) - - return await self._version.delete_with_response_info_async( - method="DELETE", uri=self._uri, headers=headers - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the AssistantInstance - - - :returns: True if delete succeeds, False otherwise - """ - success, _, _ = await self._delete_async() - return success - - async def delete_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine that deletes the AssistantInstance and return response metadata - - - :returns: ApiResponse with success boolean, status code, and headers - """ - success, status_code, headers = await self._delete_async() - return ApiResponse(data=success, status_code=status_code, headers=headers) - - 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) -> AssistantInstance: - """ - Fetch the AssistantInstance - - - :returns: The fetched AssistantInstance - """ - payload, _, _ = self._fetch() - return AssistantInstance( - self._version, - payload, - id=self._solution["id"], - ) - - def fetch_with_http_info(self) -> ApiResponse: - """ - Fetch the AssistantInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._fetch() - instance = AssistantInstance( - self._version, - payload, - id=self._solution["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) -> AssistantInstance: - """ - Asynchronous coroutine to fetch the AssistantInstance - - - :returns: The fetched AssistantInstance - """ - payload, _, _ = await self._fetch_async() - return AssistantInstance( - self._version, - payload, - id=self._solution["id"], - ) - - async def fetch_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine to fetch the AssistantInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._fetch_async() - instance = AssistantInstance( - self._version, - payload, - id=self._solution["id"], - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def _update( - self, - assistants_v1_service_update_assistant_request: Union[ - AssistantsV1ServiceUpdateAssistantRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal helper for update operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = assistants_v1_service_update_assistant_request.to_dict() - - headers = values.of({}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return self._version.update_with_response_info( - method="PUT", uri=self._uri, data=data, headers=headers - ) - - def update( - self, - assistants_v1_service_update_assistant_request: Union[ - AssistantsV1ServiceUpdateAssistantRequest, object - ] = values.unset, - ) -> AssistantInstance: - """ - Update the AssistantInstance - - :param assistants_v1_service_update_assistant_request: - - :returns: The updated AssistantInstance - """ - payload, _, _ = self._update( - assistants_v1_service_update_assistant_request=assistants_v1_service_update_assistant_request - ) - return AssistantInstance(self._version, payload, id=self._solution["id"]) - - def update_with_http_info( - self, - assistants_v1_service_update_assistant_request: Union[ - AssistantsV1ServiceUpdateAssistantRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Update the AssistantInstance and return response metadata - - :param assistants_v1_service_update_assistant_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._update( - assistants_v1_service_update_assistant_request=assistants_v1_service_update_assistant_request - ) - instance = AssistantInstance(self._version, payload, id=self._solution["id"]) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _update_async( - self, - assistants_v1_service_update_assistant_request: Union[ - AssistantsV1ServiceUpdateAssistantRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal async helper for update operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = assistants_v1_service_update_assistant_request.to_dict() - - headers = values.of({}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return await self._version.update_with_response_info_async( - method="PUT", uri=self._uri, data=data, headers=headers - ) - - async def update_async( - self, - assistants_v1_service_update_assistant_request: Union[ - AssistantsV1ServiceUpdateAssistantRequest, object - ] = values.unset, - ) -> AssistantInstance: - """ - Asynchronous coroutine to update the AssistantInstance - - :param assistants_v1_service_update_assistant_request: - - :returns: The updated AssistantInstance - """ - payload, _, _ = await self._update_async( - assistants_v1_service_update_assistant_request=assistants_v1_service_update_assistant_request - ) - return AssistantInstance(self._version, payload, id=self._solution["id"]) - - async def update_with_http_info_async( - self, - assistants_v1_service_update_assistant_request: Union[ - AssistantsV1ServiceUpdateAssistantRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronous coroutine to update the AssistantInstance and return response metadata - - :param assistants_v1_service_update_assistant_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._update_async( - assistants_v1_service_update_assistant_request=assistants_v1_service_update_assistant_request - ) - instance = AssistantInstance(self._version, payload, id=self._solution["id"]) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - @property - def assistants_knowledge(self) -> AssistantsKnowledgeList: - """ - Access the assistants_knowledge - """ - if self._assistants_knowledge is None: - self._assistants_knowledge = AssistantsKnowledgeList( - self._version, - self._solution["id"], - ) - return self._assistants_knowledge - - @property - def assistants_tools(self) -> AssistantsToolList: - """ - Access the assistants_tools - """ - if self._assistants_tools is None: - self._assistants_tools = AssistantsToolList( - self._version, - self._solution["id"], - ) - return self._assistants_tools - - @property - def feedbacks(self) -> FeedbackList: - """ - Access the feedbacks - """ - if self._feedbacks is None: - self._feedbacks = FeedbackList( - self._version, - self._solution["id"], - ) - return self._feedbacks - - @property - def messages(self) -> MessageList: - """ - Access the messages - """ - if self._messages is None: - self._messages = MessageList( - self._version, - self._solution["id"], - ) - return self._messages - - 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 AssistantPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> AssistantInstance: - """ - Build an instance of AssistantInstance - - :param payload: Payload response from the API - """ - - return AssistantInstance(self._version, payload) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class AssistantList(ListResource): - - class AssistantsV1ServiceCreateAssistantRequest(object): - """ - :ivar customer_ai: - :ivar name: The name of the assistant. - :ivar owner: The owner/company of the assistant. - :ivar personality_prompt: The personality prompt to be used for assistant. - :ivar segment_credential: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.customer_ai: Optional[AssistantList.AssistantsV1ServiceCustomerAi] = ( - payload.get("customer_ai") - ) - self.name: Optional[str] = payload.get("name") - self.owner: Optional[str] = payload.get("owner") - self.personality_prompt: Optional[str] = payload.get("personality_prompt") - self.segment_credential: Optional[ - AssistantList.AssistantsV1ServiceSegmentCredential - ] = payload.get("segment_credential") - - def to_dict(self): - return { - "customer_ai": ( - self.customer_ai.to_dict() if self.customer_ai is not None else None - ), - "name": self.name, - "owner": self.owner, - "personality_prompt": self.personality_prompt, - "segment_credential": ( - self.segment_credential.to_dict() - if self.segment_credential is not None - else None - ), - } - - class AssistantsV1ServiceCustomerAi(object): - """ - :ivar perception_engine_enabled: True if the perception engine is enabled. - :ivar personalization_engine_enabled: True if the personalization engine is enabled. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.perception_engine_enabled: Optional[bool] = payload.get( - "perception_engine_enabled" - ) - self.personalization_engine_enabled: Optional[bool] = payload.get( - "personalization_engine_enabled" - ) - - def to_dict(self): - return { - "perception_engine_enabled": self.perception_engine_enabled, - "personalization_engine_enabled": self.personalization_engine_enabled, - } - - class AssistantsV1ServiceSegmentCredential(object): - """ - :ivar profile_api_key: The profile API key. - :ivar space_id: The space ID. - :ivar write_key: The write key. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.profile_api_key: Optional[str] = payload.get("profile_api_key") - self.space_id: Optional[str] = payload.get("space_id") - self.write_key: Optional[str] = payload.get("write_key") - - def to_dict(self): - return { - "profile_api_key": self.profile_api_key, - "space_id": self.space_id, - "write_key": self.write_key, - } - - class AssistantsV1ServiceUpdateAssistantRequest(object): - """ - :ivar customer_ai: - :ivar name: The name of the assistant. - :ivar owner: The owner/company of the assistant. - :ivar personality_prompt: The personality prompt to be used for assistant. - :ivar segment_credential: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.customer_ai: Optional[AssistantList.AssistantsV1ServiceCustomerAi] = ( - payload.get("customer_ai") - ) - self.name: Optional[str] = payload.get("name") - self.owner: Optional[str] = payload.get("owner") - self.personality_prompt: Optional[str] = payload.get("personality_prompt") - self.segment_credential: Optional[ - AssistantList.AssistantsV1ServiceSegmentCredential - ] = payload.get("segment_credential") - - def to_dict(self): - return { - "customer_ai": ( - self.customer_ai.to_dict() if self.customer_ai is not None else None - ), - "name": self.name, - "owner": self.owner, - "personality_prompt": self.personality_prompt, - "segment_credential": ( - self.segment_credential.to_dict() - if self.segment_credential is not None - else None - ), - } - - def __init__(self, version: Version): - """ - Initialize the AssistantList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/Assistants" - - def _create( - self, - assistants_v1_service_create_assistant_request: AssistantsV1ServiceCreateAssistantRequest, - ) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = assistants_v1_service_create_assistant_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, - assistants_v1_service_create_assistant_request: AssistantsV1ServiceCreateAssistantRequest, - ) -> AssistantInstance: - """ - Create the AssistantInstance - - :param assistants_v1_service_create_assistant_request: - - :returns: The created AssistantInstance - """ - payload, _, _ = self._create( - assistants_v1_service_create_assistant_request=assistants_v1_service_create_assistant_request - ) - return AssistantInstance(self._version, payload) - - def create_with_http_info( - self, - assistants_v1_service_create_assistant_request: AssistantsV1ServiceCreateAssistantRequest, - ) -> ApiResponse: - """ - Create the AssistantInstance and return response metadata - - :param assistants_v1_service_create_assistant_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create( - assistants_v1_service_create_assistant_request=assistants_v1_service_create_assistant_request - ) - instance = AssistantInstance(self._version, payload) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _create_async( - self, - assistants_v1_service_create_assistant_request: AssistantsV1ServiceCreateAssistantRequest, - ) -> tuple: - """ - Internal async helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = assistants_v1_service_create_assistant_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, - assistants_v1_service_create_assistant_request: AssistantsV1ServiceCreateAssistantRequest, - ) -> AssistantInstance: - """ - Asynchronously create the AssistantInstance - - :param assistants_v1_service_create_assistant_request: - - :returns: The created AssistantInstance - """ - payload, _, _ = await self._create_async( - assistants_v1_service_create_assistant_request=assistants_v1_service_create_assistant_request - ) - return AssistantInstance(self._version, payload) - - async def create_with_http_info_async( - self, - assistants_v1_service_create_assistant_request: AssistantsV1ServiceCreateAssistantRequest, - ) -> ApiResponse: - """ - Asynchronously create the AssistantInstance and return response metadata - - :param assistants_v1_service_create_assistant_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async( - assistants_v1_service_create_assistant_request=assistants_v1_service_create_assistant_request - ) - instance = AssistantInstance(self._version, payload) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[AssistantInstance]: - """ - Streams AssistantInstance 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 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_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[AssistantInstance]: - """ - Asynchronously streams AssistantInstance 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 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_size=limits["page_size"]) - - return self._version.stream_async(page, limits["limit"]) - - def stream_with_http_info( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Streams AssistantInstance and returns headers from first page - - - :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_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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Asynchronously streams AssistantInstance and returns headers from first page - - - :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_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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[AssistantInstance]: - """ - Lists AssistantInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :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( - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[AssistantInstance]: - """ - Asynchronously lists AssistantInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :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( - limit=limit, - page_size=page_size, - ) - ] - - def list_with_http_info( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Lists AssistantInstance and returns headers from first page - - - :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( - 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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Asynchronously lists AssistantInstance and returns headers from first page - - - :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( - 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_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> AssistantPage: - """ - Retrieve a single page of AssistantInstance records from the API. - Request is executed immediately - - :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: Page of AssistantInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 AssistantPage(self._version, response) - - async def page_async( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> AssistantPage: - """ - Asynchronously retrieve a single page of AssistantInstance records from the API. - Request is executed immediately - - :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: Page of AssistantInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 AssistantPage(self._version, response) - - def page_with_http_info( - self, - 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: 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 AssistantPage, status code, and headers - """ - data = values.of( - { - "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 = AssistantPage(self._version, response) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - async def page_with_http_info_async( - self, - 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: 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 AssistantPage, status code, and headers - """ - data = values.of( - { - "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 = AssistantPage(self._version, response) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - def get_page(self, target_url: str) -> AssistantPage: - """ - Retrieve a specific page of AssistantInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of AssistantInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return AssistantPage(self._version, response) - - async def get_page_async(self, target_url: str) -> AssistantPage: - """ - Asynchronously retrieve a specific page of AssistantInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of AssistantInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return AssistantPage(self._version, response) - - def get(self, id: str) -> AssistantContext: - """ - Constructs a AssistantContext - - :param id: - """ - return AssistantContext(self._version, id=id) - - def __call__(self, id: str) -> AssistantContext: - """ - Constructs a AssistantContext - - :param id: - """ - return AssistantContext(self._version, id=id) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/assistants/v1/assistant/assistants_knowledge.py b/twilio/rest/assistants/v1/assistant/assistants_knowledge.py deleted file mode 100644 index e5d6ed5daa..0000000000 --- a/twilio/rest/assistants/v1/assistant/assistants_knowledge.py +++ /dev/null @@ -1,871 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Assistants - 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 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.page import Page - - -class AssistantsKnowledgeInstance(InstanceResource): - """ - :ivar description: The type of knowledge source. - :ivar id: The description of knowledge. - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Knowledge resource. - :ivar knowledge_source_details: The details of the knowledge source based on the type. - :ivar name: The name of the knowledge source. - :ivar status: The status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED') - :ivar type: The type of knowledge source ('Web', 'Database', 'Text', 'File') - :ivar url: The url of the knowledge resource. - :ivar embedding_model: The embedding model to be used for the knowledge source. - :ivar date_created: The date and time in GMT when the Knowledge was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - :ivar date_updated: The date and time in GMT when the Knowledge was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_id: str, - id: Optional[str] = None, - ): - super().__init__(version) - - self.description: Optional[str] = payload.get("description") - self.id: Optional[str] = payload.get("id") - self.account_sid: Optional[str] = payload.get("account_sid") - self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( - "knowledge_source_details" - ) - self.name: Optional[str] = payload.get("name") - self.status: Optional[str] = payload.get("status") - self.type: Optional[str] = payload.get("type") - self.url: Optional[str] = payload.get("url") - self.embedding_model: Optional[str] = payload.get("embedding_model") - self.date_created: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_created") - ) - self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_updated") - ) - - self._solution = { - "assistant_id": assistant_id, - "id": id or self.id, - } - - self._context: Optional[AssistantsKnowledgeContext] = None - - @property - def _proxy(self) -> "AssistantsKnowledgeContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: AssistantsKnowledgeContext for this AssistantsKnowledgeInstance - """ - if self._context is None: - self._context = AssistantsKnowledgeContext( - self._version, - assistant_id=self._solution["assistant_id"], - id=self._solution["id"], - ) - return self._context - - def create(self) -> "AssistantsKnowledgeInstance": - """ - Create the AssistantsKnowledgeInstance - - - :returns: The created AssistantsKnowledgeInstance - """ - return self._proxy.create() - - async def create_async(self) -> "AssistantsKnowledgeInstance": - """ - Asynchronous coroutine to create the AssistantsKnowledgeInstance - - - :returns: The created AssistantsKnowledgeInstance - """ - return await self._proxy.create_async() - - def create_with_http_info(self) -> ApiResponse: - """ - Create the AssistantsKnowledgeInstance with HTTP info - - - :returns: ApiResponse with instance, status code, and headers - """ - return self._proxy.create_with_http_info() - - async def create_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine to create the AssistantsKnowledgeInstance with HTTP info - - - :returns: ApiResponse with instance, status code, and headers - """ - return await self._proxy.create_with_http_info_async() - - def delete(self) -> bool: - """ - Deletes the AssistantsKnowledgeInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the AssistantsKnowledgeInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def delete_with_http_info(self) -> ApiResponse: - """ - Deletes the AssistantsKnowledgeInstance with HTTP info - - - :returns: ApiResponse with success boolean, status code, and headers - """ - return self._proxy.delete_with_http_info() - - async def delete_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine that deletes the AssistantsKnowledgeInstance with HTTP info - - - :returns: ApiResponse with success boolean, status code, and headers - """ - return await self._proxy.delete_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 AssistantsKnowledgeContext(InstanceContext): - - def __init__(self, version: Version, assistant_id: str, id: str): - """ - Initialize the AssistantsKnowledgeContext - - :param version: Version that contains the resource - :param assistant_id: The assistant ID. - :param id: The knowledge ID. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_id": assistant_id, - "id": id, - } - self._uri = "/Assistants/{assistant_id}/Knowledge/{id}".format(**self._solution) - - def _create(self) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - - data = values.of({}) - headers = values.of({}) - - return self._version.create_with_response_info( - method="POST", uri=self._uri, data=data, headers=headers - ) - - def create(self) -> AssistantsKnowledgeInstance: - """ - Create the AssistantsKnowledgeInstance - - - :returns: The created AssistantsKnowledgeInstance - """ - payload, _, _ = self._create() - return AssistantsKnowledgeInstance( - self._version, - payload, - assistant_id=self._solution["assistant_id"], - id=self._solution["id"], - ) - - def create_with_http_info(self) -> ApiResponse: - """ - Create the AssistantsKnowledgeInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create() - instance = AssistantsKnowledgeInstance( - self._version, - payload, - assistant_id=self._solution["assistant_id"], - id=self._solution["id"], - ) - 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) - """ - - data = values.of({}) - headers = values.of({}) - - return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - async def create_async(self) -> AssistantsKnowledgeInstance: - """ - Asynchronous coroutine to create the AssistantsKnowledgeInstance - - - :returns: The created AssistantsKnowledgeInstance - """ - payload, _, _ = await self._create_async() - return AssistantsKnowledgeInstance( - self._version, - payload, - assistant_id=self._solution["assistant_id"], - id=self._solution["id"], - ) - - async def create_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine to create the AssistantsKnowledgeInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async() - instance = AssistantsKnowledgeInstance( - self._version, - payload, - assistant_id=self._solution["assistant_id"], - id=self._solution["id"], - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def _delete(self) -> tuple: - """ - Internal helper for delete operation - - Returns: - tuple: (success_boolean, status_code, headers) - """ - - headers = values.of({}) - - return self._version.delete_with_response_info( - method="DELETE", uri=self._uri, headers=headers - ) - - def delete(self) -> bool: - """ - Deletes the AssistantsKnowledgeInstance - - - :returns: True if delete succeeds, False otherwise - """ - success, _, _ = self._delete() - return success - - def delete_with_http_info(self) -> ApiResponse: - """ - Deletes the AssistantsKnowledgeInstance and return response metadata - - - :returns: ApiResponse with success boolean, status code, and headers - """ - success, status_code, headers = self._delete() - return ApiResponse(data=success, status_code=status_code, headers=headers) - - async def _delete_async(self) -> tuple: - """ - Internal async helper for delete operation - - Returns: - tuple: (success_boolean, status_code, headers) - """ - - headers = values.of({}) - - return await self._version.delete_with_response_info_async( - method="DELETE", uri=self._uri, headers=headers - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the AssistantsKnowledgeInstance - - - :returns: True if delete succeeds, False otherwise - """ - success, _, _ = await self._delete_async() - return success - - async def delete_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine that deletes the AssistantsKnowledgeInstance and return response metadata - - - :returns: ApiResponse with success boolean, status code, and headers - """ - success, status_code, headers = await self._delete_async() - return ApiResponse(data=success, 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 AssistantsKnowledgePage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> AssistantsKnowledgeInstance: - """ - Build an instance of AssistantsKnowledgeInstance - - :param payload: Payload response from the API - """ - - return AssistantsKnowledgeInstance( - self._version, payload, assistant_id=self._solution["assistant_id"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class AssistantsKnowledgeList(ListResource): - - def __init__(self, version: Version, assistant_id: str): - """ - Initialize the AssistantsKnowledgeList - - :param version: Version that contains the resource - :param assistant_id: The assistant ID. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_id": assistant_id, - } - self._uri = "/Assistants/{assistant_id}/Knowledge".format(**self._solution) - - 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"}) - - return self._version.create_with_response_info( - method="POST", uri=self._uri, headers=headers - ) - - def create(self) -> AssistantsKnowledgeInstance: - """ - Create the AssistantsKnowledgeInstance - - - :returns: The created AssistantsKnowledgeInstance - """ - payload, _, _ = self._create() - return AssistantsKnowledgeInstance( - self._version, payload, assistant_id=self._solution["assistant_id"] - ) - - def create_with_http_info(self) -> ApiResponse: - """ - Create the AssistantsKnowledgeInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create() - instance = AssistantsKnowledgeInstance( - self._version, payload, assistant_id=self._solution["assistant_id"] - ) - 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"}) - - return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, headers=headers - ) - - async def create_async(self) -> AssistantsKnowledgeInstance: - """ - Asynchronously create the AssistantsKnowledgeInstance - - - :returns: The created AssistantsKnowledgeInstance - """ - payload, _, _ = await self._create_async() - return AssistantsKnowledgeInstance( - self._version, payload, assistant_id=self._solution["assistant_id"] - ) - - async def create_with_http_info_async(self) -> ApiResponse: - """ - Asynchronously create the AssistantsKnowledgeInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async() - instance = AssistantsKnowledgeInstance( - self._version, payload, assistant_id=self._solution["assistant_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[AssistantsKnowledgeInstance]: - """ - Streams AssistantsKnowledgeInstance 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 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_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[AssistantsKnowledgeInstance]: - """ - Asynchronously streams AssistantsKnowledgeInstance 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 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_size=limits["page_size"]) - - return self._version.stream_async(page, limits["limit"]) - - def stream_with_http_info( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Streams AssistantsKnowledgeInstance and returns headers from first page - - - :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_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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Asynchronously streams AssistantsKnowledgeInstance and returns headers from first page - - - :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_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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[AssistantsKnowledgeInstance]: - """ - Lists AssistantsKnowledgeInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :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( - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[AssistantsKnowledgeInstance]: - """ - Asynchronously lists AssistantsKnowledgeInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :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( - limit=limit, - page_size=page_size, - ) - ] - - def list_with_http_info( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Lists AssistantsKnowledgeInstance and returns headers from first page - - - :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( - 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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Asynchronously lists AssistantsKnowledgeInstance and returns headers from first page - - - :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( - 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_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> AssistantsKnowledgePage: - """ - Retrieve a single page of AssistantsKnowledgeInstance records from the API. - Request is executed immediately - - :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: Page of AssistantsKnowledgeInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 AssistantsKnowledgePage(self._version, response, solution=self._solution) - - async def page_async( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> AssistantsKnowledgePage: - """ - Asynchronously retrieve a single page of AssistantsKnowledgeInstance records from the API. - Request is executed immediately - - :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: Page of AssistantsKnowledgeInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 AssistantsKnowledgePage(self._version, response, solution=self._solution) - - def page_with_http_info( - self, - 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: 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 AssistantsKnowledgePage, status code, and headers - """ - data = values.of( - { - "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 = AssistantsKnowledgePage(self._version, response, solution=self._solution) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - async def page_with_http_info_async( - self, - 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: 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 AssistantsKnowledgePage, status code, and headers - """ - data = values.of( - { - "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 = AssistantsKnowledgePage(self._version, response, solution=self._solution) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - def get_page(self, target_url: str) -> AssistantsKnowledgePage: - """ - Retrieve a specific page of AssistantsKnowledgeInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of AssistantsKnowledgeInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return AssistantsKnowledgePage(self._version, response, solution=self._solution) - - async def get_page_async(self, target_url: str) -> AssistantsKnowledgePage: - """ - Asynchronously retrieve a specific page of AssistantsKnowledgeInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of AssistantsKnowledgeInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return AssistantsKnowledgePage(self._version, response, solution=self._solution) - - def get(self, id: str) -> AssistantsKnowledgeContext: - """ - Constructs a AssistantsKnowledgeContext - - :param id: The knowledge ID. - """ - return AssistantsKnowledgeContext( - self._version, assistant_id=self._solution["assistant_id"], id=id - ) - - def __call__(self, id: str) -> AssistantsKnowledgeContext: - """ - Constructs a AssistantsKnowledgeContext - - :param id: The knowledge ID. - """ - return AssistantsKnowledgeContext( - self._version, assistant_id=self._solution["assistant_id"], id=id - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/assistants/v1/assistant/assistants_tool.py b/twilio/rest/assistants/v1/assistant/assistants_tool.py deleted file mode 100644 index eb7ab6b8c1..0000000000 --- a/twilio/rest/assistants/v1/assistant/assistants_tool.py +++ /dev/null @@ -1,869 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Assistants - 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 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.page import Page - - -class AssistantsToolInstance(InstanceResource): - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Tool resource. - :ivar description: The description of the tool. - :ivar enabled: True if the tool is enabled. - :ivar id: The tool ID. - :ivar meta: The metadata related to method, url, input_schema to used with the Tool. - :ivar name: The name of the tool. - :ivar requires_auth: The authentication requirement for the tool. - :ivar type: The type of the tool. ('WEBHOOK') - :ivar url: The url of the tool resource. - :ivar date_created: The date and time in GMT when the Tool was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - :ivar date_updated: The date and time in GMT when the Tool was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_id: str, - id: Optional[str] = None, - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.description: Optional[str] = payload.get("description") - self.enabled: Optional[bool] = payload.get("enabled") - self.id: Optional[str] = payload.get("id") - self.meta: Optional[Dict[str, object]] = payload.get("meta") - self.name: Optional[str] = payload.get("name") - self.requires_auth: Optional[bool] = payload.get("requires_auth") - self.type: Optional[str] = payload.get("type") - self.url: Optional[str] = payload.get("url") - self.date_created: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_created") - ) - self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_updated") - ) - - self._solution = { - "assistant_id": assistant_id, - "id": id or self.id, - } - - self._context: Optional[AssistantsToolContext] = None - - @property - def _proxy(self) -> "AssistantsToolContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: AssistantsToolContext for this AssistantsToolInstance - """ - if self._context is None: - self._context = AssistantsToolContext( - self._version, - assistant_id=self._solution["assistant_id"], - id=self._solution["id"], - ) - return self._context - - def create(self) -> "AssistantsToolInstance": - """ - Create the AssistantsToolInstance - - - :returns: The created AssistantsToolInstance - """ - return self._proxy.create() - - async def create_async(self) -> "AssistantsToolInstance": - """ - Asynchronous coroutine to create the AssistantsToolInstance - - - :returns: The created AssistantsToolInstance - """ - return await self._proxy.create_async() - - def create_with_http_info(self) -> ApiResponse: - """ - Create the AssistantsToolInstance with HTTP info - - - :returns: ApiResponse with instance, status code, and headers - """ - return self._proxy.create_with_http_info() - - async def create_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine to create the AssistantsToolInstance with HTTP info - - - :returns: ApiResponse with instance, status code, and headers - """ - return await self._proxy.create_with_http_info_async() - - def delete(self) -> bool: - """ - Deletes the AssistantsToolInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the AssistantsToolInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def delete_with_http_info(self) -> ApiResponse: - """ - Deletes the AssistantsToolInstance with HTTP info - - - :returns: ApiResponse with success boolean, status code, and headers - """ - return self._proxy.delete_with_http_info() - - async def delete_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine that deletes the AssistantsToolInstance with HTTP info - - - :returns: ApiResponse with success boolean, status code, and headers - """ - return await self._proxy.delete_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 AssistantsToolContext(InstanceContext): - - def __init__(self, version: Version, assistant_id: str, id: str): - """ - Initialize the AssistantsToolContext - - :param version: Version that contains the resource - :param assistant_id: The assistant ID. - :param id: The tool ID. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_id": assistant_id, - "id": id, - } - self._uri = "/Assistants/{assistant_id}/Tools/{id}".format(**self._solution) - - def _create(self) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - - data = values.of({}) - headers = values.of({}) - - return self._version.create_with_response_info( - method="POST", uri=self._uri, data=data, headers=headers - ) - - def create(self) -> AssistantsToolInstance: - """ - Create the AssistantsToolInstance - - - :returns: The created AssistantsToolInstance - """ - payload, _, _ = self._create() - return AssistantsToolInstance( - self._version, - payload, - assistant_id=self._solution["assistant_id"], - id=self._solution["id"], - ) - - def create_with_http_info(self) -> ApiResponse: - """ - Create the AssistantsToolInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create() - instance = AssistantsToolInstance( - self._version, - payload, - assistant_id=self._solution["assistant_id"], - id=self._solution["id"], - ) - 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) - """ - - data = values.of({}) - headers = values.of({}) - - return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - async def create_async(self) -> AssistantsToolInstance: - """ - Asynchronous coroutine to create the AssistantsToolInstance - - - :returns: The created AssistantsToolInstance - """ - payload, _, _ = await self._create_async() - return AssistantsToolInstance( - self._version, - payload, - assistant_id=self._solution["assistant_id"], - id=self._solution["id"], - ) - - async def create_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine to create the AssistantsToolInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async() - instance = AssistantsToolInstance( - self._version, - payload, - assistant_id=self._solution["assistant_id"], - id=self._solution["id"], - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def _delete(self) -> tuple: - """ - Internal helper for delete operation - - Returns: - tuple: (success_boolean, status_code, headers) - """ - - headers = values.of({}) - - return self._version.delete_with_response_info( - method="DELETE", uri=self._uri, headers=headers - ) - - def delete(self) -> bool: - """ - Deletes the AssistantsToolInstance - - - :returns: True if delete succeeds, False otherwise - """ - success, _, _ = self._delete() - return success - - def delete_with_http_info(self) -> ApiResponse: - """ - Deletes the AssistantsToolInstance and return response metadata - - - :returns: ApiResponse with success boolean, status code, and headers - """ - success, status_code, headers = self._delete() - return ApiResponse(data=success, status_code=status_code, headers=headers) - - async def _delete_async(self) -> tuple: - """ - Internal async helper for delete operation - - Returns: - tuple: (success_boolean, status_code, headers) - """ - - headers = values.of({}) - - return await self._version.delete_with_response_info_async( - method="DELETE", uri=self._uri, headers=headers - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the AssistantsToolInstance - - - :returns: True if delete succeeds, False otherwise - """ - success, _, _ = await self._delete_async() - return success - - async def delete_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine that deletes the AssistantsToolInstance and return response metadata - - - :returns: ApiResponse with success boolean, status code, and headers - """ - success, status_code, headers = await self._delete_async() - return ApiResponse(data=success, 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 AssistantsToolPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> AssistantsToolInstance: - """ - Build an instance of AssistantsToolInstance - - :param payload: Payload response from the API - """ - - return AssistantsToolInstance( - self._version, payload, assistant_id=self._solution["assistant_id"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class AssistantsToolList(ListResource): - - def __init__(self, version: Version, assistant_id: str): - """ - Initialize the AssistantsToolList - - :param version: Version that contains the resource - :param assistant_id: The assistant ID. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_id": assistant_id, - } - self._uri = "/Assistants/{assistant_id}/Tools".format(**self._solution) - - 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"}) - - return self._version.create_with_response_info( - method="POST", uri=self._uri, headers=headers - ) - - def create(self) -> AssistantsToolInstance: - """ - Create the AssistantsToolInstance - - - :returns: The created AssistantsToolInstance - """ - payload, _, _ = self._create() - return AssistantsToolInstance( - self._version, payload, assistant_id=self._solution["assistant_id"] - ) - - def create_with_http_info(self) -> ApiResponse: - """ - Create the AssistantsToolInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create() - instance = AssistantsToolInstance( - self._version, payload, assistant_id=self._solution["assistant_id"] - ) - 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"}) - - return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, headers=headers - ) - - async def create_async(self) -> AssistantsToolInstance: - """ - Asynchronously create the AssistantsToolInstance - - - :returns: The created AssistantsToolInstance - """ - payload, _, _ = await self._create_async() - return AssistantsToolInstance( - self._version, payload, assistant_id=self._solution["assistant_id"] - ) - - async def create_with_http_info_async(self) -> ApiResponse: - """ - Asynchronously create the AssistantsToolInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async() - instance = AssistantsToolInstance( - self._version, payload, assistant_id=self._solution["assistant_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[AssistantsToolInstance]: - """ - Streams AssistantsToolInstance 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 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_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[AssistantsToolInstance]: - """ - Asynchronously streams AssistantsToolInstance 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 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_size=limits["page_size"]) - - return self._version.stream_async(page, limits["limit"]) - - def stream_with_http_info( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Streams AssistantsToolInstance and returns headers from first page - - - :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_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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Asynchronously streams AssistantsToolInstance and returns headers from first page - - - :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_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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[AssistantsToolInstance]: - """ - Lists AssistantsToolInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :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( - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[AssistantsToolInstance]: - """ - Asynchronously lists AssistantsToolInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :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( - limit=limit, - page_size=page_size, - ) - ] - - def list_with_http_info( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Lists AssistantsToolInstance and returns headers from first page - - - :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( - 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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Asynchronously lists AssistantsToolInstance and returns headers from first page - - - :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( - 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_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> AssistantsToolPage: - """ - Retrieve a single page of AssistantsToolInstance records from the API. - Request is executed immediately - - :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: Page of AssistantsToolInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 AssistantsToolPage(self._version, response, solution=self._solution) - - async def page_async( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> AssistantsToolPage: - """ - Asynchronously retrieve a single page of AssistantsToolInstance records from the API. - Request is executed immediately - - :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: Page of AssistantsToolInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 AssistantsToolPage(self._version, response, solution=self._solution) - - def page_with_http_info( - self, - 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: 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 AssistantsToolPage, status code, and headers - """ - data = values.of( - { - "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 = AssistantsToolPage(self._version, response, solution=self._solution) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - async def page_with_http_info_async( - self, - 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: 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 AssistantsToolPage, status code, and headers - """ - data = values.of( - { - "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 = AssistantsToolPage(self._version, response, solution=self._solution) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - def get_page(self, target_url: str) -> AssistantsToolPage: - """ - Retrieve a specific page of AssistantsToolInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of AssistantsToolInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return AssistantsToolPage(self._version, response, solution=self._solution) - - async def get_page_async(self, target_url: str) -> AssistantsToolPage: - """ - Asynchronously retrieve a specific page of AssistantsToolInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of AssistantsToolInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return AssistantsToolPage(self._version, response, solution=self._solution) - - def get(self, id: str) -> AssistantsToolContext: - """ - Constructs a AssistantsToolContext - - :param id: The tool ID. - """ - return AssistantsToolContext( - self._version, assistant_id=self._solution["assistant_id"], id=id - ) - - def __call__(self, id: str) -> AssistantsToolContext: - """ - Constructs a AssistantsToolContext - - :param id: The tool ID. - """ - return AssistantsToolContext( - self._version, assistant_id=self._solution["assistant_id"], id=id - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/assistants/v1/assistant/feedback.py b/twilio/rest/assistants/v1/assistant/feedback.py deleted file mode 100644 index b52770b788..0000000000 --- a/twilio/rest/assistants/v1/assistant/feedback.py +++ /dev/null @@ -1,638 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Assistants - 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 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_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version -from twilio.base.page import Page - - -class FeedbackInstance(InstanceResource): - - class AssistantsV1ServiceCreateFeedbackRequest(object): - """ - :ivar message_id: The message ID. - :ivar score: The score to be given(0-1). - :ivar session_id: The Session ID. - :ivar text: The text to be given as feedback. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.message_id: Optional[str] = payload.get("message_id") - self.score: Optional[float] = payload.get("score") - self.session_id: Optional[str] = payload.get("session_id") - self.text: Optional[str] = payload.get("text") - - def to_dict(self): - return { - "message_id": self.message_id, - "score": self.score, - "session_id": self.session_id, - "text": self.text, - } - - """ - :ivar assistant_id: The Assistant ID. - :ivar id: The Feedback ID. - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Feedback. - :ivar user_sid: The SID of the User created the Feedback. - :ivar message_id: The Message ID. - :ivar score: The Score to provide as Feedback (0-1) - :ivar session_id: The Session ID. - :ivar text: The text to be given as feedback. - :ivar date_created: The date and time in GMT when the Feedback was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - :ivar date_updated: The date and time in GMT when the Feedback was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - """ - - def __init__(self, version: Version, payload: Dict[str, Any], id: str): - super().__init__(version) - - self.assistant_id: Optional[str] = payload.get("assistant_id") - self.id: Optional[str] = payload.get("id") - self.account_sid: Optional[str] = payload.get("account_sid") - self.user_sid: Optional[str] = payload.get("user_sid") - self.message_id: Optional[str] = payload.get("message_id") - self.score: Optional[float] = payload.get("score") - self.session_id: Optional[str] = payload.get("session_id") - self.text: Optional[str] = payload.get("text") - self.date_created: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_created") - ) - self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_updated") - ) - - self._solution = { - "id": 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 FeedbackPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> FeedbackInstance: - """ - Build an instance of FeedbackInstance - - :param payload: Payload response from the API - """ - - return FeedbackInstance(self._version, payload, id=self._solution["id"]) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class FeedbackList(ListResource): - - class AssistantsV1ServiceCreateFeedbackRequest(object): - """ - :ivar message_id: The message ID. - :ivar score: The score to be given(0-1). - :ivar session_id: The Session ID. - :ivar text: The text to be given as feedback. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.message_id: Optional[str] = payload.get("message_id") - self.score: Optional[float] = payload.get("score") - self.session_id: Optional[str] = payload.get("session_id") - self.text: Optional[str] = payload.get("text") - - def to_dict(self): - return { - "message_id": self.message_id, - "score": self.score, - "session_id": self.session_id, - "text": self.text, - } - - def __init__(self, version: Version, id: str): - """ - Initialize the FeedbackList - - :param version: Version that contains the resource - :param id: The assistant ID. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "id": id, - } - self._uri = "/Assistants/{id}/Feedbacks".format(**self._solution) - - def _create( - self, - assistants_v1_service_create_feedback_request: AssistantsV1ServiceCreateFeedbackRequest, - ) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = assistants_v1_service_create_feedback_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, - assistants_v1_service_create_feedback_request: AssistantsV1ServiceCreateFeedbackRequest, - ) -> FeedbackInstance: - """ - Create the FeedbackInstance - - :param assistants_v1_service_create_feedback_request: - - :returns: The created FeedbackInstance - """ - payload, _, _ = self._create( - assistants_v1_service_create_feedback_request=assistants_v1_service_create_feedback_request - ) - return FeedbackInstance(self._version, payload, id=self._solution["id"]) - - def create_with_http_info( - self, - assistants_v1_service_create_feedback_request: AssistantsV1ServiceCreateFeedbackRequest, - ) -> ApiResponse: - """ - Create the FeedbackInstance and return response metadata - - :param assistants_v1_service_create_feedback_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create( - assistants_v1_service_create_feedback_request=assistants_v1_service_create_feedback_request - ) - instance = FeedbackInstance(self._version, payload, id=self._solution["id"]) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _create_async( - self, - assistants_v1_service_create_feedback_request: AssistantsV1ServiceCreateFeedbackRequest, - ) -> tuple: - """ - Internal async helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = assistants_v1_service_create_feedback_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, - assistants_v1_service_create_feedback_request: AssistantsV1ServiceCreateFeedbackRequest, - ) -> FeedbackInstance: - """ - Asynchronously create the FeedbackInstance - - :param assistants_v1_service_create_feedback_request: - - :returns: The created FeedbackInstance - """ - payload, _, _ = await self._create_async( - assistants_v1_service_create_feedback_request=assistants_v1_service_create_feedback_request - ) - return FeedbackInstance(self._version, payload, id=self._solution["id"]) - - async def create_with_http_info_async( - self, - assistants_v1_service_create_feedback_request: AssistantsV1ServiceCreateFeedbackRequest, - ) -> ApiResponse: - """ - Asynchronously create the FeedbackInstance and return response metadata - - :param assistants_v1_service_create_feedback_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async( - assistants_v1_service_create_feedback_request=assistants_v1_service_create_feedback_request - ) - instance = FeedbackInstance(self._version, payload, id=self._solution["id"]) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[FeedbackInstance]: - """ - Streams FeedbackInstance 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 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_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[FeedbackInstance]: - """ - Asynchronously streams FeedbackInstance 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 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_size=limits["page_size"]) - - return self._version.stream_async(page, limits["limit"]) - - def stream_with_http_info( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Streams FeedbackInstance and returns headers from first page - - - :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_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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Asynchronously streams FeedbackInstance and returns headers from first page - - - :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_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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[FeedbackInstance]: - """ - Lists FeedbackInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :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( - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[FeedbackInstance]: - """ - Asynchronously lists FeedbackInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :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( - limit=limit, - page_size=page_size, - ) - ] - - def list_with_http_info( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Lists FeedbackInstance and returns headers from first page - - - :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( - 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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Asynchronously lists FeedbackInstance and returns headers from first page - - - :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( - 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_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> FeedbackPage: - """ - Retrieve a single page of FeedbackInstance records from the API. - Request is executed immediately - - :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: Page of FeedbackInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 FeedbackPage(self._version, response, solution=self._solution) - - async def page_async( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> FeedbackPage: - """ - Asynchronously retrieve a single page of FeedbackInstance records from the API. - Request is executed immediately - - :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: Page of FeedbackInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 FeedbackPage(self._version, response, solution=self._solution) - - def page_with_http_info( - self, - 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: 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 FeedbackPage, status code, and headers - """ - data = values.of( - { - "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 = FeedbackPage(self._version, response, solution=self._solution) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - async def page_with_http_info_async( - self, - 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: 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 FeedbackPage, status code, and headers - """ - data = values.of( - { - "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 = FeedbackPage(self._version, response, solution=self._solution) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - def get_page(self, target_url: str) -> FeedbackPage: - """ - Retrieve a specific page of FeedbackInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of FeedbackInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return FeedbackPage(self._version, response, solution=self._solution) - - async def get_page_async(self, target_url: str) -> FeedbackPage: - """ - Asynchronously retrieve a specific page of FeedbackInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of FeedbackInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return FeedbackPage(self._version, response, solution=self._solution) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/assistants/v1/assistant/message.py b/twilio/rest/assistants/v1/assistant/message.py deleted file mode 100644 index 38adca4cec..0000000000 --- a/twilio/rest/assistants/v1/assistant/message.py +++ /dev/null @@ -1,247 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Assistants - 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 MessageInstance(InstanceResource): - - class AssistantsV1ServiceAssistantSendMessageRequest(object): - """ - :ivar identity: The unique identity of user for the session. - :ivar session_id: The unique name for the session. - :ivar body: The query to ask the assistant. - :ivar webhook: The webhook url to call after the assistant has generated a response or report an error. - :ivar mode: one of the modes 'chat', 'email' or 'voice' - """ - - def __init__(self, payload: Dict[str, Any]): - - self.identity: Optional[str] = payload.get("identity") - self.session_id: Optional[str] = payload.get("session_id") - self.body: Optional[str] = payload.get("body") - self.webhook: Optional[str] = payload.get("webhook") - self.mode: Optional[str] = payload.get("mode") - - def to_dict(self): - return { - "identity": self.identity, - "session_id": self.session_id, - "body": self.body, - "webhook": self.webhook, - "mode": self.mode, - } - - """ - :ivar status: success or failure based on whether the request successfully generated a response. - :ivar flagged: If successful, this property will denote whether the response was flagged or not. - :ivar aborted: This property will denote whether the request was aborted or not. - :ivar session_id: The unique name for the session. - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that sent the Message. - :ivar body: If successful, the body of the generated response - :ivar error: The error message if generation was not successful - """ - - def __init__(self, version: Version, payload: Dict[str, Any], id: str): - super().__init__(version) - - self.status: Optional[str] = payload.get("status") - self.flagged: Optional[bool] = payload.get("flagged") - self.aborted: Optional[bool] = payload.get("aborted") - self.session_id: Optional[str] = payload.get("session_id") - self.account_sid: Optional[str] = payload.get("account_sid") - self.body: Optional[str] = payload.get("body") - self.error: Optional[str] = payload.get("error") - - self._solution = { - "id": 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 MessageList(ListResource): - - class AssistantsV1ServiceAssistantSendMessageRequest(object): - """ - :ivar identity: The unique identity of user for the session. - :ivar session_id: The unique name for the session. - :ivar body: The query to ask the assistant. - :ivar webhook: The webhook url to call after the assistant has generated a response or report an error. - :ivar mode: one of the modes 'chat', 'email' or 'voice' - """ - - def __init__(self, payload: Dict[str, Any]): - - self.identity: Optional[str] = payload.get("identity") - self.session_id: Optional[str] = payload.get("session_id") - self.body: Optional[str] = payload.get("body") - self.webhook: Optional[str] = payload.get("webhook") - self.mode: Optional[str] = payload.get("mode") - - def to_dict(self): - return { - "identity": self.identity, - "session_id": self.session_id, - "body": self.body, - "webhook": self.webhook, - "mode": self.mode, - } - - def __init__(self, version: Version, id: str): - """ - Initialize the MessageList - - :param version: Version that contains the resource - :param id: the Assistant ID. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "id": id, - } - self._uri = "/Assistants/{id}/Messages".format(**self._solution) - - def _create( - self, - assistants_v1_service_assistant_send_message_request: AssistantsV1ServiceAssistantSendMessageRequest, - ) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = assistants_v1_service_assistant_send_message_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, - assistants_v1_service_assistant_send_message_request: AssistantsV1ServiceAssistantSendMessageRequest, - ) -> MessageInstance: - """ - Create the MessageInstance - - :param assistants_v1_service_assistant_send_message_request: - - :returns: The created MessageInstance - """ - payload, _, _ = self._create( - assistants_v1_service_assistant_send_message_request=assistants_v1_service_assistant_send_message_request - ) - return MessageInstance(self._version, payload, id=self._solution["id"]) - - def create_with_http_info( - self, - assistants_v1_service_assistant_send_message_request: AssistantsV1ServiceAssistantSendMessageRequest, - ) -> ApiResponse: - """ - Create the MessageInstance and return response metadata - - :param assistants_v1_service_assistant_send_message_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create( - assistants_v1_service_assistant_send_message_request=assistants_v1_service_assistant_send_message_request - ) - instance = MessageInstance(self._version, payload, id=self._solution["id"]) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _create_async( - self, - assistants_v1_service_assistant_send_message_request: AssistantsV1ServiceAssistantSendMessageRequest, - ) -> tuple: - """ - Internal async helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = assistants_v1_service_assistant_send_message_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, - assistants_v1_service_assistant_send_message_request: AssistantsV1ServiceAssistantSendMessageRequest, - ) -> MessageInstance: - """ - Asynchronously create the MessageInstance - - :param assistants_v1_service_assistant_send_message_request: - - :returns: The created MessageInstance - """ - payload, _, _ = await self._create_async( - assistants_v1_service_assistant_send_message_request=assistants_v1_service_assistant_send_message_request - ) - return MessageInstance(self._version, payload, id=self._solution["id"]) - - async def create_with_http_info_async( - self, - assistants_v1_service_assistant_send_message_request: AssistantsV1ServiceAssistantSendMessageRequest, - ) -> ApiResponse: - """ - Asynchronously create the MessageInstance and return response metadata - - :param assistants_v1_service_assistant_send_message_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async( - assistants_v1_service_assistant_send_message_request=assistants_v1_service_assistant_send_message_request - ) - instance = MessageInstance(self._version, payload, id=self._solution["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/assistants/v1/knowledge/__init__.py b/twilio/rest/assistants/v1/knowledge/__init__.py deleted file mode 100644 index e31a496d94..0000000000 --- a/twilio/rest/assistants/v1/knowledge/__init__.py +++ /dev/null @@ -1,1443 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Assistants - 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 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.page import Page -from twilio.rest.assistants.v1.knowledge.chunk import ChunkList -from twilio.rest.assistants.v1.knowledge.knowledge_status import KnowledgeStatusList - - -class KnowledgeInstance(InstanceResource): - - class AssistantsV1ServiceCreateKnowledgeRequest(object): - """ - :ivar assistant_id: The Assistant ID. - :ivar description: The description of the knowledge source. - :ivar knowledge_source_details: The details of the knowledge source based on the type. - :ivar name: The name of the tool. - :ivar policy: - :ivar type: The type of the knowledge source. - :ivar embedding_model: The embedding model to be used for the knowledge source. It's required for 'Database' type but disallowed for other types. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.assistant_id: Optional[str] = payload.get("assistant_id") - self.description: Optional[str] = payload.get("description") - self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( - "knowledge_source_details" - ) - self.name: Optional[str] = payload.get("name") - self.policy: Optional[ - KnowledgeList.AssistantsV1ServiceCreatePolicyRequest - ] = payload.get("policy") - self.type: Optional[str] = payload.get("type") - self.embedding_model: Optional[str] = payload.get("embedding_model") - - def to_dict(self): - return { - "assistant_id": self.assistant_id, - "description": self.description, - "knowledge_source_details": self.knowledge_source_details, - "name": self.name, - "policy": self.policy.to_dict() if self.policy is not None else None, - "type": self.type, - "embedding_model": self.embedding_model, - } - - class AssistantsV1ServiceCreatePolicyRequest(object): - """ - :ivar description: The description of the policy. - :ivar id: The Policy ID. - :ivar name: The name of the policy. - :ivar policy_details: - :ivar type: The description of the policy. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.description: Optional[str] = payload.get("description") - self.id: Optional[str] = payload.get("id") - self.name: Optional[str] = payload.get("name") - self.policy_details: Optional[Dict[str, object]] = payload.get( - "policy_details" - ) - self.type: Optional[str] = payload.get("type") - - def to_dict(self): - return { - "description": self.description, - "id": self.id, - "name": self.name, - "policy_details": self.policy_details, - "type": self.type, - } - - class AssistantsV1ServiceUpdateKnowledgeRequest(object): - """ - :ivar description: The description of the knowledge source. - :ivar knowledge_source_details: The details of the knowledge source based on the type. - :ivar name: The name of the knowledge source. - :ivar policy: - :ivar type: The description of the knowledge source. - :ivar embedding_model: The embedding model to be used for the knowledge source. It's only applicable to 'Database' type. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.description: Optional[str] = payload.get("description") - self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( - "knowledge_source_details" - ) - self.name: Optional[str] = payload.get("name") - self.policy: Optional[ - KnowledgeList.AssistantsV1ServiceCreatePolicyRequest - ] = payload.get("policy") - self.type: Optional[str] = payload.get("type") - self.embedding_model: Optional[str] = payload.get("embedding_model") - - def to_dict(self): - return { - "description": self.description, - "knowledge_source_details": self.knowledge_source_details, - "name": self.name, - "policy": self.policy.to_dict() if self.policy is not None else None, - "type": self.type, - "embedding_model": self.embedding_model, - } - - """ - :ivar description: The type of knowledge source. - :ivar id: The description of knowledge. - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Knowledge resource. - :ivar knowledge_source_details: The details of the knowledge source based on the type. - :ivar name: The name of the knowledge source. - :ivar status: The status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED') - :ivar type: The type of knowledge source ('Web', 'Database', 'Text', 'File') - :ivar url: The url of the knowledge resource. - :ivar embedding_model: The embedding model to be used for the knowledge source. - :ivar date_created: The date and time in GMT when the Knowledge was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - :ivar date_updated: The date and time in GMT when the Knowledge was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - """ - - def __init__( - self, version: Version, payload: Dict[str, Any], id: Optional[str] = None - ): - super().__init__(version) - - self.description: Optional[str] = payload.get("description") - self.id: Optional[str] = payload.get("id") - self.account_sid: Optional[str] = payload.get("account_sid") - self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( - "knowledge_source_details" - ) - self.name: Optional[str] = payload.get("name") - self.status: Optional[str] = payload.get("status") - self.type: Optional[str] = payload.get("type") - self.url: Optional[str] = payload.get("url") - self.embedding_model: Optional[str] = payload.get("embedding_model") - self.date_created: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_created") - ) - self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_updated") - ) - - self._solution = { - "id": id or self.id, - } - - self._context: Optional[KnowledgeContext] = None - - @property - def _proxy(self) -> "KnowledgeContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: KnowledgeContext for this KnowledgeInstance - """ - if self._context is None: - self._context = KnowledgeContext( - self._version, - id=self._solution["id"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the KnowledgeInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the KnowledgeInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def delete_with_http_info(self) -> ApiResponse: - """ - Deletes the KnowledgeInstance with HTTP info - - - :returns: ApiResponse with success boolean, status code, and headers - """ - return self._proxy.delete_with_http_info() - - async def delete_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine that deletes the KnowledgeInstance with HTTP info - - - :returns: ApiResponse with success boolean, status code, and headers - """ - return await self._proxy.delete_with_http_info_async() - - def fetch(self) -> "KnowledgeInstance": - """ - Fetch the KnowledgeInstance - - - :returns: The fetched KnowledgeInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "KnowledgeInstance": - """ - Asynchronous coroutine to fetch the KnowledgeInstance - - - :returns: The fetched KnowledgeInstance - """ - return await self._proxy.fetch_async() - - def fetch_with_http_info(self) -> ApiResponse: - """ - Fetch the KnowledgeInstance 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 KnowledgeInstance with HTTP info - - - :returns: ApiResponse with instance, status code, and headers - """ - return await self._proxy.fetch_with_http_info_async() - - def update( - self, - assistants_v1_service_update_knowledge_request: Union[ - AssistantsV1ServiceUpdateKnowledgeRequest, object - ] = values.unset, - ) -> "KnowledgeInstance": - """ - Update the KnowledgeInstance - - :param assistants_v1_service_update_knowledge_request: - - :returns: The updated KnowledgeInstance - """ - return self._proxy.update( - assistants_v1_service_update_knowledge_request=assistants_v1_service_update_knowledge_request, - ) - - async def update_async( - self, - assistants_v1_service_update_knowledge_request: Union[ - AssistantsV1ServiceUpdateKnowledgeRequest, object - ] = values.unset, - ) -> "KnowledgeInstance": - """ - Asynchronous coroutine to update the KnowledgeInstance - - :param assistants_v1_service_update_knowledge_request: - - :returns: The updated KnowledgeInstance - """ - return await self._proxy.update_async( - assistants_v1_service_update_knowledge_request=assistants_v1_service_update_knowledge_request, - ) - - def update_with_http_info( - self, - assistants_v1_service_update_knowledge_request: Union[ - AssistantsV1ServiceUpdateKnowledgeRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Update the KnowledgeInstance with HTTP info - - :param assistants_v1_service_update_knowledge_request: - - :returns: ApiResponse with instance, status code, and headers - """ - return self._proxy.update_with_http_info( - assistants_v1_service_update_knowledge_request=assistants_v1_service_update_knowledge_request, - ) - - async def update_with_http_info_async( - self, - assistants_v1_service_update_knowledge_request: Union[ - AssistantsV1ServiceUpdateKnowledgeRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronous coroutine to update the KnowledgeInstance with HTTP info - - :param assistants_v1_service_update_knowledge_request: - - :returns: ApiResponse with instance, status code, and headers - """ - return await self._proxy.update_with_http_info_async( - assistants_v1_service_update_knowledge_request=assistants_v1_service_update_knowledge_request, - ) - - @property - def chunks(self) -> ChunkList: - """ - Access the chunks - """ - return self._proxy.chunks - - @property - def knowledge_status(self) -> KnowledgeStatusList: - """ - Access the knowledge_status - """ - return self._proxy.knowledge_status - - 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 KnowledgeContext(InstanceContext): - - class AssistantsV1ServiceCreateKnowledgeRequest(object): - """ - :ivar assistant_id: The Assistant ID. - :ivar description: The description of the knowledge source. - :ivar knowledge_source_details: The details of the knowledge source based on the type. - :ivar name: The name of the tool. - :ivar policy: - :ivar type: The type of the knowledge source. - :ivar embedding_model: The embedding model to be used for the knowledge source. It's required for 'Database' type but disallowed for other types. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.assistant_id: Optional[str] = payload.get("assistant_id") - self.description: Optional[str] = payload.get("description") - self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( - "knowledge_source_details" - ) - self.name: Optional[str] = payload.get("name") - self.policy: Optional[ - KnowledgeList.AssistantsV1ServiceCreatePolicyRequest - ] = payload.get("policy") - self.type: Optional[str] = payload.get("type") - self.embedding_model: Optional[str] = payload.get("embedding_model") - - def to_dict(self): - return { - "assistant_id": self.assistant_id, - "description": self.description, - "knowledge_source_details": self.knowledge_source_details, - "name": self.name, - "policy": self.policy.to_dict() if self.policy is not None else None, - "type": self.type, - "embedding_model": self.embedding_model, - } - - class AssistantsV1ServiceCreatePolicyRequest(object): - """ - :ivar description: The description of the policy. - :ivar id: The Policy ID. - :ivar name: The name of the policy. - :ivar policy_details: - :ivar type: The description of the policy. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.description: Optional[str] = payload.get("description") - self.id: Optional[str] = payload.get("id") - self.name: Optional[str] = payload.get("name") - self.policy_details: Optional[Dict[str, object]] = payload.get( - "policy_details" - ) - self.type: Optional[str] = payload.get("type") - - def to_dict(self): - return { - "description": self.description, - "id": self.id, - "name": self.name, - "policy_details": self.policy_details, - "type": self.type, - } - - class AssistantsV1ServiceUpdateKnowledgeRequest(object): - """ - :ivar description: The description of the knowledge source. - :ivar knowledge_source_details: The details of the knowledge source based on the type. - :ivar name: The name of the knowledge source. - :ivar policy: - :ivar type: The description of the knowledge source. - :ivar embedding_model: The embedding model to be used for the knowledge source. It's only applicable to 'Database' type. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.description: Optional[str] = payload.get("description") - self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( - "knowledge_source_details" - ) - self.name: Optional[str] = payload.get("name") - self.policy: Optional[ - KnowledgeList.AssistantsV1ServiceCreatePolicyRequest - ] = payload.get("policy") - self.type: Optional[str] = payload.get("type") - self.embedding_model: Optional[str] = payload.get("embedding_model") - - def to_dict(self): - return { - "description": self.description, - "knowledge_source_details": self.knowledge_source_details, - "name": self.name, - "policy": self.policy.to_dict() if self.policy is not None else None, - "type": self.type, - "embedding_model": self.embedding_model, - } - - def __init__(self, version: Version, id: str): - """ - Initialize the KnowledgeContext - - :param version: Version that contains the resource - :param id: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "id": id, - } - self._uri = "/Knowledge/{id}".format(**self._solution) - - self._chunks: Optional[ChunkList] = None - self._knowledge_status: Optional[KnowledgeStatusList] = None - - def _delete(self) -> tuple: - """ - Internal helper for delete operation - - Returns: - tuple: (success_boolean, status_code, headers) - """ - - headers = values.of({}) - - return self._version.delete_with_response_info( - method="DELETE", uri=self._uri, headers=headers - ) - - def delete(self) -> bool: - """ - Deletes the KnowledgeInstance - - - :returns: True if delete succeeds, False otherwise - """ - success, _, _ = self._delete() - return success - - def delete_with_http_info(self) -> ApiResponse: - """ - Deletes the KnowledgeInstance and return response metadata - - - :returns: ApiResponse with success boolean, status code, and headers - """ - success, status_code, headers = self._delete() - return ApiResponse(data=success, status_code=status_code, headers=headers) - - async def _delete_async(self) -> tuple: - """ - Internal async helper for delete operation - - Returns: - tuple: (success_boolean, status_code, headers) - """ - - headers = values.of({}) - - return await self._version.delete_with_response_info_async( - method="DELETE", uri=self._uri, headers=headers - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the KnowledgeInstance - - - :returns: True if delete succeeds, False otherwise - """ - success, _, _ = await self._delete_async() - return success - - async def delete_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine that deletes the KnowledgeInstance and return response metadata - - - :returns: ApiResponse with success boolean, status code, and headers - """ - success, status_code, headers = await self._delete_async() - return ApiResponse(data=success, status_code=status_code, headers=headers) - - 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) -> KnowledgeInstance: - """ - Fetch the KnowledgeInstance - - - :returns: The fetched KnowledgeInstance - """ - payload, _, _ = self._fetch() - return KnowledgeInstance( - self._version, - payload, - id=self._solution["id"], - ) - - def fetch_with_http_info(self) -> ApiResponse: - """ - Fetch the KnowledgeInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._fetch() - instance = KnowledgeInstance( - self._version, - payload, - id=self._solution["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) -> KnowledgeInstance: - """ - Asynchronous coroutine to fetch the KnowledgeInstance - - - :returns: The fetched KnowledgeInstance - """ - payload, _, _ = await self._fetch_async() - return KnowledgeInstance( - self._version, - payload, - id=self._solution["id"], - ) - - async def fetch_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine to fetch the KnowledgeInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._fetch_async() - instance = KnowledgeInstance( - self._version, - payload, - id=self._solution["id"], - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def _update( - self, - assistants_v1_service_update_knowledge_request: Union[ - AssistantsV1ServiceUpdateKnowledgeRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal helper for update operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = assistants_v1_service_update_knowledge_request.to_dict() - - headers = values.of({}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return self._version.update_with_response_info( - method="PUT", uri=self._uri, data=data, headers=headers - ) - - def update( - self, - assistants_v1_service_update_knowledge_request: Union[ - AssistantsV1ServiceUpdateKnowledgeRequest, object - ] = values.unset, - ) -> KnowledgeInstance: - """ - Update the KnowledgeInstance - - :param assistants_v1_service_update_knowledge_request: - - :returns: The updated KnowledgeInstance - """ - payload, _, _ = self._update( - assistants_v1_service_update_knowledge_request=assistants_v1_service_update_knowledge_request - ) - return KnowledgeInstance(self._version, payload, id=self._solution["id"]) - - def update_with_http_info( - self, - assistants_v1_service_update_knowledge_request: Union[ - AssistantsV1ServiceUpdateKnowledgeRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Update the KnowledgeInstance and return response metadata - - :param assistants_v1_service_update_knowledge_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._update( - assistants_v1_service_update_knowledge_request=assistants_v1_service_update_knowledge_request - ) - instance = KnowledgeInstance(self._version, payload, id=self._solution["id"]) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _update_async( - self, - assistants_v1_service_update_knowledge_request: Union[ - AssistantsV1ServiceUpdateKnowledgeRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal async helper for update operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = assistants_v1_service_update_knowledge_request.to_dict() - - headers = values.of({}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return await self._version.update_with_response_info_async( - method="PUT", uri=self._uri, data=data, headers=headers - ) - - async def update_async( - self, - assistants_v1_service_update_knowledge_request: Union[ - AssistantsV1ServiceUpdateKnowledgeRequest, object - ] = values.unset, - ) -> KnowledgeInstance: - """ - Asynchronous coroutine to update the KnowledgeInstance - - :param assistants_v1_service_update_knowledge_request: - - :returns: The updated KnowledgeInstance - """ - payload, _, _ = await self._update_async( - assistants_v1_service_update_knowledge_request=assistants_v1_service_update_knowledge_request - ) - return KnowledgeInstance(self._version, payload, id=self._solution["id"]) - - async def update_with_http_info_async( - self, - assistants_v1_service_update_knowledge_request: Union[ - AssistantsV1ServiceUpdateKnowledgeRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronous coroutine to update the KnowledgeInstance and return response metadata - - :param assistants_v1_service_update_knowledge_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._update_async( - assistants_v1_service_update_knowledge_request=assistants_v1_service_update_knowledge_request - ) - instance = KnowledgeInstance(self._version, payload, id=self._solution["id"]) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - @property - def chunks(self) -> ChunkList: - """ - Access the chunks - """ - if self._chunks is None: - self._chunks = ChunkList( - self._version, - self._solution["id"], - ) - return self._chunks - - @property - def knowledge_status(self) -> KnowledgeStatusList: - """ - Access the knowledge_status - """ - if self._knowledge_status is None: - self._knowledge_status = KnowledgeStatusList( - self._version, - self._solution["id"], - ) - return self._knowledge_status - - 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 KnowledgePage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> KnowledgeInstance: - """ - Build an instance of KnowledgeInstance - - :param payload: Payload response from the API - """ - - return KnowledgeInstance(self._version, payload) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class KnowledgeList(ListResource): - - class AssistantsV1ServiceCreateKnowledgeRequest(object): - """ - :ivar assistant_id: The Assistant ID. - :ivar description: The description of the knowledge source. - :ivar knowledge_source_details: The details of the knowledge source based on the type. - :ivar name: The name of the tool. - :ivar policy: - :ivar type: The type of the knowledge source. - :ivar embedding_model: The embedding model to be used for the knowledge source. It's required for 'Database' type but disallowed for other types. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.assistant_id: Optional[str] = payload.get("assistant_id") - self.description: Optional[str] = payload.get("description") - self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( - "knowledge_source_details" - ) - self.name: Optional[str] = payload.get("name") - self.policy: Optional[ - KnowledgeList.AssistantsV1ServiceCreatePolicyRequest - ] = payload.get("policy") - self.type: Optional[str] = payload.get("type") - self.embedding_model: Optional[str] = payload.get("embedding_model") - - def to_dict(self): - return { - "assistant_id": self.assistant_id, - "description": self.description, - "knowledge_source_details": self.knowledge_source_details, - "name": self.name, - "policy": self.policy.to_dict() if self.policy is not None else None, - "type": self.type, - "embedding_model": self.embedding_model, - } - - class AssistantsV1ServiceCreatePolicyRequest(object): - """ - :ivar description: The description of the policy. - :ivar id: The Policy ID. - :ivar name: The name of the policy. - :ivar policy_details: - :ivar type: The description of the policy. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.description: Optional[str] = payload.get("description") - self.id: Optional[str] = payload.get("id") - self.name: Optional[str] = payload.get("name") - self.policy_details: Optional[Dict[str, object]] = payload.get( - "policy_details" - ) - self.type: Optional[str] = payload.get("type") - - def to_dict(self): - return { - "description": self.description, - "id": self.id, - "name": self.name, - "policy_details": self.policy_details, - "type": self.type, - } - - class AssistantsV1ServiceUpdateKnowledgeRequest(object): - """ - :ivar description: The description of the knowledge source. - :ivar knowledge_source_details: The details of the knowledge source based on the type. - :ivar name: The name of the knowledge source. - :ivar policy: - :ivar type: The description of the knowledge source. - :ivar embedding_model: The embedding model to be used for the knowledge source. It's only applicable to 'Database' type. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.description: Optional[str] = payload.get("description") - self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( - "knowledge_source_details" - ) - self.name: Optional[str] = payload.get("name") - self.policy: Optional[ - KnowledgeList.AssistantsV1ServiceCreatePolicyRequest - ] = payload.get("policy") - self.type: Optional[str] = payload.get("type") - self.embedding_model: Optional[str] = payload.get("embedding_model") - - def to_dict(self): - return { - "description": self.description, - "knowledge_source_details": self.knowledge_source_details, - "name": self.name, - "policy": self.policy.to_dict() if self.policy is not None else None, - "type": self.type, - "embedding_model": self.embedding_model, - } - - def __init__(self, version: Version): - """ - Initialize the KnowledgeList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/Knowledge" - - def _create( - self, - assistants_v1_service_create_knowledge_request: AssistantsV1ServiceCreateKnowledgeRequest, - ) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = assistants_v1_service_create_knowledge_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, - assistants_v1_service_create_knowledge_request: AssistantsV1ServiceCreateKnowledgeRequest, - ) -> KnowledgeInstance: - """ - Create the KnowledgeInstance - - :param assistants_v1_service_create_knowledge_request: - - :returns: The created KnowledgeInstance - """ - payload, _, _ = self._create( - assistants_v1_service_create_knowledge_request=assistants_v1_service_create_knowledge_request - ) - return KnowledgeInstance(self._version, payload) - - def create_with_http_info( - self, - assistants_v1_service_create_knowledge_request: AssistantsV1ServiceCreateKnowledgeRequest, - ) -> ApiResponse: - """ - Create the KnowledgeInstance and return response metadata - - :param assistants_v1_service_create_knowledge_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create( - assistants_v1_service_create_knowledge_request=assistants_v1_service_create_knowledge_request - ) - instance = KnowledgeInstance(self._version, payload) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _create_async( - self, - assistants_v1_service_create_knowledge_request: AssistantsV1ServiceCreateKnowledgeRequest, - ) -> tuple: - """ - Internal async helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = assistants_v1_service_create_knowledge_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, - assistants_v1_service_create_knowledge_request: AssistantsV1ServiceCreateKnowledgeRequest, - ) -> KnowledgeInstance: - """ - Asynchronously create the KnowledgeInstance - - :param assistants_v1_service_create_knowledge_request: - - :returns: The created KnowledgeInstance - """ - payload, _, _ = await self._create_async( - assistants_v1_service_create_knowledge_request=assistants_v1_service_create_knowledge_request - ) - return KnowledgeInstance(self._version, payload) - - async def create_with_http_info_async( - self, - assistants_v1_service_create_knowledge_request: AssistantsV1ServiceCreateKnowledgeRequest, - ) -> ApiResponse: - """ - Asynchronously create the KnowledgeInstance and return response metadata - - :param assistants_v1_service_create_knowledge_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async( - assistants_v1_service_create_knowledge_request=assistants_v1_service_create_knowledge_request - ) - instance = KnowledgeInstance(self._version, payload) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def stream( - self, - assistant_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[KnowledgeInstance]: - """ - Streams KnowledgeInstance 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 assistant_id: - :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(assistant_id=assistant_id, page_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - assistant_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[KnowledgeInstance]: - """ - Asynchronously streams KnowledgeInstance 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 assistant_id: - :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( - assistant_id=assistant_id, page_size=limits["page_size"] - ) - - return self._version.stream_async(page, limits["limit"]) - - def stream_with_http_info( - self, - assistant_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Streams KnowledgeInstance and returns headers from first page - - - :param str assistant_id: - :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( - assistant_id=assistant_id, 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, - assistant_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Asynchronously streams KnowledgeInstance and returns headers from first page - - - :param str assistant_id: - :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( - assistant_id=assistant_id, 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, - assistant_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[KnowledgeInstance]: - """ - Lists KnowledgeInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str assistant_id: - :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( - assistant_id=assistant_id, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - assistant_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[KnowledgeInstance]: - """ - Asynchronously lists KnowledgeInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str assistant_id: - :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( - assistant_id=assistant_id, - limit=limit, - page_size=page_size, - ) - ] - - def list_with_http_info( - self, - assistant_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Lists KnowledgeInstance and returns headers from first page - - - :param str assistant_id: - :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( - assistant_id=assistant_id, - 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, - assistant_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Asynchronously lists KnowledgeInstance and returns headers from first page - - - :param str assistant_id: - :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( - assistant_id=assistant_id, - 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, - assistant_id: 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, - ) -> KnowledgePage: - """ - Retrieve a single page of KnowledgeInstance records from the API. - Request is executed immediately - - :param assistant_id: - :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: Page of KnowledgeInstance - """ - data = values.of( - { - "AssistantId": assistant_id, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 KnowledgePage(self._version, response) - - async def page_async( - self, - assistant_id: 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, - ) -> KnowledgePage: - """ - Asynchronously retrieve a single page of KnowledgeInstance records from the API. - Request is executed immediately - - :param assistant_id: - :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: Page of KnowledgeInstance - """ - data = values.of( - { - "AssistantId": assistant_id, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 KnowledgePage(self._version, response) - - def page_with_http_info( - self, - assistant_id: 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 assistant_id: - :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 KnowledgePage, status code, and headers - """ - data = values.of( - { - "AssistantId": assistant_id, - "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 = KnowledgePage(self._version, response) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - async def page_with_http_info_async( - self, - assistant_id: 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 assistant_id: - :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 KnowledgePage, status code, and headers - """ - data = values.of( - { - "AssistantId": assistant_id, - "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 = KnowledgePage(self._version, response) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - def get_page(self, target_url: str) -> KnowledgePage: - """ - Retrieve a specific page of KnowledgeInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of KnowledgeInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return KnowledgePage(self._version, response) - - async def get_page_async(self, target_url: str) -> KnowledgePage: - """ - Asynchronously retrieve a specific page of KnowledgeInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of KnowledgeInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return KnowledgePage(self._version, response) - - def get(self, id: str) -> KnowledgeContext: - """ - Constructs a KnowledgeContext - - :param id: - """ - return KnowledgeContext(self._version, id=id) - - def __call__(self, id: str) -> KnowledgeContext: - """ - Constructs a KnowledgeContext - - :param id: - """ - return KnowledgeContext(self._version, id=id) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/assistants/v1/knowledge/chunk.py b/twilio/rest/assistants/v1/knowledge/chunk.py deleted file mode 100644 index fba901e7d1..0000000000 --- a/twilio/rest/assistants/v1/knowledge/chunk.py +++ /dev/null @@ -1,471 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Assistants - 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 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_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version -from twilio.base.page import Page - - -class ChunkInstance(InstanceResource): - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Knowledge resource. - :ivar content: The chunk content. - :ivar metadata: The metadata of the chunk. - :ivar date_created: The date and time in GMT when the Chunk was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - :ivar date_updated: The date and time in GMT when the Chunk was updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - """ - - def __init__(self, version: Version, payload: Dict[str, Any], id: str): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.content: Optional[str] = payload.get("content") - self.metadata: Optional[Dict[str, object]] = payload.get("metadata") - self.date_created: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_created") - ) - self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_updated") - ) - - self._solution = { - "id": 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 ChunkPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> ChunkInstance: - """ - Build an instance of ChunkInstance - - :param payload: Payload response from the API - """ - - return ChunkInstance(self._version, payload, id=self._solution["id"]) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class ChunkList(ListResource): - - def __init__(self, version: Version, id: str): - """ - Initialize the ChunkList - - :param version: Version that contains the resource - :param id: The knowledge ID. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "id": id, - } - self._uri = "/Knowledge/{id}/Chunks".format(**self._solution) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[ChunkInstance]: - """ - Streams ChunkInstance 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 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_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[ChunkInstance]: - """ - Asynchronously streams ChunkInstance 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 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_size=limits["page_size"]) - - return self._version.stream_async(page, limits["limit"]) - - def stream_with_http_info( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Streams ChunkInstance and returns headers from first page - - - :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_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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Asynchronously streams ChunkInstance and returns headers from first page - - - :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_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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[ChunkInstance]: - """ - Lists ChunkInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :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( - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[ChunkInstance]: - """ - Asynchronously lists ChunkInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :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( - limit=limit, - page_size=page_size, - ) - ] - - def list_with_http_info( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Lists ChunkInstance and returns headers from first page - - - :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( - 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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Asynchronously lists ChunkInstance and returns headers from first page - - - :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( - 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_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> ChunkPage: - """ - Retrieve a single page of ChunkInstance records from the API. - Request is executed immediately - - :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: Page of ChunkInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 ChunkPage(self._version, response, solution=self._solution) - - async def page_async( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> ChunkPage: - """ - Asynchronously retrieve a single page of ChunkInstance records from the API. - Request is executed immediately - - :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: Page of ChunkInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 ChunkPage(self._version, response, solution=self._solution) - - def page_with_http_info( - self, - 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: 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 ChunkPage, status code, and headers - """ - data = values.of( - { - "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 = ChunkPage(self._version, response, solution=self._solution) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - async def page_with_http_info_async( - self, - 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: 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 ChunkPage, status code, and headers - """ - data = values.of( - { - "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 = ChunkPage(self._version, response, solution=self._solution) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - def get_page(self, target_url: str) -> ChunkPage: - """ - Retrieve a specific page of ChunkInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of ChunkInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return ChunkPage(self._version, response, solution=self._solution) - - async def get_page_async(self, target_url: str) -> ChunkPage: - """ - Asynchronously retrieve a specific page of ChunkInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of ChunkInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return ChunkPage(self._version, response, solution=self._solution) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/assistants/v1/knowledge/knowledge_status.py b/twilio/rest/assistants/v1/knowledge/knowledge_status.py deleted file mode 100644 index a6881230e3..0000000000 --- a/twilio/rest/assistants/v1/knowledge/knowledge_status.py +++ /dev/null @@ -1,264 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Assistants - 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 datetime import datetime -from typing import Any, Dict, Optional -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 - - -class KnowledgeStatusInstance(InstanceResource): - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Knowledge resource. - :ivar status: The status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED') - :ivar last_status: The last status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED') - :ivar date_updated: The date and time in GMT when the Knowledge was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - """ - - def __init__(self, version: Version, payload: Dict[str, Any], id: str): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.status: Optional[str] = payload.get("status") - self.last_status: Optional[str] = payload.get("last_status") - self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_updated") - ) - - self._solution = { - "id": id, - } - - self._context: Optional[KnowledgeStatusContext] = None - - @property - def _proxy(self) -> "KnowledgeStatusContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: KnowledgeStatusContext for this KnowledgeStatusInstance - """ - if self._context is None: - self._context = KnowledgeStatusContext( - self._version, - id=self._solution["id"], - ) - return self._context - - def fetch(self) -> "KnowledgeStatusInstance": - """ - Fetch the KnowledgeStatusInstance - - - :returns: The fetched KnowledgeStatusInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "KnowledgeStatusInstance": - """ - Asynchronous coroutine to fetch the KnowledgeStatusInstance - - - :returns: The fetched KnowledgeStatusInstance - """ - return await self._proxy.fetch_async() - - def fetch_with_http_info(self) -> ApiResponse: - """ - Fetch the KnowledgeStatusInstance 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 KnowledgeStatusInstance 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 KnowledgeStatusContext(InstanceContext): - - def __init__(self, version: Version, id: str): - """ - Initialize the KnowledgeStatusContext - - :param version: Version that contains the resource - :param id: the Knowledge ID. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "id": id, - } - self._uri = "/Knowledge/{id}/Status".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) -> KnowledgeStatusInstance: - """ - Fetch the KnowledgeStatusInstance - - - :returns: The fetched KnowledgeStatusInstance - """ - payload, _, _ = self._fetch() - return KnowledgeStatusInstance( - self._version, - payload, - id=self._solution["id"], - ) - - def fetch_with_http_info(self) -> ApiResponse: - """ - Fetch the KnowledgeStatusInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._fetch() - instance = KnowledgeStatusInstance( - self._version, - payload, - id=self._solution["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) -> KnowledgeStatusInstance: - """ - Asynchronous coroutine to fetch the KnowledgeStatusInstance - - - :returns: The fetched KnowledgeStatusInstance - """ - payload, _, _ = await self._fetch_async() - return KnowledgeStatusInstance( - self._version, - payload, - id=self._solution["id"], - ) - - async def fetch_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine to fetch the KnowledgeStatusInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._fetch_async() - instance = KnowledgeStatusInstance( - self._version, - payload, - id=self._solution["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 KnowledgeStatusList(ListResource): - - def __init__(self, version: Version, id: str): - """ - Initialize the KnowledgeStatusList - - :param version: Version that contains the resource - :param id: the Knowledge ID. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "id": id, - } - - def get(self) -> KnowledgeStatusContext: - """ - Constructs a KnowledgeStatusContext - - """ - return KnowledgeStatusContext(self._version, id=self._solution["id"]) - - def __call__(self) -> KnowledgeStatusContext: - """ - Constructs a KnowledgeStatusContext - - """ - return KnowledgeStatusContext(self._version, id=self._solution["id"]) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/assistants/v1/policy.py b/twilio/rest/assistants/v1/policy.py deleted file mode 100644 index 37d5bb1def..0000000000 --- a/twilio/rest/assistants/v1/policy.py +++ /dev/null @@ -1,540 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Assistants - 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 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_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version -from twilio.base.page import Page - - -class PolicyInstance(InstanceResource): - """ - :ivar id: The Policy ID. - :ivar name: The name of the policy. - :ivar description: The description of the policy. - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Policy resource. - :ivar user_sid: The SID of the User that created the Policy resource. - :ivar type: The type of the policy. - :ivar policy_details: The details of the policy based on the type. - :ivar date_created: The date and time in GMT when the Policy was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - :ivar date_updated: The date and time in GMT when the Policy was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - """ - - def __init__(self, version: Version, payload: Dict[str, Any]): - super().__init__(version) - - self.id: Optional[str] = payload.get("id") - self.name: Optional[str] = payload.get("name") - self.description: Optional[str] = payload.get("description") - self.account_sid: Optional[str] = payload.get("account_sid") - self.user_sid: Optional[str] = payload.get("user_sid") - self.type: Optional[str] = payload.get("type") - self.policy_details: Optional[Dict[str, object]] = payload.get("policy_details") - self.date_created: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_created") - ) - self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_updated") - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - - return "" - - -class PolicyPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> PolicyInstance: - """ - Build an instance of PolicyInstance - - :param payload: Payload response from the API - """ - - return PolicyInstance(self._version, payload) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class PolicyList(ListResource): - - def __init__(self, version: Version): - """ - Initialize the PolicyList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/Policies" - - def stream( - self, - tool_id: Union[str, object] = values.unset, - knowledge_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[PolicyInstance]: - """ - Streams PolicyInstance 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 tool_id: The tool ID. - :param str knowledge_id: The knowledge ID. - :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( - tool_id=tool_id, knowledge_id=knowledge_id, page_size=limits["page_size"] - ) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - tool_id: Union[str, object] = values.unset, - knowledge_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[PolicyInstance]: - """ - Asynchronously streams PolicyInstance 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 tool_id: The tool ID. - :param str knowledge_id: The knowledge ID. - :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( - tool_id=tool_id, knowledge_id=knowledge_id, page_size=limits["page_size"] - ) - - return self._version.stream_async(page, limits["limit"]) - - def stream_with_http_info( - self, - tool_id: Union[str, object] = values.unset, - knowledge_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Streams PolicyInstance and returns headers from first page - - - :param str tool_id: The tool ID. - :param str knowledge_id: The knowledge ID. - :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( - tool_id=tool_id, knowledge_id=knowledge_id, 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, - tool_id: Union[str, object] = values.unset, - knowledge_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Asynchronously streams PolicyInstance and returns headers from first page - - - :param str tool_id: The tool ID. - :param str knowledge_id: The knowledge ID. - :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( - tool_id=tool_id, knowledge_id=knowledge_id, 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, - tool_id: Union[str, object] = values.unset, - knowledge_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[PolicyInstance]: - """ - Lists PolicyInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str tool_id: The tool ID. - :param str knowledge_id: The knowledge ID. - :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( - tool_id=tool_id, - knowledge_id=knowledge_id, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - tool_id: Union[str, object] = values.unset, - knowledge_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[PolicyInstance]: - """ - Asynchronously lists PolicyInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str tool_id: The tool ID. - :param str knowledge_id: The knowledge ID. - :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( - tool_id=tool_id, - knowledge_id=knowledge_id, - limit=limit, - page_size=page_size, - ) - ] - - def list_with_http_info( - self, - tool_id: Union[str, object] = values.unset, - knowledge_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Lists PolicyInstance and returns headers from first page - - - :param str tool_id: The tool ID. - :param str knowledge_id: The knowledge ID. - :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( - tool_id=tool_id, - knowledge_id=knowledge_id, - 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, - tool_id: Union[str, object] = values.unset, - knowledge_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Asynchronously lists PolicyInstance and returns headers from first page - - - :param str tool_id: The tool ID. - :param str knowledge_id: The knowledge ID. - :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( - tool_id=tool_id, - knowledge_id=knowledge_id, - 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, - tool_id: Union[str, object] = values.unset, - knowledge_id: 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, - ) -> PolicyPage: - """ - Retrieve a single page of PolicyInstance records from the API. - Request is executed immediately - - :param tool_id: The tool ID. - :param knowledge_id: The knowledge ID. - :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: Page of PolicyInstance - """ - data = values.of( - { - "ToolId": tool_id, - "KnowledgeId": knowledge_id, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 PolicyPage(self._version, response) - - async def page_async( - self, - tool_id: Union[str, object] = values.unset, - knowledge_id: 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, - ) -> PolicyPage: - """ - Asynchronously retrieve a single page of PolicyInstance records from the API. - Request is executed immediately - - :param tool_id: The tool ID. - :param knowledge_id: The knowledge ID. - :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: Page of PolicyInstance - """ - data = values.of( - { - "ToolId": tool_id, - "KnowledgeId": knowledge_id, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 PolicyPage(self._version, response) - - def page_with_http_info( - self, - tool_id: Union[str, object] = values.unset, - knowledge_id: 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 tool_id: The tool ID. - :param knowledge_id: The knowledge ID. - :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 PolicyPage, status code, and headers - """ - data = values.of( - { - "ToolId": tool_id, - "KnowledgeId": knowledge_id, - "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 = PolicyPage(self._version, response) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - async def page_with_http_info_async( - self, - tool_id: Union[str, object] = values.unset, - knowledge_id: 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 tool_id: The tool ID. - :param knowledge_id: The knowledge ID. - :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 PolicyPage, status code, and headers - """ - data = values.of( - { - "ToolId": tool_id, - "KnowledgeId": knowledge_id, - "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 = PolicyPage(self._version, response) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - def get_page(self, target_url: str) -> PolicyPage: - """ - Retrieve a specific page of PolicyInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of PolicyInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return PolicyPage(self._version, response) - - async def get_page_async(self, target_url: str) -> PolicyPage: - """ - Asynchronously retrieve a specific page of PolicyInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of PolicyInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return PolicyPage(self._version, response) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/assistants/v1/session/__init__.py b/twilio/rest/assistants/v1/session/__init__.py deleted file mode 100644 index 26b17a103c..0000000000 --- a/twilio/rest/assistants/v1/session/__init__.py +++ /dev/null @@ -1,680 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Assistants - 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 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.page import Page -from twilio.rest.assistants.v1.session.message import MessageList - - -class SessionInstance(InstanceResource): - """ - :ivar id: The Session ID. - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Session resource. - :ivar assistant_id: The Assistant ID. - :ivar verified: True if the session is verified. - :ivar identity: The unique identity of user for the session. - :ivar date_created: The date and time in GMT when the Session was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - :ivar date_updated: The date and time in GMT when the Session was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - """ - - def __init__( - self, version: Version, payload: Dict[str, Any], id: Optional[str] = None - ): - super().__init__(version) - - self.id: Optional[str] = payload.get("id") - self.account_sid: Optional[str] = payload.get("account_sid") - self.assistant_id: Optional[str] = payload.get("assistant_id") - self.verified: Optional[bool] = payload.get("verified") - self.identity: Optional[str] = payload.get("identity") - self.date_created: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_created") - ) - self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_updated") - ) - - self._solution = { - "id": id or self.id, - } - - self._context: Optional[SessionContext] = None - - @property - def _proxy(self) -> "SessionContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: SessionContext for this SessionInstance - """ - if self._context is None: - self._context = SessionContext( - self._version, - id=self._solution["id"], - ) - return self._context - - def fetch(self) -> "SessionInstance": - """ - Fetch the SessionInstance - - - :returns: The fetched SessionInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "SessionInstance": - """ - Asynchronous coroutine to fetch the SessionInstance - - - :returns: The fetched SessionInstance - """ - return await self._proxy.fetch_async() - - def fetch_with_http_info(self) -> ApiResponse: - """ - Fetch the SessionInstance 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 SessionInstance with HTTP info - - - :returns: ApiResponse with instance, status code, and headers - """ - return await self._proxy.fetch_with_http_info_async() - - @property - def messages(self) -> MessageList: - """ - Access the messages - """ - return self._proxy.messages - - 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 SessionContext(InstanceContext): - - def __init__(self, version: Version, id: str): - """ - Initialize the SessionContext - - :param version: Version that contains the resource - :param id: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "id": id, - } - self._uri = "/Sessions/{id}".format(**self._solution) - - self._messages: Optional[MessageList] = None - - 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) -> SessionInstance: - """ - Fetch the SessionInstance - - - :returns: The fetched SessionInstance - """ - payload, _, _ = self._fetch() - return SessionInstance( - self._version, - payload, - id=self._solution["id"], - ) - - def fetch_with_http_info(self) -> ApiResponse: - """ - Fetch the SessionInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._fetch() - instance = SessionInstance( - self._version, - payload, - id=self._solution["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) -> SessionInstance: - """ - Asynchronous coroutine to fetch the SessionInstance - - - :returns: The fetched SessionInstance - """ - payload, _, _ = await self._fetch_async() - return SessionInstance( - self._version, - payload, - id=self._solution["id"], - ) - - async def fetch_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine to fetch the SessionInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._fetch_async() - instance = SessionInstance( - self._version, - payload, - id=self._solution["id"], - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - @property - def messages(self) -> MessageList: - """ - Access the messages - """ - if self._messages is None: - self._messages = MessageList( - self._version, - self._solution["id"], - ) - return self._messages - - 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 SessionPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> SessionInstance: - """ - Build an instance of SessionInstance - - :param payload: Payload response from the API - """ - - return SessionInstance(self._version, payload) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class SessionList(ListResource): - - def __init__(self, version: Version): - """ - Initialize the SessionList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/Sessions" - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[SessionInstance]: - """ - Streams SessionInstance 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 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_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[SessionInstance]: - """ - Asynchronously streams SessionInstance 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 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_size=limits["page_size"]) - - return self._version.stream_async(page, limits["limit"]) - - def stream_with_http_info( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Streams SessionInstance and returns headers from first page - - - :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_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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Asynchronously streams SessionInstance and returns headers from first page - - - :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_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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SessionInstance]: - """ - Lists SessionInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :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( - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SessionInstance]: - """ - Asynchronously lists SessionInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :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( - limit=limit, - page_size=page_size, - ) - ] - - def list_with_http_info( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Lists SessionInstance and returns headers from first page - - - :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( - 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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Asynchronously lists SessionInstance and returns headers from first page - - - :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( - 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_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> SessionPage: - """ - Retrieve a single page of SessionInstance records from the API. - Request is executed immediately - - :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: Page of SessionInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 SessionPage(self._version, response) - - async def page_async( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> SessionPage: - """ - Asynchronously retrieve a single page of SessionInstance records from the API. - Request is executed immediately - - :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: Page of SessionInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 SessionPage(self._version, response) - - def page_with_http_info( - self, - 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: 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 SessionPage, status code, and headers - """ - data = values.of( - { - "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 = SessionPage(self._version, response) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - async def page_with_http_info_async( - self, - 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: 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 SessionPage, status code, and headers - """ - data = values.of( - { - "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 = SessionPage(self._version, response) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - def get_page(self, target_url: str) -> SessionPage: - """ - Retrieve a specific page of SessionInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SessionInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return SessionPage(self._version, response) - - async def get_page_async(self, target_url: str) -> SessionPage: - """ - Asynchronously retrieve a specific page of SessionInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SessionInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return SessionPage(self._version, response) - - def get(self, id: str) -> SessionContext: - """ - Constructs a SessionContext - - :param id: - """ - return SessionContext(self._version, id=id) - - def __call__(self, id: str) -> SessionContext: - """ - Constructs a SessionContext - - :param id: - """ - return SessionContext(self._version, id=id) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/assistants/v1/session/message.py b/twilio/rest/assistants/v1/session/message.py deleted file mode 100644 index f8fba1fbde..0000000000 --- a/twilio/rest/assistants/v1/session/message.py +++ /dev/null @@ -1,483 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Assistants - 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 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_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version -from twilio.base.page import Page - - -class MessageInstance(InstanceResource): - """ - :ivar id: The message ID. - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Message resource. - :ivar assistant_id: The Assistant ID. - :ivar session_id: The Session ID. - :ivar identity: The identity of the user. - :ivar role: The role of the user associated with the message. - :ivar content: The content of the message. - :ivar meta: The metadata of the message. - :ivar date_created: The date and time in GMT when the Message was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - :ivar date_updated: The date and time in GMT when the Message was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - """ - - def __init__(self, version: Version, payload: Dict[str, Any], session_id: str): - super().__init__(version) - - self.id: Optional[str] = payload.get("id") - self.account_sid: Optional[str] = payload.get("account_sid") - self.assistant_id: Optional[str] = payload.get("assistant_id") - self.session_id: Optional[str] = payload.get("session_id") - self.identity: Optional[str] = payload.get("identity") - self.role: Optional[str] = payload.get("role") - self.content: Optional[Dict[str, object]] = payload.get("content") - self.meta: Optional[Dict[str, object]] = payload.get("meta") - self.date_created: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_created") - ) - self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_updated") - ) - - self._solution = { - "session_id": session_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 MessagePage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> MessageInstance: - """ - Build an instance of MessageInstance - - :param payload: Payload response from the API - """ - - return MessageInstance( - self._version, payload, session_id=self._solution["session_id"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class MessageList(ListResource): - - def __init__(self, version: Version, session_id: str): - """ - Initialize the MessageList - - :param version: Version that contains the resource - :param session_id: Session id or name - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "session_id": session_id, - } - self._uri = "/Sessions/{session_id}/Messages".format(**self._solution) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[MessageInstance]: - """ - Streams MessageInstance 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 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_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[MessageInstance]: - """ - Asynchronously streams MessageInstance 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 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_size=limits["page_size"]) - - return self._version.stream_async(page, limits["limit"]) - - def stream_with_http_info( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Streams MessageInstance and returns headers from first page - - - :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_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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Asynchronously streams MessageInstance and returns headers from first page - - - :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_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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[MessageInstance]: - """ - Lists MessageInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :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( - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[MessageInstance]: - """ - Asynchronously lists MessageInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :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( - limit=limit, - page_size=page_size, - ) - ] - - def list_with_http_info( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Lists MessageInstance and returns headers from first page - - - :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( - 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, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Asynchronously lists MessageInstance and returns headers from first page - - - :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( - 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_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> MessagePage: - """ - Retrieve a single page of MessageInstance records from the API. - Request is executed immediately - - :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: Page of MessageInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 MessagePage(self._version, response, solution=self._solution) - - async def page_async( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> MessagePage: - """ - Asynchronously retrieve a single page of MessageInstance records from the API. - Request is executed immediately - - :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: Page of MessageInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 MessagePage(self._version, response, solution=self._solution) - - def page_with_http_info( - self, - 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: 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 MessagePage, status code, and headers - """ - data = values.of( - { - "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 = MessagePage(self._version, response, solution=self._solution) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - async def page_with_http_info_async( - self, - 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: 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 MessagePage, status code, and headers - """ - data = values.of( - { - "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 = MessagePage(self._version, response, solution=self._solution) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - def get_page(self, target_url: str) -> MessagePage: - """ - Retrieve a specific page of MessageInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of MessageInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return MessagePage(self._version, response, solution=self._solution) - - async def get_page_async(self, target_url: str) -> MessagePage: - """ - Asynchronously retrieve a specific page of MessageInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of MessageInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return MessagePage(self._version, response, solution=self._solution) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/assistants/v1/tool.py b/twilio/rest/assistants/v1/tool.py deleted file mode 100644 index 13f2c71aaa..0000000000 --- a/twilio/rest/assistants/v1/tool.py +++ /dev/null @@ -1,1397 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Assistants - 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 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.page import Page - - -class ToolInstance(InstanceResource): - - class AssistantsV1ServiceCreatePolicyRequest(object): - """ - :ivar description: The description of the policy. - :ivar id: The Policy ID. - :ivar name: The name of the policy. - :ivar policy_details: - :ivar type: The description of the policy. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.description: Optional[str] = payload.get("description") - self.id: Optional[str] = payload.get("id") - self.name: Optional[str] = payload.get("name") - self.policy_details: Optional[Dict[str, object]] = payload.get( - "policy_details" - ) - self.type: Optional[str] = payload.get("type") - - def to_dict(self): - return { - "description": self.description, - "id": self.id, - "name": self.name, - "policy_details": self.policy_details, - "type": self.type, - } - - class AssistantsV1ServiceCreateToolRequest(object): - """ - :ivar assistant_id: The Assistant ID. - :ivar description: The description of the tool. - :ivar enabled: True if the tool is enabled. - :ivar meta: The metadata related to method, url, input_schema to used with the Tool. - :ivar name: The name of the tool. - :ivar policy: - :ivar type: The description of the tool. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.assistant_id: Optional[str] = payload.get("assistant_id") - self.description: Optional[str] = payload.get("description") - self.enabled: Optional[bool] = payload.get("enabled") - self.meta: Optional[Dict[str, object]] = payload.get("meta") - self.name: Optional[str] = payload.get("name") - self.policy: Optional[ToolList.AssistantsV1ServiceCreatePolicyRequest] = ( - payload.get("policy") - ) - self.type: Optional[str] = payload.get("type") - - def to_dict(self): - return { - "assistant_id": self.assistant_id, - "description": self.description, - "enabled": self.enabled, - "meta": self.meta, - "name": self.name, - "policy": self.policy.to_dict() if self.policy is not None else None, - "type": self.type, - } - - class AssistantsV1ServiceUpdateToolRequest(object): - """ - :ivar assistant_id: The Assistant ID. - :ivar description: The description of the tool. - :ivar enabled: True if the tool is enabled. - :ivar meta: The metadata related to method, url, input_schema to used with the Tool. - :ivar name: The name of the tool. - :ivar policy: - :ivar type: The type of the tool. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.assistant_id: Optional[str] = payload.get("assistant_id") - self.description: Optional[str] = payload.get("description") - self.enabled: Optional[bool] = payload.get("enabled") - self.meta: Optional[Dict[str, object]] = payload.get("meta") - self.name: Optional[str] = payload.get("name") - self.policy: Optional[ToolList.AssistantsV1ServiceCreatePolicyRequest] = ( - payload.get("policy") - ) - self.type: Optional[str] = payload.get("type") - - def to_dict(self): - return { - "assistant_id": self.assistant_id, - "description": self.description, - "enabled": self.enabled, - "meta": self.meta, - "name": self.name, - "policy": self.policy.to_dict() if self.policy is not None else None, - "type": self.type, - } - - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Tool resource. - :ivar description: The description of the tool. - :ivar enabled: True if the tool is enabled. - :ivar id: The tool ID. - :ivar meta: The metadata related to method, url, input_schema to used with the Tool. - :ivar name: The name of the tool. - :ivar requires_auth: The authentication requirement for the tool. - :ivar type: The type of the tool. ('WEBHOOK') - :ivar url: The url of the tool resource. - :ivar date_created: The date and time in GMT when the Tool was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - :ivar date_updated: The date and time in GMT when the Tool was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - :ivar policies: The Policies associated with the tool. - """ - - def __init__( - self, version: Version, payload: Dict[str, Any], id: Optional[str] = None - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.description: Optional[str] = payload.get("description") - self.enabled: Optional[bool] = payload.get("enabled") - self.id: Optional[str] = payload.get("id") - self.meta: Optional[Dict[str, object]] = payload.get("meta") - self.name: Optional[str] = payload.get("name") - self.requires_auth: Optional[bool] = payload.get("requires_auth") - self.type: Optional[str] = payload.get("type") - self.url: Optional[str] = payload.get("url") - self.date_created: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_created") - ) - self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_updated") - ) - self.policies: Optional[List[str]] = payload.get("policies") - - self._solution = { - "id": id or self.id, - } - - self._context: Optional[ToolContext] = None - - @property - def _proxy(self) -> "ToolContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: ToolContext for this ToolInstance - """ - if self._context is None: - self._context = ToolContext( - self._version, - id=self._solution["id"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the ToolInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the ToolInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def delete_with_http_info(self) -> ApiResponse: - """ - Deletes the ToolInstance with HTTP info - - - :returns: ApiResponse with success boolean, status code, and headers - """ - return self._proxy.delete_with_http_info() - - async def delete_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine that deletes the ToolInstance with HTTP info - - - :returns: ApiResponse with success boolean, status code, and headers - """ - return await self._proxy.delete_with_http_info_async() - - def fetch(self) -> "ToolInstance": - """ - Fetch the ToolInstance - - - :returns: The fetched ToolInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "ToolInstance": - """ - Asynchronous coroutine to fetch the ToolInstance - - - :returns: The fetched ToolInstance - """ - return await self._proxy.fetch_async() - - def fetch_with_http_info(self) -> ApiResponse: - """ - Fetch the ToolInstance 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 ToolInstance with HTTP info - - - :returns: ApiResponse with instance, status code, and headers - """ - return await self._proxy.fetch_with_http_info_async() - - def update( - self, - assistants_v1_service_update_tool_request: Union[ - AssistantsV1ServiceUpdateToolRequest, object - ] = values.unset, - ) -> "ToolInstance": - """ - Update the ToolInstance - - :param assistants_v1_service_update_tool_request: - - :returns: The updated ToolInstance - """ - return self._proxy.update( - assistants_v1_service_update_tool_request=assistants_v1_service_update_tool_request, - ) - - async def update_async( - self, - assistants_v1_service_update_tool_request: Union[ - AssistantsV1ServiceUpdateToolRequest, object - ] = values.unset, - ) -> "ToolInstance": - """ - Asynchronous coroutine to update the ToolInstance - - :param assistants_v1_service_update_tool_request: - - :returns: The updated ToolInstance - """ - return await self._proxy.update_async( - assistants_v1_service_update_tool_request=assistants_v1_service_update_tool_request, - ) - - def update_with_http_info( - self, - assistants_v1_service_update_tool_request: Union[ - AssistantsV1ServiceUpdateToolRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Update the ToolInstance with HTTP info - - :param assistants_v1_service_update_tool_request: - - :returns: ApiResponse with instance, status code, and headers - """ - return self._proxy.update_with_http_info( - assistants_v1_service_update_tool_request=assistants_v1_service_update_tool_request, - ) - - async def update_with_http_info_async( - self, - assistants_v1_service_update_tool_request: Union[ - AssistantsV1ServiceUpdateToolRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronous coroutine to update the ToolInstance with HTTP info - - :param assistants_v1_service_update_tool_request: - - :returns: ApiResponse with instance, status code, and headers - """ - return await self._proxy.update_with_http_info_async( - assistants_v1_service_update_tool_request=assistants_v1_service_update_tool_request, - ) - - 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 ToolContext(InstanceContext): - - class AssistantsV1ServiceCreatePolicyRequest(object): - """ - :ivar description: The description of the policy. - :ivar id: The Policy ID. - :ivar name: The name of the policy. - :ivar policy_details: - :ivar type: The description of the policy. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.description: Optional[str] = payload.get("description") - self.id: Optional[str] = payload.get("id") - self.name: Optional[str] = payload.get("name") - self.policy_details: Optional[Dict[str, object]] = payload.get( - "policy_details" - ) - self.type: Optional[str] = payload.get("type") - - def to_dict(self): - return { - "description": self.description, - "id": self.id, - "name": self.name, - "policy_details": self.policy_details, - "type": self.type, - } - - class AssistantsV1ServiceCreateToolRequest(object): - """ - :ivar assistant_id: The Assistant ID. - :ivar description: The description of the tool. - :ivar enabled: True if the tool is enabled. - :ivar meta: The metadata related to method, url, input_schema to used with the Tool. - :ivar name: The name of the tool. - :ivar policy: - :ivar type: The description of the tool. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.assistant_id: Optional[str] = payload.get("assistant_id") - self.description: Optional[str] = payload.get("description") - self.enabled: Optional[bool] = payload.get("enabled") - self.meta: Optional[Dict[str, object]] = payload.get("meta") - self.name: Optional[str] = payload.get("name") - self.policy: Optional[ToolList.AssistantsV1ServiceCreatePolicyRequest] = ( - payload.get("policy") - ) - self.type: Optional[str] = payload.get("type") - - def to_dict(self): - return { - "assistant_id": self.assistant_id, - "description": self.description, - "enabled": self.enabled, - "meta": self.meta, - "name": self.name, - "policy": self.policy.to_dict() if self.policy is not None else None, - "type": self.type, - } - - class AssistantsV1ServiceUpdateToolRequest(object): - """ - :ivar assistant_id: The Assistant ID. - :ivar description: The description of the tool. - :ivar enabled: True if the tool is enabled. - :ivar meta: The metadata related to method, url, input_schema to used with the Tool. - :ivar name: The name of the tool. - :ivar policy: - :ivar type: The type of the tool. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.assistant_id: Optional[str] = payload.get("assistant_id") - self.description: Optional[str] = payload.get("description") - self.enabled: Optional[bool] = payload.get("enabled") - self.meta: Optional[Dict[str, object]] = payload.get("meta") - self.name: Optional[str] = payload.get("name") - self.policy: Optional[ToolList.AssistantsV1ServiceCreatePolicyRequest] = ( - payload.get("policy") - ) - self.type: Optional[str] = payload.get("type") - - def to_dict(self): - return { - "assistant_id": self.assistant_id, - "description": self.description, - "enabled": self.enabled, - "meta": self.meta, - "name": self.name, - "policy": self.policy.to_dict() if self.policy is not None else None, - "type": self.type, - } - - def __init__(self, version: Version, id: str): - """ - Initialize the ToolContext - - :param version: Version that contains the resource - :param id: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "id": id, - } - self._uri = "/Tools/{id}".format(**self._solution) - - def _delete(self) -> tuple: - """ - Internal helper for delete operation - - Returns: - tuple: (success_boolean, status_code, headers) - """ - - headers = values.of({}) - - return self._version.delete_with_response_info( - method="DELETE", uri=self._uri, headers=headers - ) - - def delete(self) -> bool: - """ - Deletes the ToolInstance - - - :returns: True if delete succeeds, False otherwise - """ - success, _, _ = self._delete() - return success - - def delete_with_http_info(self) -> ApiResponse: - """ - Deletes the ToolInstance and return response metadata - - - :returns: ApiResponse with success boolean, status code, and headers - """ - success, status_code, headers = self._delete() - return ApiResponse(data=success, status_code=status_code, headers=headers) - - async def _delete_async(self) -> tuple: - """ - Internal async helper for delete operation - - Returns: - tuple: (success_boolean, status_code, headers) - """ - - headers = values.of({}) - - return await self._version.delete_with_response_info_async( - method="DELETE", uri=self._uri, headers=headers - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the ToolInstance - - - :returns: True if delete succeeds, False otherwise - """ - success, _, _ = await self._delete_async() - return success - - async def delete_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine that deletes the ToolInstance and return response metadata - - - :returns: ApiResponse with success boolean, status code, and headers - """ - success, status_code, headers = await self._delete_async() - return ApiResponse(data=success, status_code=status_code, headers=headers) - - 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) -> ToolInstance: - """ - Fetch the ToolInstance - - - :returns: The fetched ToolInstance - """ - payload, _, _ = self._fetch() - return ToolInstance( - self._version, - payload, - id=self._solution["id"], - ) - - def fetch_with_http_info(self) -> ApiResponse: - """ - Fetch the ToolInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._fetch() - instance = ToolInstance( - self._version, - payload, - id=self._solution["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) -> ToolInstance: - """ - Asynchronous coroutine to fetch the ToolInstance - - - :returns: The fetched ToolInstance - """ - payload, _, _ = await self._fetch_async() - return ToolInstance( - self._version, - payload, - id=self._solution["id"], - ) - - async def fetch_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine to fetch the ToolInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._fetch_async() - instance = ToolInstance( - self._version, - payload, - id=self._solution["id"], - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def _update( - self, - assistants_v1_service_update_tool_request: Union[ - AssistantsV1ServiceUpdateToolRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal helper for update operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = assistants_v1_service_update_tool_request.to_dict() - - headers = values.of({}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return self._version.update_with_response_info( - method="PUT", uri=self._uri, data=data, headers=headers - ) - - def update( - self, - assistants_v1_service_update_tool_request: Union[ - AssistantsV1ServiceUpdateToolRequest, object - ] = values.unset, - ) -> ToolInstance: - """ - Update the ToolInstance - - :param assistants_v1_service_update_tool_request: - - :returns: The updated ToolInstance - """ - payload, _, _ = self._update( - assistants_v1_service_update_tool_request=assistants_v1_service_update_tool_request - ) - return ToolInstance(self._version, payload, id=self._solution["id"]) - - def update_with_http_info( - self, - assistants_v1_service_update_tool_request: Union[ - AssistantsV1ServiceUpdateToolRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Update the ToolInstance and return response metadata - - :param assistants_v1_service_update_tool_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._update( - assistants_v1_service_update_tool_request=assistants_v1_service_update_tool_request - ) - instance = ToolInstance(self._version, payload, id=self._solution["id"]) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _update_async( - self, - assistants_v1_service_update_tool_request: Union[ - AssistantsV1ServiceUpdateToolRequest, object - ] = values.unset, - ) -> tuple: - """ - Internal async helper for update operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = assistants_v1_service_update_tool_request.to_dict() - - headers = values.of({}) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return await self._version.update_with_response_info_async( - method="PUT", uri=self._uri, data=data, headers=headers - ) - - async def update_async( - self, - assistants_v1_service_update_tool_request: Union[ - AssistantsV1ServiceUpdateToolRequest, object - ] = values.unset, - ) -> ToolInstance: - """ - Asynchronous coroutine to update the ToolInstance - - :param assistants_v1_service_update_tool_request: - - :returns: The updated ToolInstance - """ - payload, _, _ = await self._update_async( - assistants_v1_service_update_tool_request=assistants_v1_service_update_tool_request - ) - return ToolInstance(self._version, payload, id=self._solution["id"]) - - async def update_with_http_info_async( - self, - assistants_v1_service_update_tool_request: Union[ - AssistantsV1ServiceUpdateToolRequest, object - ] = values.unset, - ) -> ApiResponse: - """ - Asynchronous coroutine to update the ToolInstance and return response metadata - - :param assistants_v1_service_update_tool_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._update_async( - assistants_v1_service_update_tool_request=assistants_v1_service_update_tool_request - ) - instance = ToolInstance(self._version, payload, id=self._solution["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 ToolPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> ToolInstance: - """ - Build an instance of ToolInstance - - :param payload: Payload response from the API - """ - - return ToolInstance(self._version, payload) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class ToolList(ListResource): - - class AssistantsV1ServiceCreatePolicyRequest(object): - """ - :ivar description: The description of the policy. - :ivar id: The Policy ID. - :ivar name: The name of the policy. - :ivar policy_details: - :ivar type: The description of the policy. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.description: Optional[str] = payload.get("description") - self.id: Optional[str] = payload.get("id") - self.name: Optional[str] = payload.get("name") - self.policy_details: Optional[Dict[str, object]] = payload.get( - "policy_details" - ) - self.type: Optional[str] = payload.get("type") - - def to_dict(self): - return { - "description": self.description, - "id": self.id, - "name": self.name, - "policy_details": self.policy_details, - "type": self.type, - } - - class AssistantsV1ServiceCreateToolRequest(object): - """ - :ivar assistant_id: The Assistant ID. - :ivar description: The description of the tool. - :ivar enabled: True if the tool is enabled. - :ivar meta: The metadata related to method, url, input_schema to used with the Tool. - :ivar name: The name of the tool. - :ivar policy: - :ivar type: The description of the tool. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.assistant_id: Optional[str] = payload.get("assistant_id") - self.description: Optional[str] = payload.get("description") - self.enabled: Optional[bool] = payload.get("enabled") - self.meta: Optional[Dict[str, object]] = payload.get("meta") - self.name: Optional[str] = payload.get("name") - self.policy: Optional[ToolList.AssistantsV1ServiceCreatePolicyRequest] = ( - payload.get("policy") - ) - self.type: Optional[str] = payload.get("type") - - def to_dict(self): - return { - "assistant_id": self.assistant_id, - "description": self.description, - "enabled": self.enabled, - "meta": self.meta, - "name": self.name, - "policy": self.policy.to_dict() if self.policy is not None else None, - "type": self.type, - } - - class AssistantsV1ServiceUpdateToolRequest(object): - """ - :ivar assistant_id: The Assistant ID. - :ivar description: The description of the tool. - :ivar enabled: True if the tool is enabled. - :ivar meta: The metadata related to method, url, input_schema to used with the Tool. - :ivar name: The name of the tool. - :ivar policy: - :ivar type: The type of the tool. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.assistant_id: Optional[str] = payload.get("assistant_id") - self.description: Optional[str] = payload.get("description") - self.enabled: Optional[bool] = payload.get("enabled") - self.meta: Optional[Dict[str, object]] = payload.get("meta") - self.name: Optional[str] = payload.get("name") - self.policy: Optional[ToolList.AssistantsV1ServiceCreatePolicyRequest] = ( - payload.get("policy") - ) - self.type: Optional[str] = payload.get("type") - - def to_dict(self): - return { - "assistant_id": self.assistant_id, - "description": self.description, - "enabled": self.enabled, - "meta": self.meta, - "name": self.name, - "policy": self.policy.to_dict() if self.policy is not None else None, - "type": self.type, - } - - def __init__(self, version: Version): - """ - Initialize the ToolList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/Tools" - - def _create( - self, - assistants_v1_service_create_tool_request: AssistantsV1ServiceCreateToolRequest, - ) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = assistants_v1_service_create_tool_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, - assistants_v1_service_create_tool_request: AssistantsV1ServiceCreateToolRequest, - ) -> ToolInstance: - """ - Create the ToolInstance - - :param assistants_v1_service_create_tool_request: - - :returns: The created ToolInstance - """ - payload, _, _ = self._create( - assistants_v1_service_create_tool_request=assistants_v1_service_create_tool_request - ) - return ToolInstance(self._version, payload) - - def create_with_http_info( - self, - assistants_v1_service_create_tool_request: AssistantsV1ServiceCreateToolRequest, - ) -> ApiResponse: - """ - Create the ToolInstance and return response metadata - - :param assistants_v1_service_create_tool_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create( - assistants_v1_service_create_tool_request=assistants_v1_service_create_tool_request - ) - instance = ToolInstance(self._version, payload) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _create_async( - self, - assistants_v1_service_create_tool_request: AssistantsV1ServiceCreateToolRequest, - ) -> tuple: - """ - Internal async helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = assistants_v1_service_create_tool_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, - assistants_v1_service_create_tool_request: AssistantsV1ServiceCreateToolRequest, - ) -> ToolInstance: - """ - Asynchronously create the ToolInstance - - :param assistants_v1_service_create_tool_request: - - :returns: The created ToolInstance - """ - payload, _, _ = await self._create_async( - assistants_v1_service_create_tool_request=assistants_v1_service_create_tool_request - ) - return ToolInstance(self._version, payload) - - async def create_with_http_info_async( - self, - assistants_v1_service_create_tool_request: AssistantsV1ServiceCreateToolRequest, - ) -> ApiResponse: - """ - Asynchronously create the ToolInstance and return response metadata - - :param assistants_v1_service_create_tool_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async( - assistants_v1_service_create_tool_request=assistants_v1_service_create_tool_request - ) - instance = ToolInstance(self._version, payload) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def stream( - self, - assistant_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[ToolInstance]: - """ - Streams ToolInstance 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 assistant_id: - :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(assistant_id=assistant_id, page_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - assistant_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[ToolInstance]: - """ - Asynchronously streams ToolInstance 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 assistant_id: - :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( - assistant_id=assistant_id, page_size=limits["page_size"] - ) - - return self._version.stream_async(page, limits["limit"]) - - def stream_with_http_info( - self, - assistant_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Streams ToolInstance and returns headers from first page - - - :param str assistant_id: - :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( - assistant_id=assistant_id, 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, - assistant_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Asynchronously streams ToolInstance and returns headers from first page - - - :param str assistant_id: - :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( - assistant_id=assistant_id, 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, - assistant_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[ToolInstance]: - """ - Lists ToolInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str assistant_id: - :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( - assistant_id=assistant_id, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - assistant_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[ToolInstance]: - """ - Asynchronously lists ToolInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str assistant_id: - :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( - assistant_id=assistant_id, - limit=limit, - page_size=page_size, - ) - ] - - def list_with_http_info( - self, - assistant_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Lists ToolInstance and returns headers from first page - - - :param str assistant_id: - :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( - assistant_id=assistant_id, - 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, - assistant_id: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Asynchronously lists ToolInstance and returns headers from first page - - - :param str assistant_id: - :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( - assistant_id=assistant_id, - 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, - assistant_id: 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, - ) -> ToolPage: - """ - Retrieve a single page of ToolInstance records from the API. - Request is executed immediately - - :param assistant_id: - :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: Page of ToolInstance - """ - data = values.of( - { - "AssistantId": assistant_id, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 ToolPage(self._version, response) - - async def page_async( - self, - assistant_id: 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, - ) -> ToolPage: - """ - Asynchronously retrieve a single page of ToolInstance records from the API. - Request is executed immediately - - :param assistant_id: - :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: Page of ToolInstance - """ - data = values.of( - { - "AssistantId": assistant_id, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - 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 ToolPage(self._version, response) - - def page_with_http_info( - self, - assistant_id: 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 assistant_id: - :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 ToolPage, status code, and headers - """ - data = values.of( - { - "AssistantId": assistant_id, - "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 = ToolPage(self._version, response) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - async def page_with_http_info_async( - self, - assistant_id: 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 assistant_id: - :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 ToolPage, status code, and headers - """ - data = values.of( - { - "AssistantId": assistant_id, - "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 = ToolPage(self._version, response) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - def get_page(self, target_url: str) -> ToolPage: - """ - Retrieve a specific page of ToolInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of ToolInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return ToolPage(self._version, response) - - async def get_page_async(self, target_url: str) -> ToolPage: - """ - Asynchronously retrieve a specific page of ToolInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of ToolInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return ToolPage(self._version, response) - - def get(self, id: str) -> ToolContext: - """ - Constructs a ToolContext - - :param id: - """ - return ToolContext(self._version, id=id) - - def __call__(self, id: str) -> ToolContext: - """ - Constructs a ToolContext - - :param id: - """ - return ToolContext(self._version, id=id) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/content/v1/content/__init__.py b/twilio/rest/content/v1/content/__init__.py index 5432e54944..3e38e775a7 100644 --- a/twilio/rest/content/v1/content/__init__.py +++ b/twilio/rest/content/v1/content/__init__.py @@ -838,6 +838,7 @@ class CallToActionActionType(object): COPY_CODE = "COPY_CODE" VOICE_CALL = "VOICE_CALL" VOICE_CALL_REQUEST = "VOICE_CALL_REQUEST" + REQUEST_CONTACT_INFO = "REQUEST_CONTACT_INFO" class CardActionType(object): URL = "URL" diff --git a/twilio/rest/conversations/v1/conversation/message/__init__.py b/twilio/rest/conversations/v1/conversation/message/__init__.py index 4d1345715e..947d8f466d 100644 --- a/twilio/rest/conversations/v1/conversation/message/__init__.py +++ b/twilio/rest/conversations/v1/conversation/message/__init__.py @@ -228,8 +228,8 @@ def update( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param subject: The subject of the message, can be up to 256 characters long. @@ -263,8 +263,8 @@ async def update_async( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param subject: The subject of the message, can be up to 256 characters long. @@ -298,8 +298,8 @@ def update_with_http_info( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param subject: The subject of the message, can be up to 256 characters long. @@ -333,8 +333,8 @@ async def update_with_http_info_async( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param subject: The subject of the message, can be up to 256 characters long. @@ -668,8 +668,8 @@ def update( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param subject: The subject of the message, can be up to 256 characters long. @@ -709,8 +709,8 @@ def update_with_http_info( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param subject: The subject of the message, can be up to 256 characters long. @@ -799,8 +799,8 @@ async def update_async( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param subject: The subject of the message, can be up to 256 characters long. @@ -840,8 +840,8 @@ async def update_with_http_info_async( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param subject: The subject of the message, can be up to 256 characters long. @@ -1000,8 +1000,8 @@ def create( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param media_sid: The Media SID to be attached to the new Message. :param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored. @@ -1047,8 +1047,8 @@ def create_with_http_info( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param media_sid: The Media SID to be attached to the new Message. :param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored. @@ -1145,8 +1145,8 @@ async def create_async( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param media_sid: The Media SID to be attached to the new Message. :param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored. @@ -1192,8 +1192,8 @@ async def create_with_http_info_async( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param media_sid: The Media SID to be attached to the new Message. :param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored. diff --git a/twilio/rest/conversations/v1/service/conversation/message/__init__.py b/twilio/rest/conversations/v1/service/conversation/message/__init__.py index 6c4e26231b..1ae1acbaf0 100644 --- a/twilio/rest/conversations/v1/service/conversation/message/__init__.py +++ b/twilio/rest/conversations/v1/service/conversation/message/__init__.py @@ -233,8 +233,8 @@ def update( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param subject: The subject of the message, can be up to 256 characters long. @@ -268,8 +268,8 @@ async def update_async( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param subject: The subject of the message, can be up to 256 characters long. @@ -303,8 +303,8 @@ def update_with_http_info( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param subject: The subject of the message, can be up to 256 characters long. @@ -338,8 +338,8 @@ async def update_with_http_info_async( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param subject: The subject of the message, can be up to 256 characters long. @@ -681,8 +681,8 @@ def update( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param subject: The subject of the message, can be up to 256 characters long. @@ -723,8 +723,8 @@ def update_with_http_info( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param subject: The subject of the message, can be up to 256 characters long. @@ -814,8 +814,8 @@ async def update_async( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param subject: The subject of the message, can be up to 256 characters long. @@ -856,8 +856,8 @@ async def update_with_http_info_async( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param subject: The subject of the message, can be up to 256 characters long. @@ -1023,8 +1023,8 @@ def create( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param media_sid: The Media SID to be attached to the new Message. :param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored. @@ -1073,8 +1073,8 @@ def create_with_http_info( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param media_sid: The Media SID to be attached to the new Message. :param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored. @@ -1174,8 +1174,8 @@ async def create_async( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param media_sid: The Media SID to be attached to the new Message. :param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored. @@ -1224,8 +1224,8 @@ async def create_with_http_info_async( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param author: The channel specific identifier of the message's author. Defaults to `system`. :param body: The content of the message, can be up to 1,600 characters long. - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. + :param date_created: The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. + :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param media_sid: The Media SID to be attached to the new Message. :param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored. diff --git a/twilio/rest/conversations/v2/__init__.py b/twilio/rest/conversations/v2/__init__.py index fd904a0c7b..20b77dcd96 100644 --- a/twilio/rest/conversations/v2/__init__.py +++ b/twilio/rest/conversations/v2/__init__.py @@ -50,16 +50,16 @@ def actions(self, conversation_id: str, action_id: str = None): return list_instance(action_id) return list_instance - def communications(self, conversation_sid: str, communication_id: str = None): + def communications(self, conversation_id: str, communication_id: str = None): """ Access the CommunicationList resource - :param conversation_sid: + :param conversation_id: :param communication_id: Optional instance ID to directly access CommunicationContext :returns: CommunicationList instance if communication_id is None, otherwise CommunicationContext """ - list_instance = CommunicationList(self, conversation_sid) + list_instance = CommunicationList(self, conversation_id) if communication_id is not None: return list_instance(communication_id) return list_instance @@ -82,16 +82,16 @@ def operations(self) -> OperationList: self._operations = OperationList(self) return self._operations - def participants(self, conversation_sid: str, participant_id: str = None): + def participants(self, conversation_id: str, participant_id: str = None): """ Access the ParticipantList resource - :param conversation_sid: + :param conversation_id: :param participant_id: Optional instance ID to directly access ParticipantContext :returns: ParticipantList instance if participant_id is None, otherwise ParticipantContext """ - list_instance = ParticipantList(self, conversation_sid) + list_instance = ParticipantList(self, conversation_id) if participant_id is not None: return list_instance(participant_id) return list_instance diff --git a/twilio/rest/conversations/v2/action.py b/twilio/rest/conversations/v2/action.py index b2a656f35a..6f907b17d7 100644 --- a/twilio/rest/conversations/v2/action.py +++ b/twilio/rest/conversations/v2/action.py @@ -25,12 +25,25 @@ class ActionInstance(InstanceResource): + + class ConversationsV2ActionStatus(object): + PENDING = "PENDING" + COMPLETED = "COMPLETED" + FAILED = "FAILED" + + class ConversationsV2Channel(object): + VOICE = "VOICE" + SMS = "SMS" + RCS = "RCS" + WHATSAPP = "WHATSAPP" + CHAT = "CHAT" + """ :ivar id: Unique identifier for this Action. :ivar type: The type of action. Accepted values: SEND_MESSAGE. - :ivar status: Current status of the Action. - PENDING: Action accepted, awaiting downstream confirmation - COMPLETED: Downstream backend confirmed the action - FAILED: Downstream backend reported a failure + :ivar status: :ivar conversation_id: The conversation this action belongs to. - :ivar related: Named identifiers from downstream. For SEND_MESSAGE: - messageSid: The downstream message SID (present when PENDING or COMPLETED) - communicationId: The Communication ID (present when COMPLETED) + :ivar related: Named identifiers from downstream. For SEND_MESSAGE: - messageSid: The downstream message SID (present when PENDING or COMPLETED) - communicationId: The Communication ID (present when COMPLETED) :ivar created_at: Timestamp when the action was created. :ivar updated_at: Timestamp when the action was last updated. :ivar completed_at: Timestamp when the action reached a terminal status. @@ -285,14 +298,16 @@ class ConversationsV2SendMessageParticipant(object): """ :ivar participant_id: Participant ID to resolve address from. :ivar address: Explicit address formatted according to channel type. - :ivar channel: Channel type for address resolution. + :ivar channel: """ def __init__(self, payload: Dict[str, Any]): self.participant_id: Optional[str] = payload.get("participantId") self.address: Optional[str] = payload.get("address") - self.channel: Optional["ActionInstance.str"] = payload.get("channel") + self.channel: Optional["ActionInstance.ConversationsV2Channel"] = ( + payload.get("channel") + ) def to_dict(self): return { diff --git a/twilio/rest/conversations/v2/communication.py b/twilio/rest/conversations/v2/communication.py index c8875a2756..adecbdd956 100644 --- a/twilio/rest/conversations/v2/communication.py +++ b/twilio/rest/conversations/v2/communication.py @@ -26,12 +26,27 @@ class CommunicationInstance(InstanceResource): + + class ConversationsV2Channel(object): + VOICE = "VOICE" + SMS = "SMS" + RCS = "RCS" + WHATSAPP = "WHATSAPP" + CHAT = "CHAT" + + class ConversationsV2RecipientDeliveryStatus(object): + INITIATED = "INITIATED" + IN_PROGRESS = "IN_PROGRESS" + DELIVERED = "DELIVERED" + COMPLETED = "COMPLETED" + FAILED = "FAILED" + """ :ivar id: Communication ID. :ivar conversation_id: Conversation ID. :ivar account_id: Account ID. - :ivar author: - :ivar content: + :ivar author: + :ivar content: :ivar channel_id: Channel-specific reference ID. :ivar resource_id: External resource identifier for this Communication (e.g. MessageSid for SMS/RCS/WhatsApp, TranscriptionSid + MessageIndex for Voice). When set, used for Communication deduplication/uniqueness within a Conversation. :ivar recipients: Communication recipients. @@ -44,8 +59,8 @@ def __init__( self, version: Version, payload: Dict[str, Any], - conversation_sid: str, - sid: Optional[str] = None, + conversation_id: str, + id: Optional[str] = None, ): super().__init__(version) @@ -68,10 +83,10 @@ def __init__( ) # Only set _solution if path params are provided (not None) - if conversation_sid is not None or sid is not None: + if conversation_id is not None or id is not None: self._solution = { - "conversation_sid": conversation_sid, - "sid": sid, + "conversation_id": conversation_id, + "id": id, } self._context: Optional[CommunicationContext] = None @@ -87,8 +102,8 @@ def _proxy(self) -> "CommunicationContext": if self._context is None: self._context = CommunicationContext( self._version, - conversation_sid=self._solution["conversation_sid"], - sid=self._solution["sid"], + conversation_id=self._solution["conversation_id"], + id=self._solution["id"], ) return self._context @@ -140,22 +155,22 @@ def __repr__(self) -> str: class CommunicationContext(InstanceContext): - def __init__(self, version: Version, conversation_sid: str, sid: str): + def __init__(self, version: Version, conversation_id: str, id: str): """ Initialize the CommunicationContext :param version: Version that contains the resource - :param conversation_sid: - :param sid: + :param conversation_id: + :param id: """ super().__init__(version) # Path Solution self._solution = { - "conversation_sid": conversation_sid, - "sid": sid, + "conversation_id": conversation_id, + "id": id, } - self._uri = "/Conversations/{conversation_sid}/Communications/{sid}".format( + self._uri = "/Conversations/{conversation_id}/Communications/{id}".format( **self._solution ) @@ -186,8 +201,8 @@ def fetch(self) -> CommunicationInstance: return CommunicationInstance( self._version, payload, - conversation_sid=self._solution["conversation_sid"], - sid=self._solution["sid"], + conversation_id=self._solution["conversation_id"], + id=self._solution["id"], ) def fetch_with_http_info(self) -> ApiResponse: @@ -201,8 +216,8 @@ def fetch_with_http_info(self) -> ApiResponse: instance = CommunicationInstance( self._version, payload, - conversation_sid=self._solution["conversation_sid"], - sid=self._solution["sid"], + conversation_id=self._solution["conversation_id"], + id=self._solution["id"], ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -233,8 +248,8 @@ async def fetch_async(self) -> CommunicationInstance: return CommunicationInstance( self._version, payload, - conversation_sid=self._solution["conversation_sid"], - sid=self._solution["sid"], + conversation_id=self._solution["conversation_id"], + id=self._solution["id"], ) async def fetch_with_http_info_async(self) -> ApiResponse: @@ -248,8 +263,8 @@ async def fetch_with_http_info_async(self) -> ApiResponse: instance = CommunicationInstance( self._version, payload, - conversation_sid=self._solution["conversation_sid"], - sid=self._solution["sid"], + conversation_id=self._solution["conversation_id"], + id=self._solution["id"], ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -273,7 +288,7 @@ def get_instance(self, payload: Dict[str, Any]) -> CommunicationInstance: """ return CommunicationInstance( - self._version, payload, conversation_sid=self._solution["conversation_sid"] + self._version, payload, conversation_id=self._solution["conversation_id"] ) def __repr__(self) -> str: @@ -362,6 +377,7 @@ class CreateCommunicationInConversationRequest(object): :ivar content: :ivar channel_id: :ivar recipients: + :ivar occurred_at: Timestamp when this Communication occurred. If omitted, the server uses the current time. """ def __init__(self, payload: Dict[str, Any]): @@ -374,8 +390,11 @@ def __init__(self, payload: Dict[str, Any]): ] = payload.get("content") self.channel_id: Optional[str] = payload.get("channelId") self.recipients: Optional[ - List[CommunicationList.CreateCommunicationInConversationRequestAuthor] + List[ + CommunicationList.CreateCommunicationInConversationRequestRecipients + ] ] = payload.get("recipients") + self.occurred_at: Optional[datetime] = payload.get("occurredAt") def to_dict(self): return { @@ -387,12 +406,13 @@ def to_dict(self): if self.recipients is not None else None ), + "occurredAt": self.occurred_at, } class CreateCommunicationInConversationRequestAuthor(object): """ :ivar address: - :ivar channel: + :ivar channel: Channel type for a Communication address. :ivar participant_id: """ @@ -435,21 +455,41 @@ def to_dict(self): ), } - def __init__(self, version: Version, conversation_sid: str): + class CreateCommunicationInConversationRequestRecipients(object): + """ + :ivar address: + :ivar channel: Channel type for a Communication address. + :ivar participant_id: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.address: Optional[str] = payload.get("address") + self.channel: Optional["CommunicationInstance.str"] = payload.get("channel") + self.participant_id: Optional[str] = payload.get("participantId") + + def to_dict(self): + return { + "address": self.address, + "channel": self.channel, + "participantId": self.participant_id, + } + + def __init__(self, version: Version, conversation_id: str): """ Initialize the CommunicationList :param version: Version that contains the resource - :param conversation_sid: + :param conversation_id: """ super().__init__(version) # Path Solution self._solution = { - "conversation_sid": conversation_sid, + "conversation_id": conversation_id, } - self._uri = "/Conversations/{conversation_sid}/Communications".format( + self._uri = "/Conversations/{conversation_id}/Communications".format( **self._solution ) @@ -494,7 +534,7 @@ def create( create_communication_in_conversation_request=create_communication_in_conversation_request ) return CommunicationInstance( - self._version, payload, conversation_sid=self._solution["conversation_sid"] + self._version, payload, conversation_id=self._solution["conversation_id"] ) def create_with_http_info( @@ -514,7 +554,7 @@ def create_with_http_info( create_communication_in_conversation_request=create_communication_in_conversation_request ) instance = CommunicationInstance( - self._version, payload, conversation_sid=self._solution["conversation_sid"] + self._version, payload, conversation_id=self._solution["conversation_id"] ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -559,7 +599,7 @@ async def create_async( create_communication_in_conversation_request=create_communication_in_conversation_request ) return CommunicationInstance( - self._version, payload, conversation_sid=self._solution["conversation_sid"] + self._version, payload, conversation_id=self._solution["conversation_id"] ) async def create_with_http_info_async( @@ -579,7 +619,7 @@ async def create_with_http_info_async( create_communication_in_conversation_request=create_communication_in_conversation_request ) instance = CommunicationInstance( - self._version, payload, conversation_sid=self._solution["conversation_sid"] + self._version, payload, conversation_id=self._solution["conversation_id"] ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -1008,24 +1048,24 @@ async def get_page_async(self, target_url: str) -> CommunicationPage: response = await self._version.domain.twilio.request_async("GET", target_url) return CommunicationPage(self._version, response, solution=self._solution) - def get(self, sid: str) -> CommunicationContext: + def get(self, id: str) -> CommunicationContext: """ Constructs a CommunicationContext - :param sid: + :param id: """ return CommunicationContext( - self._version, conversation_sid=self._solution["conversation_sid"], sid=sid + self._version, conversation_id=self._solution["conversation_id"], id=id ) - def __call__(self, sid: str) -> CommunicationContext: + def __call__(self, id: str) -> CommunicationContext: """ Constructs a CommunicationContext - :param sid: + :param id: """ return CommunicationContext( - self._version, conversation_sid=self._solution["conversation_sid"], sid=sid + self._version, conversation_id=self._solution["conversation_id"], id=id ) def __repr__(self) -> str: diff --git a/twilio/rest/conversations/v2/configuration.py b/twilio/rest/conversations/v2/configuration.py index f2939d1359..fb481bcc49 100644 --- a/twilio/rest/conversations/v2/configuration.py +++ b/twilio/rest/conversations/v2/configuration.py @@ -26,35 +26,45 @@ class ConfigurationInstance(InstanceResource): + + class ConversationsV2ConversationGroupingType(object): + GROUP_BY_PROFILE = "GROUP_BY_PROFILE" + GROUP_BY_PARTICIPANT_ADDRESSES = "GROUP_BY_PARTICIPANT_ADDRESSES" + GROUP_BY_PARTICIPANT_ADDRESSES_AND_CHANNEL_TYPE = ( + "GROUP_BY_PARTICIPANT_ADDRESSES_AND_CHANNEL_TYPE" + ) + """ + :ivar status_url: URL to poll for operation status. + :ivar related: Named resource identifiers associated with this operation. Keys depend on the operation type: - config-create, config-update, config-delete: configurationId - conversation-delete: conversationId :ivar id: Configuration ID. :ivar display_name: A human-readable name for the configuration. Limited to 32 characters. :ivar description: Human-readable description for the Configuration. Allows spaces and special characters, typically limited to a paragraph of text. This serves as a descriptive field rather than just a name. - :ivar conversation_grouping_type: Type of Conversation grouping strategy: - `GROUP_BY_PROFILE`: Groups Communications by resolved Profile from the Memory Store. A Profile is looked up or created for `CUSTOMER` Participant types. All Communications from the same Profile are in the same Conversation, regardless of address or channel. - `GROUP_BY_PARTICIPANT_ADDRESSES`: Groups Communications by Participant addresses across all channels. A customer using +18005550100 will be in the same Conversation whether they contact by SMS, WhatsApp, or RCS. - `GROUP_BY_PARTICIPANT_ADDRESSES_AND_CHANNEL_TYPE`: Groups Communications by both Participant addresses AND channel. A customer using +18005550100 by SMS will be in a different Conversation than the same customer by Voice. + :ivar conversation_grouping_type: :ivar memory_store_id: Memory Store ID for Profile resolution. :ivar channel_settings: Channel-specific configuration settings by channel type. Keys should be valid channel types (`VOICE`, `SMS`, `RCS`, `WHATSAPP`, `CHAT`). :ivar status_callbacks: List of default webhook configurations applied to Conversations under this Configuration. :ivar intelligence_configuration_ids: A list of Conversational Intelligence configuration IDs. :ivar memory_extraction_enabled: Whether memory extraction is enabled for conversations under this configuration. Defaults to false. - :ivar conversations_v1_bridge: + :ivar conversations_v1_bridge: :ivar created_at: Timestamp when this Configuration was created. :ivar updated_at: Timestamp when this Configuration was last updated. :ivar version: Version number used for optimistic locking. - :ivar status_url: URL to poll for operation status. - :ivar related: Named resource identifiers associated with this operation. Keys depend on the operation type: - config-create, config-update, config-delete: configurationId - conversation-delete: conversationId """ def __init__( - self, version: Version, payload: ResponseResource, sid: Optional[str] = None + self, version: Version, payload: ResponseResource, id: Optional[str] = None ): super().__init__(version) + self.status_url: Optional[str] = payload.get("statusUrl") + self.related: Optional[Dict[str, str]] = payload.get("related") self.id: Optional[str] = payload.get("id") self.display_name: Optional[str] = payload.get("displayName") self.description: Optional[str] = payload.get("description") - self.conversation_grouping_type: Optional["ConfigurationInstance.str"] = ( - payload.get("conversationGroupingType") - ) + self.conversation_grouping_type: Optional[ + "ConfigurationInstance.ConversationsV2ConversationGroupingType" + ] = payload.get("conversationGroupingType") self.memory_store_id: Optional[str] = payload.get("memoryStoreId") self.channel_settings: Optional[Dict[str, ConversationsV2ChannelSetting]] = ( payload.get("channelSettings") @@ -78,13 +88,11 @@ def __init__( payload.get("updatedAt") ) self.version: Optional[int] = payload.get("version") - self.status_url: Optional[str] = payload.get("statusUrl") - self.related: Optional[Dict[str, str]] = payload.get("related") # Only set _solution if path params are provided (not None) - if sid is not None: + if id is not None: self._solution = { - "sid": sid, + "id": id, } self._context: Optional[ConfigurationContext] = None @@ -100,7 +108,7 @@ def _proxy(self) -> "ConfigurationContext": if self._context is None: self._context = ConfigurationContext( self._version, - sid=self._solution["sid"], + id=self._solution["id"], ) return self._context @@ -286,20 +294,20 @@ def __repr__(self) -> str: class ConfigurationContext(InstanceContext): - def __init__(self, version: Version, sid: str): + def __init__(self, version: Version, id: str): """ Initialize the ConfigurationContext :param version: Version that contains the resource - :param sid: + :param id: """ super().__init__(version) # Path Solution self._solution = { - "sid": sid, + "id": id, } - self._uri = "/ControlPlane/Configurations/{sid}".format(**self._solution) + self._uri = "/ControlPlane/Configurations/{id}".format(**self._solution) def _delete(self, idempotency_key: Union[str, object] = values.unset) -> tuple: """ @@ -424,7 +432,7 @@ def fetch(self) -> ConfigurationInstance: return ConfigurationInstance( self._version, payload, - sid=self._solution["sid"], + id=self._solution["id"], ) def fetch_with_http_info(self) -> ApiResponse: @@ -438,7 +446,7 @@ def fetch_with_http_info(self) -> ApiResponse: instance = ConfigurationInstance( self._version, payload, - sid=self._solution["sid"], + id=self._solution["id"], ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -469,7 +477,7 @@ async def fetch_async(self) -> ConfigurationInstance: return ConfigurationInstance( self._version, payload, - sid=self._solution["sid"], + id=self._solution["id"], ) async def fetch_with_http_info_async(self) -> ApiResponse: @@ -483,7 +491,7 @@ async def fetch_with_http_info_async(self) -> ApiResponse: instance = ConfigurationInstance( self._version, payload, - sid=self._solution["sid"], + id=self._solution["id"], ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -537,7 +545,7 @@ def update( idempotency_key=idempotency_key, update_configuration_request=update_configuration_request, ) - return ConfigurationInstance(self._version, payload, sid=self._solution["sid"]) + return ConfigurationInstance(self._version, payload, id=self._solution["id"]) def update_with_http_info( self, @@ -559,7 +567,7 @@ def update_with_http_info( update_configuration_request=update_configuration_request, ) instance = ConfigurationInstance( - self._version, payload, sid=self._solution["sid"] + self._version, payload, id=self._solution["id"] ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -613,7 +621,7 @@ async def update_async( idempotency_key=idempotency_key, update_configuration_request=update_configuration_request, ) - return ConfigurationInstance(self._version, payload, sid=self._solution["sid"]) + return ConfigurationInstance(self._version, payload, id=self._solution["id"]) async def update_with_http_info_async( self, @@ -635,7 +643,7 @@ async def update_with_http_info_async( update_configuration_request=update_configuration_request, ) instance = ConfigurationInstance( - self._version, payload, sid=self._solution["sid"] + self._version, payload, id=self._solution["id"] ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -772,12 +780,13 @@ class CreateConfigurationRequest(object): """ :ivar display_name: A human-readable name for the configuration. Limited to 32 characters. :ivar description: Human-readable description for the configuration. - :ivar conversation_grouping_type: The strategy Conversation Orchestrator uses to assign communications to conversations. + :ivar conversation_grouping_type: Type of Conversation grouping strategy: - `GROUP_BY_PROFILE`: Groups Communications by resolved Profile from the Memory Store. A Profile is looked up or created for `CUSTOMER` Participant types. All Communications from the same Profile are in the same Conversation, regardless of address or channel. - `GROUP_BY_PARTICIPANT_ADDRESSES`: Groups Communications by Participant addresses across all channels. A customer using +18005550100 will be in the same Conversation whether they contact by SMS, WhatsApp, or RCS. - `GROUP_BY_PARTICIPANT_ADDRESSES_AND_CHANNEL_TYPE`: Groups Communications by both Participant addresses AND channel. A customer using +18005550100 by SMS will be in a different Conversation than the same customer by Voice. :ivar memory_store_id: The memory store ID that Conversation Orchestrator uses for profile resolution. :ivar channel_settings: :ivar status_callbacks: A list of webhook configurations. :ivar intelligence_configuration_ids: A list of Conversational Intelligence configuration IDs. :ivar memory_extraction_enabled: Whether memory extraction is enabled for conversations under this configuration. Defaults to false. + :ivar conversations_v1_bridge: """ def __init__(self, payload: Dict[str, Any]): @@ -800,6 +809,9 @@ def __init__(self, payload: Dict[str, Any]): self.memory_extraction_enabled: Optional[bool] = payload.get( "memoryExtractionEnabled" ) + self.conversations_v1_bridge: Optional[ + ConfigurationList.CreateConfigurationRequestConversationsV1Bridge + ] = payload.get("conversationsV1Bridge") def to_dict(self): return { @@ -822,6 +834,11 @@ def to_dict(self): ), "intelligenceConfigurationIds": self.intelligence_configuration_ids, "memoryExtractionEnabled": self.memory_extraction_enabled, + "conversationsV1Bridge": ( + self.conversations_v1_bridge.to_dict() + if self.conversations_v1_bridge is not None + else None + ), } class CreateConfigurationRequestChannelSettingsValue(object): @@ -890,6 +907,20 @@ def to_dict(self): "closed": self.closed, } + class CreateConfigurationRequestConversationsV1Bridge(object): + """ + :ivar service_id: The Conversations V1 Service SID (IS prefix). One configuration per V1 Service SID. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.service_id: Optional[str] = payload.get("serviceId") + + def to_dict(self): + return { + "serviceId": self.service_id, + } + class CreateConfigurationRequestStatusCallbacks(object): """ :ivar url: The destination URL for webhooks. @@ -911,12 +942,13 @@ class UpdateConfigurationRequest(object): """ :ivar display_name: A human-readable name for the configuration. Limited to 32 characters. :ivar description: Human-readable description for the configuration. - :ivar conversation_grouping_type: The strategy Conversation Orchestrator uses to assign communications to conversations. + :ivar conversation_grouping_type: Type of Conversation grouping strategy: - `GROUP_BY_PROFILE`: Groups Communications by resolved Profile from the Memory Store. A Profile is looked up or created for `CUSTOMER` Participant types. All Communications from the same Profile are in the same Conversation, regardless of address or channel. - `GROUP_BY_PARTICIPANT_ADDRESSES`: Groups Communications by Participant addresses across all channels. A customer using +18005550100 will be in the same Conversation whether they contact by SMS, WhatsApp, or RCS. - `GROUP_BY_PARTICIPANT_ADDRESSES_AND_CHANNEL_TYPE`: Groups Communications by both Participant addresses AND channel. A customer using +18005550100 by SMS will be in a different Conversation than the same customer by Voice. :ivar memory_store_id: The Memory Store ID for profile resolution. :ivar channel_settings: :ivar status_callbacks: :ivar intelligence_configuration_ids: A list of Conversational Intelligence configuration IDs. :ivar memory_extraction_enabled: Whether memory extraction is enabled for conversations under this configuration. Defaults to false. + :ivar conversations_v1_bridge: """ def __init__(self, payload: Dict[str, Any]): @@ -939,6 +971,9 @@ def __init__(self, payload: Dict[str, Any]): self.memory_extraction_enabled: Optional[bool] = payload.get( "memoryExtractionEnabled" ) + self.conversations_v1_bridge: Optional[ + ConfigurationList.CreateConfigurationRequestConversationsV1Bridge + ] = payload.get("conversationsV1Bridge") def to_dict(self): return { @@ -961,6 +996,11 @@ def to_dict(self): ), "intelligenceConfigurationIds": self.intelligence_configuration_ids, "memoryExtractionEnabled": self.memory_extraction_enabled, + "conversationsV1Bridge": ( + self.conversations_v1_bridge.to_dict() + if self.conversations_v1_bridge is not None + else None + ), } class UpdateConfigurationRequestChannelSettingsValue(object): @@ -1630,21 +1670,21 @@ async def get_page_async(self, target_url: str) -> ConfigurationPage: response = await self._version.domain.twilio.request_async("GET", target_url) return ConfigurationPage(self._version, response) - def get(self, sid: str) -> ConfigurationContext: + def get(self, id: str) -> ConfigurationContext: """ Constructs a ConfigurationContext - :param sid: + :param id: """ - return ConfigurationContext(self._version, sid=sid) + return ConfigurationContext(self._version, id=id) - def __call__(self, sid: str) -> ConfigurationContext: + def __call__(self, id: str) -> ConfigurationContext: """ Constructs a ConfigurationContext - :param sid: + :param id: """ - return ConfigurationContext(self._version, sid=sid) + return ConfigurationContext(self._version, id=id) def __repr__(self) -> str: """ diff --git a/twilio/rest/conversations/v2/conversation.py b/twilio/rest/conversations/v2/conversation.py index 62a48c115b..43a44569ba 100644 --- a/twilio/rest/conversations/v2/conversation.py +++ b/twilio/rest/conversations/v2/conversation.py @@ -26,22 +26,49 @@ class ConversationInstance(InstanceResource): + + class ConversationsV2Channel(object): + VOICE = "VOICE" + SMS = "SMS" + RCS = "RCS" + WHATSAPP = "WHATSAPP" + CHAT = "CHAT" + + class ConversationsV2ConversationGroupingType(object): + GROUP_BY_PROFILE = "GROUP_BY_PROFILE" + GROUP_BY_PARTICIPANT_ADDRESSES = "GROUP_BY_PARTICIPANT_ADDRESSES" + GROUP_BY_PARTICIPANT_ADDRESSES_AND_CHANNEL_TYPE = ( + "GROUP_BY_PARTICIPANT_ADDRESSES_AND_CHANNEL_TYPE" + ) + + class ConversationsV2ConversationStatus(object): + ACTIVE = "ACTIVE" + INACTIVE = "INACTIVE" + CLOSED = "CLOSED" + + class ConversationsV2ParticipantType(object): + HUMAN_AGENT = "HUMAN_AGENT" + CUSTOMER = "CUSTOMER" + AI_AGENT = "AI_AGENT" + AGENT = "AGENT" + UNKNOWN = "UNKNOWN" + """ :ivar id: Conversation ID. :ivar account_id: Account ID. :ivar configuration_id: Configuration ID. - :ivar status: Conversation status. + :ivar status: :ivar name: Conversation name. :ivar created_at: Timestamp when this Conversation was created. :ivar updated_at: Timestamp when this Conversation was last updated. - :ivar configuration: + :ivar configuration: :ivar participants: Participants in this Conversation. :ivar status_url: URL to poll for operation status. - :ivar related: Named resource identifiers associated with this operation. Keys depend on the operation type: - config-create, config-update, config-delete: configurationId - conversation-delete: conversationId + :ivar related: Named resource identifiers associated with this operation. Keys depend on the operation type: - config-create, config-update, config-delete: configurationId - conversation-delete: conversationId """ def __init__( - self, version: Version, payload: ResponseResource, sid: Optional[str] = None + self, version: Version, payload: ResponseResource, id: Optional[str] = None ): super().__init__(version) @@ -62,9 +89,9 @@ def __init__( self.related: Optional[Dict[str, str]] = payload.get("related") # Only set _solution if path params are provided (not None) - if sid is not None: + if id is not None: self._solution = { - "sid": sid, + "id": id, } self._context: Optional[ConversationContext] = None @@ -80,7 +107,7 @@ def _proxy(self) -> "ConversationContext": if self._context is None: self._context = ConversationContext( self._version, - sid=self._solution["sid"], + id=self._solution["id"], ) return self._context @@ -288,20 +315,20 @@ def __repr__(self) -> str: class ConversationContext(InstanceContext): - def __init__(self, version: Version, sid: str): + def __init__(self, version: Version, id: str): """ Initialize the ConversationContext :param version: Version that contains the resource - :param sid: + :param id: """ super().__init__(version) # Path Solution self._solution = { - "sid": sid, + "id": id, } - self._uri = "/Conversations/{sid}".format(**self._solution) + self._uri = "/Conversations/{id}".format(**self._solution) def _delete(self, idempotency_key: Union[str, object] = values.unset) -> tuple: """ @@ -426,7 +453,7 @@ def fetch(self) -> ConversationInstance: return ConversationInstance( self._version, payload, - sid=self._solution["sid"], + id=self._solution["id"], ) def fetch_with_http_info(self) -> ApiResponse: @@ -440,7 +467,7 @@ def fetch_with_http_info(self) -> ApiResponse: instance = ConversationInstance( self._version, payload, - sid=self._solution["sid"], + id=self._solution["id"], ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -471,7 +498,7 @@ async def fetch_async(self) -> ConversationInstance: return ConversationInstance( self._version, payload, - sid=self._solution["sid"], + id=self._solution["id"], ) async def fetch_with_http_info_async(self) -> ApiResponse: @@ -485,7 +512,7 @@ async def fetch_with_http_info_async(self) -> ApiResponse: instance = ConversationInstance( self._version, payload, - sid=self._solution["sid"], + id=self._solution["id"], ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -529,7 +556,7 @@ def patch( payload, _, _ = self._patch( patch_conversation_by_id_request=patch_conversation_by_id_request ) - return ConversationInstance(self._version, payload, sid=self._solution["sid"]) + return ConversationInstance(self._version, payload, id=self._solution["id"]) def patch_with_http_info( self, @@ -547,9 +574,7 @@ def patch_with_http_info( payload, status_code, headers = self._patch( patch_conversation_by_id_request=patch_conversation_by_id_request ) - instance = ConversationInstance( - self._version, payload, sid=self._solution["sid"] - ) + instance = ConversationInstance(self._version, payload, id=self._solution["id"]) return ApiResponse(data=instance, status_code=status_code, headers=headers) async def _patch_async( @@ -592,7 +617,7 @@ async def patch_async( payload, _, _ = await self._patch_async( patch_conversation_by_id_request=patch_conversation_by_id_request ) - return ConversationInstance(self._version, payload, sid=self._solution["sid"]) + return ConversationInstance(self._version, payload, id=self._solution["id"]) async def patch_with_http_info_async( self, @@ -610,9 +635,7 @@ async def patch_with_http_info_async( payload, status_code, headers = await self._patch_async( patch_conversation_by_id_request=patch_conversation_by_id_request ) - instance = ConversationInstance( - self._version, payload, sid=self._solution["sid"] - ) + instance = ConversationInstance(self._version, payload, id=self._solution["id"]) return ApiResponse(data=instance, status_code=status_code, headers=headers) def _update( @@ -655,7 +678,7 @@ def update( payload, _, _ = self._update( update_conversation_by_id_request=update_conversation_by_id_request ) - return ConversationInstance(self._version, payload, sid=self._solution["sid"]) + return ConversationInstance(self._version, payload, id=self._solution["id"]) def update_with_http_info( self, @@ -673,9 +696,7 @@ def update_with_http_info( payload, status_code, headers = self._update( update_conversation_by_id_request=update_conversation_by_id_request ) - instance = ConversationInstance( - self._version, payload, sid=self._solution["sid"] - ) + instance = ConversationInstance(self._version, payload, id=self._solution["id"]) return ApiResponse(data=instance, status_code=status_code, headers=headers) async def _update_async( @@ -718,7 +739,7 @@ async def update_async( payload, _, _ = await self._update_async( update_conversation_by_id_request=update_conversation_by_id_request ) - return ConversationInstance(self._version, payload, sid=self._solution["sid"]) + return ConversationInstance(self._version, payload, id=self._solution["id"]) async def update_with_http_info_async( self, @@ -736,9 +757,7 @@ async def update_with_http_info_async( payload, status_code, headers = await self._update_async( update_conversation_by_id_request=update_conversation_by_id_request ) - instance = ConversationInstance( - self._version, payload, sid=self._solution["sid"] - ) + instance = ConversationInstance(self._version, payload, id=self._solution["id"]) return ApiResponse(data=instance, status_code=status_code, headers=headers) def __repr__(self) -> str: @@ -775,20 +794,20 @@ class ConversationList(ListResource): class ConversationsV2Address(object): """ - :ivar channel: The channel for Communication. + :ivar channel: :ivar address: The address value formatted according to channel type: - SMS/VOICE: E.164 phone number (such as \"+18005550100\") - WHATSAPP: Phone number with whatsapp prefix (such as \"whatsapp:+18005550100\") - RCS: Sender ID or phone number with rcs prefix (such as \"rcs:brand_acme_agent\" or \"rcs:+18005550100\") - CHAT: Customer-defined string identifier :ivar channel_id: Channel-specific ID for correlating Communications. """ def __init__(self, payload: Dict[str, Any]): - self.channel: Optional[str] = payload.get("channel") + self.channel: Optional[ConversationsV2Channel] = payload.get("channel") self.address: Optional[str] = payload.get("address") self.channel_id: Optional[str] = payload.get("channelId") def to_dict(self): return { - "channel": self.channel, + "channel": self.channel.to_dict() if self.channel is not None else None, "address": self.address, "channelId": self.channel_id, } @@ -908,7 +927,7 @@ def to_dict(self): class CreateConversationWithConfigRequestParticipantsAddresses(object): """ - :ivar channel: + :ivar channel: Channel type for a Communication address. :ivar address: :ivar channel_id: """ @@ -929,7 +948,7 @@ def to_dict(self): class PatchConversationByIdRequest(object): """ :ivar name: The name of the Conversation. - :ivar status: The state of the Conversation. + :ivar status: Lifecycle status of a Conversation. :ivar configuration: """ @@ -978,7 +997,7 @@ def to_dict(self): class UpdateConversationByIdRequest(object): """ :ivar name: The name of the Conversation. - :ivar status: The state of the Conversation. + :ivar status: Lifecycle status of a Conversation. """ def __init__(self, payload: Dict[str, Any]): @@ -1588,21 +1607,21 @@ async def get_page_async(self, target_url: str) -> ConversationPage: response = await self._version.domain.twilio.request_async("GET", target_url) return ConversationPage(self._version, response) - def get(self, sid: str) -> ConversationContext: + def get(self, id: str) -> ConversationContext: """ Constructs a ConversationContext - :param sid: + :param id: """ - return ConversationContext(self._version, sid=sid) + return ConversationContext(self._version, id=id) - def __call__(self, sid: str) -> ConversationContext: + def __call__(self, id: str) -> ConversationContext: """ Constructs a ConversationContext - :param sid: + :param id: """ - return ConversationContext(self._version, sid=sid) + return ConversationContext(self._version, id=id) def __repr__(self) -> str: """ diff --git a/twilio/rest/conversations/v2/operation.py b/twilio/rest/conversations/v2/operation.py index b7e62cfa27..9eaad7cd4c 100644 --- a/twilio/rest/conversations/v2/operation.py +++ b/twilio/rest/conversations/v2/operation.py @@ -25,18 +25,24 @@ class OperationInstance(InstanceResource): + + class ConversationsV2OperationStatusValue(object): + PENDING = "PENDING" + COMPLETED = "COMPLETED" + FAILED = "FAILED" + """ :ivar operation_id: Unique identifier for the long-running operation. - :ivar status: Current status of the operation. + :ivar status: :ivar created_at: Timestamp when the operation was created. :ivar completed_at: Timestamp when the operation completed. Only present for completed or failed operations. :ivar status_url: URL to poll for operation status. - :ivar error: - :ivar related: Named resource identifiers associated with this operation. Keys depend on the operation type: - config-create, config-update, config-delete: configurationId - conversation-delete: conversationId + :ivar error: + :ivar related: Named resource identifiers associated with this operation. Keys depend on the operation type: - config-create, config-update, config-delete: configurationId - conversation-delete: conversationId """ def __init__( - self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None + self, version: Version, payload: Dict[str, Any], id: Optional[str] = None ): super().__init__(version) @@ -53,9 +59,9 @@ def __init__( self.related: Optional[Dict[str, str]] = payload.get("related") # Only set _solution if path params are provided (not None) - if sid is not None: + if id is not None: self._solution = { - "sid": sid, + "id": id, } self._context: Optional[OperationContext] = None @@ -71,7 +77,7 @@ def _proxy(self) -> "OperationContext": if self._context is None: self._context = OperationContext( self._version, - sid=self._solution["sid"], + id=self._solution["id"], ) return self._context @@ -123,20 +129,20 @@ def __repr__(self) -> str: class OperationContext(InstanceContext): - def __init__(self, version: Version, sid: str): + def __init__(self, version: Version, id: str): """ Initialize the OperationContext :param version: Version that contains the resource - :param sid: + :param id: """ super().__init__(version) # Path Solution self._solution = { - "sid": sid, + "id": id, } - self._uri = "/ControlPlane/Operations/{sid}".format(**self._solution) + self._uri = "/ControlPlane/Operations/{id}".format(**self._solution) def _fetch(self) -> tuple: """ @@ -165,7 +171,7 @@ def fetch(self) -> OperationInstance: return OperationInstance( self._version, payload, - sid=self._solution["sid"], + id=self._solution["id"], ) def fetch_with_http_info(self) -> ApiResponse: @@ -179,7 +185,7 @@ def fetch_with_http_info(self) -> ApiResponse: instance = OperationInstance( self._version, payload, - sid=self._solution["sid"], + id=self._solution["id"], ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -210,7 +216,7 @@ async def fetch_async(self) -> OperationInstance: return OperationInstance( self._version, payload, - sid=self._solution["sid"], + id=self._solution["id"], ) async def fetch_with_http_info_async(self) -> ApiResponse: @@ -224,7 +230,7 @@ async def fetch_with_http_info_async(self) -> ApiResponse: instance = OperationInstance( self._version, payload, - sid=self._solution["sid"], + id=self._solution["id"], ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -249,21 +255,21 @@ def __init__(self, version: Version): """ super().__init__(version) - def get(self, sid: str) -> OperationContext: + def get(self, id: str) -> OperationContext: """ Constructs a OperationContext - :param sid: + :param id: """ - return OperationContext(self._version, sid=sid) + return OperationContext(self._version, id=id) - def __call__(self, sid: str) -> OperationContext: + def __call__(self, id: str) -> OperationContext: """ Constructs a OperationContext - :param sid: + :param id: """ - return OperationContext(self._version, sid=sid) + return OperationContext(self._version, id=id) def __repr__(self) -> str: """ diff --git a/twilio/rest/conversations/v2/participant.py b/twilio/rest/conversations/v2/participant.py index e752af8c91..63daceda08 100644 --- a/twilio/rest/conversations/v2/participant.py +++ b/twilio/rest/conversations/v2/participant.py @@ -26,14 +26,29 @@ class ParticipantInstance(InstanceResource): + + class ConversationsV2Channel(object): + VOICE = "VOICE" + SMS = "SMS" + RCS = "RCS" + WHATSAPP = "WHATSAPP" + CHAT = "CHAT" + + class ConversationsV2ParticipantType(object): + HUMAN_AGENT = "HUMAN_AGENT" + CUSTOMER = "CUSTOMER" + AI_AGENT = "AI_AGENT" + AGENT = "AGENT" + UNKNOWN = "UNKNOWN" + """ :ivar id: Participant ID. :ivar conversation_id: Conversation ID. :ivar account_id: Account ID. :ivar name: Participant display name. - :ivar type: Type of Participant in the Conversation. + :ivar type: :ivar profile_id: Profile ID. Note: This field is only resolved for `CUSTOMER` participant types, not for `HUMAN_AGENT` or `AI_AGENT` participants. - :ivar addresses: Communication addresses for this Participant. Address format varies by channel: - SMS/VOICE: E.164 phone number (such as \"+18005550100\") - EMAIL: Email address (such as \"user@example.com\") - WHATSAPP: Phone number with whatsapp prefix (such as \"whatsapp:+18005550100\") - RCS: Sender ID or phone number with rcs prefix (such as \"rcs:brand_acme_agent\" or \"rcs:+18005550100\") + :ivar addresses: Communication addresses for this Participant. Address format varies by channel: - SMS/VOICE: E.164 phone number (such as \"+18005550100\") - EMAIL: Email address (such as \"user@example.com\") - WHATSAPP: Phone number with whatsapp prefix (such as \"whatsapp:+18005550100\") - RCS: Sender ID or phone number with rcs prefix (such as \"rcs:brand_acme_agent\" or \"rcs:+18005550100\") :ivar created_at: Timestamp when this Participant was created. :ivar updated_at: Timestamp when this Participant was last updated. """ @@ -42,8 +57,8 @@ def __init__( self, version: Version, payload: Dict[str, Any], - conversation_sid: str, - sid: Optional[str] = None, + conversation_id: str, + id: Optional[str] = None, ): super().__init__(version) @@ -62,10 +77,10 @@ def __init__( ) # Only set _solution if path params are provided (not None) - if conversation_sid is not None or sid is not None: + if conversation_id is not None or id is not None: self._solution = { - "conversation_sid": conversation_sid, - "sid": sid, + "conversation_id": conversation_id, + "id": id, } self._context: Optional[ParticipantContext] = None @@ -81,8 +96,8 @@ def _proxy(self) -> "ParticipantContext": if self._context is None: self._context = ParticipantContext( self._version, - conversation_sid=self._solution["conversation_sid"], - sid=self._solution["sid"], + conversation_id=self._solution["conversation_id"], + id=self._solution["id"], ) return self._context @@ -202,22 +217,22 @@ def __repr__(self) -> str: class ParticipantContext(InstanceContext): - def __init__(self, version: Version, conversation_sid: str, sid: str): + def __init__(self, version: Version, conversation_id: str, id: str): """ Initialize the ParticipantContext :param version: Version that contains the resource - :param conversation_sid: - :param sid: + :param conversation_id: + :param id: """ super().__init__(version) # Path Solution self._solution = { - "conversation_sid": conversation_sid, - "sid": sid, + "conversation_id": conversation_id, + "id": id, } - self._uri = "/Conversations/{conversation_sid}/Participants/{sid}".format( + self._uri = "/Conversations/{conversation_id}/Participants/{id}".format( **self._solution ) @@ -248,8 +263,8 @@ def fetch(self) -> ParticipantInstance: return ParticipantInstance( self._version, payload, - conversation_sid=self._solution["conversation_sid"], - sid=self._solution["sid"], + conversation_id=self._solution["conversation_id"], + id=self._solution["id"], ) def fetch_with_http_info(self) -> ApiResponse: @@ -263,8 +278,8 @@ def fetch_with_http_info(self) -> ApiResponse: instance = ParticipantInstance( self._version, payload, - conversation_sid=self._solution["conversation_sid"], - sid=self._solution["sid"], + conversation_id=self._solution["conversation_id"], + id=self._solution["id"], ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -295,8 +310,8 @@ async def fetch_async(self) -> ParticipantInstance: return ParticipantInstance( self._version, payload, - conversation_sid=self._solution["conversation_sid"], - sid=self._solution["sid"], + conversation_id=self._solution["conversation_id"], + id=self._solution["id"], ) async def fetch_with_http_info_async(self) -> ApiResponse: @@ -310,8 +325,8 @@ async def fetch_with_http_info_async(self) -> ApiResponse: instance = ParticipantInstance( self._version, payload, - conversation_sid=self._solution["conversation_sid"], - sid=self._solution["sid"], + conversation_id=self._solution["conversation_id"], + id=self._solution["id"], ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -358,8 +373,8 @@ def update( return ParticipantInstance( self._version, payload, - conversation_sid=self._solution["conversation_sid"], - sid=self._solution["sid"], + conversation_id=self._solution["conversation_id"], + id=self._solution["id"], ) def update_with_http_info( @@ -381,8 +396,8 @@ def update_with_http_info( instance = ParticipantInstance( self._version, payload, - conversation_sid=self._solution["conversation_sid"], - sid=self._solution["sid"], + conversation_id=self._solution["conversation_id"], + id=self._solution["id"], ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -429,8 +444,8 @@ async def update_async( return ParticipantInstance( self._version, payload, - conversation_sid=self._solution["conversation_sid"], - sid=self._solution["sid"], + conversation_id=self._solution["conversation_id"], + id=self._solution["id"], ) async def update_with_http_info_async( @@ -452,8 +467,8 @@ async def update_with_http_info_async( instance = ParticipantInstance( self._version, payload, - conversation_sid=self._solution["conversation_sid"], - sid=self._solution["sid"], + conversation_id=self._solution["conversation_id"], + id=self._solution["id"], ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -477,7 +492,7 @@ def get_instance(self, payload: Dict[str, Any]) -> ParticipantInstance: """ return ParticipantInstance( - self._version, payload, conversation_sid=self._solution["conversation_sid"] + self._version, payload, conversation_id=self._solution["conversation_id"] ) def __repr__(self) -> str: @@ -491,10 +506,30 @@ def __repr__(self) -> str: class ParticipantList(ListResource): + class CreateConversationWithConfigRequestParticipantsAddresses(object): + """ + :ivar channel: Channel type for a Communication address. + :ivar address: + :ivar channel_id: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.channel: Optional["ConversationInstance.str"] = payload.get("channel") + self.address: Optional[str] = payload.get("address") + self.channel_id: Optional[str] = payload.get("channelId") + + def to_dict(self): + return { + "channel": self.channel, + "address": self.address, + "channelId": self.channel_id, + } + class CreateParticipantInConversationRequest(object): """ :ivar name: - :ivar type: + :ivar type: Type of Participant in the Conversation. :ivar profile_id: :ivar addresses: """ @@ -505,7 +540,9 @@ def __init__(self, payload: Dict[str, Any]): self.type: Optional["ParticipantInstance.str"] = payload.get("type") self.profile_id: Optional[str] = payload.get("profileId") self.addresses: Optional[ - List[ParticipantList.CreateParticipantInConversationRequestAddresses] + List[ + ParticipantList.CreateConversationWithConfigRequestParticipantsAddresses + ] ] = payload.get("addresses") def to_dict(self): @@ -520,30 +557,10 @@ def to_dict(self): ), } - class CreateParticipantInConversationRequestAddresses(object): - """ - :ivar channel: - :ivar address: - :ivar channel_id: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.channel: Optional["ParticipantInstance.str"] = payload.get("channel") - self.address: Optional[str] = payload.get("address") - self.channel_id: Optional[str] = payload.get("channelId") - - def to_dict(self): - return { - "channel": self.channel, - "address": self.address, - "channelId": self.channel_id, - } - class UpdateParticipantInConversationRequest(object): """ :ivar name: - :ivar type: + :ivar type: Type of Participant in the Conversation. :ivar profile_id: :ivar addresses: """ @@ -554,7 +571,9 @@ def __init__(self, payload: Dict[str, Any]): self.type: Optional["ParticipantInstance.str"] = payload.get("type") self.profile_id: Optional[str] = payload.get("profileId") self.addresses: Optional[ - List[ParticipantList.CreateParticipantInConversationRequestAddresses] + List[ + ParticipantList.CreateConversationWithConfigRequestParticipantsAddresses + ] ] = payload.get("addresses") def to_dict(self): @@ -569,21 +588,21 @@ def to_dict(self): ), } - def __init__(self, version: Version, conversation_sid: str): + def __init__(self, version: Version, conversation_id: str): """ Initialize the ParticipantList :param version: Version that contains the resource - :param conversation_sid: + :param conversation_id: """ super().__init__(version) # Path Solution self._solution = { - "conversation_sid": conversation_sid, + "conversation_id": conversation_id, } - self._uri = "/Conversations/{conversation_sid}/Participants".format( + self._uri = "/Conversations/{conversation_id}/Participants".format( **self._solution ) @@ -628,7 +647,7 @@ def create( create_participant_in_conversation_request=create_participant_in_conversation_request ) return ParticipantInstance( - self._version, payload, conversation_sid=self._solution["conversation_sid"] + self._version, payload, conversation_id=self._solution["conversation_id"] ) def create_with_http_info( @@ -648,7 +667,7 @@ def create_with_http_info( create_participant_in_conversation_request=create_participant_in_conversation_request ) instance = ParticipantInstance( - self._version, payload, conversation_sid=self._solution["conversation_sid"] + self._version, payload, conversation_id=self._solution["conversation_id"] ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -693,7 +712,7 @@ async def create_async( create_participant_in_conversation_request=create_participant_in_conversation_request ) return ParticipantInstance( - self._version, payload, conversation_sid=self._solution["conversation_sid"] + self._version, payload, conversation_id=self._solution["conversation_id"] ) async def create_with_http_info_async( @@ -713,7 +732,7 @@ async def create_with_http_info_async( create_participant_in_conversation_request=create_participant_in_conversation_request ) instance = ParticipantInstance( - self._version, payload, conversation_sid=self._solution["conversation_sid"] + self._version, payload, conversation_id=self._solution["conversation_id"] ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -1108,24 +1127,24 @@ async def get_page_async(self, target_url: str) -> ParticipantPage: response = await self._version.domain.twilio.request_async("GET", target_url) return ParticipantPage(self._version, response, solution=self._solution) - def get(self, sid: str) -> ParticipantContext: + def get(self, id: str) -> ParticipantContext: """ Constructs a ParticipantContext - :param sid: + :param id: """ return ParticipantContext( - self._version, conversation_sid=self._solution["conversation_sid"], sid=sid + self._version, conversation_id=self._solution["conversation_id"], id=id ) - def __call__(self, sid: str) -> ParticipantContext: + def __call__(self, id: str) -> ParticipantContext: """ Constructs a ParticipantContext - :param sid: + :param id: """ return ParticipantContext( - self._version, conversation_sid=self._solution["conversation_sid"], sid=sid + self._version, conversation_id=self._solution["conversation_id"], id=id ) def __repr__(self) -> str: diff --git a/twilio/rest/iam/IamBase.py b/twilio/rest/iam/IamBase.py index fc056efe43..2882ec145b 100644 --- a/twilio/rest/iam/IamBase.py +++ b/twilio/rest/iam/IamBase.py @@ -9,8 +9,11 @@ Do not edit the class manually. """ +from typing import Optional + from twilio.base.domain import Domain from twilio.rest import Client +from twilio.rest.iam.v1 import V1 class IamBase(Domain): @@ -22,6 +25,16 @@ def __init__(self, twilio: Client): :returns: Domain for Iam """ super().__init__(twilio, "https://iam.twilio.com") + self._v1: Optional[V1] = None + + @property + def v1(self) -> V1: + """ + :returns: Versions v1 of Iam + """ + if self._v1 is None: + self._v1 = V1(self) + return self._v1 def __repr__(self) -> str: """ diff --git a/twilio/rest/iam/v1/new_api_key.py b/twilio/rest/iam/v1/new_api_key.py index a89d5cc60b..0a5e395ec2 100644 --- a/twilio/rest/iam/v1/new_api_key.py +++ b/twilio/rest/iam/v1/new_api_key.py @@ -23,10 +23,6 @@ class NewApiKeyInstance(InstanceResource): - - class Keytype(object): - RESTRICTED = "restricted" - """ :ivar sid: The unique string that that we created to identify the NewKey resource. You will use this as the basic-auth `user` when authenticating to the API. :ivar friendly_name: The string that you assigned to describe the resource. @@ -77,7 +73,7 @@ def _create( self, account_sid: str, friendly_name: Union[str, object] = values.unset, - key_type: Union["NewApiKeyInstance.Keytype", object] = values.unset, + key_type: Union[str, object] = values.unset, policy: Union[object, object] = values.unset, ) -> tuple: """ @@ -109,7 +105,7 @@ def create( self, account_sid: str, friendly_name: Union[str, object] = values.unset, - key_type: Union["NewApiKeyInstance.Keytype", object] = values.unset, + key_type: Union[str, object] = values.unset, policy: Union[object, object] = values.unset, ) -> NewApiKeyInstance: """ @@ -117,7 +113,7 @@ def create( :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource. :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long. - :param key_type: + :param key_type: The \\\\`KeyType\\\\` form parameter is used to specify the type of key you want to create. **Default Behavior**: If \\\\`KeyType\\\\` is not specified, the API will generate a standard key. **Restricted Key**: If \\\\`KeyType\\\\` is set to \\\\`restricted\\\\`, the API will create a new restricted key. In this case, a policy object is required to define the permissions. :param policy: The \\\\`Policy\\\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys). :returns: The created NewApiKeyInstance @@ -134,7 +130,7 @@ def create_with_http_info( self, account_sid: str, friendly_name: Union[str, object] = values.unset, - key_type: Union["NewApiKeyInstance.Keytype", object] = values.unset, + key_type: Union[str, object] = values.unset, policy: Union[object, object] = values.unset, ) -> ApiResponse: """ @@ -142,7 +138,7 @@ def create_with_http_info( :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource. :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long. - :param key_type: + :param key_type: The \\\\`KeyType\\\\` form parameter is used to specify the type of key you want to create. **Default Behavior**: If \\\\`KeyType\\\\` is not specified, the API will generate a standard key. **Restricted Key**: If \\\\`KeyType\\\\` is set to \\\\`restricted\\\\`, the API will create a new restricted key. In this case, a policy object is required to define the permissions. :param policy: The \\\\`Policy\\\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys). :returns: ApiResponse with instance, status code, and headers @@ -160,7 +156,7 @@ async def _create_async( self, account_sid: str, friendly_name: Union[str, object] = values.unset, - key_type: Union["NewApiKeyInstance.Keytype", object] = values.unset, + key_type: Union[str, object] = values.unset, policy: Union[object, object] = values.unset, ) -> tuple: """ @@ -192,7 +188,7 @@ async def create_async( self, account_sid: str, friendly_name: Union[str, object] = values.unset, - key_type: Union["NewApiKeyInstance.Keytype", object] = values.unset, + key_type: Union[str, object] = values.unset, policy: Union[object, object] = values.unset, ) -> NewApiKeyInstance: """ @@ -200,7 +196,7 @@ async def create_async( :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource. :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long. - :param key_type: + :param key_type: The \\\\`KeyType\\\\` form parameter is used to specify the type of key you want to create. **Default Behavior**: If \\\\`KeyType\\\\` is not specified, the API will generate a standard key. **Restricted Key**: If \\\\`KeyType\\\\` is set to \\\\`restricted\\\\`, the API will create a new restricted key. In this case, a policy object is required to define the permissions. :param policy: The \\\\`Policy\\\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys). :returns: The created NewApiKeyInstance @@ -217,7 +213,7 @@ async def create_with_http_info_async( self, account_sid: str, friendly_name: Union[str, object] = values.unset, - key_type: Union["NewApiKeyInstance.Keytype", object] = values.unset, + key_type: Union[str, object] = values.unset, policy: Union[object, object] = values.unset, ) -> ApiResponse: """ @@ -225,7 +221,7 @@ async def create_with_http_info_async( :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource. :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long. - :param key_type: + :param key_type: The \\\\`KeyType\\\\` form parameter is used to specify the type of key you want to create. **Default Behavior**: If \\\\`KeyType\\\\` is not specified, the API will generate a standard key. **Restricted Key**: If \\\\`KeyType\\\\` is set to \\\\`restricted\\\\`, the API will create a new restricted key. In this case, a policy object is required to define the permissions. :param policy: The \\\\`Policy\\\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys). :returns: ApiResponse with instance, status code, and headers diff --git a/twilio/rest/iam/v1/o_auth_app.py b/twilio/rest/iam/v1/o_auth_app.py index 1a8e3ecd22..14d069bcea 100644 --- a/twilio/rest/iam/v1/o_auth_app.py +++ b/twilio/rest/iam/v1/o_auth_app.py @@ -31,6 +31,7 @@ class IamV1AccountVendorOauthAppCreateRequest(object): :ivar owner_sid: :ivar description: :ivar client_sid: + :ivar token_endpoint_auth_method: Determines how the client authenticates. Account OAuth apps on v1 only support 'client_secret_basic'. For PKCE (none), use the v2 API. :ivar policy: :ivar access_token_ttl: """ @@ -42,6 +43,9 @@ def __init__(self, payload: Dict[str, Any]): self.owner_sid: Optional[str] = payload.get("owner_sid") self.description: Optional[str] = payload.get("description") self.client_sid: Optional[str] = payload.get("client_sid") + self.token_endpoint_auth_method: Optional["OAuthAppInstance.str"] = ( + payload.get("token_endpoint_auth_method") + ) self.policy: Optional[ OAuthAppList.IamV1OrganizationVendoroauthappPolicy ] = payload.get("policy") @@ -54,6 +58,7 @@ def to_dict(self): "owner_sid": self.owner_sid, "description": self.description, "client_sid": self.client_sid, + "token_endpoint_auth_method": self.token_endpoint_auth_method, "policy": self.policy.to_dict() if self.policy is not None else None, "access_token_ttl": self.access_token_ttl, } @@ -127,6 +132,7 @@ def to_dict(self): :ivar description: :ivar date_created: :ivar created_by: + :ivar creator_sid: The unique identifier (SID) of the user who created this OAuth app. :ivar secret: :ivar status: :ivar policy: @@ -149,6 +155,7 @@ def __init__( payload.get("date_created") ) self.created_by: Optional[str] = payload.get("created_by") + self.creator_sid: Optional[str] = payload.get("creator_sid") self.secret: Optional[str] = payload.get("secret") self.status: Optional[str] = payload.get("status") self.policy: Optional[str] = payload.get("policy") @@ -295,6 +302,7 @@ class IamV1AccountVendorOauthAppCreateRequest(object): :ivar owner_sid: :ivar description: :ivar client_sid: + :ivar token_endpoint_auth_method: Determines how the client authenticates. Account OAuth apps on v1 only support 'client_secret_basic'. For PKCE (none), use the v2 API. :ivar policy: :ivar access_token_ttl: """ @@ -306,6 +314,9 @@ def __init__(self, payload: Dict[str, Any]): self.owner_sid: Optional[str] = payload.get("owner_sid") self.description: Optional[str] = payload.get("description") self.client_sid: Optional[str] = payload.get("client_sid") + self.token_endpoint_auth_method: Optional["OAuthAppInstance.str"] = ( + payload.get("token_endpoint_auth_method") + ) self.policy: Optional[ OAuthAppList.IamV1OrganizationVendoroauthappPolicy ] = payload.get("policy") @@ -318,6 +329,7 @@ def to_dict(self): "owner_sid": self.owner_sid, "description": self.description, "client_sid": self.client_sid, + "token_endpoint_auth_method": self.token_endpoint_auth_method, "policy": self.policy.to_dict() if self.policy is not None else None, "access_token_ttl": self.access_token_ttl, } @@ -600,6 +612,7 @@ class IamV1AccountVendorOauthAppCreateRequest(object): :ivar owner_sid: :ivar description: :ivar client_sid: + :ivar token_endpoint_auth_method: Determines how the client authenticates. Account OAuth apps on v1 only support 'client_secret_basic'. For PKCE (none), use the v2 API. :ivar policy: :ivar access_token_ttl: """ @@ -611,6 +624,9 @@ def __init__(self, payload: Dict[str, Any]): self.owner_sid: Optional[str] = payload.get("owner_sid") self.description: Optional[str] = payload.get("description") self.client_sid: Optional[str] = payload.get("client_sid") + self.token_endpoint_auth_method: Optional["OAuthAppInstance.str"] = ( + payload.get("token_endpoint_auth_method") + ) self.policy: Optional[ OAuthAppList.IamV1OrganizationVendoroauthappPolicy ] = payload.get("policy") @@ -623,6 +639,7 @@ def to_dict(self): "owner_sid": self.owner_sid, "description": self.description, "client_sid": self.client_sid, + "token_endpoint_auth_method": self.token_endpoint_auth_method, "policy": self.policy.to_dict() if self.policy is not None else None, "access_token_ttl": self.access_token_ttl, } diff --git a/twilio/rest/insights/v1/call/call_summary.py b/twilio/rest/insights/v1/call/call_summary.py index edb1ba1178..4d1e0d94de 100644 --- a/twilio/rest/insights/v1/call/call_summary.py +++ b/twilio/rest/insights/v1/call/call_summary.py @@ -24,6 +24,12 @@ class CallSummaryInstance(InstanceResource): + class CallSummaryCrelaySessionState(object): + UNKNOWN = "unknown" + FAILURE = "failure" + ENDED = "ended" + HUNG_UP = "hung_up" + class AnsweredBy(object): UNKNOWN = "unknown" MACHINE_START = "machine_start" @@ -78,6 +84,7 @@ class ProcessingState(object): :ivar properties: `object` Contains edge-agnostic call-level details. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#properties-object) for the object properties. :ivar trust: `object` Contains trusted communications details including Branded Call and verified caller ID. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#trust-object) for the object properties. :ivar annotation: `object` Programmatically labeled annotations for the Call. Developers can update the Call Summary records with Annotation during or after a Call. Annotations can be updated as long as the Call Summary record is addressable via the API. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#annotation-object) for the object properties. + :ivar agent_session_summaries: `object` List of session summaries for conversation relay. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#conversation-relay-object) for the object properties. """ def __init__(self, version: Version, payload: Dict[str, Any], call_sid: str): @@ -122,6 +129,9 @@ def __init__(self, version: Version, payload: Dict[str, Any], call_sid: str): self.properties: Optional[Dict[str, object]] = payload.get("properties") self.trust: Optional[Dict[str, object]] = payload.get("trust") self.annotation: Optional[Dict[str, object]] = payload.get("annotation") + self.agent_session_summaries: Optional[List[str]] = payload.get( + "agent_session_summaries" + ) self._solution = { "call_sid": call_sid, diff --git a/twilio/rest/insights/v1/call/event.py b/twilio/rest/insights/v1/call/event.py index ca9b99ccc6..68f4893cd1 100644 --- a/twilio/rest/insights/v1/call/event.py +++ b/twilio/rest/insights/v1/call/event.py @@ -50,6 +50,7 @@ class TwilioEdge(object): :ivar sip_edge: `object` Represents the Twilio media gateway for SIP interface and SIP trunking calls. The events here describe the call lifecycle as reported by Twilio's public media gateways. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#edges-and-their-properties) for the object properties. :ivar sdk_edge: `object` Represents the Voice SDK running locally in the browser or in the Android/iOS application. The events here are emitted by the Voice SDK in response to certain call progress events, network changes, or call quality conditions. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#edges-and-their-properties) for the object properties. :ivar client_edge: `object` Represents the Twilio media gateway for Client calls. The events here describe the call lifecycle as reported by Twilio's Voice SDK media gateways. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#edges-and-their-properties) for the object properties. + :ivar conversation_relay_data: """ def __init__(self, version: Version, payload: Dict[str, Any], call_sid: str): @@ -66,6 +67,9 @@ def __init__(self, version: Version, payload: Dict[str, Any], call_sid: str): self.sip_edge: Optional[Dict[str, object]] = payload.get("sip_edge") self.sdk_edge: Optional[Dict[str, object]] = payload.get("sdk_edge") self.client_edge: Optional[Dict[str, object]] = payload.get("client_edge") + self.conversation_relay_data: Optional[str] = payload.get( + "conversation_relay_data" + ) self._solution = { "call_sid": call_sid, diff --git a/twilio/rest/insights/v1/call_summaries.py b/twilio/rest/insights/v1/call_summaries.py index c1de69c6d5..1f66d767ef 100644 --- a/twilio/rest/insights/v1/call_summaries.py +++ b/twilio/rest/insights/v1/call_summaries.py @@ -65,6 +65,12 @@ class SortBy(object): START_TIME = "start_time" END_TIME = "end_time" + class CallSummaryCrelaySessionState(object): + UNKNOWN = "unknown" + FAILURE = "failure" + ENDED = "ended" + HUNG_UP = "hung_up" + """ :ivar account_sid: The unique SID identifier of the Account. :ivar call_sid: The unique SID identifier of the Call. @@ -89,6 +95,7 @@ class SortBy(object): :ivar properties: `object` Contains edge-agnostic call-level details. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#properties-object) for the object properties. :ivar trust: `object` Contains trusted communications details including Branded Call and verified caller ID. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#trust-object) for the object properties. :ivar annotation: `object` Programmatically labeled annotations for the Call. Developers can update the Call Summary records with Annotation during or after a Call. Annotations can be updated as long as the Call Summary record is addressable via the API. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#annotation-object) for the object properties. + :ivar agent_session_summaries: `array[object]` List of agent session summaries for conversation relay. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#conversation-relay-object) for the object properties. """ def __init__(self, version: Version, payload: Dict[str, Any]): @@ -133,6 +140,9 @@ def __init__(self, version: Version, payload: Dict[str, Any]): self.properties: Optional[Dict[str, object]] = payload.get("properties") self.trust: Optional[Dict[str, object]] = payload.get("trust") self.annotation: Optional[Dict[str, object]] = payload.get("annotation") + self.agent_session_summaries: Optional[List[str]] = payload.get( + "agent_session_summaries" + ) def __repr__(self) -> str: """ diff --git a/twilio/rest/insights/v3/__init__.py b/twilio/rest/insights/v3/__init__.py index dd519de5fc..2939808165 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. + 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 @@ -17,6 +17,7 @@ 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): @@ -30,6 +31,7 @@ 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: @@ -43,6 +45,12 @@ 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 48fe25e158..30e8d8f110 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. + 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 diff --git a/twilio/rest/insights/v3/query.py b/twilio/rest/insights/v3/query.py index e40fa1c744..b65b0aaec0 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. + 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 diff --git a/twilio/rest/insights/v3/query_job.py b/twilio/rest/insights/v3/query_job.py new file mode 100644 index 0000000000..893dce9760 --- /dev/null +++ b/twilio/rest/insights/v3/query_job.py @@ -0,0 +1,1004 @@ +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 new file mode 100644 index 0000000000..239c7208dc --- /dev/null +++ b/twilio/rest/insights/v3/result.py @@ -0,0 +1,208 @@ +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/__init__.py b/twilio/rest/intelligence/v3/__init__.py index 2e3f84bdf5..4aff29efe0 100644 --- a/twilio/rest/intelligence/v3/__init__.py +++ b/twilio/rest/intelligence/v3/__init__.py @@ -19,6 +19,7 @@ from twilio.rest.intelligence.v3.conversation import ConversationList from twilio.rest.intelligence.v3.operator import OperatorList from twilio.rest.intelligence.v3.operator_result import OperatorResultList +from twilio.rest.intelligence.v3.rule_execution import RuleExecutionList from twilio.rest.intelligence.v3.version import VersionList @@ -35,6 +36,7 @@ def __init__(self, domain: Domain): self._conversations: Optional[ConversationList] = None self._operators: Optional[OperatorList] = None self._operator_results: Optional[OperatorResultList] = None + self._rule_executions: Optional[RuleExecutionList] = None @property def configurations(self) -> ConfigurationList: @@ -60,6 +62,12 @@ def operator_results(self) -> OperatorResultList: self._operator_results = OperatorResultList(self) return self._operator_results + @property + def rule_executions(self) -> RuleExecutionList: + if self._rule_executions is None: + self._rule_executions = RuleExecutionList(self) + return self._rule_executions + def versions(self, id: str, version_id: str = None): """ Access the VersionList resource diff --git a/twilio/rest/intelligence/v3/conversation.py b/twilio/rest/intelligence/v3/conversation.py index 0d99163014..62faa0809b 100644 --- a/twilio/rest/intelligence/v3/conversation.py +++ b/twilio/rest/intelligence/v3/conversation.py @@ -325,8 +325,8 @@ def stream( The results are returned as a generator, so this operation is memory efficient. :param str page_token: Token for pagination - :param datetime created_at_before: Filter by Conversations created before this timestamp. - :param datetime created_at_after: Filter by Conversations created after this timestamp. + :param datetime created_at_before: Filter by Conversations created before this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. + :param datetime created_at_after: Filter by Conversations created after this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. :param str status: Filter by Conversation status. :param str channel_id: Filters Conversations by the underlying channel resource ID, such as a Call ID or Message ID. :param List[str] channels: Filters Conversations that include one or more of the specified communication channels (`OR` match). @@ -379,8 +379,8 @@ async def stream_async( The results are returned as a generator, so this operation is memory efficient. :param str page_token: Token for pagination - :param datetime created_at_before: Filter by Conversations created before this timestamp. - :param datetime created_at_after: Filter by Conversations created after this timestamp. + :param datetime created_at_before: Filter by Conversations created before this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. + :param datetime created_at_after: Filter by Conversations created after this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. :param str status: Filter by Conversation status. :param str channel_id: Filters Conversations by the underlying channel resource ID, such as a Call ID or Message ID. :param List[str] channels: Filters Conversations that include one or more of the specified communication channels (`OR` match). @@ -431,8 +431,8 @@ def stream_with_http_info( :param str page_token: Token for pagination - :param datetime created_at_before: Filter by Conversations created before this timestamp. - :param datetime created_at_after: Filter by Conversations created after this timestamp. + :param datetime created_at_before: Filter by Conversations created before this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. + :param datetime created_at_after: Filter by Conversations created after this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. :param str status: Filter by Conversation status. :param str channel_id: Filters Conversations by the underlying channel resource ID, such as a Call ID or Message ID. :param List[str] channels: Filters Conversations that include one or more of the specified communication channels (`OR` match). @@ -484,8 +484,8 @@ async def stream_with_http_info_async( :param str page_token: Token for pagination - :param datetime created_at_before: Filter by Conversations created before this timestamp. - :param datetime created_at_after: Filter by Conversations created after this timestamp. + :param datetime created_at_before: Filter by Conversations created before this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. + :param datetime created_at_after: Filter by Conversations created after this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. :param str status: Filter by Conversation status. :param str channel_id: Filters Conversations by the underlying channel resource ID, such as a Call ID or Message ID. :param List[str] channels: Filters Conversations that include one or more of the specified communication channels (`OR` match). @@ -538,8 +538,8 @@ def list( memory before returning. :param str page_token: Token for pagination - :param datetime created_at_before: Filter by Conversations created before this timestamp. - :param datetime created_at_after: Filter by Conversations created after this timestamp. + :param datetime created_at_before: Filter by Conversations created before this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. + :param datetime created_at_after: Filter by Conversations created after this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. :param str status: Filter by Conversation status. :param str channel_id: Filters Conversations by the underlying channel resource ID, such as a Call ID or Message ID. :param List[str] channels: Filters Conversations that include one or more of the specified communication channels (`OR` match). @@ -592,8 +592,8 @@ async def list_async( memory before returning. :param str page_token: Token for pagination - :param datetime created_at_before: Filter by Conversations created before this timestamp. - :param datetime created_at_after: Filter by Conversations created after this timestamp. + :param datetime created_at_before: Filter by Conversations created before this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. + :param datetime created_at_after: Filter by Conversations created after this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. :param str status: Filter by Conversation status. :param str channel_id: Filters Conversations by the underlying channel resource ID, such as a Call ID or Message ID. :param List[str] channels: Filters Conversations that include one or more of the specified communication channels (`OR` match). @@ -646,8 +646,8 @@ def list_with_http_info( :param str page_token: Token for pagination - :param datetime created_at_before: Filter by Conversations created before this timestamp. - :param datetime created_at_after: Filter by Conversations created after this timestamp. + :param datetime created_at_before: Filter by Conversations created before this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. + :param datetime created_at_after: Filter by Conversations created after this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. :param str status: Filter by Conversation status. :param str channel_id: Filters Conversations by the underlying channel resource ID, such as a Call ID or Message ID. :param List[str] channels: Filters Conversations that include one or more of the specified communication channels (`OR` match). @@ -698,8 +698,8 @@ async def list_with_http_info_async( :param str page_token: Token for pagination - :param datetime created_at_before: Filter by Conversations created before this timestamp. - :param datetime created_at_after: Filter by Conversations created after this timestamp. + :param datetime created_at_before: Filter by Conversations created before this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. + :param datetime created_at_after: Filter by Conversations created after this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. :param str status: Filter by Conversation status. :param str channel_id: Filters Conversations by the underlying channel resource ID, such as a Call ID or Message ID. :param List[str] channels: Filters Conversations that include one or more of the specified communication channels (`OR` match). @@ -750,8 +750,8 @@ def page( :param page_size: The maximum number of resources to return :param page_token: Token for pagination - :param created_at_before: Filter by Conversations created before this timestamp. - :param created_at_after: Filter by Conversations created after this timestamp. + :param created_at_before: Filter by Conversations created before this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. + :param created_at_after: Filter by Conversations created after this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. :param status: Filter by Conversation status. :param channel_id: Filters Conversations by the underlying channel resource ID, such as a Call ID or Message ID. :param channels: Filters Conversations that include one or more of the specified communication channels (`OR` match). @@ -805,8 +805,8 @@ async def page_async( :param page_size: The maximum number of resources to return :param page_token: Token for pagination - :param created_at_before: Filter by Conversations created before this timestamp. - :param created_at_after: Filter by Conversations created after this timestamp. + :param created_at_before: Filter by Conversations created before this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. + :param created_at_after: Filter by Conversations created after this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. :param status: Filter by Conversation status. :param channel_id: Filters Conversations by the underlying channel resource ID, such as a Call ID or Message ID. :param channels: Filters Conversations that include one or more of the specified communication channels (`OR` match). @@ -860,8 +860,8 @@ def page_with_http_info( :param page_token: Token for pagination - :param created_at_before: Filter by Conversations created before this timestamp. - :param created_at_after: Filter by Conversations created after this timestamp. + :param created_at_before: Filter by Conversations created before this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. + :param created_at_after: Filter by Conversations created after this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. :param status: Filter by Conversation status. :param channel_id: Filters Conversations by the underlying channel resource ID, such as a Call ID or Message ID. :param channels: Filters Conversations that include one or more of the specified communication channels (`OR` match). @@ -922,8 +922,8 @@ async def page_with_http_info_async( :param page_token: Token for pagination - :param created_at_before: Filter by Conversations created before this timestamp. - :param created_at_after: Filter by Conversations created after this timestamp. + :param created_at_before: Filter by Conversations created before this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. + :param created_at_after: Filter by Conversations created after this timestamp. The maximum allowed time range between `createdAtBefore` and `createdAtAfter` is 31 days. :param status: Filter by Conversation status. :param channel_id: Filters Conversations by the underlying channel resource ID, such as a Call ID or Message ID. :param channels: Filters Conversations that include one or more of the specified communication channels (`OR` match). diff --git a/twilio/rest/intelligence/v3/operator.py b/twilio/rest/intelligence/v3/operator.py index 6306102919..cbd7499a58 100644 --- a/twilio/rest/intelligence/v3/operator.py +++ b/twilio/rest/intelligence/v3/operator.py @@ -70,13 +70,17 @@ def __init__( self.version: Optional[int] = deserialize.integer(payload.get("version")) self.author: Optional["OperatorInstance.OperatorAuthor"] = payload.get("author") self.prompt: Optional[str] = payload.get("prompt") - self.output_format: Optional["OperatorInstance.str"] = payload.get( - "outputFormat" + self.output_format: Optional["OperatorInstance.OperatorOutputFormat"] = ( + payload.get("outputFormat") ) self.output_schema: Optional[Dict[str, object]] = payload.get("outputSchema") - self.training_examples: Optional[List[str]] = payload.get("trainingExamples") - self.context: Optional[str] = payload.get("context") - self.parameters: Optional[Dict[str, str]] = payload.get("parameters") + self.training_examples: Optional[List[OperatorList.OperatorTrainingExample]] = ( + payload.get("trainingExamples") + ) + self.context: Optional[OperatorList.OperatorContext] = payload.get("context") + self.parameters: Optional[Dict[str, OperatorParameter]] = payload.get( + "parameters" + ) # Only set _solution if path params are provided (not None) if id is not None: diff --git a/twilio/rest/intelligence/v3/rule_execution.py b/twilio/rest/intelligence/v3/rule_execution.py new file mode 100644 index 0000000000..a365eab628 --- /dev/null +++ b/twilio/rest/intelligence/v3/rule_execution.py @@ -0,0 +1,199 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio Conversational Intelligence API + The Conversational Intelligence API includes resources to create and manage intelligence configurations, define and run language operators, and retrieve processed conversations and operator results. * Use the Configurations resource to create and manage intelligence configurations and define rules that control how and when language operators analyze and transform conversations. * Use the Operators resource to create custom language operators or retrieve Twilio-author and custom operators. * Use the Conversations resource to retrieve conversations processed with an intelligence configuration, and the OperatorResults resource to retrieve language operator results for those conversations. + + 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, 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 RuleExecutionInstance(InstanceResource): + """ + :ivar code: Twilio-specific error code + :ivar message: A human readable error message + :ivar http_status_code: HTTP response status code + :ivar user_error: Whether the error is a user error (true) or a system error (false) + :ivar params: A map of parameters related to the error, for example, a `params.twilioErrorCodeUrl` might hold a URL or link to additional information + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.code: Optional[int] = payload.get("code") + self.message: Optional[str] = payload.get("message") + self.http_status_code: Optional[int] = payload.get("httpStatusCode") + self.user_error: Optional[bool] = payload.get("userError") + self.params: Optional[Dict[str, str]] = payload.get("params") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class RuleExecutionList(ListResource): + + class CreateRuleExecutionRequest(object): + """ + :ivar intelligence_configuration_id: The Intelligence Configuration identifier to execute the Rule within. + :ivar rule_id: The rule identifier to execute within the selected Intelligence Configuration. + :ivar conversation_id: The Conversation identifier to execute the Rule against. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.intelligence_configuration_id: Optional[str] = payload.get( + "intelligenceConfigurationId" + ) + self.rule_id: Optional[str] = payload.get("ruleId") + self.conversation_id: Optional[str] = payload.get("conversationId") + + def to_dict(self): + return { + "intelligenceConfigurationId": self.intelligence_configuration_id, + "ruleId": self.rule_id, + "conversationId": self.conversation_id, + } + + def __init__(self, version: Version): + """ + Initialize the RuleExecutionList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/RuleExecutions" + + def _create( + self, create_rule_execution_request: CreateRuleExecutionRequest + ) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = create_rule_execution_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, create_rule_execution_request: CreateRuleExecutionRequest + ) -> RuleExecutionInstance: + """ + Create the RuleExecutionInstance + + :param create_rule_execution_request: + + :returns: The created RuleExecutionInstance + """ + payload, _, _ = self._create( + create_rule_execution_request=create_rule_execution_request + ) + return RuleExecutionInstance(self._version, payload) + + def create_with_http_info( + self, create_rule_execution_request: CreateRuleExecutionRequest + ) -> ApiResponse: + """ + Create the RuleExecutionInstance and return response metadata + + :param create_rule_execution_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create( + create_rule_execution_request=create_rule_execution_request + ) + instance = RuleExecutionInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async( + self, create_rule_execution_request: CreateRuleExecutionRequest + ) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = create_rule_execution_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, create_rule_execution_request: CreateRuleExecutionRequest + ) -> RuleExecutionInstance: + """ + Asynchronously create the RuleExecutionInstance + + :param create_rule_execution_request: + + :returns: The created RuleExecutionInstance + """ + payload, _, _ = await self._create_async( + create_rule_execution_request=create_rule_execution_request + ) + return RuleExecutionInstance(self._version, payload) + + async def create_with_http_info_async( + self, create_rule_execution_request: CreateRuleExecutionRequest + ) -> ApiResponse: + """ + Asynchronously create the RuleExecutionInstance and return response metadata + + :param create_rule_execution_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async( + create_rule_execution_request=create_rule_execution_request + ) + instance = RuleExecutionInstance(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/knowledge/v2/__init__.py b/twilio/rest/knowledge/v2/__init__.py index f329d0911d..ac09c8bd51 100644 --- a/twilio/rest/knowledge/v2/__init__.py +++ b/twilio/rest/knowledge/v2/__init__.py @@ -85,8 +85,10 @@ def search(self, kb_id: str, search_id: str = None): :param search_id: Optional instance ID to directly access SearchContext :returns: SearchList instance if search_id is None, otherwise SearchContext """ - list_instance = SearchList(self) - return list_instance(kb_id) + list_instance = SearchList(self, kb_id) + if search_id is not None: + return list_instance(search_id) + return list_instance def __repr__(self) -> str: """ diff --git a/twilio/rest/knowledge/v2/chunk.py b/twilio/rest/knowledge/v2/chunk.py index 6537de31a8..42b8e14f7a 100644 --- a/twilio/rest/knowledge/v2/chunk.py +++ b/twilio/rest/knowledge/v2/chunk.py @@ -29,6 +29,10 @@ class ChunkInstance(InstanceResource): """ :ivar content: The chunk content. :ivar created_at: The date and time in GMT when the Chunk was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar chunk_index: 0-based position of this chunk within its source document for a single ingestion run. + :ivar document_title: Human-readable title of the source document. Web: HTML from the crawled page. File: filename from Unstructured metadata. Text: knowledge name from the knowledge source. + :ivar document_url: Specific page URL this chunk was crawled from. Web sources only; null for File and Text sources. + :ivar document_number: Physical page number (1-based). PDF sources only; omitted for all other source types. """ def __init__( @@ -40,6 +44,12 @@ def __init__( self.created_at: Optional[datetime] = deserialize.iso8601_datetime( payload.get("createdAt") ) + self.chunk_index: Optional[int] = deserialize.integer(payload.get("chunkIndex")) + self.document_title: Optional[str] = payload.get("documentTitle") + self.document_url: Optional[str] = payload.get("documentUrl") + self.document_number: Optional[int] = deserialize.integer( + payload.get("documentNumber") + ) # Only set _solution if path params are provided (not None) if kb_id is not None or knowledge_id is not None: diff --git a/twilio/rest/knowledge/v2/knowledge.py b/twilio/rest/knowledge/v2/knowledge.py index 446135b3cc..dc40d54a9b 100644 --- a/twilio/rest/knowledge/v2/knowledge.py +++ b/twilio/rest/knowledge/v2/knowledge.py @@ -30,7 +30,6 @@ class KnowledgeInstance(InstanceResource): class SupportedFileMimeType(object): TEXT_CSV = "text/csv" TEXT_MARKDOWN = "text/markdown" - TEXT_MDX = "text/mdx" APPLICATION_PDF = "application/pdf" TEXT_TAB_SEPARATED_VALUES = "text/tab-separated-values" TEXT_PLAIN = "text/plain" @@ -652,7 +651,7 @@ class KnowledgeSourceTypes(object): :ivar file_name: Name of the file to be uploaded :ivar file_size: Expected size of the file in bytes :ivar mime_type: - :ivar import_url: Presigned S3 URL for file upload (when status is SCHEDULED) or the permanent S3 location after upload completes. Use PUT method to upload the file to this URL when status is SCHEDULED. + :ivar import_url: Presigned S3 URL for file upload (when status is SCHEDULED). Use PUT method to upload the file to this URL when status is SCHEDULED. :ivar upload_expiration: Expiration time of the presigned upload URL in ISO 8601 format (only present when status is SCHEDULED) """ diff --git a/twilio/rest/knowledge/v2/knowledge_basis.py b/twilio/rest/knowledge/v2/knowledge_basis.py index 629b2083b9..d4fa29ac7d 100644 --- a/twilio/rest/knowledge/v2/knowledge_basis.py +++ b/twilio/rest/knowledge/v2/knowledge_basis.py @@ -27,7 +27,6 @@ class KnowledgeBasisInstance(InstanceResource): """ - :ivar message: :ivar display_name: Provides a unique and addressable name to be assigned to this Knowledge Base. This name is assigned by the developer and can be used in addition to the ID. It is intended to be human-readable and unique within the account. :ivar description: A human readable description of this resource, up to 128 characters. :ivar id: The unique identifier for the Knowledge Base @@ -35,6 +34,7 @@ class KnowledgeBasisInstance(InstanceResource): :ivar created_at: The ISO 8601 timestamp when the Knowledge Base was created. :ivar updated_at: The ISO 8601 timestamp when the Knowledge Base was last updated. :ivar version: The current version number of the Knowledge Base. Incremented on each successful mutable update. + :ivar message: :ivar status_url: URI to check operation status. """ @@ -43,7 +43,6 @@ def __init__( ): super().__init__(version) - self.message: Optional[str] = payload.get("message") self.display_name: Optional[str] = payload.get("displayName") self.description: Optional[str] = payload.get("description") self.id: Optional[str] = payload.get("id") @@ -55,6 +54,7 @@ def __init__( payload.get("updatedAt") ) self.version: Optional[int] = deserialize.integer(payload.get("version")) + self.message: Optional[str] = payload.get("message") self.status_url: Optional[str] = payload.get("statusUrl") # Only set _solution if path params are provided (not None) diff --git a/twilio/rest/knowledge/v2/search.py b/twilio/rest/knowledge/v2/search.py index cf2f5ff87c..38ac0a573d 100644 --- a/twilio/rest/knowledge/v2/search.py +++ b/twilio/rest/knowledge/v2/search.py @@ -17,7 +17,7 @@ from typing import Any, Dict, List, Optional, Union 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 from twilio.base.list_resource import ListResource from twilio.base.version import Version @@ -28,9 +28,7 @@ class SearchInstance(InstanceResource): :ivar chunks: """ - def __init__( - self, version: Version, payload: Dict[str, Any], kb_id: Optional[str] = None - ): + def __init__(self, version: Version, payload: Dict[str, Any], kb_id: str): super().__init__(version) self.chunks: Optional[List[str]] = payload.get("chunks") @@ -41,97 +39,45 @@ def __init__( "kb_id": kb_id, } - self._context: Optional[SearchContext] = None - - @property - def _proxy(self) -> "SearchContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: SearchContext for this SearchInstance - """ - if self._context is None: - self._context = SearchContext( - self._version, - kb_id=self._solution["kb_id"], - ) - return self._context - - def create( - self, knowledge_search: Union[KnowledgeSearch, object] = values.unset - ) -> "SearchInstance": - """ - Create the SearchInstance - - :param knowledge_search: - - :returns: The created SearchInstance - """ - return self._proxy.create( - knowledge_search=knowledge_search, - ) - - async def create_async( - self, knowledge_search: Union[KnowledgeSearch, object] = values.unset - ) -> "SearchInstance": - """ - Asynchronous coroutine to create the SearchInstance - - :param knowledge_search: - - :returns: The created SearchInstance - """ - return await self._proxy.create_async( - knowledge_search=knowledge_search, - ) - - def create_with_http_info( - self, knowledge_search: Union[KnowledgeSearch, object] = values.unset - ) -> ApiResponse: + def __repr__(self) -> str: """ - Create the SearchInstance with HTTP info - - :param knowledge_search: + Provide a friendly representation - :returns: ApiResponse with instance, status code, and headers + :returns: Machine friendly representation """ - return self._proxy.create_with_http_info( - knowledge_search=knowledge_search, - ) + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "<Twilio.Knowledge.V2.SearchInstance {}>".format(context) - async def create_with_http_info_async( - self, knowledge_search: Union[KnowledgeSearch, object] = values.unset - ) -> ApiResponse: - """ - Asynchronous coroutine to create the SearchInstance with HTTP info - :param knowledge_search: +class SearchList(ListResource): - :returns: ApiResponse with instance, status code, and headers + class KnowledgeSearch(object): """ - return await self._proxy.create_with_http_info_async( - knowledge_search=knowledge_search, - ) - - def __repr__(self) -> str: + :ivar query: The query to search the knowledge source. + :ivar top: The top K results to return. + :ivar knowledge_ids: The list of knowledge IDs to search. """ - Provide a friendly representation - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "<Twilio.Knowledge.V2.SearchInstance {}>".format(context) + def __init__(self, payload: Dict[str, Any]): + self.query: Optional[str] = payload.get("query") + self.top: Optional[int] = payload.get("top") + self.knowledge_ids: Optional[List[str]] = payload.get("knowledgeIds") -class SearchContext(InstanceContext): + def to_dict(self): + return { + "query": self.query, + "top": self.top, + "knowledgeIds": self.knowledge_ids, + } def __init__(self, version: Version, kb_id: str): """ - Initialize the SearchContext + Initialize the SearchList :param version: Version that contains the resource :param kb_id: A unique Knowledge Base ID using Twilio Type ID (TTID) format + """ super().__init__(version) @@ -152,7 +98,7 @@ def _create( """ data = knowledge_search.to_dict() - headers = values.of({}) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) headers["Content-Type"] = "application/json" @@ -200,7 +146,7 @@ async def _create_async( """ data = knowledge_search.to_dict() - headers = values.of({}) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) headers["Content-Type"] = "application/json" @@ -214,7 +160,7 @@ async def create_async( self, knowledge_search: Union[KnowledgeSearch, object] = values.unset ) -> SearchInstance: """ - Asynchronous coroutine to create the SearchInstance + Asynchronously create the SearchInstance :param knowledge_search: @@ -227,7 +173,7 @@ async def create_with_http_info_async( self, knowledge_search: Union[KnowledgeSearch, object] = values.unset ) -> ApiResponse: """ - Asynchronous coroutine to create the SearchInstance and return response metadata + Asynchronously create the SearchInstance and return response metadata :param knowledge_search: @@ -239,63 +185,6 @@ async def create_with_http_info_async( instance = SearchInstance(self._version, payload, kb_id=self._solution["kb_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 "<Twilio.Knowledge.V2.SearchContext {}>".format(context) - - -class SearchList(ListResource): - - class KnowledgeSearch(object): - """ - :ivar query: The query to search the knowledge source. - :ivar top: The top K results to return. - :ivar knowledge_ids: The list of knowledge IDs to search. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.query: Optional[str] = payload.get("query") - self.top: Optional[int] = payload.get("top") - self.knowledge_ids: Optional[List[str]] = payload.get("knowledgeIds") - - def to_dict(self): - return { - "query": self.query, - "top": self.top, - "knowledgeIds": self.knowledge_ids, - } - - def __init__(self, version: Version): - """ - Initialize the SearchList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - def get(self, kb_id: str) -> SearchContext: - """ - Constructs a SearchContext - - :param kb_id: A unique Knowledge Base ID using Twilio Type ID (TTID) format - """ - return SearchContext(self._version, kb_id=kb_id) - - def __call__(self, kb_id: str) -> SearchContext: - """ - Constructs a SearchContext - - :param kb_id: A unique Knowledge Base ID using Twilio Type ID (TTID) format - """ - return SearchContext(self._version, kb_id=kb_id) - def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/memory/v1/__init__.py b/twilio/rest/memory/v1/__init__.py index 9aa8e05f55..3f312e4706 100644 --- a/twilio/rest/memory/v1/__init__.py +++ b/twilio/rest/memory/v1/__init__.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio Memory API - APIs for managing memory stores, profiles, events, and conversational intelligence capabilities. + APIs for managing memory stores, profiles, and conversational intelligence capabilities. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech @@ -18,7 +18,6 @@ from twilio.rest.memory.v1.bulk import BulkList from twilio.rest.memory.v1.conversation_summary import ConversationSummaryList from twilio.rest.memory.v1.data_mapping import DataMappingList -from twilio.rest.memory.v1.event import EventList from twilio.rest.memory.v1.identifier import IdentifierList from twilio.rest.memory.v1.identity_resolution_setting import ( IdentityResolutionSettingList, @@ -56,8 +55,10 @@ def bulk(self, store_id: str, bulk_id: str = None): :param bulk_id: Optional instance ID to directly access BulkContext :returns: BulkList instance if bulk_id is None, otherwise BulkContext """ - list_instance = BulkList(self) - return list_instance(store_id) + list_instance = BulkList(self, store_id) + if bulk_id is not None: + return list_instance(bulk_id) + return list_instance def conversation_summaries( self, store_id: str, profile_id: str, conversation_summary_id: str = None @@ -91,22 +92,6 @@ def data_mappings(self, store_id: str, data_mapping_id: str = None): return list_instance(data_mapping_id) return list_instance - def events(self, store_id: str, profile_id: str, event_id: str = None): - """ - Access the EventList resource - - :param store_id: The storeId identifier - - :param profile_id: The profileId identifier - - :param event_id: Optional instance ID to directly access EventContext - :returns: EventList instance if event_id is None, otherwise EventContext - """ - list_instance = EventList(self, store_id, profile_id) - if event_id is not None: - return list_instance(event_id) - return list_instance - def identifiers(self, store_id: str, profile_id: str, identifier_id: str = None): """ Access the IdentifierList resource @@ -134,8 +119,10 @@ def identity_resolution_settings( :param identity_resolution_setting_id: Optional instance ID to directly access IdentityResolutionSettingContext :returns: IdentityResolutionSettingList instance if identity_resolution_setting_id is None, otherwise IdentityResolutionSettingContext """ - list_instance = IdentityResolutionSettingList(self) - return list_instance(store_id) + list_instance = IdentityResolutionSettingList(self, store_id) + if identity_resolution_setting_id is not None: + return list_instance(identity_resolution_setting_id) + return list_instance def imports(self, store_id: str, import_id: str = None): """ diff --git a/twilio/rest/memory/v1/bulk.py b/twilio/rest/memory/v1/bulk.py index 4112d066f6..eb77945844 100644 --- a/twilio/rest/memory/v1/bulk.py +++ b/twilio/rest/memory/v1/bulk.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio Memory API - APIs for managing memory stores, profiles, events, and conversational intelligence capabilities. + APIs for managing memory stores, profiles, and conversational intelligence capabilities. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech @@ -17,7 +17,7 @@ from typing import Any, Dict, List, Optional 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 from twilio.base.list_resource import ListResource from twilio.base.version import Version @@ -28,9 +28,7 @@ class BulkInstance(InstanceResource): :ivar message: """ - def __init__( - self, version: Version, payload: Dict[str, Any], store_id: Optional[str] = None - ): + def __init__(self, version: Version, payload: Dict[str, Any], store_id: str): super().__init__(version) self.message: Optional[str] = payload.get("message") @@ -41,97 +39,59 @@ def __init__( "store_id": store_id, } - self._context: Optional[BulkContext] = None - - @property - def _proxy(self) -> "BulkContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: BulkContext for this BulkInstance - """ - if self._context is None: - self._context = BulkContext( - self._version, - store_id=self._solution["store_id"], - ) - return self._context - - def update( - self, update_profiles_bulk_request: UpdateProfilesBulkRequest - ) -> "BulkInstance": + def __repr__(self) -> str: """ - Update the BulkInstance - - :param update_profiles_bulk_request: + Provide a friendly representation - :returns: The updated BulkInstance + :returns: Machine friendly representation """ - return self._proxy.update( - update_profiles_bulk_request=update_profiles_bulk_request, - ) + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "<Twilio.Memory.V1.BulkInstance {}>".format(context) - async def update_async( - self, update_profiles_bulk_request: UpdateProfilesBulkRequest - ) -> "BulkInstance": - """ - Asynchronous coroutine to update the BulkInstance - :param update_profiles_bulk_request: +class BulkList(ListResource): - :returns: The updated BulkInstance + class ProfileData(object): """ - return await self._proxy.update_async( - update_profiles_bulk_request=update_profiles_bulk_request, - ) - - def update_with_http_info( - self, update_profiles_bulk_request: UpdateProfilesBulkRequest - ) -> ApiResponse: + :ivar traits: Multiple trait groups. """ - Update the BulkInstance with HTTP info - - :param update_profiles_bulk_request: - :returns: ApiResponse with instance, status code, and headers - """ - return self._proxy.update_with_http_info( - update_profiles_bulk_request=update_profiles_bulk_request, - ) + def __init__(self, payload: Dict[str, Any]): - async def update_with_http_info_async( - self, update_profiles_bulk_request: UpdateProfilesBulkRequest - ) -> ApiResponse: - """ - Asynchronous coroutine to update the BulkInstance with HTTP info + self.traits: Optional[Dict[str, Dict[str, object]]] = payload.get("traits") - :param update_profiles_bulk_request: + def to_dict(self): + return { + "traits": self.traits, + } - :returns: ApiResponse with instance, status code, and headers + class UpdateProfilesBulkRequest(object): """ - return await self._proxy.update_with_http_info_async( - update_profiles_bulk_request=update_profiles_bulk_request, - ) - - def __repr__(self) -> str: + :ivar profiles: """ - Provide a friendly representation - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "<Twilio.Memory.V1.BulkInstance {}>".format(context) + def __init__(self, payload: Dict[str, Any]): + self.profiles: Optional[List[BulkList.ProfileData]] = payload.get( + "profiles" + ) -class BulkContext(InstanceContext): + def to_dict(self): + return { + "profiles": ( + [profiles.to_dict() for profiles in self.profiles] + if self.profiles is not None + else None + ), + } def __init__(self, version: Version, store_id: str): """ - Initialize the BulkContext + Initialize the BulkList :param version: Version that contains the resource :param store_id: A unique Memory Store ID using Twilio Type ID (TTID) format + """ super().__init__(version) @@ -150,7 +110,7 @@ def _update(self, update_profiles_bulk_request: UpdateProfilesBulkRequest) -> tu """ data = update_profiles_bulk_request.to_dict() - headers = values.of({}) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) headers["Content-Type"] = "application/json" @@ -204,7 +164,7 @@ async def _update_async( """ data = update_profiles_bulk_request.to_dict() - headers = values.of({}) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) headers["Content-Type"] = "application/json" @@ -218,7 +178,7 @@ async def update_async( self, update_profiles_bulk_request: UpdateProfilesBulkRequest ) -> BulkInstance: """ - Asynchronous coroutine to update the BulkInstance + Asynchronously update the BulkInstance :param update_profiles_bulk_request: @@ -233,7 +193,7 @@ async def update_with_http_info_async( self, update_profiles_bulk_request: UpdateProfilesBulkRequest ) -> ApiResponse: """ - Asynchronous coroutine to update the BulkInstance and return response metadata + Asynchronously update the BulkInstance and return response metadata :param update_profiles_bulk_request: @@ -247,77 +207,6 @@ async def update_with_http_info_async( ) 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 "<Twilio.Memory.V1.BulkContext {}>".format(context) - - -class BulkList(ListResource): - - class ProfileData(object): - """ - :ivar traits: Multiple trait groups. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.traits: Optional[Dict[str, Dict[str, object]]] = payload.get("traits") - - def to_dict(self): - return { - "traits": self.traits, - } - - class UpdateProfilesBulkRequest(object): - """ - :ivar profiles: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.profiles: Optional[List[BulkList.ProfileData]] = payload.get( - "profiles" - ) - - def to_dict(self): - return { - "profiles": ( - [profiles.to_dict() for profiles in self.profiles] - if self.profiles is not None - else None - ), - } - - def __init__(self, version: Version): - """ - Initialize the BulkList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - def get(self, store_id: str) -> BulkContext: - """ - Constructs a BulkContext - - :param store_id: A unique Memory Store ID using Twilio Type ID (TTID) format - """ - return BulkContext(self._version, store_id=store_id) - - def __call__(self, store_id: str) -> BulkContext: - """ - Constructs a BulkContext - - :param store_id: A unique Memory Store ID using Twilio Type ID (TTID) format - """ - return BulkContext(self._version, store_id=store_id) - def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/memory/v1/conversation_summary.py b/twilio/rest/memory/v1/conversation_summary.py index adada4fabd..7f95b1beb9 100644 --- a/twilio/rest/memory/v1/conversation_summary.py +++ b/twilio/rest/memory/v1/conversation_summary.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio Memory API - APIs for managing memory stores, profiles, events, and conversational intelligence capabilities. + APIs for managing memory stores, profiles, and conversational intelligence capabilities. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech @@ -810,6 +810,7 @@ async def create_with_http_info_async( def stream( self, page_token: Union[str, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -821,6 +822,7 @@ def stream( The results are returned as a generator, so this operation is memory efficient. :param str page_token: The token for the page of results to retrieve. + :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param str accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -834,6 +836,7 @@ def stream( limits = self._version.read_limits(limit, page_size) page = self.page( page_token=page_token, + conversation_id=conversation_id, accept_encoding=accept_encoding, page_size=limits["page_size"], ) @@ -843,6 +846,7 @@ def stream( async def stream_async( self, page_token: Union[str, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -854,6 +858,7 @@ async def stream_async( The results are returned as a generator, so this operation is memory efficient. :param str page_token: The token for the page of results to retrieve. + :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param str accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -867,6 +872,7 @@ async def stream_async( limits = self._version.read_limits(limit, page_size) page = await self.page_async( page_token=page_token, + conversation_id=conversation_id, accept_encoding=accept_encoding, page_size=limits["page_size"], ) @@ -876,6 +882,7 @@ async def stream_async( def stream_with_http_info( self, page_token: Union[str, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -885,6 +892,7 @@ def stream_with_http_info( :param str page_token: The token for the page of results to retrieve. + :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param str accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -898,6 +906,7 @@ def stream_with_http_info( limits = self._version.read_limits(limit, page_size) page_response = self.page_with_http_info( page_token=page_token, + conversation_id=conversation_id, accept_encoding=accept_encoding, page_size=limits["page_size"], ) @@ -908,6 +917,7 @@ def stream_with_http_info( async def stream_with_http_info_async( self, page_token: Union[str, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -917,6 +927,7 @@ async def stream_with_http_info_async( :param str page_token: The token for the page of results to retrieve. + :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param str accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -930,6 +941,7 @@ async def stream_with_http_info_async( limits = self._version.read_limits(limit, page_size) page_response = await self.page_with_http_info_async( page_token=page_token, + conversation_id=conversation_id, accept_encoding=accept_encoding, page_size=limits["page_size"], ) @@ -940,6 +952,7 @@ async def stream_with_http_info_async( def list( self, page_token: Union[str, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -950,6 +963,7 @@ def list( memory before returning. :param str page_token: The token for the page of results to retrieve. + :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param str accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -964,6 +978,7 @@ def list( return list( self.stream( page_token=page_token, + conversation_id=conversation_id, accept_encoding=accept_encoding, limit=limit, page_size=page_size, @@ -973,6 +988,7 @@ def list( async def list_async( self, page_token: Union[str, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -983,6 +999,7 @@ async def list_async( memory before returning. :param str page_token: The token for the page of results to retrieve. + :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param str accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -998,6 +1015,7 @@ async def list_async( record async for record in await self.stream_async( page_token=page_token, + conversation_id=conversation_id, accept_encoding=accept_encoding, limit=limit, page_size=page_size, @@ -1007,6 +1025,7 @@ async def list_async( def list_with_http_info( self, page_token: Union[str, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -1016,6 +1035,7 @@ def list_with_http_info( :param str page_token: The token for the page of results to retrieve. + :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param str accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -1028,6 +1048,7 @@ def list_with_http_info( """ generator, status_code, headers = self.stream_with_http_info( page_token=page_token, + conversation_id=conversation_id, accept_encoding=accept_encoding, limit=limit, page_size=page_size, @@ -1038,6 +1059,7 @@ def list_with_http_info( async def list_with_http_info_async( self, page_token: Union[str, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -1047,6 +1069,7 @@ async def list_with_http_info_async( :param str page_token: The token for the page of results to retrieve. + :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param str accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -1059,6 +1082,7 @@ async def list_with_http_info_async( """ generator, status_code, headers = await self.stream_with_http_info_async( page_token=page_token, + conversation_id=conversation_id, accept_encoding=accept_encoding, limit=limit, page_size=page_size, @@ -1070,6 +1094,7 @@ def page( self, page_size: Union[int, object] = values.unset, page_token: Union[str, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, ) -> ConversationSummaryPage: """ @@ -1078,6 +1103,7 @@ def page( :param page_size: The maximum number of items to return per page, maximum of 1000. :param page_token: The token for the page of results to retrieve. + :param conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :returns: Page of ConversationSummaryInstance """ @@ -1085,6 +1111,7 @@ def page( { "pageSize": page_size, "pageToken": page_token, + "conversationId": conversation_id, "Accept-Encoding": accept_encoding, } ) @@ -1109,6 +1136,7 @@ async def page_async( self, page_size: Union[int, object] = values.unset, page_token: Union[str, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, ) -> ConversationSummaryPage: """ @@ -1117,6 +1145,7 @@ async def page_async( :param page_size: The maximum number of items to return per page, maximum of 1000. :param page_token: The token for the page of results to retrieve. + :param conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :returns: Page of ConversationSummaryInstance """ @@ -1124,6 +1153,7 @@ async def page_async( { "pageSize": page_size, "pageToken": page_token, + "conversationId": conversation_id, "Accept-Encoding": accept_encoding, } ) @@ -1146,6 +1176,7 @@ async def page_async( def page_with_http_info( self, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, @@ -1156,6 +1187,7 @@ def page_with_http_info( :param page_token: The token for the page of results to retrieve. + :param conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -1166,6 +1198,7 @@ def page_with_http_info( data = values.of( { "pageToken": page_token, + "conversationId": conversation_id, "Accept-Encoding": accept_encoding, "PageToken": page_token, "Page": page_number, @@ -1192,6 +1225,7 @@ def page_with_http_info( async def page_with_http_info_async( self, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, @@ -1202,6 +1236,7 @@ async def page_with_http_info_async( :param page_token: The token for the page of results to retrieve. + :param conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -1212,6 +1247,7 @@ async def page_with_http_info_async( data = values.of( { "pageToken": page_token, + "conversationId": conversation_id, "Accept-Encoding": accept_encoding, "PageToken": page_token, "Page": page_number, diff --git a/twilio/rest/memory/v1/data_mapping.py b/twilio/rest/memory/v1/data_mapping.py index 4a055daed3..8cefd6789e 100644 --- a/twilio/rest/memory/v1/data_mapping.py +++ b/twilio/rest/memory/v1/data_mapping.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio Memory API - APIs for managing memory stores, profiles, events, and conversational intelligence capabilities. + APIs for managing memory stores, profiles, and conversational intelligence capabilities. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech @@ -28,6 +28,7 @@ class DataMappingInstance(InstanceResource): class DataMappingType(object): + CSV = "CSV" DATASET = "DATASET" """ @@ -59,7 +60,7 @@ def __init__( self.description: Optional[str] = payload.get("description") self.is_enabled: Optional[bool] = payload.get("isEnabled") self.mapping_to: Optional[DataMappingToTraits] = payload.get("mappingTo") - self.mapping_from: Optional[DataMappingFromDataSet] = payload.get("mappingFrom") + self.mapping_from: Optional[DataMappingFromTypes] = payload.get("mappingFrom") self.id: Optional[str] = payload.get("id") self.created_at: Optional[datetime] = deserialize.iso8601_datetime( payload.get("createdAt") @@ -602,7 +603,7 @@ def __init__(self, payload: Dict[str, Any]): self.mapping_to: Optional[DataMappingList.DataMappingToTraits] = ( payload.get("mappingTo") ) - self.mapping_from: Optional[DataMappingList.DataMappingFromDataSet] = ( + self.mapping_from: Optional[DataMappingList.DataMappingFromTypes] = ( payload.get("mappingFrom") ) @@ -648,20 +649,23 @@ def to_dict(self): ), } - class DataMappingFromDataSet(object): + 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 dataset_id: The unique identifier of the TDI dataset to connect. """ def __init__(self, payload: Dict[str, Any]): self.type: Optional["DataMappingInstance.str"] = payload.get("type") + self.columns: Optional[List[str]] = payload.get("columns") self.dataset_id: Optional[str] = payload.get("datasetId") def to_dict(self): return { "type": self.type, + "columns": self.columns, "datasetId": self.dataset_id, } @@ -690,7 +694,6 @@ def to_dict(self): class MappingTraitItem(object): """ - :ivar field_name: The name of the field/column in the source. Deprecated in favor of expression. :ivar expression: The expression identifying the field/column in the source. :ivar trait_group: The name of the Trait Group to map to. :ivar trait_name: The name of the trait within the Trait Group to map to. @@ -698,14 +701,12 @@ class MappingTraitItem(object): def __init__(self, payload: Dict[str, Any]): - self.field_name: Optional[str] = payload.get("fieldName") self.expression: Optional[str] = payload.get("expression") self.trait_group: Optional[str] = payload.get("traitGroup") self.trait_name: Optional[str] = payload.get("traitName") def to_dict(self): return { - "fieldName": self.field_name, "expression": self.expression, "traitGroup": self.trait_group, "traitName": self.trait_name, diff --git a/twilio/rest/memory/v1/event.py b/twilio/rest/memory/v1/event.py deleted file mode 100644 index 39d17cd57d..0000000000 --- a/twilio/rest/memory/v1/event.py +++ /dev/null @@ -1,315 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio Memory API - APIs for managing memory stores, profiles, events, and conversational intelligence capabilities. - - 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 -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 EventInstance(InstanceResource): - """ - :ivar message: - """ - - def __init__( - self, version: Version, payload: Dict[str, Any], store_id: str, profile_id: str - ): - super().__init__(version) - - self.message: Optional[str] = payload.get("message") - - # Only set _solution if path params are provided (not None) - if store_id is not None or profile_id is not None: - self._solution = { - "store_id": store_id, - "profile_id": profile_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 "<Twilio.Memory.V1.EventInstance {}>".format(context) - - -class EventList(ListResource): - - class CommunicationLifecycleEventRecipient(object): - """ - :ivar address: The recipient's address. Must be a valid address matching the channel type such as E.164 format for phone numbers. - :ivar participant_id: The unique identifier for the recipient participant. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.address: Optional[str] = payload.get("address") - self.participant_id: Optional[str] = payload.get("participantId") - - def to_dict(self): - return { - "address": self.address, - "participantId": self.participant_id, - } - - class CommunicationLifecycleEventSender(object): - """ - :ivar address: The sender's address. Must be a valid address matching the channel type such as E.164 format for phone numbers. - :ivar participant_id: The unique identifier for the sender participant. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.address: Optional[str] = payload.get("address") - self.participant_id: Optional[str] = payload.get("participantId") - - def to_dict(self): - return { - "address": self.address, - "participantId": self.participant_id, - } - - class ProfileEventRequest(object): - """ - :ivar type: The type of event being sent. - :ivar events: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.type: Optional["EventInstance.str"] = payload.get("type") - self.events: Optional[List[EventList.ProfileEventRequestEvents]] = ( - payload.get("events") - ) - - def to_dict(self): - return { - "type": self.type, - "events": ( - [events.to_dict() for events in self.events] - if self.events is not None - else None - ), - } - - class ProfileEventRequestEvents(object): - """ - :ivar timestamp: The time the event occurred in ISO8601 format with millisecond resolution. Defaults to received time if not provided. - :ivar lifecycle: The lifecycle event type of the communication. - :ivar conversation_id: The unique identifier for the conversation. - :ivar communication_id: The unique identifier for the communication. - :ivar communication_type: The communication channel type. - :ivar communication_status: The lifecycle status of the communication. - :ivar direction: The direction of the communication. - :ivar sender: - :ivar recipient: - :ivar error_code: Error code for FAILED communication status. - :ivar error_message: Error message for FAILED communication status. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.timestamp: Optional[datetime] = payload.get("timestamp") - self.lifecycle: Optional[str] = payload.get("lifecycle") - self.conversation_id: Optional[str] = payload.get("conversationId") - self.communication_id: Optional[str] = payload.get("communicationId") - self.communication_type: Optional[str] = payload.get("communicationType") - self.communication_status: Optional[str] = payload.get( - "communicationStatus" - ) - self.direction: Optional["EventInstance.str"] = payload.get("direction") - self.sender: Optional[EventList.CommunicationLifecycleEventSender] = ( - payload.get("sender") - ) - self.recipient: Optional[EventList.CommunicationLifecycleEventRecipient] = ( - payload.get("recipient") - ) - self.error_code: Optional[str] = payload.get("errorCode") - self.error_message: Optional[str] = payload.get("errorMessage") - - def to_dict(self): - return { - "timestamp": self.timestamp, - "lifecycle": self.lifecycle, - "conversationId": self.conversation_id, - "communicationId": self.communication_id, - "communicationType": self.communication_type, - "communicationStatus": self.communication_status, - "direction": self.direction, - "sender": self.sender.to_dict() if self.sender is not None else None, - "recipient": ( - self.recipient.to_dict() if self.recipient is not None else None - ), - "errorCode": self.error_code, - "errorMessage": self.error_message, - } - - def __init__(self, version: Version, store_id: str, profile_id: str): - """ - Initialize the EventList - - :param version: Version that contains the resource - :param store_id: The storeId identifier - :param profile_id: The profileId identifier - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "store_id": store_id, - "profile_id": profile_id, - } - self._uri = "/Stores/{store_id}/Profiles/{profile_id}/Events".format( - **self._solution - ) - - def _create( - self, profile_event_request: Union[ProfileEventRequest, object] = values.unset - ) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = profile_event_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, profile_event_request: Union[ProfileEventRequest, object] = values.unset - ) -> EventInstance: - """ - Create the EventInstance - - :param profile_event_request: - - :returns: The created EventInstance - """ - payload, _, _ = self._create(profile_event_request=profile_event_request) - return EventInstance( - self._version, - payload, - store_id=self._solution["store_id"], - profile_id=self._solution["profile_id"], - ) - - def create_with_http_info( - self, profile_event_request: Union[ProfileEventRequest, object] = values.unset - ) -> ApiResponse: - """ - Create the EventInstance and return response metadata - - :param profile_event_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create( - profile_event_request=profile_event_request - ) - instance = EventInstance( - self._version, - payload, - store_id=self._solution["store_id"], - profile_id=self._solution["profile_id"], - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _create_async( - self, profile_event_request: Union[ProfileEventRequest, object] = values.unset - ) -> tuple: - """ - Internal async helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = profile_event_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, profile_event_request: Union[ProfileEventRequest, object] = values.unset - ) -> EventInstance: - """ - Asynchronously create the EventInstance - - :param profile_event_request: - - :returns: The created EventInstance - """ - payload, _, _ = await self._create_async( - profile_event_request=profile_event_request - ) - return EventInstance( - self._version, - payload, - store_id=self._solution["store_id"], - profile_id=self._solution["profile_id"], - ) - - async def create_with_http_info_async( - self, profile_event_request: Union[ProfileEventRequest, object] = values.unset - ) -> ApiResponse: - """ - Asynchronously create the EventInstance and return response metadata - - :param profile_event_request: - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async( - profile_event_request=profile_event_request - ) - instance = EventInstance( - self._version, - payload, - store_id=self._solution["store_id"], - profile_id=self._solution["profile_id"], - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "<Twilio.Memory.V1.EventList>" diff --git a/twilio/rest/memory/v1/identifier.py b/twilio/rest/memory/v1/identifier.py index 3ac08f718b..b6579a3221 100644 --- a/twilio/rest/memory/v1/identifier.py +++ b/twilio/rest/memory/v1/identifier.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio Memory API - APIs for managing memory stores, profiles, events, and conversational intelligence capabilities. + APIs for managing memory stores, profiles, and conversational intelligence capabilities. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech diff --git a/twilio/rest/memory/v1/identity_resolution_setting.py b/twilio/rest/memory/v1/identity_resolution_setting.py index c575c283b0..6c1ea44397 100644 --- a/twilio/rest/memory/v1/identity_resolution_setting.py +++ b/twilio/rest/memory/v1/identity_resolution_setting.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio Memory API - APIs for managing memory stores, profiles, events, and conversational intelligence capabilities. + APIs for managing memory stores, profiles, and conversational intelligence capabilities. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech @@ -17,7 +17,7 @@ from typing import Any, Dict, List, Optional, Union 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 @@ -26,18 +26,13 @@ class IdentityResolutionSettingInstance(InstanceResource): """ :ivar identifier_configs: List of identifier types and their resolution settings. - :ivar matching_rules: Priority list of identifiers to locate profiles to apply new data to, or for determining if two existing profiles should merge. Rules are evaluated in order. - If no rule matches against existing profiles, a new profile will be created. - If a rule matches to a single existing profile, the profile will be updated. - If a rule matches to multiple existing profiles, those existing profiles will be merged. + :ivar matching_rules: Priority list of identifiers to locate profiles to apply new data to, or for determining if two existing profiles should merge. Individual rules are evaluated with `OR` logic between them, meaning that satisfying any single rule will trigger a match. Each rule is a single identifier type; compound rules are not supported. Rules are evaluated in order. - If no rule matches against existing profiles, a new profile will be created. - If a rule matches to a single existing profile, the profile will be updated. - If a rule matches to multiple existing profiles, those existing profiles will be merged. :ivar version: The current version number of the Identity Resolution Settings. Incremented on each successful update. :ivar message: :ivar status_url: URI to check operation status. """ - def __init__( - self, - version: Version, - payload: ResponseResource, - store_id: Optional[str] = None, - ): + def __init__(self, version: Version, payload: ResponseResource, store_id: str): super().__init__(version) self.identifier_configs: Optional[List[str]] = payload.get("identifierConfigs") @@ -52,149 +47,89 @@ def __init__( "store_id": store_id, } - self._context: Optional[IdentityResolutionSettingContext] = None - - @property - def _proxy(self) -> "IdentityResolutionSettingContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: IdentityResolutionSettingContext for this IdentityResolutionSettingInstance - """ - if self._context is None: - self._context = IdentityResolutionSettingContext( - self._version, - store_id=self._solution["store_id"], - ) - return self._context - - def fetch(self) -> "IdentityResolutionSettingInstance": - """ - Fetch the IdentityResolutionSettingInstance - - - :returns: The fetched IdentityResolutionSettingInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "IdentityResolutionSettingInstance": - """ - Asynchronous coroutine to fetch the IdentityResolutionSettingInstance - - - :returns: The fetched IdentityResolutionSettingInstance - """ - return await self._proxy.fetch_async() - - def fetch_with_http_info(self) -> ApiResponse: - """ - Fetch the IdentityResolutionSettingInstance 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 IdentityResolutionSettingInstance with HTTP info - - - :returns: ApiResponse with instance, status code, and headers - """ - return await self._proxy.fetch_with_http_info_async() - - def update( - self, - identity_resolution_settings_core: IdentityResolutionSettingsCore, - if_match: Union[str, object] = values.unset, - ) -> "IdentityResolutionSettingInstance": + def __repr__(self) -> str: """ - Update the IdentityResolutionSettingInstance - - :param identity_resolution_settings_core: - :param if_match: Allows for optimistic concurrency control by making the request conditional. Server will only act if the resource's current Entity Tag (ETag) matches the one provided, preventing accidental overwrites. + Provide a friendly representation - :returns: The updated IdentityResolutionSettingInstance + :returns: Machine friendly representation """ - return self._proxy.update( - identity_resolution_settings_core=identity_resolution_settings_core, - if_match=if_match, - ) + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "<Twilio.Memory.V1.IdentityResolutionSettingInstance {}>".format(context) - async def update_async( - self, - identity_resolution_settings_core: IdentityResolutionSettingsCore, - if_match: Union[str, object] = values.unset, - ) -> "IdentityResolutionSettingInstance": - """ - Asynchronous coroutine to update the IdentityResolutionSettingInstance - :param identity_resolution_settings_core: - :param if_match: Allows for optimistic concurrency control by making the request conditional. Server will only act if the resource's current Entity Tag (ETag) matches the one provided, preventing accidental overwrites. +class IdentityResolutionSettingList(ListResource): - :returns: The updated IdentityResolutionSettingInstance + class IdentifierConfig(object): """ - return await self._proxy.update_async( - identity_resolution_settings_core=identity_resolution_settings_core, - if_match=if_match, - ) - - def update_with_http_info( - self, - identity_resolution_settings_core: IdentityResolutionSettingsCore, - if_match: Union[str, object] = values.unset, - ) -> ApiResponse: + :ivar id_type: Name of the identifier type. Usual values are email, phone, external_id etc. + :ivar matching_algo: The algorithm to use for matching identifier values. - `exact`, exact string match. - `fuzzy`, low precision match allowing for some variations. + :ivar matching_threshold: The `fuzzy` matching threshold percentage. + :ivar limit: Maximum number of historical values to retain. + :ivar limit_policy: Removal policy to apply when the number of values exceeds the limit and is based on the timestamp of the request when the identifier was added. - `fifo`: First In First Out, removes the oldest values first. - `lifo`: Last In First Out, removes the most recent values first. + :ivar enforce_unique: When enabled, more than one profile may not share the same identifier value. Adding a shared identifier to a second profile may trigger a merge. Disabling creates a compound identifier where merges are only triggered if two or more identifiers satisfy a matching rule. + :ivar normalization: Normalization to apply to the identifier value before storing and matching. - `phone`: Normalize phone numbers to E.164 format. - `email`: Normalize email addresses by coverting to lowercase and removing spaces. - `trim`: Removes spaces from both ends of the string. - `none`: No normalization. **Important Note for Phone Number Normalization:** When using the `phone` normalization option, please adhere to the following guidelines to ensure proper formatting: - All US numbers must be at least valid 10 digit phone numbers with area code. They may also include or omit the \"+1\" prefix. - Non-US numbers must include a 1-3 digit country code (a \"+\" prefix is optional). Non-US national formats are not supported and will be interpreted as US numbers. """ - Update the IdentityResolutionSettingInstance with HTTP info - - :param identity_resolution_settings_core: - :param if_match: Allows for optimistic concurrency control by making the request conditional. Server will only act if the resource's current Entity Tag (ETag) matches the one provided, preventing accidental overwrites. - :returns: ApiResponse with instance, status code, and headers - """ - return self._proxy.update_with_http_info( - identity_resolution_settings_core=identity_resolution_settings_core, - if_match=if_match, - ) + def __init__(self, payload: Dict[str, Any]): - async def update_with_http_info_async( - self, - identity_resolution_settings_core: IdentityResolutionSettingsCore, - if_match: Union[str, object] = values.unset, - ) -> ApiResponse: - """ - Asynchronous coroutine to update the IdentityResolutionSettingInstance with HTTP info + self.id_type: Optional[str] = payload.get("idType") + self.matching_algo: Optional["IdentityResolutionSettingInstance.str"] = ( + payload.get("matchingAlgo") + ) + self.matching_threshold: Optional[int] = payload.get("matchingThreshold") + self.limit: Optional[int] = payload.get("limit") + self.limit_policy: Optional["IdentityResolutionSettingInstance.str"] = ( + payload.get("limitPolicy") + ) + self.enforce_unique: Optional[bool] = payload.get("enforceUnique") + self.normalization: Optional["IdentityResolutionSettingInstance.str"] = ( + payload.get("normalization") + ) - :param identity_resolution_settings_core: - :param if_match: Allows for optimistic concurrency control by making the request conditional. Server will only act if the resource's current Entity Tag (ETag) matches the one provided, preventing accidental overwrites. + def to_dict(self): + return { + "idType": self.id_type, + "matchingAlgo": self.matching_algo, + "matchingThreshold": self.matching_threshold, + "limit": self.limit, + "limitPolicy": self.limit_policy, + "enforceUnique": self.enforce_unique, + "normalization": self.normalization, + } - :returns: ApiResponse with instance, status code, and headers + class IdentityResolutionSettingsCore(object): """ - return await self._proxy.update_with_http_info_async( - identity_resolution_settings_core=identity_resolution_settings_core, - if_match=if_match, - ) - - def __repr__(self) -> str: + :ivar identifier_configs: List of identifier types and their resolution settings. + :ivar matching_rules: Priority list of identifiers to locate profiles to apply new data to, or for determining if two existing profiles should merge. Individual rules are evaluated with `OR` logic between them, meaning that satisfying any single rule will trigger a match. Each rule is a single identifier type; compound rules are not supported. Rules are evaluated in order. - If no rule matches against existing profiles, a new profile will be created. - If a rule matches to a single existing profile, the profile will be updated. - If a rule matches to multiple existing profiles, those existing profiles will be merged. """ - Provide a friendly representation - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "<Twilio.Memory.V1.IdentityResolutionSettingInstance {}>".format(context) + def __init__(self, payload: Dict[str, Any]): + self.identifier_configs: Optional[ + List[IdentityResolutionSettingList.IdentifierConfig] + ] = payload.get("identifierConfigs") + self.matching_rules: Optional[List[str]] = payload.get("matchingRules") -class IdentityResolutionSettingContext(InstanceContext): + def to_dict(self): + return { + "identifierConfigs": ( + [ + identifier_configs.to_dict() + for identifier_configs in self.identifier_configs + ] + if self.identifier_configs is not None + else None + ), + "matchingRules": self.matching_rules, + } def __init__(self, version: Version, store_id: str): """ - Initialize the IdentityResolutionSettingContext + Initialize the IdentityResolutionSettingList :param version: Version that contains the resource :param store_id: A unique Memory Store ID using Twilio Type ID (TTID) format + """ super().__init__(version) @@ -213,8 +148,7 @@ def _fetch(self) -> tuple: Returns: tuple: (payload, status_code, headers) """ - - headers = values.of({}) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) headers["Accept"] = "application/json" @@ -231,9 +165,7 @@ def fetch(self) -> IdentityResolutionSettingInstance: """ payload, _, _ = self._fetch() return IdentityResolutionSettingInstance( - self._version, - payload, - store_id=self._solution["store_id"], + self._version, payload, store_id=self._solution["store_id"] ) def fetch_with_http_info(self) -> ApiResponse: @@ -245,9 +177,7 @@ def fetch_with_http_info(self) -> ApiResponse: """ payload, status_code, headers = self._fetch() instance = IdentityResolutionSettingInstance( - self._version, - payload, - store_id=self._solution["store_id"], + self._version, payload, store_id=self._solution["store_id"] ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -258,8 +188,7 @@ async def _fetch_async(self) -> tuple: Returns: tuple: (payload, status_code, headers) """ - - headers = values.of({}) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) headers["Accept"] = "application/json" @@ -269,30 +198,26 @@ async def _fetch_async(self) -> tuple: async def fetch_async(self) -> IdentityResolutionSettingInstance: """ - Asynchronous coroutine to fetch the IdentityResolutionSettingInstance + Asynchronously fetch the IdentityResolutionSettingInstance :returns: The fetched IdentityResolutionSettingInstance """ payload, _, _ = await self._fetch_async() return IdentityResolutionSettingInstance( - self._version, - payload, - store_id=self._solution["store_id"], + self._version, payload, store_id=self._solution["store_id"] ) async def fetch_with_http_info_async(self) -> ApiResponse: """ - Asynchronous coroutine to fetch the IdentityResolutionSettingInstance and return response metadata + Asynchronously fetch the IdentityResolutionSettingInstance and return response metadata :returns: ApiResponse with instance, status code, and headers """ payload, status_code, headers = await self._fetch_async() instance = IdentityResolutionSettingInstance( - self._version, - payload, - store_id=self._solution["store_id"], + self._version, payload, store_id=self._solution["store_id"] ) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -309,12 +234,9 @@ def _update( """ data = identity_resolution_settings_core.to_dict() - headers = values.of({}) - - if not ( - if_match is values.unset or (isinstance(if_match, str) and not if_match) - ): - headers["If-Match"] = if_match + headers = values.of( + {"If-Match": if_match, "Content-Type": "application/x-www-form-urlencoded"} + ) headers["Content-Type"] = "application/json" @@ -380,12 +302,9 @@ async def _update_async( """ data = identity_resolution_settings_core.to_dict() - headers = values.of({}) - - if not ( - if_match is values.unset or (isinstance(if_match, str) and not if_match) - ): - headers["If-Match"] = if_match + headers = values.of( + {"If-Match": if_match, "Content-Type": "application/x-www-form-urlencoded"} + ) headers["Content-Type"] = "application/json" @@ -401,7 +320,7 @@ async def update_async( if_match: Union[str, object] = values.unset, ) -> IdentityResolutionSettingInstance: """ - Asynchronous coroutine to update the IdentityResolutionSettingInstance + Asynchronously update the IdentityResolutionSettingInstance :param identity_resolution_settings_core: :param if_match: Allows for optimistic concurrency control by making the request conditional. Server will only act if the resource's current Entity Tag (ETag) matches the one provided, preventing accidental overwrites. @@ -422,7 +341,7 @@ async def update_with_http_info_async( if_match: Union[str, object] = values.unset, ) -> ApiResponse: """ - Asynchronous coroutine to update the IdentityResolutionSettingInstance and return response metadata + Asynchronously update the IdentityResolutionSettingInstance and return response metadata :param identity_resolution_settings_core: :param if_match: Allows for optimistic concurrency control by making the request conditional. Server will only act if the resource's current Entity Tag (ETag) matches the one provided, preventing accidental overwrites. @@ -438,107 +357,6 @@ async def update_with_http_info_async( ) 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 "<Twilio.Memory.V1.IdentityResolutionSettingContext {}>".format(context) - - -class IdentityResolutionSettingList(ListResource): - - class IdentifierConfig(object): - """ - :ivar id_type: Name of the identifier type. Usual values are email, phone, external_id etc. - :ivar matching_algo: The algorithm to use for matching identifier values. - `exact`, exact string match. - `fuzzy`, low precision match allowing for some variations. - :ivar matching_threshold: The `fuzzy` matching threshold percentage. - :ivar limit: Maximum number of historical values to retain. - :ivar limit_policy: Removal policy to apply when the number of values exceeds the limit and is based on the timestamp of the request when the identifier was added. - `fifo`: First In First Out, removes the oldest values first. - `lifo`: Last In First Out, removes the most recent values first. - :ivar enforce_unique: When enabled, more than one profile may not share the same identifier value. Adding a shared identifier to a second profile may trigger a merge. Disabling creates a compound identifier where merges are only triggered if two or more identifiers satisfy a matching rule. - :ivar normalization: Normalization to apply to the identifier value before storing and matching. - `phone`: Normalize phone numbers to E.164 format. - `email`: Normalize email addresses by coverting to lowercase and removing spaces. - `trim`: Removes spaces from both ends of the string. - `none`: No normalization. **Important Note for Phone Number Normalization:** When using the `phone` normalization option, please adhere to the following guidelines to ensure proper formatting: - All US numbers must be at least valid 10 digit phone numbers with area code. They may also include or omit the \"+1\" prefix. - Non-US numbers must include a 1-3 digit country code (a \"+\" prefix is optional). Non-US national formats are not supported and will be interpreted as US numbers. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.id_type: Optional[str] = payload.get("idType") - self.matching_algo: Optional["IdentityResolutionSettingInstance.str"] = ( - payload.get("matchingAlgo") - ) - self.matching_threshold: Optional[int] = payload.get("matchingThreshold") - self.limit: Optional[int] = payload.get("limit") - self.limit_policy: Optional["IdentityResolutionSettingInstance.str"] = ( - payload.get("limitPolicy") - ) - self.enforce_unique: Optional[bool] = payload.get("enforceUnique") - self.normalization: Optional["IdentityResolutionSettingInstance.str"] = ( - payload.get("normalization") - ) - - def to_dict(self): - return { - "idType": self.id_type, - "matchingAlgo": self.matching_algo, - "matchingThreshold": self.matching_threshold, - "limit": self.limit, - "limitPolicy": self.limit_policy, - "enforceUnique": self.enforce_unique, - "normalization": self.normalization, - } - - class IdentityResolutionSettingsCore(object): - """ - :ivar identifier_configs: List of identifier types and their resolution settings. - :ivar matching_rules: Priority list of identifiers to locate profiles to apply new data to, or for determining if two existing profiles should merge. Rules are evaluated in order. - If no rule matches against existing profiles, a new profile will be created. - If a rule matches to a single existing profile, the profile will be updated. - If a rule matches to multiple existing profiles, those existing profiles will be merged. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.identifier_configs: Optional[ - List[IdentityResolutionSettingList.IdentifierConfig] - ] = payload.get("identifierConfigs") - self.matching_rules: Optional[List[str]] = payload.get("matchingRules") - - def to_dict(self): - return { - "identifierConfigs": ( - [ - identifier_configs.to_dict() - for identifier_configs in self.identifier_configs - ] - if self.identifier_configs is not None - else None - ), - "matchingRules": self.matching_rules, - } - - def __init__(self, version: Version): - """ - Initialize the IdentityResolutionSettingList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - def get(self, store_id: str) -> IdentityResolutionSettingContext: - """ - Constructs a IdentityResolutionSettingContext - - :param store_id: A unique Memory Store ID using Twilio Type ID (TTID) format - """ - return IdentityResolutionSettingContext(self._version, store_id=store_id) - - def __call__(self, store_id: str) -> IdentityResolutionSettingContext: - """ - Constructs a IdentityResolutionSettingContext - - :param store_id: A unique Memory Store ID using Twilio Type ID (TTID) format - """ - return IdentityResolutionSettingContext(self._version, store_id=store_id) - def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/memory/v1/import_.py b/twilio/rest/memory/v1/import_.py index 73a65e96e1..3c30af4c5c 100644 --- a/twilio/rest/memory/v1/import_.py +++ b/twilio/rest/memory/v1/import_.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio Memory API - APIs for managing memory stores, profiles, events, and conversational intelligence capabilities. + APIs for managing memory stores, profiles, and conversational intelligence capabilities. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech @@ -15,7 +15,7 @@ from __future__ import annotations from datetime import datetime -from typing import Any, Dict, List, Optional, Union +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 @@ -27,7 +27,6 @@ class ImportInstance(InstanceResource): """ - :ivar imports: :ivar status: Current processing status of the import task :ivar filename: Original filename of the uploaded CSV :ivar created_at: Timestamp when the import was created @@ -35,6 +34,8 @@ class ImportInstance(InstanceResource): :ivar file_size: Size of the uploaded file in bytes (1 byte to 100 MiB) :ivar column_mappings: Mappings of CSV header columns to traits' fields :ivar summary: + :ivar imports: + :ivar meta: :ivar import_id: ID of the import task. :ivar url: Pre-signed URL to upload the CSV via a single PUT request. """ @@ -48,7 +49,6 @@ def __init__( ): super().__init__(version) - self.imports: Optional[List[str]] = payload.get("imports") self.status: Optional["ImportInstance.str"] = payload.get("status") self.filename: Optional[str] = payload.get("filename") self.created_at: Optional[datetime] = deserialize.iso8601_datetime( @@ -64,6 +64,8 @@ def __init__( self.summary: Optional[FetchProfileImportV2200ResponseSummary] = payload.get( "summary" ) + self.imports: Optional[List[str]] = payload.get("imports") + self.meta: Optional[ListProfileImportsV2200ResponseMeta] = payload.get("meta") self.import_id: Optional[str] = payload.get("importId") self.url: Optional[str] = payload.get("url") @@ -351,6 +353,29 @@ def to_dict(self): "warnings": self.warnings, } + class ListProfileImportsV2200ResponseMeta(object): + """ + :ivar key: + :ivar page_size: + :ivar next_token: + :ivar previous_token: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.key: Optional[object] = payload.get("key") + self.page_size: Optional[int] = payload.get("pageSize") + self.next_token: Optional[str] = payload.get("nextToken") + self.previous_token: Optional[str] = payload.get("previousToken") + + def to_dict(self): + return { + "key": self.key, + "pageSize": self.page_size, + "nextToken": self.next_token, + "previousToken": self.previous_token, + } + def __init__(self, version: Version, store_id: str): """ Initialize the ImportList @@ -479,48 +504,199 @@ async def create_with_http_info_async( ) return ApiResponse(data=instance, status_code=status_code, headers=headers) - def list( + def stream( self, - ) -> List[str]: + page_token: Union[str, object] = values.unset, + order_by: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[ImportInstance]: """ - Lists ImportInstance IDs from the API as a list. + Streams ImportInstance 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. - :returns: list that will contain up to limit results + :param str page_token: The token for the page of results to retrieve. + :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. + :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, order_by=order_by, page_size=limits["page_size"] + ) - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + return self._version.stream(page, limits["limit"]) - headers["Accept"] = "application/json" + async def stream_async( + self, + page_token: Union[str, object] = values.unset, + order_by: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[ImportInstance]: + """ + Asynchronously streams ImportInstance 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. - data = values.of({}) - payload, _, _ = self._version.fetch_with_response_info( - method="GET", uri=self._uri, params=data, headers=headers + :param str page_token: The token for the page of results to retrieve. + :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. + :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, order_by=order_by, page_size=limits["page_size"] ) - return list(payload["imports"]) + return self._version.stream_async(page, limits["limit"]) - async def list_async( + def stream_with_http_info( + self, + page_token: Union[str, object] = values.unset, + order_by: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> tuple: + """ + Streams ImportInstance and returns headers from first page + + + :param str page_token: The token for the page of results to retrieve. + :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. + :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, order_by=order_by, 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, + order_by: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> tuple: + """ + Asynchronously streams ImportInstance and returns headers from first page + + + :param str page_token: The token for the page of results to retrieve. + :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. + :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, order_by=order_by, 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, + order_by: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, ) -> List[str]: """ - Asynchronously lists ImportInstance IDs from the API as a list. + Lists ImportInstance IDs 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: The token for the page of results to retrieve. + :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. + :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 """ - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + return list( + self.stream( + page_token=page_token, + order_by=order_by, + limit=limit, + page_size=page_size, + ) + ) - headers["Accept"] = "application/json" + async def list_async( + self, + page_token: Union[str, object] = values.unset, + order_by: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[str]: + """ + Asynchronously lists ImportInstance IDs from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. - data = values.of({}) - payload, _, _ = await self._version.fetch_with_response_info_async( - method="GET", uri=self._uri, params=data, headers=headers - ) + :param str page_token: The token for the page of results to retrieve. + :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. + :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) - return list(payload["imports"]) + :returns: list that will contain up to limit results + """ + + return [ + record + async for record in await self.stream_async( + page_token=page_token, + order_by=order_by, + limit=limit, + page_size=page_size, + ) + ] def list_with_http_info( self, + page_token: Union[str, object] = values.unset, + order_by: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> ApiResponse: @@ -528,6 +704,8 @@ def list_with_http_info( Lists ImportInstance and returns headers from first page + :param str page_token: The token for the page of results to retrieve. + :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. :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 @@ -538,6 +716,8 @@ def list_with_http_info( :returns: ApiResponse with list of instances, status code, and headers """ generator, status_code, headers = self.stream_with_http_info( + page_token=page_token, + order_by=order_by, limit=limit, page_size=page_size, ) @@ -546,6 +726,8 @@ def list_with_http_info( async def list_with_http_info_async( self, + page_token: Union[str, object] = values.unset, + order_by: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> ApiResponse: @@ -553,6 +735,8 @@ async def list_with_http_info_async( Asynchronously lists ImportInstance and returns headers from first page + :param str page_token: The token for the page of results to retrieve. + :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. :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 @@ -563,6 +747,8 @@ async def list_with_http_info_async( :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, + order_by=order_by, limit=limit, page_size=page_size, ) @@ -571,14 +757,26 @@ async def list_with_http_info_async( def page( self, + page_size: Union[int, object] = values.unset, + page_token: Union[str, object] = values.unset, + order_by: Union[str, object] = values.unset, ) -> ImportPage: """ Retrieve a single page of ImportInstance records from the API. Request is executed immediately + :param page_size: The maximum number of items to return per page, maximum of 1000. + :param page_token: The token for the page of results to retrieve. + :param order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. :returns: Page of ImportInstance """ - data = values.of({}) + data = values.of( + { + "pageSize": page_size, + "pageToken": page_token, + "orderBy": order_by, + } + ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) @@ -593,14 +791,26 @@ def page( async def page_async( self, + page_size: Union[int, object] = values.unset, + page_token: Union[str, object] = values.unset, + order_by: Union[str, object] = values.unset, ) -> ImportPage: """ Asynchronously retrieve a single page of ImportInstance records from the API. Request is executed immediately + :param page_size: The maximum number of items to return per page, maximum of 1000. + :param page_token: The token for the page of results to retrieve. + :param order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. :returns: Page of ImportInstance """ - data = values.of({}) + data = values.of( + { + "pageSize": page_size, + "pageToken": page_token, + "orderBy": order_by, + } + ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) @@ -615,6 +825,7 @@ async def page_async( def page_with_http_info( self, + order_by: 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, @@ -623,6 +834,8 @@ def page_with_http_info( Retrieve a single page with response metadata + :param page_token: The token for the page of results to retrieve. + :param order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. :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 @@ -631,6 +844,8 @@ def page_with_http_info( """ data = values.of( { + "pageToken": page_token, + "orderBy": order_by, "PageToken": page_token, "Page": page_number, "PageSize": page_size, @@ -651,6 +866,7 @@ def page_with_http_info( async def page_with_http_info_async( self, + order_by: 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, @@ -659,6 +875,8 @@ async def page_with_http_info_async( Asynchronously retrieve a single page with response metadata + :param page_token: The token for the page of results to retrieve. + :param order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. :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 @@ -667,6 +885,8 @@ async def page_with_http_info_async( """ data = values.of( { + "pageToken": page_token, + "orderBy": order_by, "PageToken": page_token, "Page": page_number, "PageSize": page_size, diff --git a/twilio/rest/memory/v1/lookup.py b/twilio/rest/memory/v1/lookup.py index 11721acfab..f14fc0fac0 100644 --- a/twilio/rest/memory/v1/lookup.py +++ b/twilio/rest/memory/v1/lookup.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio Memory API - APIs for managing memory stores, profiles, events, and conversational intelligence capabilities. + APIs for managing memory stores, profiles, and conversational intelligence capabilities. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech diff --git a/twilio/rest/memory/v1/observation.py b/twilio/rest/memory/v1/observation.py index 9150a75ef0..3f61682c75 100644 --- a/twilio/rest/memory/v1/observation.py +++ b/twilio/rest/memory/v1/observation.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio Memory API - APIs for managing memory stores, profiles, events, and conversational intelligence capabilities. + APIs for managing memory stores, profiles, and conversational intelligence capabilities. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech @@ -27,6 +27,7 @@ class ObservationInstance(InstanceResource): """ + :ivar message: :ivar content: The main content of the observation. :ivar occurred_at: The timestamp when the observation originally occurred. :ivar source: The source system that generated this observation. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. @@ -34,7 +35,6 @@ class ObservationInstance(InstanceResource): :ivar id: A unique identifier for the observation using Twilio Type ID (TTID) format. :ivar created_at: The timestamp when the observation was created. :ivar updated_at: The timestamp when the observation was last updated. - :ivar message: """ def __init__( @@ -47,6 +47,7 @@ def __init__( ): super().__init__(version) + self.message: Optional[str] = payload.get("message") self.content: Optional[str] = payload.get("content") self.occurred_at: Optional[datetime] = deserialize.iso8601_datetime( payload.get("occurredAt") @@ -60,7 +61,6 @@ def __init__( self.updated_at: Optional[datetime] = deserialize.iso8601_datetime( payload.get("updatedAt") ) - self.message: Optional[str] = payload.get("message") # Only set _solution if path params are provided (not None) if store_id is not None or profile_id is not None or observation_id is not None: @@ -161,30 +161,30 @@ async def fetch_with_http_info_async(self) -> ApiResponse: """ return await self._proxy.fetch_with_http_info_async() - def patch(self, observation_core: ObservationCore) -> "ObservationInstance": + def patch(self, observation_base: ObservationBase) -> "ObservationInstance": """ Patch the ObservationInstance - :param observation_core: + :param observation_base: :returns: The patched ObservationInstance """ return self._proxy.patch( - observation_core=observation_core, + observation_base=observation_base, ) async def patch_async( - self, observation_core: ObservationCore + self, observation_base: ObservationBase ) -> "ObservationInstance": """ Asynchronous coroutine to patch the ObservationInstance - :param observation_core: + :param observation_base: :returns: The patched ObservationInstance """ return await self._proxy.patch_async( - observation_core=observation_core, + observation_base=observation_base, ) def __repr__(self) -> str: @@ -392,14 +392,14 @@ async def fetch_with_http_info_async(self) -> ApiResponse: ) return ApiResponse(data=instance, status_code=status_code, headers=headers) - def _patch(self, observation_core: ObservationCore) -> tuple: + def _patch(self, observation_base: ObservationBase) -> tuple: """ Internal helper for patch operation Returns: tuple: (payload, status_code, headers) """ - data = observation_core.to_dict() + data = observation_base.to_dict() headers = values.of({}) @@ -411,15 +411,15 @@ def _patch(self, observation_core: ObservationCore) -> tuple: method="PATCH", uri=self._uri, data=data, headers=headers ) - def patch(self, observation_core: ObservationCore) -> ObservationInstance: + def patch(self, observation_base: ObservationBase) -> ObservationInstance: """ Patch the ObservationInstance - :param observation_core: + :param observation_base: :returns: The patched ObservationInstance """ - payload, _, _ = self._patch(observation_core=observation_core) + payload, _, _ = self._patch(observation_base=observation_base) return ObservationInstance( self._version, payload, @@ -428,15 +428,15 @@ def patch(self, observation_core: ObservationCore) -> ObservationInstance: observation_id=self._solution["observation_id"], ) - def patch_with_http_info(self, observation_core: ObservationCore) -> ApiResponse: + def patch_with_http_info(self, observation_base: ObservationBase) -> ApiResponse: """ Patch the ObservationInstance and return response metadata - :param observation_core: + :param observation_base: :returns: ApiResponse with instance, status code, and headers """ - payload, status_code, headers = self._patch(observation_core=observation_core) + payload, status_code, headers = self._patch(observation_base=observation_base) instance = ObservationInstance( self._version, payload, @@ -446,14 +446,14 @@ def patch_with_http_info(self, observation_core: ObservationCore) -> ApiResponse ) return ApiResponse(data=instance, status_code=status_code, headers=headers) - async def _patch_async(self, observation_core: ObservationCore) -> tuple: + async def _patch_async(self, observation_base: ObservationBase) -> tuple: """ Internal async helper for patch operation Returns: tuple: (payload, status_code, headers) """ - data = observation_core.to_dict() + data = observation_base.to_dict() headers = values.of({}) @@ -466,16 +466,16 @@ async def _patch_async(self, observation_core: ObservationCore) -> tuple: ) async def patch_async( - self, observation_core: ObservationCore + self, observation_base: ObservationBase ) -> ObservationInstance: """ Asynchronous coroutine to patch the ObservationInstance - :param observation_core: + :param observation_base: :returns: The patched ObservationInstance """ - payload, _, _ = await self._patch_async(observation_core=observation_core) + payload, _, _ = await self._patch_async(observation_base=observation_base) return ObservationInstance( self._version, payload, @@ -485,17 +485,17 @@ async def patch_async( ) async def patch_with_http_info_async( - self, observation_core: ObservationCore + self, observation_base: ObservationBase ) -> ApiResponse: """ Asynchronous coroutine to patch the ObservationInstance and return response metadata - :param observation_core: + :param observation_base: :returns: ApiResponse with instance, status code, and headers """ payload, status_code, headers = await self._patch_async( - observation_core=observation_core + observation_base=observation_base ) instance = ObservationInstance( self._version, @@ -550,9 +550,9 @@ class CreateObservationsRequest(object): def __init__(self, payload: Dict[str, Any]): - self.observations: Optional[List[ObservationList.ObservationCore]] = ( - payload.get("observations") - ) + self.observations: Optional[ + List[ObservationList.ObservationCreateRequest] + ] = payload.get("observations") def to_dict(self): return { @@ -563,7 +563,30 @@ def to_dict(self): ), } - class ObservationCore(object): + class ObservationBase(object): + """ + :ivar content: The main content of the observation. + :ivar occurred_at: The timestamp when the observation originally occurred. + :ivar source: The source system that generated this observation. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :ivar conversation_ids: Array of conversation IDs associated with this observation. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.content: Optional[str] = payload.get("content") + self.occurred_at: Optional[datetime] = payload.get("occurredAt") + self.source: Optional[str] = payload.get("source") + self.conversation_ids: Optional[List[str]] = payload.get("conversationIds") + + def to_dict(self): + return { + "content": self.content, + "occurredAt": self.occurred_at, + "source": self.source, + "conversationIds": self.conversation_ids, + } + + class ObservationCreateRequest(object): """ :ivar content: The main content of the observation. :ivar occurred_at: The timestamp when the observation originally occurred. @@ -783,6 +806,7 @@ def stream( source: Union[str, object] = values.unset, created_after: Union[datetime, object] = values.unset, created_before: Union[datetime, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -798,6 +822,7 @@ def stream( :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). + :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param str accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -815,6 +840,7 @@ def stream( source=source, created_after=created_after, created_before=created_before, + conversation_id=conversation_id, accept_encoding=accept_encoding, page_size=limits["page_size"], ) @@ -828,6 +854,7 @@ async def stream_async( source: Union[str, object] = values.unset, created_after: Union[datetime, object] = values.unset, created_before: Union[datetime, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -843,6 +870,7 @@ async def stream_async( :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). + :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param str accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -860,6 +888,7 @@ async def stream_async( source=source, created_after=created_after, created_before=created_before, + conversation_id=conversation_id, accept_encoding=accept_encoding, page_size=limits["page_size"], ) @@ -873,6 +902,7 @@ def stream_with_http_info( source: Union[str, object] = values.unset, created_after: Union[datetime, object] = values.unset, created_before: Union[datetime, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -886,6 +916,7 @@ def stream_with_http_info( :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). + :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param str accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -903,6 +934,7 @@ def stream_with_http_info( source=source, created_after=created_after, created_before=created_before, + conversation_id=conversation_id, accept_encoding=accept_encoding, page_size=limits["page_size"], ) @@ -917,6 +949,7 @@ async def stream_with_http_info_async( source: Union[str, object] = values.unset, created_after: Union[datetime, object] = values.unset, created_before: Union[datetime, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -930,6 +963,7 @@ async def stream_with_http_info_async( :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). + :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param str accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -947,6 +981,7 @@ async def stream_with_http_info_async( source=source, created_after=created_after, created_before=created_before, + conversation_id=conversation_id, accept_encoding=accept_encoding, page_size=limits["page_size"], ) @@ -961,6 +996,7 @@ def list( source: Union[str, object] = values.unset, created_after: Union[datetime, object] = values.unset, created_before: Union[datetime, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -975,6 +1011,7 @@ def list( :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). + :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param str accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -993,6 +1030,7 @@ def list( source=source, created_after=created_after, created_before=created_before, + conversation_id=conversation_id, accept_encoding=accept_encoding, limit=limit, page_size=page_size, @@ -1006,6 +1044,7 @@ async def list_async( source: Union[str, object] = values.unset, created_after: Union[datetime, object] = values.unset, created_before: Union[datetime, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -1020,6 +1059,7 @@ async def list_async( :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). + :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param str accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -1039,6 +1079,7 @@ async def list_async( source=source, created_after=created_after, created_before=created_before, + conversation_id=conversation_id, accept_encoding=accept_encoding, limit=limit, page_size=page_size, @@ -1052,6 +1093,7 @@ def list_with_http_info( source: Union[str, object] = values.unset, created_after: Union[datetime, object] = values.unset, created_before: Union[datetime, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -1065,6 +1107,7 @@ def list_with_http_info( :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). + :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param str accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -1081,6 +1124,7 @@ def list_with_http_info( source=source, created_after=created_after, created_before=created_before, + conversation_id=conversation_id, accept_encoding=accept_encoding, limit=limit, page_size=page_size, @@ -1095,6 +1139,7 @@ async def list_with_http_info_async( source: Union[str, object] = values.unset, created_after: Union[datetime, object] = values.unset, created_before: Union[datetime, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -1108,6 +1153,7 @@ async def list_with_http_info_async( :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). + :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param str accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -1124,6 +1170,7 @@ async def list_with_http_info_async( source=source, created_after=created_after, created_before=created_before, + conversation_id=conversation_id, accept_encoding=accept_encoding, limit=limit, page_size=page_size, @@ -1139,6 +1186,7 @@ def page( source: Union[str, object] = values.unset, created_after: Union[datetime, object] = values.unset, created_before: Union[datetime, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, ) -> ObservationPage: """ @@ -1151,6 +1199,7 @@ def page( :param source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. :param created_after: Filter observations created after this timestamp (inclusive). :param created_before: Filter observations created before this timestamp (exclusive). + :param conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :returns: Page of ObservationInstance """ @@ -1162,6 +1211,7 @@ def page( "source": source, "createdAfter": serialize.iso8601_datetime(created_after), "createdBefore": serialize.iso8601_datetime(created_before), + "conversationId": conversation_id, "Accept-Encoding": accept_encoding, } ) @@ -1190,6 +1240,7 @@ async def page_async( source: Union[str, object] = values.unset, created_after: Union[datetime, object] = values.unset, created_before: Union[datetime, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, ) -> ObservationPage: """ @@ -1202,6 +1253,7 @@ async def page_async( :param source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. :param created_after: Filter observations created after this timestamp (inclusive). :param created_before: Filter observations created before this timestamp (exclusive). + :param conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :returns: Page of ObservationInstance """ @@ -1213,6 +1265,7 @@ async def page_async( "source": source, "createdAfter": serialize.iso8601_datetime(created_after), "createdBefore": serialize.iso8601_datetime(created_before), + "conversationId": conversation_id, "Accept-Encoding": accept_encoding, } ) @@ -1239,6 +1292,7 @@ def page_with_http_info( source: Union[str, object] = values.unset, created_after: Union[datetime, object] = values.unset, created_before: Union[datetime, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, @@ -1253,6 +1307,7 @@ def page_with_http_info( :param source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. :param created_after: Filter observations created after this timestamp (inclusive). :param created_before: Filter observations created before this timestamp (exclusive). + :param conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -1267,6 +1322,7 @@ def page_with_http_info( "source": source, "createdAfter": serialize.iso8601_datetime(created_after), "createdBefore": serialize.iso8601_datetime(created_before), + "conversationId": conversation_id, "Accept-Encoding": accept_encoding, "PageToken": page_token, "Page": page_number, @@ -1297,6 +1353,7 @@ async def page_with_http_info_async( source: Union[str, object] = values.unset, created_after: Union[datetime, object] = values.unset, created_before: Union[datetime, object] = values.unset, + conversation_id: Union[str, object] = values.unset, accept_encoding: Union[str, object] = values.unset, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, @@ -1311,6 +1368,7 @@ async def page_with_http_info_async( :param source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. :param created_after: Filter observations created after this timestamp (inclusive). :param created_before: Filter observations created before this timestamp (exclusive). + :param conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. :param accept_encoding: Compression algorithms supported by the client (e.g., gzip, deflate, br) :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -1325,6 +1383,7 @@ async def page_with_http_info_async( "source": source, "createdAfter": serialize.iso8601_datetime(created_after), "createdBefore": serialize.iso8601_datetime(created_before), + "conversationId": conversation_id, "Accept-Encoding": accept_encoding, "PageToken": page_token, "Page": page_number, diff --git a/twilio/rest/memory/v1/operation.py b/twilio/rest/memory/v1/operation.py index b8faac294a..7c0c5aa8e0 100644 --- a/twilio/rest/memory/v1/operation.py +++ b/twilio/rest/memory/v1/operation.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio Memory API - APIs for managing memory stores, profiles, events, and conversational intelligence capabilities. + APIs for managing memory stores, profiles, and conversational intelligence capabilities. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech diff --git a/twilio/rest/memory/v1/profile.py b/twilio/rest/memory/v1/profile.py index 01b1080902..de1016ce6b 100644 --- a/twilio/rest/memory/v1/profile.py +++ b/twilio/rest/memory/v1/profile.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio Memory API - APIs for managing memory stores, profiles, events, and conversational intelligence capabilities. + APIs for managing memory stores, profiles, and conversational intelligence capabilities. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech @@ -45,7 +45,7 @@ def __init__( super().__init__(version) self.profiles: Optional[List[str]] = payload.get("profiles") - self.meta: Optional[ProfilesMeta] = payload.get("meta") + self.meta: Optional[IdentityProfilesMeta] = payload.get("meta") self.message: Optional[str] = payload.get("message") self.id: Optional[str] = payload.get("id") self.created_at: Optional[datetime] = deserialize.iso8601_datetime( @@ -555,21 +555,30 @@ def __repr__(self) -> str: class ProfileList(ListResource): - class ProfileData(object): + class IdentityProfilesMeta(object): """ - :ivar traits: Multiple trait groups. + :ivar key: The key of the list property contains the actual data items. This enables programmatic iteration over paginated results. + :ivar page_size: + :ivar next_token: + :ivar previous_token: """ def __init__(self, payload: Dict[str, Any]): - self.traits: Optional[Dict[str, Dict[str, object]]] = payload.get("traits") + self.key: Optional[str] = payload.get("key") + self.page_size: Optional[int] = payload.get("pageSize") + self.next_token: Optional[str] = payload.get("nextToken") + self.previous_token: Optional[str] = payload.get("previousToken") def to_dict(self): return { - "traits": self.traits, + "key": self.key, + "pageSize": self.page_size, + "nextToken": self.next_token, + "previousToken": self.previous_token, } - class ProfilePatch(object): + class ProfileData(object): """ :ivar traits: Multiple trait groups. """ @@ -583,27 +592,18 @@ def to_dict(self): "traits": self.traits, } - class ProfilesMeta(object): + class ProfilePatch(object): """ - :ivar key: The key of the list property contains the actual data items. This enables programmatic iteration over paginated results. - :ivar page_size: - :ivar next_token: - :ivar previous_token: + :ivar traits: Multiple trait groups. """ def __init__(self, payload: Dict[str, Any]): - self.key: Optional[str] = payload.get("key") - self.page_size: Optional[int] = payload.get("pageSize") - self.next_token: Optional[str] = payload.get("nextToken") - self.previous_token: Optional[str] = payload.get("previousToken") + self.traits: Optional[Dict[str, Dict[str, object]]] = payload.get("traits") def to_dict(self): return { - "key": self.key, - "pageSize": self.page_size, - "nextToken": self.next_token, - "previousToken": self.previous_token, + "traits": self.traits, } def __init__(self, version: Version, store_id: str): diff --git a/twilio/rest/memory/v1/recall.py b/twilio/rest/memory/v1/recall.py index 5258e3eb09..ff759be74f 100644 --- a/twilio/rest/memory/v1/recall.py +++ b/twilio/rest/memory/v1/recall.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio Memory API - APIs for managing memory stores, profiles, events, and conversational intelligence capabilities. + APIs for managing memory stores, profiles, and conversational intelligence capabilities. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech diff --git a/twilio/rest/memory/v1/revision.py b/twilio/rest/memory/v1/revision.py index 84b8a13a69..34684c4081 100644 --- a/twilio/rest/memory/v1/revision.py +++ b/twilio/rest/memory/v1/revision.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio Memory API - APIs for managing memory stores, profiles, events, and conversational intelligence capabilities. + APIs for managing memory stores, profiles, and conversational intelligence capabilities. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech diff --git a/twilio/rest/memory/v1/store.py b/twilio/rest/memory/v1/store.py index c617301a0e..2821e49925 100644 --- a/twilio/rest/memory/v1/store.py +++ b/twilio/rest/memory/v1/store.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio Memory API - APIs for managing memory stores, profiles, events, and conversational intelligence capabilities. + APIs for managing memory stores, profiles, and conversational intelligence capabilities. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech @@ -552,7 +552,7 @@ class StoreList(ListResource): class Meta(object): """ :ivar key: The key of the list property contains the actual data items. This enables programmatic iteration over paginated results. - :ivar page_size: + :ivar page_size: The number of items returned in this page of results. :ivar next_token: :ivar previous_token: """ diff --git a/twilio/rest/memory/v1/trait.py b/twilio/rest/memory/v1/trait.py index b565d8066c..dc317640a1 100644 --- a/twilio/rest/memory/v1/trait.py +++ b/twilio/rest/memory/v1/trait.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio Memory API - APIs for managing memory stores, profiles, events, and conversational intelligence capabilities. + APIs for managing memory stores, profiles, and conversational intelligence capabilities. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech diff --git a/twilio/rest/memory/v1/trait_group.py b/twilio/rest/memory/v1/trait_group.py index 5cf1c5d276..1412ffc70a 100644 --- a/twilio/rest/memory/v1/trait_group.py +++ b/twilio/rest/memory/v1/trait_group.py @@ -5,7 +5,7 @@ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ Twilio Memory API - APIs for managing memory stores, profiles, events, and conversational intelligence capabilities. + APIs for managing memory stores, profiles, and conversational intelligence capabilities. NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech @@ -51,9 +51,7 @@ def __init__( self.status_url: Optional[str] = payload.get("statusUrl") self.display_name: Optional[str] = payload.get("displayName") self.description: Optional[str] = payload.get("description") - self.traits: Optional[Dict[str, TraitGroupCoreTraitsValue]] = payload.get( - "traits" - ) + self.traits: Optional[Dict[str, TraitGroupCoreTraits]] = payload.get("traits") self.version: Optional[int] = deserialize.integer(payload.get("version")) # Only set _solution if path params are provided (not None) @@ -725,7 +723,7 @@ class TraitGroupList(ListResource): class Meta(object): """ :ivar key: The key of the list property contains the actual data items. This enables programmatic iteration over paginated results. - :ivar page_size: + :ivar page_size: The number of items returned in this page of results. :ivar next_token: :ivar previous_token: """ @@ -770,6 +768,7 @@ class TraitDefinition(object): """ :ivar data_type: Data type of the Trait, such as STRING, NUMBER, BOOLEAN, ARRAY. For DELETE operations in PATCH requests, set this to an empty string (\"\") to mark the trait for deletion. :ivar description: Description of the Trait, providing additional context or information. + :ivar validation_rule: :ivar id_type_promotion: The name of the identifier type to promote the trait value to, such as ''email'', ''phone'', ''user_id'', etc. This allows the trait to be mapped to an identifier in Identity Resolution. The identifier type should be configured in the Identity Resolution Settings. """ @@ -777,12 +776,20 @@ 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.id_type_promotion: Optional[str] = payload.get("idTypePromotion") def to_dict(self): return { "dataType": self.data_type, "description": self.description, + "validationRule": ( + self.validation_rule.to_dict() + if self.validation_rule is not None + else None + ), "idTypePromotion": self.id_type_promotion, } @@ -798,7 +805,7 @@ def __init__(self, payload: Dict[str, Any]): self.display_name: Optional[str] = payload.get("displayName") self.description: Optional[str] = payload.get("description") - self.traits: Optional[Dict[str, TraitGroupCoreTraitsValue]] = payload.get( + self.traits: Optional[Dict[str, TraitGroupCoreTraits]] = payload.get( "traits" ) self.version: Optional[int] = deserialize.integer(payload.get("version")) @@ -815,7 +822,7 @@ def to_dict(self): "version": self.version, } - class TraitGroupCoreTraitsValue(object): + class TraitGroupCoreTraits(object): """ :ivar data_type: Data type of the Trait, such as STRING, NUMBER, BOOLEAN, ARRAY. For DELETE operations in PATCH requests, set this to an empty string (\"\") to mark the trait for deletion. :ivar description: Description of the Trait, providing additional context or information. @@ -855,7 +862,7 @@ def __init__(self, payload: Dict[str, Any]): self.display_name: Optional[str] = payload.get("displayName") self.description: Optional[str] = payload.get("description") - self.traits: Optional[Dict[str, TraitGroupCoreTraitsValue]] = payload.get( + self.traits: Optional[Dict[str, TraitGroupRequestTraits]] = payload.get( "traits" ) @@ -870,6 +877,35 @@ def to_dict(self): ), } + class TraitGroupRequestTraits(object): + """ + :ivar data_type: Data type of the Trait, such as STRING, NUMBER, BOOLEAN, ARRAY. For DELETE operations in PATCH requests, set this to an empty string (\"\") to mark the trait for deletion. + :ivar description: Description of the Trait, providing additional context or information. + :ivar validation_rule: + :ivar id_type_promotion: The name of the identifier type to promote the trait value to, such as ''email'', ''phone'', ''user_id'', etc. This allows the trait to be mapped to an identifier in Identity Resolution. The identifier type should be configured in the Identity Resolution Settings. + """ + + 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.id_type_promotion: Optional[str] = payload.get("idTypePromotion") + + def to_dict(self): + return { + "dataType": self.data_type, + "description": self.description, + "validationRule": ( + self.validation_rule.to_dict() + if self.validation_rule is not None + else None + ), + "idTypePromotion": self.id_type_promotion, + } + class ValidationRule(object): """ :ivar pattern: Regex pattern (max 1000 chars) diff --git a/twilio/rest/messaging/v2/channels_sender.py b/twilio/rest/messaging/v2/channels_sender.py index 46d944f1ff..603a4c7ed8 100644 --- a/twilio/rest/messaging/v2/channels_sender.py +++ b/twilio/rest/messaging/v2/channels_sender.py @@ -169,6 +169,7 @@ def to_dict(self): class MessagingV2ChannelsSenderRequestsCreate(object): """ :ivar sender_id: The ID of the sender in `whatsapp:<E.164_PHONE_NUMBER>` format. + :ivar friendly_name: Optional display label for the sender in the Twilio Console. :ivar configuration: :ivar webhook: :ivar profile: @@ -177,6 +178,7 @@ class MessagingV2ChannelsSenderRequestsCreate(object): def __init__(self, payload: Dict[str, Any]): self.sender_id: Optional[str] = payload.get("sender_id") + self.friendly_name: Optional[str] = payload.get("friendly_name") self.configuration: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderConfiguration ] = payload.get("configuration") @@ -190,6 +192,7 @@ def __init__(self, payload: Dict[str, Any]): def to_dict(self): return { "sender_id": self.sender_id, + "friendly_name": self.friendly_name, "configuration": ( self.configuration.to_dict() if self.configuration is not None @@ -201,6 +204,7 @@ def to_dict(self): class MessagingV2ChannelsSenderRequestsUpdate(object): """ + :ivar friendly_name: Optional display label for the sender in the Twilio Console. :ivar configuration: :ivar webhook: :ivar profile: @@ -208,6 +212,7 @@ class MessagingV2ChannelsSenderRequestsUpdate(object): def __init__(self, payload: Dict[str, Any]): + self.friendly_name: Optional[str] = payload.get("friendly_name") self.configuration: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderConfiguration ] = payload.get("configuration") @@ -220,6 +225,7 @@ def __init__(self, payload: Dict[str, Any]): def to_dict(self): return { + "friendly_name": self.friendly_name, "configuration": ( self.configuration.to_dict() if self.configuration is not None @@ -339,6 +345,7 @@ class MessagingV2RcsCountryStatus(object): :ivar sid: The SID of the sender. :ivar status: :ivar sender_id: The ID of the sender in `whatsapp:<E.164_PHONE_NUMBER>` format. + :ivar friendly_name: Optional display label for the sender in the Twilio Console. :ivar configuration: :ivar webhook: :ivar profile: @@ -356,6 +363,7 @@ def __init__( self.sid: Optional[str] = payload.get("sid") self.status: Optional["ChannelsSenderInstance.Status"] = payload.get("status") self.sender_id: Optional[str] = payload.get("sender_id") + self.friendly_name: Optional[str] = payload.get("friendly_name") self.configuration: Optional[str] = payload.get("configuration") self.webhook: Optional[str] = payload.get("webhook") self.profile: Optional[str] = payload.get("profile") @@ -682,6 +690,7 @@ def to_dict(self): class MessagingV2ChannelsSenderRequestsCreate(object): """ :ivar sender_id: The ID of the sender in `whatsapp:<E.164_PHONE_NUMBER>` format. + :ivar friendly_name: Optional display label for the sender in the Twilio Console. :ivar configuration: :ivar webhook: :ivar profile: @@ -690,6 +699,7 @@ class MessagingV2ChannelsSenderRequestsCreate(object): def __init__(self, payload: Dict[str, Any]): self.sender_id: Optional[str] = payload.get("sender_id") + self.friendly_name: Optional[str] = payload.get("friendly_name") self.configuration: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderConfiguration ] = payload.get("configuration") @@ -703,6 +713,7 @@ def __init__(self, payload: Dict[str, Any]): def to_dict(self): return { "sender_id": self.sender_id, + "friendly_name": self.friendly_name, "configuration": ( self.configuration.to_dict() if self.configuration is not None @@ -714,6 +725,7 @@ def to_dict(self): class MessagingV2ChannelsSenderRequestsUpdate(object): """ + :ivar friendly_name: Optional display label for the sender in the Twilio Console. :ivar configuration: :ivar webhook: :ivar profile: @@ -721,6 +733,7 @@ class MessagingV2ChannelsSenderRequestsUpdate(object): def __init__(self, payload: Dict[str, Any]): + self.friendly_name: Optional[str] = payload.get("friendly_name") self.configuration: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderConfiguration ] = payload.get("configuration") @@ -733,6 +746,7 @@ def __init__(self, payload: Dict[str, Any]): def to_dict(self): return { + "friendly_name": self.friendly_name, "configuration": ( self.configuration.to_dict() if self.configuration is not None @@ -1299,6 +1313,7 @@ def to_dict(self): class MessagingV2ChannelsSenderRequestsCreate(object): """ :ivar sender_id: The ID of the sender in `whatsapp:<E.164_PHONE_NUMBER>` format. + :ivar friendly_name: Optional display label for the sender in the Twilio Console. :ivar configuration: :ivar webhook: :ivar profile: @@ -1307,6 +1322,7 @@ class MessagingV2ChannelsSenderRequestsCreate(object): def __init__(self, payload: Dict[str, Any]): self.sender_id: Optional[str] = payload.get("sender_id") + self.friendly_name: Optional[str] = payload.get("friendly_name") self.configuration: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderConfiguration ] = payload.get("configuration") @@ -1320,6 +1336,7 @@ def __init__(self, payload: Dict[str, Any]): def to_dict(self): return { "sender_id": self.sender_id, + "friendly_name": self.friendly_name, "configuration": ( self.configuration.to_dict() if self.configuration is not None @@ -1331,6 +1348,7 @@ def to_dict(self): class MessagingV2ChannelsSenderRequestsUpdate(object): """ + :ivar friendly_name: Optional display label for the sender in the Twilio Console. :ivar configuration: :ivar webhook: :ivar profile: @@ -1338,6 +1356,7 @@ class MessagingV2ChannelsSenderRequestsUpdate(object): def __init__(self, payload: Dict[str, Any]): + self.friendly_name: Optional[str] = payload.get("friendly_name") self.configuration: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderConfiguration ] = payload.get("configuration") @@ -1350,6 +1369,7 @@ def __init__(self, payload: Dict[str, Any]): def to_dict(self): return { + "friendly_name": self.friendly_name, "configuration": ( self.configuration.to_dict() if self.configuration is not None diff --git a/twilio/rest/messaging/v3/typing_indicator.py b/twilio/rest/messaging/v3/typing_indicator.py index 2fc385b528..43f1732c60 100644 --- a/twilio/rest/messaging/v3/typing_indicator.py +++ b/twilio/rest/messaging/v3/typing_indicator.py @@ -25,11 +25,11 @@ class TypingIndicatorInstance(InstanceResource): class TypingIndicatorRequest(object): """ - :ivar channel: The messaging channel. Must be \"APPLE\". + :ivar channel: The messaging channel. Must be \"RCS\". :ivar message_id: The SID of a recent inbound message from the recipient. Must be an SM or MM SID format. - :ivar _from: The Apple Messages for Business identifier of the sender (business). - :ivar to: The Apple Messages for Business identifier of the recipient (customer). - :ivar event: The type of typing event. \"START\" indicates the agent began typing, \"END\" indicates the agent stopped typing. Defaults to \"START\". + :ivar _from: The RCS agent identifier of the sender (business). + :ivar to: The RCS recipient identifier in E.164 format prefixed with \"rcs:\". + :ivar event: The type of typing event. Currently only \"START\" is supported for RCS, indicating the agent began typing. Defaults to \"START\". """ def __init__(self, payload: Dict[str, Any]): @@ -74,11 +74,11 @@ class TypingIndicatorList(ListResource): class TypingIndicatorRequest(object): """ - :ivar channel: The messaging channel. Must be \"APPLE\". + :ivar channel: The messaging channel. Must be \"RCS\". :ivar message_id: The SID of a recent inbound message from the recipient. Must be an SM or MM SID format. - :ivar _from: The Apple Messages for Business identifier of the sender (business). - :ivar to: The Apple Messages for Business identifier of the recipient (customer). - :ivar event: The type of typing event. \"START\" indicates the agent began typing, \"END\" indicates the agent stopped typing. Defaults to \"START\". + :ivar _from: The RCS agent identifier of the sender (business). + :ivar to: The RCS recipient identifier in E.164 format prefixed with \"rcs:\". + :ivar event: The type of typing event. Currently only \"START\" is supported for RCS, indicating the agent began typing. Defaults to \"START\". """ def __init__(self, payload: Dict[str, Any]): diff --git a/twilio/rest/oauth/v1/oauth_authorization_server.py b/twilio/rest/oauth/v1/oauth_authorization_server.py new file mode 100644 index 0000000000..4fcdd357c5 --- /dev/null +++ b/twilio/rest/oauth/v1/oauth_authorization_server.py @@ -0,0 +1,157 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Oauth + 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 OauthAuthorizationServerInstance(InstanceResource): + """ + :ivar issuer: + :ivar authorization_endpoint: + :ivar token_endpoint: + :ivar response_types_supported: + :ivar grant_types_supported: + :ivar code_challenge_methods_supported: + :ivar token_endpoint_auth_methods_supported: + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.issuer: Optional[str] = payload.get("issuer") + self.authorization_endpoint: Optional[str] = payload.get( + "authorization_endpoint" + ) + self.token_endpoint: Optional[str] = payload.get("token_endpoint") + self.response_types_supported: Optional[ + "OauthAuthorizationServerInstance.str]" + ] = payload.get("response_types_supported") + self.grant_types_supported: Optional[ + "OauthAuthorizationServerInstance.str]" + ] = payload.get("grant_types_supported") + self.code_challenge_methods_supported: Optional[ + "OauthAuthorizationServerInstance.str]" + ] = payload.get("code_challenge_methods_supported") + self.token_endpoint_auth_methods_supported: Optional[ + "OauthAuthorizationServerInstance.str]" + ] = payload.get("token_endpoint_auth_methods_supported") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "<Twilio.Oauth.V1.OauthAuthorizationServerInstance>" + + +class OauthAuthorizationServerList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the OauthAuthorizationServerList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/oauth-authorization-server" + + def _fetch(self) -> 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" + + return self._version.fetch_with_response_info( + method="GET", uri=self._uri, headers=headers + ) + + def fetch(self) -> OauthAuthorizationServerInstance: + """ + Fetch the OauthAuthorizationServerInstance + + + :returns: The fetched OauthAuthorizationServerInstance + """ + payload, _, _ = self._fetch() + return OauthAuthorizationServerInstance(self._version, payload) + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the OauthAuthorizationServerInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._fetch() + instance = OauthAuthorizationServerInstance(self._version, payload) + 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({"Content-Type": "application/x-www-form-urlencoded"}) + + 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) -> OauthAuthorizationServerInstance: + """ + Asynchronously fetch the OauthAuthorizationServerInstance + + + :returns: The fetched OauthAuthorizationServerInstance + """ + payload, _, _ = await self._fetch_async() + return OauthAuthorizationServerInstance(self._version, payload) + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronously fetch the OauthAuthorizationServerInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._fetch_async() + instance = OauthAuthorizationServerInstance(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 "<Twilio.Oauth.V1.OauthAuthorizationServerList>" diff --git a/twilio/rest/oauth/v2/authorize.py b/twilio/rest/oauth/v2/authorize.py index 53841e7188..717b31b5aa 100644 --- a/twilio/rest/oauth/v2/authorize.py +++ b/twilio/rest/oauth/v2/authorize.py @@ -61,6 +61,8 @@ def _fetch( redirect_uri: Union[str, object] = values.unset, scope: Union[str, object] = values.unset, state: Union[str, object] = values.unset, + code_challenge: Union[str, object] = values.unset, + code_challenge_method: Union[str, object] = values.unset, ) -> tuple: """ Internal helper for fetch operation @@ -79,6 +81,8 @@ def _fetch( "redirect_uri": redirect_uri, "scope": scope, "state": state, + "code_challenge": code_challenge, + "code_challenge_method": code_challenge_method, } ) @@ -93,11 +97,13 @@ def fetch( redirect_uri: Union[str, object] = values.unset, scope: Union[str, object] = values.unset, state: Union[str, object] = values.unset, + code_challenge: Union[str, object] = values.unset, + code_challenge_method: Union[str, object] = values.unset, ) -> AuthorizeInstance: """ Fetch the AuthorizeInstance - :param response_type: :param client_id: :param redirect_uri: :param scope: :param state: + :param response_type: :param client_id: :param redirect_uri: :param scope: :param state: :param code_challenge: :param code_challenge_method: :returns: The fetched AuthorizeInstance """ payload, _, _ = self._fetch( @@ -106,6 +112,8 @@ def fetch( redirect_uri=redirect_uri, scope=scope, state=state, + code_challenge=code_challenge, + code_challenge_method=code_challenge_method, ) return AuthorizeInstance(self._version, payload) @@ -116,11 +124,13 @@ def fetch_with_http_info( redirect_uri: Union[str, object] = values.unset, scope: Union[str, object] = values.unset, state: Union[str, object] = values.unset, + code_challenge: Union[str, object] = values.unset, + code_challenge_method: Union[str, object] = values.unset, ) -> ApiResponse: """ Fetch the AuthorizeInstance and return response metadata - :param response_type: :param client_id: :param redirect_uri: :param scope: :param state: + :param response_type: :param client_id: :param redirect_uri: :param scope: :param state: :param code_challenge: :param code_challenge_method: :returns: ApiResponse with instance, status code, and headers """ payload, status_code, headers = self._fetch( @@ -129,6 +139,8 @@ def fetch_with_http_info( redirect_uri=redirect_uri, scope=scope, state=state, + code_challenge=code_challenge, + code_challenge_method=code_challenge_method, ) instance = AuthorizeInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -140,6 +152,8 @@ async def _fetch_async( redirect_uri: Union[str, object] = values.unset, scope: Union[str, object] = values.unset, state: Union[str, object] = values.unset, + code_challenge: Union[str, object] = values.unset, + code_challenge_method: Union[str, object] = values.unset, ) -> tuple: """ Internal async helper for fetch operation @@ -158,6 +172,8 @@ async def _fetch_async( "redirect_uri": redirect_uri, "scope": scope, "state": state, + "code_challenge": code_challenge, + "code_challenge_method": code_challenge_method, } ) @@ -172,11 +188,13 @@ async def fetch_async( redirect_uri: Union[str, object] = values.unset, scope: Union[str, object] = values.unset, state: Union[str, object] = values.unset, + code_challenge: Union[str, object] = values.unset, + code_challenge_method: Union[str, object] = values.unset, ) -> AuthorizeInstance: """ Asynchronously fetch the AuthorizeInstance - :param response_type: :param client_id: :param redirect_uri: :param scope: :param state: + :param response_type: :param client_id: :param redirect_uri: :param scope: :param state: :param code_challenge: :param code_challenge_method: :returns: The fetched AuthorizeInstance """ payload, _, _ = await self._fetch_async( @@ -185,6 +203,8 @@ async def fetch_async( redirect_uri=redirect_uri, scope=scope, state=state, + code_challenge=code_challenge, + code_challenge_method=code_challenge_method, ) return AuthorizeInstance(self._version, payload) @@ -195,11 +215,13 @@ async def fetch_with_http_info_async( redirect_uri: Union[str, object] = values.unset, scope: Union[str, object] = values.unset, state: Union[str, object] = values.unset, + code_challenge: Union[str, object] = values.unset, + code_challenge_method: Union[str, object] = values.unset, ) -> ApiResponse: """ Asynchronously fetch the AuthorizeInstance and return response metadata - :param response_type: :param client_id: :param redirect_uri: :param scope: :param state: + :param response_type: :param client_id: :param redirect_uri: :param scope: :param state: :param code_challenge: :param code_challenge_method: :returns: ApiResponse with instance, status code, and headers """ payload, status_code, headers = await self._fetch_async( @@ -208,6 +230,8 @@ async def fetch_with_http_info_async( redirect_uri=redirect_uri, scope=scope, state=state, + code_challenge=code_challenge, + code_challenge_method=code_challenge_method, ) instance = AuthorizeInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) diff --git a/twilio/rest/oauth/v2/token.py b/twilio/rest/oauth/v2/token.py index 3550e4b506..07bff732c5 100644 --- a/twilio/rest/oauth/v2/token.py +++ b/twilio/rest/oauth/v2/token.py @@ -73,6 +73,7 @@ def _create( audience: Union[str, object] = values.unset, refresh_token: Union[str, object] = values.unset, scope: Union[str, object] = values.unset, + code_verifier: Union[str, object] = values.unset, ) -> tuple: """ Internal helper for create operation @@ -91,6 +92,7 @@ def _create( "audience": audience, "refresh_token": refresh_token, "scope": scope, + "code_verifier": code_verifier, } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) @@ -120,6 +122,7 @@ def create( audience: Union[str, object] = values.unset, refresh_token: Union[str, object] = values.unset, scope: Union[str, object] = values.unset, + code_verifier: Union[str, object] = values.unset, ) -> TokenInstance: """ Create the TokenInstance @@ -133,6 +136,7 @@ def create( :param audience: The targeted audience uri :param refresh_token: JWT token related to refresh access token. :param scope: The scope of token + :param code_verifier: The PKCE code verifier used to generate the code_challenge in the authorization request. :returns: The created TokenInstance """ @@ -146,6 +150,7 @@ def create( audience=audience, refresh_token=refresh_token, scope=scope, + code_verifier=code_verifier, ) return TokenInstance(self._version, payload) @@ -160,6 +165,7 @@ def create_with_http_info( audience: Union[str, object] = values.unset, refresh_token: Union[str, object] = values.unset, scope: Union[str, object] = values.unset, + code_verifier: Union[str, object] = values.unset, ) -> ApiResponse: """ Create the TokenInstance and return response metadata @@ -173,6 +179,7 @@ def create_with_http_info( :param audience: The targeted audience uri :param refresh_token: JWT token related to refresh access token. :param scope: The scope of token + :param code_verifier: The PKCE code verifier used to generate the code_challenge in the authorization request. :returns: ApiResponse with instance, status code, and headers """ @@ -186,6 +193,7 @@ def create_with_http_info( audience=audience, refresh_token=refresh_token, scope=scope, + code_verifier=code_verifier, ) instance = TokenInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) @@ -201,6 +209,7 @@ async def _create_async( audience: Union[str, object] = values.unset, refresh_token: Union[str, object] = values.unset, scope: Union[str, object] = values.unset, + code_verifier: Union[str, object] = values.unset, ) -> tuple: """ Internal async helper for create operation @@ -219,6 +228,7 @@ async def _create_async( "audience": audience, "refresh_token": refresh_token, "scope": scope, + "code_verifier": code_verifier, } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) @@ -248,6 +258,7 @@ async def create_async( audience: Union[str, object] = values.unset, refresh_token: Union[str, object] = values.unset, scope: Union[str, object] = values.unset, + code_verifier: Union[str, object] = values.unset, ) -> TokenInstance: """ Asynchronously create the TokenInstance @@ -261,6 +272,7 @@ async def create_async( :param audience: The targeted audience uri :param refresh_token: JWT token related to refresh access token. :param scope: The scope of token + :param code_verifier: The PKCE code verifier used to generate the code_challenge in the authorization request. :returns: The created TokenInstance """ @@ -274,6 +286,7 @@ async def create_async( audience=audience, refresh_token=refresh_token, scope=scope, + code_verifier=code_verifier, ) return TokenInstance(self._version, payload) @@ -288,6 +301,7 @@ async def create_with_http_info_async( audience: Union[str, object] = values.unset, refresh_token: Union[str, object] = values.unset, scope: Union[str, object] = values.unset, + code_verifier: Union[str, object] = values.unset, ) -> ApiResponse: """ Asynchronously create the TokenInstance and return response metadata @@ -301,6 +315,7 @@ async def create_with_http_info_async( :param audience: The targeted audience uri :param refresh_token: JWT token related to refresh access token. :param scope: The scope of token + :param code_verifier: The PKCE code verifier used to generate the code_challenge in the authorization request. :returns: ApiResponse with instance, status code, and headers """ @@ -314,6 +329,7 @@ async def create_with_http_info_async( audience=audience, refresh_token=refresh_token, scope=scope, + code_verifier=code_verifier, ) instance = TokenInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) diff --git a/twilio/rest/routes/RoutesBase.py b/twilio/rest/routes/RoutesBase.py index a47d67f093..d156f7c44b 100644 --- a/twilio/rest/routes/RoutesBase.py +++ b/twilio/rest/routes/RoutesBase.py @@ -14,6 +14,7 @@ from twilio.base.domain import Domain from twilio.rest import Client from twilio.rest.routes.v2 import V2 +from twilio.rest.routes.v3 import V3 class RoutesBase(Domain): @@ -26,6 +27,7 @@ def __init__(self, twilio: Client): """ super().__init__(twilio, "https://routes.twilio.com") self._v2: Optional[V2] = None + self._v3: Optional[V3] = None @property def v2(self) -> V2: @@ -36,6 +38,15 @@ def v2(self) -> V2: self._v2 = V2(self) return self._v2 + @property + def v3(self) -> V3: + """ + :returns: Versions v3 of Routes + """ + if self._v3 is None: + self._v3 = V3(self) + return self._v3 + def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/routes/v3/__init__.py b/twilio/rest/routes/v3/__init__.py new file mode 100644 index 0000000000..07d47c0f6f --- /dev/null +++ b/twilio/rest/routes/v3/__init__.py @@ -0,0 +1,43 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Routes + 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 Optional +from twilio.base.version import Version +from twilio.base.domain import Domain +from twilio.rest.routes.v3.phone_number import PhoneNumberList + + +class V3(Version): + + def __init__(self, domain: Domain): + """ + Initialize the V3 version of Routes + + :param domain: The Twilio.routes domain + """ + super().__init__(domain, "v3") + self._phone_numbers: Optional[PhoneNumberList] = None + + @property + def phone_numbers(self) -> PhoneNumberList: + if self._phone_numbers is None: + self._phone_numbers = PhoneNumberList(self) + return self._phone_numbers + + def __repr__(self) -> str: + """ + Provide a friendly representation + :returns: Machine friendly representation + """ + return "<Twilio.Routes.V3>" diff --git a/twilio/rest/routes/v3/phone_number.py b/twilio/rest/routes/v3/phone_number.py new file mode 100644 index 0000000000..c308460ccb --- /dev/null +++ b/twilio/rest/routes/v3/phone_number.py @@ -0,0 +1,521 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Routes + 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 __future__ import annotations + +from datetime import datetime +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 +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class PhoneNumberInstance(InstanceResource): + """ + :ivar phone_number: The phone number in E.164 format + :ivar url: The absolute URL of the resource. + :ivar account_sid: The unique SID identifier of the Account. + :ivar friendly_name: A human readable description of the Inbound Processing Region assignments for this phone number, up to 64 characters. + :ivar voice_region: The Inbound Processing Region used for this phone number for voice. + :ivar messaging_region: The Inbound Processing Region used for this phone number for messaging. + :ivar date_created: The date that this phone number was assigned an Inbound Processing Region, given in ISO 8601 format. + :ivar date_updated: The date that the Inbound Processing Region was updated for this phone number, given in ISO 8601 format. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + phone_number: Optional[str] = None, + ): + super().__init__(version) + + self.phone_number: Optional[str] = payload.get("phoneNumber") + self.url: Optional[str] = payload.get("url") + self.account_sid: Optional[str] = payload.get("accountSid") + self.friendly_name: Optional[str] = payload.get("friendlyName") + self.voice_region: Optional[str] = payload.get("voiceRegion") + self.messaging_region: Optional[str] = payload.get("messagingRegion") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("dateCreated") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("dateUpdated") + ) + + # Only set _solution if path params are provided (not None) + if phone_number is not None: + self._solution = { + "phone_number": phone_number, + } + + self._context: Optional[PhoneNumberContext] = None + + @property + def _proxy(self) -> "PhoneNumberContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: PhoneNumberContext for this PhoneNumberInstance + """ + if self._context is None: + self._context = PhoneNumberContext( + self._version, + phone_number=self._solution["phone_number"], + ) + return self._context + + def fetch(self) -> "PhoneNumberInstance": + """ + Fetch the PhoneNumberInstance + + + :returns: The fetched PhoneNumberInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "PhoneNumberInstance": + """ + Asynchronous coroutine to fetch the PhoneNumberInstance + + + :returns: The fetched PhoneNumberInstance + """ + return await self._proxy.fetch_async() + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the PhoneNumberInstance 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 PhoneNumberInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.fetch_with_http_info_async() + + def update( + self, + voice_region: Union[str, object] = values.unset, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> "PhoneNumberInstance": + """ + Update the PhoneNumberInstance + + :param voice_region: The Inbound Processing Region used for this phone number for voice + :param messaging_region: The Inbound Processing Region used for this phone number for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: The updated PhoneNumberInstance + """ + return self._proxy.update( + voice_region=voice_region, + messaging_region=messaging_region, + friendly_name=friendly_name, + ) + + async def update_async( + self, + voice_region: Union[str, object] = values.unset, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> "PhoneNumberInstance": + """ + Asynchronous coroutine to update the PhoneNumberInstance + + :param voice_region: The Inbound Processing Region used for this phone number for voice + :param messaging_region: The Inbound Processing Region used for this phone number for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: The updated PhoneNumberInstance + """ + return await self._proxy.update_async( + voice_region=voice_region, + messaging_region=messaging_region, + friendly_name=friendly_name, + ) + + def update_with_http_info( + self, + voice_region: Union[str, object] = values.unset, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> ApiResponse: + """ + Update the PhoneNumberInstance with HTTP info + + :param voice_region: The Inbound Processing Region used for this phone number for voice + :param messaging_region: The Inbound Processing Region used for this phone number for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.update_with_http_info( + voice_region=voice_region, + messaging_region=messaging_region, + friendly_name=friendly_name, + ) + + async def update_with_http_info_async( + self, + voice_region: Union[str, object] = values.unset, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to update the PhoneNumberInstance with HTTP info + + :param voice_region: The Inbound Processing Region used for this phone number for voice + :param messaging_region: The Inbound Processing Region used for this phone number for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.update_with_http_info_async( + voice_region=voice_region, + messaging_region=messaging_region, + friendly_name=friendly_name, + ) + + 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 "<Twilio.Routes.V3.PhoneNumberInstance {}>".format(context) + + +class PhoneNumberContext(InstanceContext): + + def __init__(self, version: Version, phone_number: str): + """ + Initialize the PhoneNumberContext + + :param version: Version that contains the resource + :param phone_number: The phone number in E.164 format + """ + super().__init__(version) + + # Path Solution + self._solution = { + "phone_number": phone_number, + } + self._uri = "/PhoneNumbers/{phone_number}".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) -> PhoneNumberInstance: + """ + Fetch the PhoneNumberInstance + + + :returns: The fetched PhoneNumberInstance + """ + payload, _, _ = self._fetch() + return PhoneNumberInstance( + self._version, + payload, + phone_number=self._solution["phone_number"], + ) + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the PhoneNumberInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._fetch() + instance = PhoneNumberInstance( + self._version, + payload, + phone_number=self._solution["phone_number"], + ) + 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) -> PhoneNumberInstance: + """ + Asynchronous coroutine to fetch the PhoneNumberInstance + + + :returns: The fetched PhoneNumberInstance + """ + payload, _, _ = await self._fetch_async() + return PhoneNumberInstance( + self._version, + payload, + phone_number=self._solution["phone_number"], + ) + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to fetch the PhoneNumberInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._fetch_async() + instance = PhoneNumberInstance( + self._version, + payload, + phone_number=self._solution["phone_number"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def _update( + self, + voice_region: Union[str, object] = values.unset, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> tuple: + """ + Internal helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + + data = values.of( + { + "voiceRegion": voice_region, + "messagingRegion": messaging_region, + "friendlyName": friendly_name, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + return self._version.update_with_response_info( + method="POST", uri=self._uri, data=data, headers=headers + ) + + def update( + self, + voice_region: Union[str, object] = values.unset, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> PhoneNumberInstance: + """ + Update the PhoneNumberInstance + + :param voice_region: The Inbound Processing Region used for this phone number for voice + :param messaging_region: The Inbound Processing Region used for this phone number for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: The updated PhoneNumberInstance + """ + payload, _, _ = self._update( + voice_region=voice_region, + messaging_region=messaging_region, + friendly_name=friendly_name, + ) + return PhoneNumberInstance( + self._version, payload, phone_number=self._solution["phone_number"] + ) + + def update_with_http_info( + self, + voice_region: Union[str, object] = values.unset, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> ApiResponse: + """ + Update the PhoneNumberInstance and return response metadata + + :param voice_region: The Inbound Processing Region used for this phone number for voice + :param messaging_region: The Inbound Processing Region used for this phone number for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._update( + voice_region=voice_region, + messaging_region=messaging_region, + friendly_name=friendly_name, + ) + instance = PhoneNumberInstance( + self._version, payload, phone_number=self._solution["phone_number"] + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _update_async( + self, + voice_region: Union[str, object] = values.unset, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> tuple: + """ + Internal async helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + + data = values.of( + { + "voiceRegion": voice_region, + "messagingRegion": messaging_region, + "friendlyName": friendly_name, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + return await self._version.update_with_response_info_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + async def update_async( + self, + voice_region: Union[str, object] = values.unset, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> PhoneNumberInstance: + """ + Asynchronous coroutine to update the PhoneNumberInstance + + :param voice_region: The Inbound Processing Region used for this phone number for voice + :param messaging_region: The Inbound Processing Region used for this phone number for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: The updated PhoneNumberInstance + """ + payload, _, _ = await self._update_async( + voice_region=voice_region, + messaging_region=messaging_region, + friendly_name=friendly_name, + ) + return PhoneNumberInstance( + self._version, payload, phone_number=self._solution["phone_number"] + ) + + async def update_with_http_info_async( + self, + voice_region: Union[str, object] = values.unset, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to update the PhoneNumberInstance and return response metadata + + :param voice_region: The Inbound Processing Region used for this phone number for voice + :param messaging_region: The Inbound Processing Region used for this phone number for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._update_async( + voice_region=voice_region, + messaging_region=messaging_region, + friendly_name=friendly_name, + ) + instance = PhoneNumberInstance( + self._version, payload, phone_number=self._solution["phone_number"] + ) + 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 "<Twilio.Routes.V3.PhoneNumberContext {}>".format(context) + + +class PhoneNumberList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the PhoneNumberList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, phone_number: str) -> PhoneNumberContext: + """ + Constructs a PhoneNumberContext + + :param phone_number: The phone number in E.164 format + """ + return PhoneNumberContext(self._version, phone_number=phone_number) + + def __call__(self, phone_number: str) -> PhoneNumberContext: + """ + Constructs a PhoneNumberContext + + :param phone_number: The phone number in E.164 format + """ + return PhoneNumberContext(self._version, phone_number=phone_number) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "<Twilio.Routes.V3.PhoneNumberList>" diff --git a/twilio/rest/serverless/v1/service/build/__init__.py b/twilio/rest/serverless/v1/service/build/__init__.py index bc54d0b495..01c1856027 100644 --- a/twilio/rest/serverless/v1/service/build/__init__.py +++ b/twilio/rest/serverless/v1/service/build/__init__.py @@ -44,6 +44,7 @@ class Runtime(object): NODE18 = "node18" NODE20 = "node20" NODE22 = "node22" + NODE24 = "node24" class Status(object): BUILDING = "building" diff --git a/twilio/rest/trusthub/v1/__init__.py b/twilio/rest/trusthub/v1/__init__.py index 596c5ea758..cfe702b2ed 100644 --- a/twilio/rest/trusthub/v1/__init__.py +++ b/twilio/rest/trusthub/v1/__init__.py @@ -15,6 +15,16 @@ from typing import Optional from twilio.base.version import Version from twilio.base.domain import Domain +from twilio.rest.trusthub.v1.a2_p_brand_registration import A2PBrandRegistrationList +from twilio.rest.trusthub.v1.a2_p_brand_registration_embedded_session import ( + A2PBrandRegistrationEmbeddedSessionList, +) +from twilio.rest.trusthub.v1.a2_p_campaign_registration import ( + A2PCampaignRegistrationList, +) +from twilio.rest.trusthub.v1.a2_p_campaign_registration_embedded_session import ( + A2PCampaignRegistrationEmbeddedSessionList, +) from twilio.rest.trusthub.v1.compliance_inquiries import ComplianceInquiriesList from twilio.rest.trusthub.v1.compliance_registration_inquiries import ( ComplianceRegistrationInquiriesList, @@ -23,12 +33,18 @@ ComplianceTollfreeInquiriesList, ) from twilio.rest.trusthub.v1.customer_profiles import CustomerProfilesList +from twilio.rest.trusthub.v1.customer_profiles_provisional_copy import ( + CustomerProfilesProvisionalCopyList, +) from twilio.rest.trusthub.v1.end_user import EndUserList from twilio.rest.trusthub.v1.end_user_type import EndUserTypeList from twilio.rest.trusthub.v1.policies import PoliciesList from twilio.rest.trusthub.v1.supporting_document import SupportingDocumentList from twilio.rest.trusthub.v1.supporting_document_type import SupportingDocumentTypeList from twilio.rest.trusthub.v1.trust_products import TrustProductsList +from twilio.rest.trusthub.v1.trust_products_provisional_copy import ( + TrustProductsProvisionalCopyList, +) class V1(Version): @@ -40,6 +56,8 @@ def __init__(self, domain: Domain): :param domain: The Twilio.trusthub domain """ super().__init__(domain, "v1") + self._a2_p_brand_registrations: Optional[A2PBrandRegistrationList] = None + self._a2_p_campaign_registrations: Optional[A2PCampaignRegistrationList] = None self._compliance_inquiries: Optional[ComplianceInquiriesList] = None self._compliance_registration_inquiries: Optional[ ComplianceRegistrationInquiriesList @@ -48,12 +66,62 @@ def __init__(self, domain: Domain): ComplianceTollfreeInquiriesList ] = None self._customer_profiles: Optional[CustomerProfilesList] = None + self._customer_profiles_provisional_copy: Optional[ + CustomerProfilesProvisionalCopyList + ] = None self._end_users: Optional[EndUserList] = None self._end_user_types: Optional[EndUserTypeList] = None self._policies: Optional[PoliciesList] = None self._supporting_documents: Optional[SupportingDocumentList] = None self._supporting_document_types: Optional[SupportingDocumentTypeList] = None self._trust_products: Optional[TrustProductsList] = None + self._trust_products_provisional_copy: Optional[ + TrustProductsProvisionalCopyList + ] = None + + @property + def a2_p_brand_registrations(self) -> A2PBrandRegistrationList: + if self._a2_p_brand_registrations is None: + self._a2_p_brand_registrations = A2PBrandRegistrationList(self) + return self._a2_p_brand_registrations + + def a2_p_brand_registration_embedded_sessions( + self, id: str, a2p_brand_registration_embedded_session_id: str = None + ): + """ + Access the A2PBrandRegistrationEmbeddedSessionList resource + + :param id: The unique identifier for the A2P Brand Registration. + + :param a2p_brand_registration_embedded_session_id: Optional instance ID to directly access A2PBrandRegistrationEmbeddedSessionContext + :returns: A2PBrandRegistrationEmbeddedSessionList instance if a2p_brand_registration_embedded_session_id is None, otherwise A2PBrandRegistrationEmbeddedSessionContext + """ + list_instance = A2PBrandRegistrationEmbeddedSessionList(self, id) + if a2p_brand_registration_embedded_session_id is not None: + return list_instance(a2p_brand_registration_embedded_session_id) + return list_instance + + @property + def a2_p_campaign_registrations(self) -> A2PCampaignRegistrationList: + if self._a2_p_campaign_registrations is None: + self._a2_p_campaign_registrations = A2PCampaignRegistrationList(self) + return self._a2_p_campaign_registrations + + def a2_p_campaign_registration_embedded_sessions( + self, id: str, a2p_campaign_registration_embedded_session_id: str = None + ): + """ + Access the A2PCampaignRegistrationEmbeddedSessionList resource + + :param id: The unique identifier for the A2P Campaign Registration. This can be either an A2P Campaign Registration ID (formatted `tri1.us1.account.AC.../registration.BU...`) returned from the Initialize Campaign endpoint, or a Messaging Service SID (`MG...`) for campaigns created outside the embeddable. + + :param a2p_campaign_registration_embedded_session_id: Optional instance ID to directly access A2PCampaignRegistrationEmbeddedSessionContext + :returns: A2PCampaignRegistrationEmbeddedSessionList instance if a2p_campaign_registration_embedded_session_id is None, otherwise A2PCampaignRegistrationEmbeddedSessionContext + """ + list_instance = A2PCampaignRegistrationEmbeddedSessionList(self, id) + if a2p_campaign_registration_embedded_session_id is not None: + return list_instance(a2p_campaign_registration_embedded_session_id) + return list_instance @property def compliance_inquiries(self) -> ComplianceInquiriesList: @@ -81,6 +149,14 @@ def customer_profiles(self) -> CustomerProfilesList: self._customer_profiles = CustomerProfilesList(self) return self._customer_profiles + @property + def customer_profiles_provisional_copy(self) -> CustomerProfilesProvisionalCopyList: + if self._customer_profiles_provisional_copy is None: + self._customer_profiles_provisional_copy = ( + CustomerProfilesProvisionalCopyList(self) + ) + return self._customer_profiles_provisional_copy + @property def end_users(self) -> EndUserList: if self._end_users is None: @@ -117,6 +193,14 @@ def trust_products(self) -> TrustProductsList: self._trust_products = TrustProductsList(self) return self._trust_products + @property + def trust_products_provisional_copy(self) -> TrustProductsProvisionalCopyList: + if self._trust_products_provisional_copy is None: + self._trust_products_provisional_copy = TrustProductsProvisionalCopyList( + self + ) + return self._trust_products_provisional_copy + def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/trusthub/v1/a2_p_brand_registration.py b/twilio/rest/trusthub/v1/a2_p_brand_registration.py new file mode 100644 index 0000000000..de712d4fad --- /dev/null +++ b/twilio/rest/trusthub/v1/a2_p_brand_registration.py @@ -0,0 +1,436 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Trusthub + 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 A2PBrandRegistrationInstance(InstanceResource): + + class TrusthubV1A2pBrandRegistrationRequest(object): + """ + :ivar brand_type: The type of brand being registered. + :ivar theme_set_id: Theme ID for styling the inquiry form. + :ivar friendly_name: A human-readable name for the brand registration. + :ivar notification_email: The email address to receive notifications about the registration. + :ivar business_name: The legal name of the business. + :ivar business_registration_authority: The authority with which the business is registered. + :ivar business_registration_number: The business registration number (e.g., EIN, CBN, ACN). Maximum 21 characters. + :ivar business_industry: The industry of the business. + :ivar business_website: The business website URL (must use https://). + :ivar business_type: The type of business entity. + :ivar business_stock_symbol: The stock symbol for publicly traded companies. + :ivar business_stock_exchange: The stock exchange where the business is listed. + :ivar business_tax_exempt_status: Nonprofit/political organization tax-exempt status per the U.S. tax code (e.g. 501c3, 501c1, 527). A value of 527 (political organization) requires a Campaign Verify token in brandExternalVettingToken. + :ivar brand_external_vetting_token: Campaign Verify token for externally vetted brands. + :ivar business_street_address: The street address of the business. + :ivar business_street_address2: Additional street address information. + :ivar business_city: The city of the business. + :ivar business_state_province_region: The state, province, or region of the business. + :ivar business_postal_code: The postal code of the business. + :ivar business_country: The two-letter ISO country code of the business. + :ivar business_contact_first_name: The first name of the business contact. + :ivar business_contact_last_name: The last name of the business contact. + :ivar business_contact_email: The email address of the business contact. + :ivar business_contact_phone: The phone number of the business contact in E.164 format. + :ivar authorized_contact_verification_email: The email address for authorized contact verification. + :ivar authorized_contact_mobile_phone_number_e164: The mobile phone number for authorized contact in E.164 format. + :ivar is_test: Whether this is a test brand registration. + :ivar skip_automatic_sec_vet: Whether to skip automatic secondary vetting. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.brand_type: Optional["A2PBrandRegistrationInstance.str"] = payload.get( + "brandType" + ) + self.theme_set_id: Optional[str] = payload.get("themeSetId") + self.friendly_name: Optional[str] = payload.get("friendlyName") + self.notification_email: Optional[str] = payload.get("notificationEmail") + self.business_name: Optional[str] = payload.get("businessName") + self.business_registration_authority: Optional[str] = payload.get( + "businessRegistrationAuthority" + ) + self.business_registration_number: Optional[str] = payload.get( + "businessRegistrationNumber" + ) + self.business_industry: Optional[str] = payload.get("businessIndustry") + self.business_website: Optional[str] = payload.get("businessWebsite") + self.business_type: Optional[str] = payload.get("businessType") + self.business_stock_symbol: Optional[str] = payload.get( + "businessStockSymbol" + ) + self.business_stock_exchange: Optional[str] = payload.get( + "businessStockExchange" + ) + self.business_tax_exempt_status: Optional[str] = payload.get( + "businessTaxExemptStatus" + ) + self.brand_external_vetting_token: Optional[str] = payload.get( + "brandExternalVettingToken" + ) + self.business_street_address: Optional[str] = payload.get( + "businessStreetAddress" + ) + self.business_street_address2: Optional[str] = payload.get( + "businessStreetAddress2" + ) + self.business_city: Optional[str] = payload.get("businessCity") + self.business_state_province_region: Optional[str] = payload.get( + "businessStateProvinceRegion" + ) + self.business_postal_code: Optional[str] = payload.get("businessPostalCode") + self.business_country: Optional[str] = payload.get("businessCountry") + self.business_contact_first_name: Optional[str] = payload.get( + "businessContactFirstName" + ) + self.business_contact_last_name: Optional[str] = payload.get( + "businessContactLastName" + ) + self.business_contact_email: Optional[str] = payload.get( + "businessContactEmail" + ) + self.business_contact_phone: Optional[str] = payload.get( + "businessContactPhone" + ) + self.authorized_contact_verification_email: Optional[str] = payload.get( + "authorizedContactVerificationEmail" + ) + self.authorized_contact_mobile_phone_number_e164: Optional[str] = ( + payload.get("authorizedContactMobilePhoneNumberE164") + ) + self.is_test: Optional[bool] = payload.get("isTest") + self.skip_automatic_sec_vet: Optional[bool] = payload.get( + "skipAutomaticSecVet" + ) + + def to_dict(self): + return { + "brandType": self.brand_type, + "themeSetId": self.theme_set_id, + "friendlyName": self.friendly_name, + "notificationEmail": self.notification_email, + "businessName": self.business_name, + "businessRegistrationAuthority": self.business_registration_authority, + "businessRegistrationNumber": self.business_registration_number, + "businessIndustry": self.business_industry, + "businessWebsite": self.business_website, + "businessType": self.business_type, + "businessStockSymbol": self.business_stock_symbol, + "businessStockExchange": self.business_stock_exchange, + "businessTaxExemptStatus": self.business_tax_exempt_status, + "brandExternalVettingToken": self.brand_external_vetting_token, + "businessStreetAddress": self.business_street_address, + "businessStreetAddress2": self.business_street_address2, + "businessCity": self.business_city, + "businessStateProvinceRegion": self.business_state_province_region, + "businessPostalCode": self.business_postal_code, + "businessCountry": self.business_country, + "businessContactFirstName": self.business_contact_first_name, + "businessContactLastName": self.business_contact_last_name, + "businessContactEmail": self.business_contact_email, + "businessContactPhone": self.business_contact_phone, + "authorizedContactVerificationEmail": self.authorized_contact_verification_email, + "authorizedContactMobilePhoneNumberE164": self.authorized_contact_mobile_phone_number_e164, + "isTest": self.is_test, + "skipAutomaticSecVet": self.skip_automatic_sec_vet, + } + + """ + :ivar id: The unique A2P Brand or Campaign Registration identifier, formatted as `tri1.us1.account.AC.../registration.BU...`. + :ivar session_id: The Persona inquiry ID used to start the embedded compliance session. + :ivar session_token: The Persona session token for embedding the compliance UI. Expires in 24 hours. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.id: Optional[str] = payload.get("id") + self.session_id: Optional[str] = payload.get("sessionId") + self.session_token: Optional[str] = payload.get("sessionToken") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "<Twilio.Trusthub.V1.A2PBrandRegistrationInstance>" + + +class A2PBrandRegistrationList(ListResource): + + class TrusthubV1A2pBrandRegistrationRequest(object): + """ + :ivar brand_type: The type of brand being registered. + :ivar theme_set_id: Theme ID for styling the inquiry form. + :ivar friendly_name: A human-readable name for the brand registration. + :ivar notification_email: The email address to receive notifications about the registration. + :ivar business_name: The legal name of the business. + :ivar business_registration_authority: The authority with which the business is registered. + :ivar business_registration_number: The business registration number (e.g., EIN, CBN, ACN). Maximum 21 characters. + :ivar business_industry: The industry of the business. + :ivar business_website: The business website URL (must use https://). + :ivar business_type: The type of business entity. + :ivar business_stock_symbol: The stock symbol for publicly traded companies. + :ivar business_stock_exchange: The stock exchange where the business is listed. + :ivar business_tax_exempt_status: Nonprofit/political organization tax-exempt status per the U.S. tax code (e.g. 501c3, 501c1, 527). A value of 527 (political organization) requires a Campaign Verify token in brandExternalVettingToken. + :ivar brand_external_vetting_token: Campaign Verify token for externally vetted brands. + :ivar business_street_address: The street address of the business. + :ivar business_street_address2: Additional street address information. + :ivar business_city: The city of the business. + :ivar business_state_province_region: The state, province, or region of the business. + :ivar business_postal_code: The postal code of the business. + :ivar business_country: The two-letter ISO country code of the business. + :ivar business_contact_first_name: The first name of the business contact. + :ivar business_contact_last_name: The last name of the business contact. + :ivar business_contact_email: The email address of the business contact. + :ivar business_contact_phone: The phone number of the business contact in E.164 format. + :ivar authorized_contact_verification_email: The email address for authorized contact verification. + :ivar authorized_contact_mobile_phone_number_e164: The mobile phone number for authorized contact in E.164 format. + :ivar is_test: Whether this is a test brand registration. + :ivar skip_automatic_sec_vet: Whether to skip automatic secondary vetting. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.brand_type: Optional["A2PBrandRegistrationInstance.str"] = payload.get( + "brandType" + ) + self.theme_set_id: Optional[str] = payload.get("themeSetId") + self.friendly_name: Optional[str] = payload.get("friendlyName") + self.notification_email: Optional[str] = payload.get("notificationEmail") + self.business_name: Optional[str] = payload.get("businessName") + self.business_registration_authority: Optional[str] = payload.get( + "businessRegistrationAuthority" + ) + self.business_registration_number: Optional[str] = payload.get( + "businessRegistrationNumber" + ) + self.business_industry: Optional[str] = payload.get("businessIndustry") + self.business_website: Optional[str] = payload.get("businessWebsite") + self.business_type: Optional[str] = payload.get("businessType") + self.business_stock_symbol: Optional[str] = payload.get( + "businessStockSymbol" + ) + self.business_stock_exchange: Optional[str] = payload.get( + "businessStockExchange" + ) + self.business_tax_exempt_status: Optional[str] = payload.get( + "businessTaxExemptStatus" + ) + self.brand_external_vetting_token: Optional[str] = payload.get( + "brandExternalVettingToken" + ) + self.business_street_address: Optional[str] = payload.get( + "businessStreetAddress" + ) + self.business_street_address2: Optional[str] = payload.get( + "businessStreetAddress2" + ) + self.business_city: Optional[str] = payload.get("businessCity") + self.business_state_province_region: Optional[str] = payload.get( + "businessStateProvinceRegion" + ) + self.business_postal_code: Optional[str] = payload.get("businessPostalCode") + self.business_country: Optional[str] = payload.get("businessCountry") + self.business_contact_first_name: Optional[str] = payload.get( + "businessContactFirstName" + ) + self.business_contact_last_name: Optional[str] = payload.get( + "businessContactLastName" + ) + self.business_contact_email: Optional[str] = payload.get( + "businessContactEmail" + ) + self.business_contact_phone: Optional[str] = payload.get( + "businessContactPhone" + ) + self.authorized_contact_verification_email: Optional[str] = payload.get( + "authorizedContactVerificationEmail" + ) + self.authorized_contact_mobile_phone_number_e164: Optional[str] = ( + payload.get("authorizedContactMobilePhoneNumberE164") + ) + self.is_test: Optional[bool] = payload.get("isTest") + self.skip_automatic_sec_vet: Optional[bool] = payload.get( + "skipAutomaticSecVet" + ) + + def to_dict(self): + return { + "brandType": self.brand_type, + "themeSetId": self.theme_set_id, + "friendlyName": self.friendly_name, + "notificationEmail": self.notification_email, + "businessName": self.business_name, + "businessRegistrationAuthority": self.business_registration_authority, + "businessRegistrationNumber": self.business_registration_number, + "businessIndustry": self.business_industry, + "businessWebsite": self.business_website, + "businessType": self.business_type, + "businessStockSymbol": self.business_stock_symbol, + "businessStockExchange": self.business_stock_exchange, + "businessTaxExemptStatus": self.business_tax_exempt_status, + "brandExternalVettingToken": self.brand_external_vetting_token, + "businessStreetAddress": self.business_street_address, + "businessStreetAddress2": self.business_street_address2, + "businessCity": self.business_city, + "businessStateProvinceRegion": self.business_state_province_region, + "businessPostalCode": self.business_postal_code, + "businessCountry": self.business_country, + "businessContactFirstName": self.business_contact_first_name, + "businessContactLastName": self.business_contact_last_name, + "businessContactEmail": self.business_contact_email, + "businessContactPhone": self.business_contact_phone, + "authorizedContactVerificationEmail": self.authorized_contact_verification_email, + "authorizedContactMobilePhoneNumberE164": self.authorized_contact_mobile_phone_number_e164, + "isTest": self.is_test, + "skipAutomaticSecVet": self.skip_automatic_sec_vet, + } + + def __init__(self, version: Version): + """ + Initialize the A2PBrandRegistrationList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/A2PBrandRegistrations" + + def _create( + self, + trusthub_v1_a2p_brand_registration_request: TrusthubV1A2pBrandRegistrationRequest, + ) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = trusthub_v1_a2p_brand_registration_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, + trusthub_v1_a2p_brand_registration_request: TrusthubV1A2pBrandRegistrationRequest, + ) -> A2PBrandRegistrationInstance: + """ + Create the A2PBrandRegistrationInstance + + :param trusthub_v1_a2p_brand_registration_request: + + :returns: The created A2PBrandRegistrationInstance + """ + payload, _, _ = self._create( + trusthub_v1_a2p_brand_registration_request=trusthub_v1_a2p_brand_registration_request + ) + return A2PBrandRegistrationInstance(self._version, payload) + + def create_with_http_info( + self, + trusthub_v1_a2p_brand_registration_request: TrusthubV1A2pBrandRegistrationRequest, + ) -> ApiResponse: + """ + Create the A2PBrandRegistrationInstance and return response metadata + + :param trusthub_v1_a2p_brand_registration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create( + trusthub_v1_a2p_brand_registration_request=trusthub_v1_a2p_brand_registration_request + ) + instance = A2PBrandRegistrationInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async( + self, + trusthub_v1_a2p_brand_registration_request: TrusthubV1A2pBrandRegistrationRequest, + ) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = trusthub_v1_a2p_brand_registration_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, + trusthub_v1_a2p_brand_registration_request: TrusthubV1A2pBrandRegistrationRequest, + ) -> A2PBrandRegistrationInstance: + """ + Asynchronously create the A2PBrandRegistrationInstance + + :param trusthub_v1_a2p_brand_registration_request: + + :returns: The created A2PBrandRegistrationInstance + """ + payload, _, _ = await self._create_async( + trusthub_v1_a2p_brand_registration_request=trusthub_v1_a2p_brand_registration_request + ) + return A2PBrandRegistrationInstance(self._version, payload) + + async def create_with_http_info_async( + self, + trusthub_v1_a2p_brand_registration_request: TrusthubV1A2pBrandRegistrationRequest, + ) -> ApiResponse: + """ + Asynchronously create the A2PBrandRegistrationInstance and return response metadata + + :param trusthub_v1_a2p_brand_registration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async( + trusthub_v1_a2p_brand_registration_request=trusthub_v1_a2p_brand_registration_request + ) + instance = A2PBrandRegistrationInstance(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 "<Twilio.Trusthub.V1.A2PBrandRegistrationList>" diff --git a/twilio/rest/trusthub/v1/a2_p_brand_registration_embedded_session.py b/twilio/rest/trusthub/v1/a2_p_brand_registration_embedded_session.py new file mode 100644 index 0000000000..6f69a8534c --- /dev/null +++ b/twilio/rest/trusthub/v1/a2_p_brand_registration_embedded_session.py @@ -0,0 +1,164 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Trusthub + 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 A2PBrandRegistrationEmbeddedSessionInstance(InstanceResource): + """ + :ivar id: The unique A2P Brand or Campaign Registration identifier, formatted as `tri1.us1.account.AC.../registration.BU...`. + :ivar session_id: The Persona inquiry ID used to start the embedded compliance session. + :ivar session_token: The Persona session token for embedding the compliance UI. Expires in 24 hours. + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], id: Optional[str] = None + ): + super().__init__(version) + + self.id: Optional[str] = payload.get("id") + self.session_id: Optional[str] = payload.get("sessionId") + self.session_token: Optional[str] = payload.get("sessionToken") + + self._solution = { + "id": id or self.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 "<Twilio.Trusthub.V1.A2PBrandRegistrationEmbeddedSessionInstance {}>".format( + context + ) + + +class A2PBrandRegistrationEmbeddedSessionList(ListResource): + + def __init__(self, version: Version, id: str): + """ + Initialize the A2PBrandRegistrationEmbeddedSessionList + + :param version: Version that contains the resource + :param id: The unique identifier for the A2P Brand Registration. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id": id, + } + self._uri = "/A2PBrandRegistrations/{id}/EmbeddedSessions".format( + **self._solution + ) + + 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) -> A2PBrandRegistrationEmbeddedSessionInstance: + """ + Create the A2PBrandRegistrationEmbeddedSessionInstance + + + :returns: The created A2PBrandRegistrationEmbeddedSessionInstance + """ + payload, _, _ = self._create() + return A2PBrandRegistrationEmbeddedSessionInstance( + self._version, payload, id=self._solution["id"] + ) + + def create_with_http_info(self) -> ApiResponse: + """ + Create the A2PBrandRegistrationEmbeddedSessionInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create() + instance = A2PBrandRegistrationEmbeddedSessionInstance( + self._version, payload, id=self._solution["id"] + ) + 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) -> A2PBrandRegistrationEmbeddedSessionInstance: + """ + Asynchronously create the A2PBrandRegistrationEmbeddedSessionInstance + + + :returns: The created A2PBrandRegistrationEmbeddedSessionInstance + """ + payload, _, _ = await self._create_async() + return A2PBrandRegistrationEmbeddedSessionInstance( + self._version, payload, id=self._solution["id"] + ) + + async def create_with_http_info_async(self) -> ApiResponse: + """ + Asynchronously create the A2PBrandRegistrationEmbeddedSessionInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async() + instance = A2PBrandRegistrationEmbeddedSessionInstance( + self._version, payload, id=self._solution["id"] + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "<Twilio.Trusthub.V1.A2PBrandRegistrationEmbeddedSessionList>" diff --git a/twilio/rest/trusthub/v1/a2_p_campaign_registration.py b/twilio/rest/trusthub/v1/a2_p_campaign_registration.py new file mode 100644 index 0000000000..b3f0dd160b --- /dev/null +++ b/twilio/rest/trusthub/v1/a2_p_campaign_registration.py @@ -0,0 +1,402 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Trusthub + 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 A2PCampaignRegistrationInstance(InstanceResource): + + class TrusthubV1A2pCampaignRegistrationRequest(object): + """ + :ivar a2p_brand_registration_sid: The legacy Twilio A2P Brand SID (BN-prefixed) for the brand this campaign is registered under. This is a different identifier from the `id` returned by the Initialize Brand endpoint (which is formatted as `tri1.us1.account.AC.../registration.BU...`). Retrieve the BN brand SID via [GET /v1/a2p/BrandRegistrations/{Sid}](https://www.twilio.com/docs/messaging/api/brand-registration-resource) on `messaging.twilio.com`. + :ivar messaging_service_sid: The SID of the Messaging Service. + :ivar theme_set_id: Theme ID for styling the inquiry form. + :ivar use_case_categories: The categories of the messaging use case. + :ivar use_case_description: A description of the messaging use case. + :ivar use_case_sample_message1: A sample message for the use case. + :ivar use_case_sample_message2: A second sample message for the use case. + :ivar use_case_sample_message3: A third sample message for the use case. + :ivar use_case_sample_message4: A fourth sample message for the use case. + :ivar use_case_sample_message5: A fifth sample message for the use case. + :ivar use_case_opt_in_types: The opt-in methods for the use case. + :ivar use_case_opt_in_description: A description of the opt-in process. + :ivar has_embedded_links: Whether messages will contain embedded links. + :ivar has_embedded_phone: Whether messages will contain embedded phone numbers. + :ivar embedded_url_sample: A sample URL that will be embedded in messages (must use https://). + :ivar direct_lending: Whether the campaign involves direct lending. + :ivar age_gated: Whether the content is age-gated. + :ivar privacy_policy_url: The URL to the privacy policy. + :ivar terms_and_conditions_url: The URL to the terms and conditions. + :ivar opt_in_keywords: Keywords users can text to opt in. + :ivar opt_in_message_sample: A sample opt-in confirmation message. + :ivar opt_out_keywords: Keywords users can text to opt out. + :ivar opt_out_message_sample: A sample opt-out confirmation message. + :ivar help_keywords: Keywords users can text for help. + :ivar help_message_sample: A sample help message. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.a2p_brand_registration_sid: Optional[str] = payload.get( + "a2pBrandRegistrationSid" + ) + self.messaging_service_sid: Optional[str] = payload.get( + "messagingServiceSid" + ) + self.theme_set_id: Optional[str] = payload.get("themeSetId") + self.use_case_categories: Optional[List[str]] = payload.get( + "useCaseCategories" + ) + self.use_case_description: Optional[str] = payload.get("useCaseDescription") + self.use_case_sample_message1: Optional[str] = payload.get( + "useCaseSampleMessage1" + ) + self.use_case_sample_message2: Optional[str] = payload.get( + "useCaseSampleMessage2" + ) + self.use_case_sample_message3: Optional[str] = payload.get( + "useCaseSampleMessage3" + ) + self.use_case_sample_message4: Optional[str] = payload.get( + "useCaseSampleMessage4" + ) + self.use_case_sample_message5: Optional[str] = payload.get( + "useCaseSampleMessage5" + ) + self.use_case_opt_in_types: Optional[List[str]] = payload.get( + "useCaseOptInTypes" + ) + self.use_case_opt_in_description: Optional[str] = payload.get( + "useCaseOptInDescription" + ) + self.has_embedded_links: Optional[bool] = payload.get("hasEmbeddedLinks") + self.has_embedded_phone: Optional[bool] = payload.get("hasEmbeddedPhone") + self.embedded_url_sample: Optional[str] = payload.get("embeddedUrlSample") + self.direct_lending: Optional[bool] = payload.get("directLending") + self.age_gated: Optional[bool] = payload.get("ageGated") + self.privacy_policy_url: Optional[str] = payload.get("privacyPolicyUrl") + self.terms_and_conditions_url: Optional[str] = payload.get( + "termsAndConditionsUrl" + ) + self.opt_in_keywords: Optional[List[str]] = payload.get("optInKeywords") + self.opt_in_message_sample: Optional[str] = payload.get( + "optInMessageSample" + ) + self.opt_out_keywords: Optional[List[str]] = payload.get("optOutKeywords") + self.opt_out_message_sample: Optional[str] = payload.get( + "optOutMessageSample" + ) + self.help_keywords: Optional[List[str]] = payload.get("helpKeywords") + self.help_message_sample: Optional[str] = payload.get("helpMessageSample") + + def to_dict(self): + return { + "a2pBrandRegistrationSid": self.a2p_brand_registration_sid, + "messagingServiceSid": self.messaging_service_sid, + "themeSetId": self.theme_set_id, + "useCaseCategories": self.use_case_categories, + "useCaseDescription": self.use_case_description, + "useCaseSampleMessage1": self.use_case_sample_message1, + "useCaseSampleMessage2": self.use_case_sample_message2, + "useCaseSampleMessage3": self.use_case_sample_message3, + "useCaseSampleMessage4": self.use_case_sample_message4, + "useCaseSampleMessage5": self.use_case_sample_message5, + "useCaseOptInTypes": self.use_case_opt_in_types, + "useCaseOptInDescription": self.use_case_opt_in_description, + "hasEmbeddedLinks": self.has_embedded_links, + "hasEmbeddedPhone": self.has_embedded_phone, + "embeddedUrlSample": self.embedded_url_sample, + "directLending": self.direct_lending, + "ageGated": self.age_gated, + "privacyPolicyUrl": self.privacy_policy_url, + "termsAndConditionsUrl": self.terms_and_conditions_url, + "optInKeywords": self.opt_in_keywords, + "optInMessageSample": self.opt_in_message_sample, + "optOutKeywords": self.opt_out_keywords, + "optOutMessageSample": self.opt_out_message_sample, + "helpKeywords": self.help_keywords, + "helpMessageSample": self.help_message_sample, + } + + """ + :ivar id: The unique A2P Brand or Campaign Registration identifier, formatted as `tri1.us1.account.AC.../registration.BU...`. + :ivar session_id: The Persona inquiry ID used to start the embedded compliance session. + :ivar session_token: The Persona session token for embedding the compliance UI. Expires in 24 hours. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.id: Optional[str] = payload.get("id") + self.session_id: Optional[str] = payload.get("sessionId") + self.session_token: Optional[str] = payload.get("sessionToken") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "<Twilio.Trusthub.V1.A2PCampaignRegistrationInstance>" + + +class A2PCampaignRegistrationList(ListResource): + + class TrusthubV1A2pCampaignRegistrationRequest(object): + """ + :ivar a2p_brand_registration_sid: The legacy Twilio A2P Brand SID (BN-prefixed) for the brand this campaign is registered under. This is a different identifier from the `id` returned by the Initialize Brand endpoint (which is formatted as `tri1.us1.account.AC.../registration.BU...`). Retrieve the BN brand SID via [GET /v1/a2p/BrandRegistrations/{Sid}](https://www.twilio.com/docs/messaging/api/brand-registration-resource) on `messaging.twilio.com`. + :ivar messaging_service_sid: The SID of the Messaging Service. + :ivar theme_set_id: Theme ID for styling the inquiry form. + :ivar use_case_categories: The categories of the messaging use case. + :ivar use_case_description: A description of the messaging use case. + :ivar use_case_sample_message1: A sample message for the use case. + :ivar use_case_sample_message2: A second sample message for the use case. + :ivar use_case_sample_message3: A third sample message for the use case. + :ivar use_case_sample_message4: A fourth sample message for the use case. + :ivar use_case_sample_message5: A fifth sample message for the use case. + :ivar use_case_opt_in_types: The opt-in methods for the use case. + :ivar use_case_opt_in_description: A description of the opt-in process. + :ivar has_embedded_links: Whether messages will contain embedded links. + :ivar has_embedded_phone: Whether messages will contain embedded phone numbers. + :ivar embedded_url_sample: A sample URL that will be embedded in messages (must use https://). + :ivar direct_lending: Whether the campaign involves direct lending. + :ivar age_gated: Whether the content is age-gated. + :ivar privacy_policy_url: The URL to the privacy policy. + :ivar terms_and_conditions_url: The URL to the terms and conditions. + :ivar opt_in_keywords: Keywords users can text to opt in. + :ivar opt_in_message_sample: A sample opt-in confirmation message. + :ivar opt_out_keywords: Keywords users can text to opt out. + :ivar opt_out_message_sample: A sample opt-out confirmation message. + :ivar help_keywords: Keywords users can text for help. + :ivar help_message_sample: A sample help message. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.a2p_brand_registration_sid: Optional[str] = payload.get( + "a2pBrandRegistrationSid" + ) + self.messaging_service_sid: Optional[str] = payload.get( + "messagingServiceSid" + ) + self.theme_set_id: Optional[str] = payload.get("themeSetId") + self.use_case_categories: Optional[List[str]] = payload.get( + "useCaseCategories" + ) + self.use_case_description: Optional[str] = payload.get("useCaseDescription") + self.use_case_sample_message1: Optional[str] = payload.get( + "useCaseSampleMessage1" + ) + self.use_case_sample_message2: Optional[str] = payload.get( + "useCaseSampleMessage2" + ) + self.use_case_sample_message3: Optional[str] = payload.get( + "useCaseSampleMessage3" + ) + self.use_case_sample_message4: Optional[str] = payload.get( + "useCaseSampleMessage4" + ) + self.use_case_sample_message5: Optional[str] = payload.get( + "useCaseSampleMessage5" + ) + self.use_case_opt_in_types: Optional[List[str]] = payload.get( + "useCaseOptInTypes" + ) + self.use_case_opt_in_description: Optional[str] = payload.get( + "useCaseOptInDescription" + ) + self.has_embedded_links: Optional[bool] = payload.get("hasEmbeddedLinks") + self.has_embedded_phone: Optional[bool] = payload.get("hasEmbeddedPhone") + self.embedded_url_sample: Optional[str] = payload.get("embeddedUrlSample") + self.direct_lending: Optional[bool] = payload.get("directLending") + self.age_gated: Optional[bool] = payload.get("ageGated") + self.privacy_policy_url: Optional[str] = payload.get("privacyPolicyUrl") + self.terms_and_conditions_url: Optional[str] = payload.get( + "termsAndConditionsUrl" + ) + self.opt_in_keywords: Optional[List[str]] = payload.get("optInKeywords") + self.opt_in_message_sample: Optional[str] = payload.get( + "optInMessageSample" + ) + self.opt_out_keywords: Optional[List[str]] = payload.get("optOutKeywords") + self.opt_out_message_sample: Optional[str] = payload.get( + "optOutMessageSample" + ) + self.help_keywords: Optional[List[str]] = payload.get("helpKeywords") + self.help_message_sample: Optional[str] = payload.get("helpMessageSample") + + def to_dict(self): + return { + "a2pBrandRegistrationSid": self.a2p_brand_registration_sid, + "messagingServiceSid": self.messaging_service_sid, + "themeSetId": self.theme_set_id, + "useCaseCategories": self.use_case_categories, + "useCaseDescription": self.use_case_description, + "useCaseSampleMessage1": self.use_case_sample_message1, + "useCaseSampleMessage2": self.use_case_sample_message2, + "useCaseSampleMessage3": self.use_case_sample_message3, + "useCaseSampleMessage4": self.use_case_sample_message4, + "useCaseSampleMessage5": self.use_case_sample_message5, + "useCaseOptInTypes": self.use_case_opt_in_types, + "useCaseOptInDescription": self.use_case_opt_in_description, + "hasEmbeddedLinks": self.has_embedded_links, + "hasEmbeddedPhone": self.has_embedded_phone, + "embeddedUrlSample": self.embedded_url_sample, + "directLending": self.direct_lending, + "ageGated": self.age_gated, + "privacyPolicyUrl": self.privacy_policy_url, + "termsAndConditionsUrl": self.terms_and_conditions_url, + "optInKeywords": self.opt_in_keywords, + "optInMessageSample": self.opt_in_message_sample, + "optOutKeywords": self.opt_out_keywords, + "optOutMessageSample": self.opt_out_message_sample, + "helpKeywords": self.help_keywords, + "helpMessageSample": self.help_message_sample, + } + + def __init__(self, version: Version): + """ + Initialize the A2PCampaignRegistrationList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/A2PCampaignRegistrations" + + def _create( + self, + trusthub_v1_a2p_campaign_registration_request: TrusthubV1A2pCampaignRegistrationRequest, + ) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = trusthub_v1_a2p_campaign_registration_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, + trusthub_v1_a2p_campaign_registration_request: TrusthubV1A2pCampaignRegistrationRequest, + ) -> A2PCampaignRegistrationInstance: + """ + Create the A2PCampaignRegistrationInstance + + :param trusthub_v1_a2p_campaign_registration_request: + + :returns: The created A2PCampaignRegistrationInstance + """ + payload, _, _ = self._create( + trusthub_v1_a2p_campaign_registration_request=trusthub_v1_a2p_campaign_registration_request + ) + return A2PCampaignRegistrationInstance(self._version, payload) + + def create_with_http_info( + self, + trusthub_v1_a2p_campaign_registration_request: TrusthubV1A2pCampaignRegistrationRequest, + ) -> ApiResponse: + """ + Create the A2PCampaignRegistrationInstance and return response metadata + + :param trusthub_v1_a2p_campaign_registration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create( + trusthub_v1_a2p_campaign_registration_request=trusthub_v1_a2p_campaign_registration_request + ) + instance = A2PCampaignRegistrationInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async( + self, + trusthub_v1_a2p_campaign_registration_request: TrusthubV1A2pCampaignRegistrationRequest, + ) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = trusthub_v1_a2p_campaign_registration_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, + trusthub_v1_a2p_campaign_registration_request: TrusthubV1A2pCampaignRegistrationRequest, + ) -> A2PCampaignRegistrationInstance: + """ + Asynchronously create the A2PCampaignRegistrationInstance + + :param trusthub_v1_a2p_campaign_registration_request: + + :returns: The created A2PCampaignRegistrationInstance + """ + payload, _, _ = await self._create_async( + trusthub_v1_a2p_campaign_registration_request=trusthub_v1_a2p_campaign_registration_request + ) + return A2PCampaignRegistrationInstance(self._version, payload) + + async def create_with_http_info_async( + self, + trusthub_v1_a2p_campaign_registration_request: TrusthubV1A2pCampaignRegistrationRequest, + ) -> ApiResponse: + """ + Asynchronously create the A2PCampaignRegistrationInstance and return response metadata + + :param trusthub_v1_a2p_campaign_registration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async( + trusthub_v1_a2p_campaign_registration_request=trusthub_v1_a2p_campaign_registration_request + ) + instance = A2PCampaignRegistrationInstance(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 "<Twilio.Trusthub.V1.A2PCampaignRegistrationList>" diff --git a/twilio/rest/trusthub/v1/a2_p_campaign_registration_embedded_session.py b/twilio/rest/trusthub/v1/a2_p_campaign_registration_embedded_session.py new file mode 100644 index 0000000000..ea8b150b69 --- /dev/null +++ b/twilio/rest/trusthub/v1/a2_p_campaign_registration_embedded_session.py @@ -0,0 +1,164 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Trusthub + 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 A2PCampaignRegistrationEmbeddedSessionInstance(InstanceResource): + """ + :ivar id: The unique A2P Brand or Campaign Registration identifier, formatted as `tri1.us1.account.AC.../registration.BU...`. + :ivar session_id: The Persona inquiry ID used to start the embedded compliance session. + :ivar session_token: The Persona session token for embedding the compliance UI. Expires in 24 hours. + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], id: Optional[str] = None + ): + super().__init__(version) + + self.id: Optional[str] = payload.get("id") + self.session_id: Optional[str] = payload.get("sessionId") + self.session_token: Optional[str] = payload.get("sessionToken") + + self._solution = { + "id": id or self.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 "<Twilio.Trusthub.V1.A2PCampaignRegistrationEmbeddedSessionInstance {}>".format( + context + ) + + +class A2PCampaignRegistrationEmbeddedSessionList(ListResource): + + def __init__(self, version: Version, id: str): + """ + Initialize the A2PCampaignRegistrationEmbeddedSessionList + + :param version: Version that contains the resource + :param id: The unique identifier for the A2P Campaign Registration. This can be either an A2P Campaign Registration ID (formatted `tri1.us1.account.AC.../registration.BU...`) returned from the Initialize Campaign endpoint, or a Messaging Service SID (`MG...`) for campaigns created outside the embeddable. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id": id, + } + self._uri = "/A2PCampaignRegistrations/{id}/EmbeddedSessions".format( + **self._solution + ) + + 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) -> A2PCampaignRegistrationEmbeddedSessionInstance: + """ + Create the A2PCampaignRegistrationEmbeddedSessionInstance + + + :returns: The created A2PCampaignRegistrationEmbeddedSessionInstance + """ + payload, _, _ = self._create() + return A2PCampaignRegistrationEmbeddedSessionInstance( + self._version, payload, id=self._solution["id"] + ) + + def create_with_http_info(self) -> ApiResponse: + """ + Create the A2PCampaignRegistrationEmbeddedSessionInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create() + instance = A2PCampaignRegistrationEmbeddedSessionInstance( + self._version, payload, id=self._solution["id"] + ) + 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) -> A2PCampaignRegistrationEmbeddedSessionInstance: + """ + Asynchronously create the A2PCampaignRegistrationEmbeddedSessionInstance + + + :returns: The created A2PCampaignRegistrationEmbeddedSessionInstance + """ + payload, _, _ = await self._create_async() + return A2PCampaignRegistrationEmbeddedSessionInstance( + self._version, payload, id=self._solution["id"] + ) + + async def create_with_http_info_async(self) -> ApiResponse: + """ + Asynchronously create the A2PCampaignRegistrationEmbeddedSessionInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async() + instance = A2PCampaignRegistrationEmbeddedSessionInstance( + self._version, payload, id=self._solution["id"] + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "<Twilio.Trusthub.V1.A2PCampaignRegistrationEmbeddedSessionList>" diff --git a/twilio/rest/trusthub/v1/customer_profiles_provisional_copy.py b/twilio/rest/trusthub/v1/customer_profiles_provisional_copy.py new file mode 100644 index 0000000000..65c0823003 --- /dev/null +++ b/twilio/rest/trusthub/v1/customer_profiles_provisional_copy.py @@ -0,0 +1,423 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Trusthub + 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 datetime import datetime +from typing import Any, Dict, Optional +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 + + +class CustomerProfilesProvisionalCopyInstance(InstanceResource): + """ + :ivar customer_profile_sid: The unique SID identifier of the Customer Profile. + :ivar account_sid: The unique SID identifier of the Account. + :ivar policy_sid: The unique string of a policy that is associated to the Customer-Profile resource. + :ivar friendly_name: A human readable description of this resource, up to 64 characters. + :ivar status: The verification status of the Customer-Profile resource. + :ivar email: The email address that will receive updates when the Customer-Profile resource changes status. + :ivar status_callback: The URL we call to inform your application of status changes. + :ivar valid_until: The date and time in GMT in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format when the resource will be valid until. + :ivar date_created: The date that this Customer Profiles Provisional Copy was created, given in ISO 8601 format. + :ivar date_updated: The date that this Customer Profiles Provisional Copy was updated, given in ISO 8601 format. + :ivar url: The URL of this resource. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + customer_profile_sid: Optional[str] = None, + ): + super().__init__(version) + + self.customer_profile_sid: Optional[str] = payload.get("customer_profile_sid") + self.account_sid: Optional[str] = payload.get("account_sid") + self.policy_sid: Optional[str] = payload.get("policy_sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.status: Optional[str] = payload.get("status") + self.email: Optional[str] = payload.get("email") + self.status_callback: Optional[str] = payload.get("status_callback") + self.valid_until: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("valid_until") + ) + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + self.url: Optional[str] = payload.get("url") + + self._solution = { + "customer_profile_sid": customer_profile_sid or self.customer_profile_sid, + } + + self._context: Optional[CustomerProfilesProvisionalCopyContext] = None + + @property + def _proxy(self) -> "CustomerProfilesProvisionalCopyContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: CustomerProfilesProvisionalCopyContext for this CustomerProfilesProvisionalCopyInstance + """ + if self._context is None: + self._context = CustomerProfilesProvisionalCopyContext( + self._version, + customer_profile_sid=self._solution["customer_profile_sid"], + ) + return self._context + + def create(self) -> "CustomerProfilesProvisionalCopyInstance": + """ + Create the CustomerProfilesProvisionalCopyInstance + + + :returns: The created CustomerProfilesProvisionalCopyInstance + """ + return self._proxy.create() + + async def create_async(self) -> "CustomerProfilesProvisionalCopyInstance": + """ + Asynchronous coroutine to create the CustomerProfilesProvisionalCopyInstance + + + :returns: The created CustomerProfilesProvisionalCopyInstance + """ + return await self._proxy.create_async() + + def create_with_http_info(self) -> ApiResponse: + """ + Create the CustomerProfilesProvisionalCopyInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.create_with_http_info() + + async def create_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to create the CustomerProfilesProvisionalCopyInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.create_with_http_info_async() + + def fetch(self) -> "CustomerProfilesProvisionalCopyInstance": + """ + Fetch the CustomerProfilesProvisionalCopyInstance + + + :returns: The fetched CustomerProfilesProvisionalCopyInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "CustomerProfilesProvisionalCopyInstance": + """ + Asynchronous coroutine to fetch the CustomerProfilesProvisionalCopyInstance + + + :returns: The fetched CustomerProfilesProvisionalCopyInstance + """ + return await self._proxy.fetch_async() + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the CustomerProfilesProvisionalCopyInstance 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 CustomerProfilesProvisionalCopyInstance 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 "<Twilio.Trusthub.V1.CustomerProfilesProvisionalCopyInstance {}>".format( + context + ) + + +class CustomerProfilesProvisionalCopyContext(InstanceContext): + + def __init__(self, version: Version, customer_profile_sid: str): + """ + Initialize the CustomerProfilesProvisionalCopyContext + + :param version: Version that contains the resource + :param customer_profile_sid: The unique SID identifier of the Customer Profile. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "customer_profile_sid": customer_profile_sid, + } + self._uri = "/CustomerProfiles/{customer_profile_sid}/ProvisionalCopy".format( + **self._solution + ) + + def _create(self) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + + data = values.of({}) + headers = values.of({}) + + headers["Accept"] = "application/json" + + return self._version.create_with_response_info( + method="POST", uri=self._uri, data=data, headers=headers + ) + + def create(self) -> CustomerProfilesProvisionalCopyInstance: + """ + Create the CustomerProfilesProvisionalCopyInstance + + + :returns: The created CustomerProfilesProvisionalCopyInstance + """ + payload, _, _ = self._create() + return CustomerProfilesProvisionalCopyInstance( + self._version, + payload, + customer_profile_sid=self._solution["customer_profile_sid"], + ) + + def create_with_http_info(self) -> ApiResponse: + """ + Create the CustomerProfilesProvisionalCopyInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create() + instance = CustomerProfilesProvisionalCopyInstance( + self._version, + payload, + customer_profile_sid=self._solution["customer_profile_sid"], + ) + 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) + """ + + data = values.of({}) + headers = values.of({}) + + 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) -> CustomerProfilesProvisionalCopyInstance: + """ + Asynchronous coroutine to create the CustomerProfilesProvisionalCopyInstance + + + :returns: The created CustomerProfilesProvisionalCopyInstance + """ + payload, _, _ = await self._create_async() + return CustomerProfilesProvisionalCopyInstance( + self._version, + payload, + customer_profile_sid=self._solution["customer_profile_sid"], + ) + + async def create_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to create the CustomerProfilesProvisionalCopyInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async() + instance = CustomerProfilesProvisionalCopyInstance( + self._version, + payload, + customer_profile_sid=self._solution["customer_profile_sid"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + 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) -> CustomerProfilesProvisionalCopyInstance: + """ + Fetch the CustomerProfilesProvisionalCopyInstance + + + :returns: The fetched CustomerProfilesProvisionalCopyInstance + """ + payload, _, _ = self._fetch() + return CustomerProfilesProvisionalCopyInstance( + self._version, + payload, + customer_profile_sid=self._solution["customer_profile_sid"], + ) + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the CustomerProfilesProvisionalCopyInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._fetch() + instance = CustomerProfilesProvisionalCopyInstance( + self._version, + payload, + customer_profile_sid=self._solution["customer_profile_sid"], + ) + 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) -> CustomerProfilesProvisionalCopyInstance: + """ + Asynchronous coroutine to fetch the CustomerProfilesProvisionalCopyInstance + + + :returns: The fetched CustomerProfilesProvisionalCopyInstance + """ + payload, _, _ = await self._fetch_async() + return CustomerProfilesProvisionalCopyInstance( + self._version, + payload, + customer_profile_sid=self._solution["customer_profile_sid"], + ) + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to fetch the CustomerProfilesProvisionalCopyInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._fetch_async() + instance = CustomerProfilesProvisionalCopyInstance( + self._version, + payload, + customer_profile_sid=self._solution["customer_profile_sid"], + ) + 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 "<Twilio.Trusthub.V1.CustomerProfilesProvisionalCopyContext {}>".format( + context + ) + + +class CustomerProfilesProvisionalCopyList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the CustomerProfilesProvisionalCopyList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, customer_profile_sid: str) -> CustomerProfilesProvisionalCopyContext: + """ + Constructs a CustomerProfilesProvisionalCopyContext + + :param customer_profile_sid: The unique SID identifier of the Customer Profile. + """ + return CustomerProfilesProvisionalCopyContext( + self._version, customer_profile_sid=customer_profile_sid + ) + + def __call__( + self, customer_profile_sid: str + ) -> CustomerProfilesProvisionalCopyContext: + """ + Constructs a CustomerProfilesProvisionalCopyContext + + :param customer_profile_sid: The unique SID identifier of the Customer Profile. + """ + return CustomerProfilesProvisionalCopyContext( + self._version, customer_profile_sid=customer_profile_sid + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "<Twilio.Trusthub.V1.CustomerProfilesProvisionalCopyList>" diff --git a/twilio/rest/trusthub/v1/trust_products_provisional_copy.py b/twilio/rest/trusthub/v1/trust_products_provisional_copy.py new file mode 100644 index 0000000000..249e489e0c --- /dev/null +++ b/twilio/rest/trusthub/v1/trust_products_provisional_copy.py @@ -0,0 +1,421 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Trusthub + 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 datetime import datetime +from typing import Any, Dict, Optional +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 + + +class TrustProductsProvisionalCopyInstance(InstanceResource): + """ + :ivar trust_product_sid: The unique SID identifier of the Trust Product. + :ivar account_sid: The unique SID identifier of the Account. + :ivar policy_sid: The unique SID identifier of the Policy. + :ivar friendly_name: A human readable description of this resource, up to 64 characters. + :ivar status: The verification status of the Customer-Profile resource. + :ivar email: The email address that will receive updates when the trust product resource changes status. + :ivar status_callback: The URL we call to inform your application of status changes. + :ivar valid_until: The date and time in GMT in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format when the resource will be valid until. + :ivar date_created: The date that this Trust Products Provisional Copy was created, given in ISO 8601 format. + :ivar date_updated: The date that this Trust Products Provisional Copy was updated, given in ISO 8601 format. + :ivar url: The URL of this resource. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + trust_product_sid: Optional[str] = None, + ): + super().__init__(version) + + self.trust_product_sid: Optional[str] = payload.get("trust_product_sid") + self.account_sid: Optional[str] = payload.get("account_sid") + self.policy_sid: Optional[str] = payload.get("policy_sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.status: Optional[str] = payload.get("status") + self.email: Optional[str] = payload.get("email") + self.status_callback: Optional[str] = payload.get("status_callback") + self.valid_until: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("valid_until") + ) + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + self.url: Optional[str] = payload.get("url") + + self._solution = { + "trust_product_sid": trust_product_sid or self.trust_product_sid, + } + + self._context: Optional[TrustProductsProvisionalCopyContext] = None + + @property + def _proxy(self) -> "TrustProductsProvisionalCopyContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: TrustProductsProvisionalCopyContext for this TrustProductsProvisionalCopyInstance + """ + if self._context is None: + self._context = TrustProductsProvisionalCopyContext( + self._version, + trust_product_sid=self._solution["trust_product_sid"], + ) + return self._context + + def create(self) -> "TrustProductsProvisionalCopyInstance": + """ + Create the TrustProductsProvisionalCopyInstance + + + :returns: The created TrustProductsProvisionalCopyInstance + """ + return self._proxy.create() + + async def create_async(self) -> "TrustProductsProvisionalCopyInstance": + """ + Asynchronous coroutine to create the TrustProductsProvisionalCopyInstance + + + :returns: The created TrustProductsProvisionalCopyInstance + """ + return await self._proxy.create_async() + + def create_with_http_info(self) -> ApiResponse: + """ + Create the TrustProductsProvisionalCopyInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.create_with_http_info() + + async def create_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to create the TrustProductsProvisionalCopyInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.create_with_http_info_async() + + def fetch(self) -> "TrustProductsProvisionalCopyInstance": + """ + Fetch the TrustProductsProvisionalCopyInstance + + + :returns: The fetched TrustProductsProvisionalCopyInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "TrustProductsProvisionalCopyInstance": + """ + Asynchronous coroutine to fetch the TrustProductsProvisionalCopyInstance + + + :returns: The fetched TrustProductsProvisionalCopyInstance + """ + return await self._proxy.fetch_async() + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the TrustProductsProvisionalCopyInstance 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 TrustProductsProvisionalCopyInstance 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 "<Twilio.Trusthub.V1.TrustProductsProvisionalCopyInstance {}>".format( + context + ) + + +class TrustProductsProvisionalCopyContext(InstanceContext): + + def __init__(self, version: Version, trust_product_sid: str): + """ + Initialize the TrustProductsProvisionalCopyContext + + :param version: Version that contains the resource + :param trust_product_sid: The unique SID identifier of the Trust Product. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "trust_product_sid": trust_product_sid, + } + self._uri = "/TrustProducts/{trust_product_sid}/ProvisionalCopy".format( + **self._solution + ) + + def _create(self) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + + data = values.of({}) + headers = values.of({}) + + headers["Accept"] = "application/json" + + return self._version.create_with_response_info( + method="POST", uri=self._uri, data=data, headers=headers + ) + + def create(self) -> TrustProductsProvisionalCopyInstance: + """ + Create the TrustProductsProvisionalCopyInstance + + + :returns: The created TrustProductsProvisionalCopyInstance + """ + payload, _, _ = self._create() + return TrustProductsProvisionalCopyInstance( + self._version, + payload, + trust_product_sid=self._solution["trust_product_sid"], + ) + + def create_with_http_info(self) -> ApiResponse: + """ + Create the TrustProductsProvisionalCopyInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create() + instance = TrustProductsProvisionalCopyInstance( + self._version, + payload, + trust_product_sid=self._solution["trust_product_sid"], + ) + 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) + """ + + data = values.of({}) + headers = values.of({}) + + 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) -> TrustProductsProvisionalCopyInstance: + """ + Asynchronous coroutine to create the TrustProductsProvisionalCopyInstance + + + :returns: The created TrustProductsProvisionalCopyInstance + """ + payload, _, _ = await self._create_async() + return TrustProductsProvisionalCopyInstance( + self._version, + payload, + trust_product_sid=self._solution["trust_product_sid"], + ) + + async def create_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to create the TrustProductsProvisionalCopyInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async() + instance = TrustProductsProvisionalCopyInstance( + self._version, + payload, + trust_product_sid=self._solution["trust_product_sid"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + 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) -> TrustProductsProvisionalCopyInstance: + """ + Fetch the TrustProductsProvisionalCopyInstance + + + :returns: The fetched TrustProductsProvisionalCopyInstance + """ + payload, _, _ = self._fetch() + return TrustProductsProvisionalCopyInstance( + self._version, + payload, + trust_product_sid=self._solution["trust_product_sid"], + ) + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the TrustProductsProvisionalCopyInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._fetch() + instance = TrustProductsProvisionalCopyInstance( + self._version, + payload, + trust_product_sid=self._solution["trust_product_sid"], + ) + 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) -> TrustProductsProvisionalCopyInstance: + """ + Asynchronous coroutine to fetch the TrustProductsProvisionalCopyInstance + + + :returns: The fetched TrustProductsProvisionalCopyInstance + """ + payload, _, _ = await self._fetch_async() + return TrustProductsProvisionalCopyInstance( + self._version, + payload, + trust_product_sid=self._solution["trust_product_sid"], + ) + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to fetch the TrustProductsProvisionalCopyInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._fetch_async() + instance = TrustProductsProvisionalCopyInstance( + self._version, + payload, + trust_product_sid=self._solution["trust_product_sid"], + ) + 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 "<Twilio.Trusthub.V1.TrustProductsProvisionalCopyContext {}>".format( + context + ) + + +class TrustProductsProvisionalCopyList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the TrustProductsProvisionalCopyList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, trust_product_sid: str) -> TrustProductsProvisionalCopyContext: + """ + Constructs a TrustProductsProvisionalCopyContext + + :param trust_product_sid: The unique SID identifier of the Trust Product. + """ + return TrustProductsProvisionalCopyContext( + self._version, trust_product_sid=trust_product_sid + ) + + def __call__(self, trust_product_sid: str) -> TrustProductsProvisionalCopyContext: + """ + Constructs a TrustProductsProvisionalCopyContext + + :param trust_product_sid: The unique SID identifier of the Trust Product. + """ + return TrustProductsProvisionalCopyContext( + self._version, trust_product_sid=trust_product_sid + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "<Twilio.Trusthub.V1.TrustProductsProvisionalCopyList>" diff --git a/twilio/rest/voice/VoiceBase.py b/twilio/rest/voice/VoiceBase.py index 3bcc12e228..2485e826d0 100644 --- a/twilio/rest/voice/VoiceBase.py +++ b/twilio/rest/voice/VoiceBase.py @@ -14,6 +14,7 @@ from twilio.base.domain import Domain from twilio.rest import Client from twilio.rest.voice.v1 import V1 +from twilio.rest.voice.v2 import V2 from twilio.rest.voice.v3 import V3 @@ -27,6 +28,7 @@ def __init__(self, twilio: Client): """ super().__init__(twilio, "https://voice.twilio.com") self._v1: Optional[V1] = None + self._v2: Optional[V2] = None self._v3: Optional[V3] = None @property @@ -38,6 +40,15 @@ def v1(self) -> V1: self._v1 = V1(self) return self._v1 + @property + def v2(self) -> V2: + """ + :returns: Versions v2 of Voice + """ + if self._v2 is None: + self._v2 = V2(self) + return self._v2 + @property def v3(self) -> V3: """ diff --git a/twilio/rest/voice/v2/__init__.py b/twilio/rest/voice/v2/__init__.py new file mode 100644 index 0000000000..6256684366 --- /dev/null +++ b/twilio/rest/voice/v2/__init__.py @@ -0,0 +1,79 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio API definition for public-api voice + Powers Twilio public-api voice + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Optional +from twilio.base.version import Version +from twilio.base.domain import Domain +from twilio.rest.voice.v2.account_default_configuration import ( + AccountDefaultConfigurationList, +) +from twilio.rest.voice.v2.configuration import ConfigurationList +from twilio.rest.voice.v2.recording import RecordingList +from twilio.rest.voice.v2.transcription import TranscriptionList +from twilio.rest.voice.v2.type import TypeList + + +class V2(Version): + + def __init__(self, domain: Domain): + """ + Initialize the V2 version of Voice + + :param domain: The Twilio.voice domain + """ + super().__init__(domain, "v2") + self._account_default_configuration: Optional[ + AccountDefaultConfigurationList + ] = None + self._configurations: Optional[ConfigurationList] = None + self._recording: Optional[RecordingList] = None + self._transcription: Optional[TranscriptionList] = None + self._type: Optional[TypeList] = None + + @property + def account_default_configuration(self) -> AccountDefaultConfigurationList: + if self._account_default_configuration is None: + self._account_default_configuration = AccountDefaultConfigurationList(self) + return self._account_default_configuration + + @property + def configurations(self) -> ConfigurationList: + if self._configurations is None: + self._configurations = ConfigurationList(self) + return self._configurations + + @property + def recording(self) -> RecordingList: + if self._recording is None: + self._recording = RecordingList(self) + return self._recording + + @property + def transcription(self) -> TranscriptionList: + if self._transcription is None: + self._transcription = TranscriptionList(self) + return self._transcription + + @property + def type(self) -> TypeList: + if self._type is None: + self._type = TypeList(self) + return self._type + + def __repr__(self) -> str: + """ + Provide a friendly representation + :returns: Machine friendly representation + """ + return "<Twilio.Voice.V2>" diff --git a/twilio/rest/voice/v2/account_default_configuration.py b/twilio/rest/voice/v2/account_default_configuration.py new file mode 100644 index 0000000000..4657f3c11c --- /dev/null +++ b/twilio/rest/voice/v2/account_default_configuration.py @@ -0,0 +1,838 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio API definition for public-api voice + Powers Twilio public-api voice + + 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, Optional, Union +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 + + +class AccountDefaultConfigurationInstance(InstanceResource): + + class VoiceV2AccountDefaultConfigurationRequest(object): + """ + :ivar description: The description + :ivar configuration: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.configuration: Optional[Dict[str, object]] = payload.get( + "configuration" + ) + + def to_dict(self): + return { + "description": self.description, + "configuration": self.configuration, + } + + """ + :ivar account_sid: Account sid + :ivar description: The description + :ivar date_created: + :ivar date_updated: + :ivar configuration: + :ivar message: Error message + :ivar code: Twilio error code + :ivar status: status code + :ivar more_info: More information about the error + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], type: Optional[str] = None + ): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.description: Optional[str] = payload.get("description") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + self.configuration: Optional[Dict[str, object]] = payload.get("configuration") + self.message: Optional[str] = payload.get("message") + self.code: Optional[int] = payload.get("code") + self.status: Optional[int] = payload.get("status") + self.more_info: Optional[str] = payload.get("more_info") + + self._solution = { + "type": type or self.type, + } + + self._context: Optional[AccountDefaultConfigurationContext] = None + + @property + def _proxy(self) -> "AccountDefaultConfigurationContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: AccountDefaultConfigurationContext for this AccountDefaultConfigurationInstance + """ + if self._context is None: + self._context = AccountDefaultConfigurationContext( + self._version, + type=self._solution["type"], + ) + return self._context + + def create( + self, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> "AccountDefaultConfigurationInstance": + """ + Create the AccountDefaultConfigurationInstance + + :param voice_v2_account_default_configuration_request: + + :returns: The created AccountDefaultConfigurationInstance + """ + return self._proxy.create( + voice_v2_account_default_configuration_request=voice_v2_account_default_configuration_request, + ) + + async def create_async( + self, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> "AccountDefaultConfigurationInstance": + """ + Asynchronous coroutine to create the AccountDefaultConfigurationInstance + + :param voice_v2_account_default_configuration_request: + + :returns: The created AccountDefaultConfigurationInstance + """ + return await self._proxy.create_async( + voice_v2_account_default_configuration_request=voice_v2_account_default_configuration_request, + ) + + def create_with_http_info( + self, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Create the AccountDefaultConfigurationInstance with HTTP info + + :param voice_v2_account_default_configuration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.create_with_http_info( + voice_v2_account_default_configuration_request=voice_v2_account_default_configuration_request, + ) + + async def create_with_http_info_async( + self, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to create the AccountDefaultConfigurationInstance with HTTP info + + :param voice_v2_account_default_configuration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.create_with_http_info_async( + voice_v2_account_default_configuration_request=voice_v2_account_default_configuration_request, + ) + + def delete(self) -> bool: + """ + Deletes the AccountDefaultConfigurationInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the AccountDefaultConfigurationInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the AccountDefaultConfigurationInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return self._proxy.delete_with_http_info() + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the AccountDefaultConfigurationInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return await self._proxy.delete_with_http_info_async() + + def fetch(self) -> "AccountDefaultConfigurationInstance": + """ + Fetch the AccountDefaultConfigurationInstance + + + :returns: The fetched AccountDefaultConfigurationInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "AccountDefaultConfigurationInstance": + """ + Asynchronous coroutine to fetch the AccountDefaultConfigurationInstance + + + :returns: The fetched AccountDefaultConfigurationInstance + """ + return await self._proxy.fetch_async() + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the AccountDefaultConfigurationInstance 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 AccountDefaultConfigurationInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.fetch_with_http_info_async() + + def update( + self, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> "AccountDefaultConfigurationInstance": + """ + Update the AccountDefaultConfigurationInstance + + :param voice_v2_account_default_configuration_request: + + :returns: The updated AccountDefaultConfigurationInstance + """ + return self._proxy.update( + voice_v2_account_default_configuration_request=voice_v2_account_default_configuration_request, + ) + + async def update_async( + self, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> "AccountDefaultConfigurationInstance": + """ + Asynchronous coroutine to update the AccountDefaultConfigurationInstance + + :param voice_v2_account_default_configuration_request: + + :returns: The updated AccountDefaultConfigurationInstance + """ + return await self._proxy.update_async( + voice_v2_account_default_configuration_request=voice_v2_account_default_configuration_request, + ) + + def update_with_http_info( + self, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Update the AccountDefaultConfigurationInstance with HTTP info + + :param voice_v2_account_default_configuration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.update_with_http_info( + voice_v2_account_default_configuration_request=voice_v2_account_default_configuration_request, + ) + + async def update_with_http_info_async( + self, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to update the AccountDefaultConfigurationInstance with HTTP info + + :param voice_v2_account_default_configuration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.update_with_http_info_async( + voice_v2_account_default_configuration_request=voice_v2_account_default_configuration_request, + ) + + 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 "<Twilio.Voice.V2.AccountDefaultConfigurationInstance {}>".format( + context + ) + + +class AccountDefaultConfigurationContext(InstanceContext): + + class VoiceV2AccountDefaultConfigurationRequest(object): + """ + :ivar description: The description + :ivar configuration: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.configuration: Optional[Dict[str, object]] = payload.get( + "configuration" + ) + + def to_dict(self): + return { + "description": self.description, + "configuration": self.configuration, + } + + def __init__(self, version: Version, type: str): + """ + Initialize the AccountDefaultConfigurationContext + + :param version: Version that contains the resource + :param type: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "type": type, + } + self._uri = "/AccountDefaultConfiguration/{type}".format(**self._solution) + + def _create( + self, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = voice_v2_account_default_configuration_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, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> AccountDefaultConfigurationInstance: + """ + Create the AccountDefaultConfigurationInstance + + :param voice_v2_account_default_configuration_request: + + :returns: The created AccountDefaultConfigurationInstance + """ + payload, _, _ = self._create( + voice_v2_account_default_configuration_request=voice_v2_account_default_configuration_request + ) + return AccountDefaultConfigurationInstance( + self._version, payload, type=self._solution["type"] + ) + + def create_with_http_info( + self, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Create the AccountDefaultConfigurationInstance and return response metadata + + :param voice_v2_account_default_configuration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create( + voice_v2_account_default_configuration_request=voice_v2_account_default_configuration_request + ) + instance = AccountDefaultConfigurationInstance( + self._version, payload, type=self._solution["type"] + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async( + self, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = voice_v2_account_default_configuration_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, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> AccountDefaultConfigurationInstance: + """ + Asynchronous coroutine to create the AccountDefaultConfigurationInstance + + :param voice_v2_account_default_configuration_request: + + :returns: The created AccountDefaultConfigurationInstance + """ + payload, _, _ = await self._create_async( + voice_v2_account_default_configuration_request=voice_v2_account_default_configuration_request + ) + return AccountDefaultConfigurationInstance( + self._version, payload, type=self._solution["type"] + ) + + async def create_with_http_info_async( + self, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to create the AccountDefaultConfigurationInstance and return response metadata + + :param voice_v2_account_default_configuration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async( + voice_v2_account_default_configuration_request=voice_v2_account_default_configuration_request + ) + instance = AccountDefaultConfigurationInstance( + self._version, payload, type=self._solution["type"] + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def _delete(self) -> tuple: + """ + Internal helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return self._version.delete_with_response_info( + method="DELETE", uri=self._uri, headers=headers + ) + + def delete(self) -> bool: + """ + Deletes the AccountDefaultConfigurationInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = self._delete() + return success + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the AccountDefaultConfigurationInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = self._delete() + return ApiResponse(data=success, status_code=status_code, headers=headers) + + async def _delete_async(self) -> tuple: + """ + Internal async helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return await self._version.delete_with_response_info_async( + method="DELETE", uri=self._uri, headers=headers + ) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the AccountDefaultConfigurationInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = await self._delete_async() + return success + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the AccountDefaultConfigurationInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = await self._delete_async() + return ApiResponse(data=success, status_code=status_code, headers=headers) + + 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) -> AccountDefaultConfigurationInstance: + """ + Fetch the AccountDefaultConfigurationInstance + + + :returns: The fetched AccountDefaultConfigurationInstance + """ + payload, _, _ = self._fetch() + return AccountDefaultConfigurationInstance( + self._version, + payload, + type=self._solution["type"], + ) + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the AccountDefaultConfigurationInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._fetch() + instance = AccountDefaultConfigurationInstance( + self._version, + payload, + type=self._solution["type"], + ) + 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) -> AccountDefaultConfigurationInstance: + """ + Asynchronous coroutine to fetch the AccountDefaultConfigurationInstance + + + :returns: The fetched AccountDefaultConfigurationInstance + """ + payload, _, _ = await self._fetch_async() + return AccountDefaultConfigurationInstance( + self._version, + payload, + type=self._solution["type"], + ) + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to fetch the AccountDefaultConfigurationInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._fetch_async() + instance = AccountDefaultConfigurationInstance( + self._version, + payload, + type=self._solution["type"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def _update( + self, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = voice_v2_account_default_configuration_request.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return self._version.update_with_response_info( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + def update( + self, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> AccountDefaultConfigurationInstance: + """ + Update the AccountDefaultConfigurationInstance + + :param voice_v2_account_default_configuration_request: + + :returns: The updated AccountDefaultConfigurationInstance + """ + payload, _, _ = self._update( + voice_v2_account_default_configuration_request=voice_v2_account_default_configuration_request + ) + return AccountDefaultConfigurationInstance( + self._version, payload, type=self._solution["type"] + ) + + def update_with_http_info( + self, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Update the AccountDefaultConfigurationInstance and return response metadata + + :param voice_v2_account_default_configuration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._update( + voice_v2_account_default_configuration_request=voice_v2_account_default_configuration_request + ) + instance = AccountDefaultConfigurationInstance( + self._version, payload, type=self._solution["type"] + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _update_async( + self, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal async helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = voice_v2_account_default_configuration_request.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return await self._version.update_with_response_info_async( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + async def update_async( + self, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> AccountDefaultConfigurationInstance: + """ + Asynchronous coroutine to update the AccountDefaultConfigurationInstance + + :param voice_v2_account_default_configuration_request: + + :returns: The updated AccountDefaultConfigurationInstance + """ + payload, _, _ = await self._update_async( + voice_v2_account_default_configuration_request=voice_v2_account_default_configuration_request + ) + return AccountDefaultConfigurationInstance( + self._version, payload, type=self._solution["type"] + ) + + async def update_with_http_info_async( + self, + voice_v2_account_default_configuration_request: Union[ + VoiceV2AccountDefaultConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to update the AccountDefaultConfigurationInstance and return response metadata + + :param voice_v2_account_default_configuration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._update_async( + voice_v2_account_default_configuration_request=voice_v2_account_default_configuration_request + ) + instance = AccountDefaultConfigurationInstance( + self._version, payload, type=self._solution["type"] + ) + 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 "<Twilio.Voice.V2.AccountDefaultConfigurationContext {}>".format(context) + + +class AccountDefaultConfigurationList(ListResource): + + class VoiceV2AccountDefaultConfigurationRequest(object): + """ + :ivar description: The description + :ivar configuration: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.configuration: Optional[Dict[str, object]] = payload.get( + "configuration" + ) + + def to_dict(self): + return { + "description": self.description, + "configuration": self.configuration, + } + + def __init__(self, version: Version): + """ + Initialize the AccountDefaultConfigurationList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, type: str) -> AccountDefaultConfigurationContext: + """ + Constructs a AccountDefaultConfigurationContext + + :param type: + """ + return AccountDefaultConfigurationContext(self._version, type=type) + + def __call__(self, type: str) -> AccountDefaultConfigurationContext: + """ + Constructs a AccountDefaultConfigurationContext + + :param type: + """ + return AccountDefaultConfigurationContext(self._version, type=type) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "<Twilio.Voice.V2.AccountDefaultConfigurationList>" diff --git a/twilio/rest/voice/v2/configuration/__init__.py b/twilio/rest/voice/v2/configuration/__init__.py new file mode 100644 index 0000000000..513cab3a3a --- /dev/null +++ b/twilio/rest/voice/v2/configuration/__init__.py @@ -0,0 +1,432 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio API definition for public-api voice + Powers Twilio public-api voice + + 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, Optional, Union +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.rest.voice.v2.configuration.default import DefaultList + + +class ConfigurationInstance(InstanceResource): + + class VoiceV2ConfigurationRequest(object): + """ + :ivar unique_name: The unique name + :ivar description: The description + :ivar configuration: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.unique_name: Optional[str] = payload.get("unique_name") + self.description: Optional[str] = payload.get("description") + self.configuration: Optional[Dict[str, object]] = payload.get( + "configuration" + ) + + def to_dict(self): + return { + "unique_name": self.unique_name, + "description": self.description, + "configuration": self.configuration, + } + + """ + :ivar id: Configuration Identifier + :ivar account_sid: Account sid + :ivar unique_name: The unique name + :ivar description: The description + :ivar date_created: + :ivar date_updated: + :ivar configuration: + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], type: Optional[str] = None + ): + super().__init__(version) + + self.id: Optional[str] = payload.get("id") + self.account_sid: Optional[str] = payload.get("account_sid") + self.unique_name: Optional[str] = payload.get("unique_name") + self.description: Optional[str] = payload.get("description") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + self.configuration: Optional[Dict[str, object]] = payload.get("configuration") + + self._solution = { + "type": type or self.type, + } + + self._context: Optional[ConfigurationContext] = None + + @property + def _proxy(self) -> "ConfigurationContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: ConfigurationContext for this ConfigurationInstance + """ + if self._context is None: + self._context = ConfigurationContext( + self._version, + type=self._solution["type"], + ) + return self._context + + def create( + self, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> "ConfigurationInstance": + """ + Create the ConfigurationInstance + + :param voice_v2_configuration_request: + + :returns: The created ConfigurationInstance + """ + return self._proxy.create( + voice_v2_configuration_request=voice_v2_configuration_request, + ) + + async def create_async( + self, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> "ConfigurationInstance": + """ + Asynchronous coroutine to create the ConfigurationInstance + + :param voice_v2_configuration_request: + + :returns: The created ConfigurationInstance + """ + return await self._proxy.create_async( + voice_v2_configuration_request=voice_v2_configuration_request, + ) + + def create_with_http_info( + self, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Create the ConfigurationInstance with HTTP info + + :param voice_v2_configuration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.create_with_http_info( + voice_v2_configuration_request=voice_v2_configuration_request, + ) + + async def create_with_http_info_async( + self, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to create the ConfigurationInstance with HTTP info + + :param voice_v2_configuration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.create_with_http_info_async( + voice_v2_configuration_request=voice_v2_configuration_request, + ) + + @property + def default(self) -> DefaultList: + """ + Access the default + """ + return self._proxy.default + + 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 "<Twilio.Voice.V2.ConfigurationInstance {}>".format(context) + + +class ConfigurationContext(InstanceContext): + + class VoiceV2ConfigurationRequest(object): + """ + :ivar unique_name: The unique name + :ivar description: The description + :ivar configuration: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.unique_name: Optional[str] = payload.get("unique_name") + self.description: Optional[str] = payload.get("description") + self.configuration: Optional[Dict[str, object]] = payload.get( + "configuration" + ) + + def to_dict(self): + return { + "unique_name": self.unique_name, + "description": self.description, + "configuration": self.configuration, + } + + def __init__(self, version: Version, type: str): + """ + Initialize the ConfigurationContext + + :param version: Version that contains the resource + :param type: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "type": type, + } + self._uri = "/Configurations/{type}".format(**self._solution) + + self._default: Optional[DefaultList] = None + + def _create( + self, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = voice_v2_configuration_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, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> ConfigurationInstance: + """ + Create the ConfigurationInstance + + :param voice_v2_configuration_request: + + :returns: The created ConfigurationInstance + """ + payload, _, _ = self._create( + voice_v2_configuration_request=voice_v2_configuration_request + ) + return ConfigurationInstance( + self._version, payload, type=self._solution["type"] + ) + + def create_with_http_info( + self, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Create the ConfigurationInstance and return response metadata + + :param voice_v2_configuration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create( + voice_v2_configuration_request=voice_v2_configuration_request + ) + instance = ConfigurationInstance( + self._version, payload, type=self._solution["type"] + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async( + self, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = voice_v2_configuration_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, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> ConfigurationInstance: + """ + Asynchronous coroutine to create the ConfigurationInstance + + :param voice_v2_configuration_request: + + :returns: The created ConfigurationInstance + """ + payload, _, _ = await self._create_async( + voice_v2_configuration_request=voice_v2_configuration_request + ) + return ConfigurationInstance( + self._version, payload, type=self._solution["type"] + ) + + async def create_with_http_info_async( + self, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to create the ConfigurationInstance and return response metadata + + :param voice_v2_configuration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async( + voice_v2_configuration_request=voice_v2_configuration_request + ) + instance = ConfigurationInstance( + self._version, payload, type=self._solution["type"] + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + @property + def default(self) -> DefaultList: + """ + Access the default + """ + if self._default is None: + self._default = DefaultList( + self._version, + self._solution["type"], + ) + return self._default + + 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 "<Twilio.Voice.V2.ConfigurationContext {}>".format(context) + + +class ConfigurationList(ListResource): + + class VoiceV2ConfigurationRequest(object): + """ + :ivar unique_name: The unique name + :ivar description: The description + :ivar configuration: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.unique_name: Optional[str] = payload.get("unique_name") + self.description: Optional[str] = payload.get("description") + self.configuration: Optional[Dict[str, object]] = payload.get( + "configuration" + ) + + def to_dict(self): + return { + "unique_name": self.unique_name, + "description": self.description, + "configuration": self.configuration, + } + + def __init__(self, version: Version): + """ + Initialize the ConfigurationList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, type: str) -> ConfigurationContext: + """ + Constructs a ConfigurationContext + + :param type: + """ + return ConfigurationContext(self._version, type=type) + + def __call__(self, type: str) -> ConfigurationContext: + """ + Constructs a ConfigurationContext + + :param type: + """ + return ConfigurationContext(self._version, type=type) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "<Twilio.Voice.V2.ConfigurationList>" diff --git a/twilio/rest/voice/v2/configuration/default.py b/twilio/rest/voice/v2/configuration/default.py new file mode 100644 index 0000000000..9a37632e19 --- /dev/null +++ b/twilio/rest/voice/v2/configuration/default.py @@ -0,0 +1,320 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio API definition for public-api voice + Powers Twilio public-api voice + + 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, Optional, Union +from twilio.base import deserialize, 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 DefaultInstance(InstanceResource): + + class DefaultConfigurationRequest(object): + """ + :ivar configuration_id: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.configuration_id: Optional[str] = payload.get("configuration_id") + + def to_dict(self): + return { + "configuration_id": self.configuration_id, + } + + """ + :ivar message: Error message + :ivar code: Twilio error code + :ivar status: status code + :ivar more_info: More information about the error + :ivar id: Configuration Identifier + :ivar account_sid: Account sid + :ivar unique_name: The unique name + :ivar description: The description + :ivar date_created: + :ivar date_updated: + :ivar configuration: + """ + + def __init__(self, version: Version, payload: Dict[str, Any], type: str): + super().__init__(version) + + self.message: Optional[str] = payload.get("message") + self.code: Optional[int] = payload.get("code") + self.status: Optional[int] = payload.get("status") + self.more_info: Optional[str] = payload.get("more_info") + self.id: Optional[str] = payload.get("id") + self.account_sid: Optional[str] = payload.get("account_sid") + self.unique_name: Optional[str] = payload.get("unique_name") + self.description: Optional[str] = payload.get("description") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + self.configuration: Optional[Dict[str, object]] = payload.get("configuration") + + self._solution = { + "type": type, + } + + 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 "<Twilio.Voice.V2.DefaultInstance {}>".format(context) + + +class DefaultList(ListResource): + + class DefaultConfigurationRequest(object): + """ + :ivar configuration_id: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.configuration_id: Optional[str] = payload.get("configuration_id") + + def to_dict(self): + return { + "configuration_id": self.configuration_id, + } + + def __init__(self, version: Version, type: str): + """ + Initialize the DefaultList + + :param version: Version that contains the resource + :param type: + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "type": type, + } + self._uri = "/Configurations/{type}/Default".format(**self._solution) + + def _create( + self, + default_configuration_request: Union[ + DefaultConfigurationRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = default_configuration_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, + default_configuration_request: Union[ + DefaultConfigurationRequest, object + ] = values.unset, + ) -> DefaultInstance: + """ + Create the DefaultInstance + + :param default_configuration_request: + + :returns: The created DefaultInstance + """ + payload, _, _ = self._create( + default_configuration_request=default_configuration_request + ) + return DefaultInstance(self._version, payload, type=self._solution["type"]) + + def create_with_http_info( + self, + default_configuration_request: Union[ + DefaultConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Create the DefaultInstance and return response metadata + + :param default_configuration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create( + default_configuration_request=default_configuration_request + ) + instance = DefaultInstance(self._version, payload, type=self._solution["type"]) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async( + self, + default_configuration_request: Union[ + DefaultConfigurationRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = default_configuration_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, + default_configuration_request: Union[ + DefaultConfigurationRequest, object + ] = values.unset, + ) -> DefaultInstance: + """ + Asynchronously create the DefaultInstance + + :param default_configuration_request: + + :returns: The created DefaultInstance + """ + payload, _, _ = await self._create_async( + default_configuration_request=default_configuration_request + ) + return DefaultInstance(self._version, payload, type=self._solution["type"]) + + async def create_with_http_info_async( + self, + default_configuration_request: Union[ + DefaultConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronously create the DefaultInstance and return response metadata + + :param default_configuration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async( + default_configuration_request=default_configuration_request + ) + instance = DefaultInstance(self._version, payload, type=self._solution["type"]) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def _fetch(self) -> 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" + + return self._version.fetch_with_response_info( + method="GET", uri=self._uri, headers=headers + ) + + def fetch(self) -> DefaultInstance: + """ + Fetch the DefaultInstance + + + :returns: The fetched DefaultInstance + """ + payload, _, _ = self._fetch() + return DefaultInstance(self._version, payload, type=self._solution["type"]) + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the DefaultInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._fetch() + instance = DefaultInstance(self._version, payload, type=self._solution["type"]) + 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({"Content-Type": "application/x-www-form-urlencoded"}) + + 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) -> DefaultInstance: + """ + Asynchronously fetch the DefaultInstance + + + :returns: The fetched DefaultInstance + """ + payload, _, _ = await self._fetch_async() + return DefaultInstance(self._version, payload, type=self._solution["type"]) + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronously fetch the DefaultInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._fetch_async() + instance = DefaultInstance(self._version, payload, type=self._solution["type"]) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "<Twilio.Voice.V2.DefaultList>" diff --git a/twilio/rest/voice/v2/recording.py b/twilio/rest/voice/v2/recording.py new file mode 100644 index 0000000000..0ae6ac1ac4 --- /dev/null +++ b/twilio/rest/voice/v2/recording.py @@ -0,0 +1,1136 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio API definition for public-api voice + Powers Twilio public-api voice + + 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 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 + + +class RecordingInstance(InstanceResource): + + class VoiceV2ConfigurationRecordingCompositionPolicy(object): + """ + :ivar channels: The number of channels to be composed. + :ivar trim: Trim the silence in the recordings. + :ivar track: The audio track to record for the call. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.channels: Optional["RecordingInstance.str"] = payload.get("channels") + self.trim: Optional["RecordingInstance.str"] = payload.get("trim") + self.track: Optional["RecordingInstance.str"] = payload.get("track") + + def to_dict(self): + return { + "channels": self.channels, + "trim": self.trim, + "track": self.track, + } + + class VoiceV2ConfigurationRecordingConfiguration(object): + """ + :ivar configuration_type: The configuration type discriminator. Always \"Recording\" for this resource. + :ivar composition_policy: + :ivar call_recording_status_callback: + :ivar conference_recording_status_callback: + :ivar features: The features to apply to this recording. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.configuration_type: Optional["RecordingInstance.str"] = payload.get( + "configurationType" + ) + self.composition_policy: Optional[ + RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy + ] = payload.get("compositionPolicy") + self.call_recording_status_callback: Optional[ + RecordingList.VoiceV2ConfigurationRecordingStatusCallback + ] = payload.get("callRecordingStatusCallback") + self.conference_recording_status_callback: Optional[ + RecordingList.VoiceV2ConfigurationRecordingStatusCallback + ] = payload.get("conferenceRecordingStatusCallback") + self.features: Optional[ + List[RecordingList.VoiceV2ConfigurationRecordingFeature] + ] = payload.get("features") + + def to_dict(self): + return { + "configurationType": self.configuration_type, + "compositionPolicy": ( + self.composition_policy.to_dict() + if self.composition_policy is not None + else None + ), + "callRecordingStatusCallback": ( + self.call_recording_status_callback.to_dict() + if self.call_recording_status_callback is not None + else None + ), + "conferenceRecordingStatusCallback": ( + self.conference_recording_status_callback.to_dict() + if self.conference_recording_status_callback is not None + else None + ), + "features": ( + [features.to_dict() for features in self.features] + if self.features is not None + else None + ), + } + + class VoiceV2ConfigurationRecordingFeature(object): + """ + :ivar type: The type of feature. + :ivar feature_id: The ID of the feature. + :ivar description: The description of the feature. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.type: Optional["RecordingInstance.str"] = payload.get("type") + self.feature_id: Optional[str] = payload.get("featureId") + self.description: Optional[str] = payload.get("description") + + def to_dict(self): + return { + "type": self.type, + "featureId": self.feature_id, + "description": self.description, + } + + class VoiceV2ConfigurationRecordingRequest(object): + """ + :ivar unique_name: The unique name. + :ivar description: The description. + :ivar configuration: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.unique_name: Optional[str] = payload.get("unique_name") + self.description: Optional[str] = payload.get("description") + self.configuration: Optional[ + RecordingList.VoiceV2ConfigurationRecordingConfiguration + ] = payload.get("configuration") + + def to_dict(self): + return { + "unique_name": self.unique_name, + "description": self.description, + "configuration": ( + self.configuration.to_dict() + if self.configuration is not None + else None + ), + } + + class VoiceV2ConfigurationRecordingStatusCallback(object): + """ + :ivar url: The recording status callback URL. + :ivar method: The recording status callback method. + :ivar events: The recording status callback events. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.url: Optional[str] = payload.get("url") + self.method: Optional["RecordingInstance.str"] = payload.get("method") + self.events: Optional[List[Enumstr]] = payload.get("events") + + def to_dict(self): + return { + "url": self.url, + "method": self.method, + "events": self.events, + } + + """ + :ivar id: Configuration Identifier. + :ivar account_sid: Account sid. + :ivar unique_name: The unique name. + :ivar description: The description. + :ivar date_created: + :ivar date_updated: + :ivar configuration: + :ivar message: Error message + :ivar code: Twilio error code + :ivar status: status code + :ivar more_info: More information about the error + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + id_or_unique_name: Optional[str] = None, + ): + super().__init__(version) + + self.id: Optional[str] = payload.get("id") + self.account_sid: Optional[str] = payload.get("account_sid") + self.unique_name: Optional[str] = payload.get("unique_name") + self.description: Optional[str] = payload.get("description") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + self.configuration: Optional[str] = payload.get("configuration") + self.message: Optional[str] = payload.get("message") + self.code: Optional[int] = payload.get("code") + self.status: Optional[int] = payload.get("status") + self.more_info: Optional[str] = payload.get("more_info") + + self._solution = { + "id_or_unique_name": id_or_unique_name or self.id_or_unique_name, + } + + self._context: Optional[RecordingContext] = None + + @property + def _proxy(self) -> "RecordingContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: RecordingContext for this RecordingInstance + """ + if self._context is None: + self._context = RecordingContext( + self._version, + id_or_unique_name=self._solution["id_or_unique_name"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the RecordingInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the RecordingInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the RecordingInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return self._proxy.delete_with_http_info() + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the RecordingInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return await self._proxy.delete_with_http_info_async() + + def fetch(self) -> "RecordingInstance": + """ + Fetch the RecordingInstance + + + :returns: The fetched RecordingInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "RecordingInstance": + """ + Asynchronous coroutine to fetch the RecordingInstance + + + :returns: The fetched RecordingInstance + """ + return await self._proxy.fetch_async() + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the RecordingInstance 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 RecordingInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.fetch_with_http_info_async() + + def update( + self, + voice_v2_configuration_recording_request: Union[ + VoiceV2ConfigurationRecordingRequest, object + ] = values.unset, + ) -> "RecordingInstance": + """ + Update the RecordingInstance + + :param voice_v2_configuration_recording_request: + + :returns: The updated RecordingInstance + """ + return self._proxy.update( + voice_v2_configuration_recording_request=voice_v2_configuration_recording_request, + ) + + async def update_async( + self, + voice_v2_configuration_recording_request: Union[ + VoiceV2ConfigurationRecordingRequest, object + ] = values.unset, + ) -> "RecordingInstance": + """ + Asynchronous coroutine to update the RecordingInstance + + :param voice_v2_configuration_recording_request: + + :returns: The updated RecordingInstance + """ + return await self._proxy.update_async( + voice_v2_configuration_recording_request=voice_v2_configuration_recording_request, + ) + + def update_with_http_info( + self, + voice_v2_configuration_recording_request: Union[ + VoiceV2ConfigurationRecordingRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Update the RecordingInstance with HTTP info + + :param voice_v2_configuration_recording_request: + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.update_with_http_info( + voice_v2_configuration_recording_request=voice_v2_configuration_recording_request, + ) + + async def update_with_http_info_async( + self, + voice_v2_configuration_recording_request: Union[ + VoiceV2ConfigurationRecordingRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to update the RecordingInstance with HTTP info + + :param voice_v2_configuration_recording_request: + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.update_with_http_info_async( + voice_v2_configuration_recording_request=voice_v2_configuration_recording_request, + ) + + 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 "<Twilio.Voice.V2.RecordingInstance {}>".format(context) + + +class RecordingContext(InstanceContext): + + class VoiceV2ConfigurationRecordingCompositionPolicy(object): + """ + :ivar channels: The number of channels to be composed. + :ivar trim: Trim the silence in the recordings. + :ivar track: The audio track to record for the call. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.channels: Optional["RecordingInstance.str"] = payload.get("channels") + self.trim: Optional["RecordingInstance.str"] = payload.get("trim") + self.track: Optional["RecordingInstance.str"] = payload.get("track") + + def to_dict(self): + return { + "channels": self.channels, + "trim": self.trim, + "track": self.track, + } + + class VoiceV2ConfigurationRecordingConfiguration(object): + """ + :ivar configuration_type: The configuration type discriminator. Always \"Recording\" for this resource. + :ivar composition_policy: + :ivar call_recording_status_callback: + :ivar conference_recording_status_callback: + :ivar features: The features to apply to this recording. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.configuration_type: Optional["RecordingInstance.str"] = payload.get( + "configurationType" + ) + self.composition_policy: Optional[ + RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy + ] = payload.get("compositionPolicy") + self.call_recording_status_callback: Optional[ + RecordingList.VoiceV2ConfigurationRecordingStatusCallback + ] = payload.get("callRecordingStatusCallback") + self.conference_recording_status_callback: Optional[ + RecordingList.VoiceV2ConfigurationRecordingStatusCallback + ] = payload.get("conferenceRecordingStatusCallback") + self.features: Optional[ + List[RecordingList.VoiceV2ConfigurationRecordingFeature] + ] = payload.get("features") + + def to_dict(self): + return { + "configurationType": self.configuration_type, + "compositionPolicy": ( + self.composition_policy.to_dict() + if self.composition_policy is not None + else None + ), + "callRecordingStatusCallback": ( + self.call_recording_status_callback.to_dict() + if self.call_recording_status_callback is not None + else None + ), + "conferenceRecordingStatusCallback": ( + self.conference_recording_status_callback.to_dict() + if self.conference_recording_status_callback is not None + else None + ), + "features": ( + [features.to_dict() for features in self.features] + if self.features is not None + else None + ), + } + + class VoiceV2ConfigurationRecordingFeature(object): + """ + :ivar type: The type of feature. + :ivar feature_id: The ID of the feature. + :ivar description: The description of the feature. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.type: Optional["RecordingInstance.str"] = payload.get("type") + self.feature_id: Optional[str] = payload.get("featureId") + self.description: Optional[str] = payload.get("description") + + def to_dict(self): + return { + "type": self.type, + "featureId": self.feature_id, + "description": self.description, + } + + class VoiceV2ConfigurationRecordingRequest(object): + """ + :ivar unique_name: The unique name. + :ivar description: The description. + :ivar configuration: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.unique_name: Optional[str] = payload.get("unique_name") + self.description: Optional[str] = payload.get("description") + self.configuration: Optional[ + RecordingList.VoiceV2ConfigurationRecordingConfiguration + ] = payload.get("configuration") + + def to_dict(self): + return { + "unique_name": self.unique_name, + "description": self.description, + "configuration": ( + self.configuration.to_dict() + if self.configuration is not None + else None + ), + } + + class VoiceV2ConfigurationRecordingStatusCallback(object): + """ + :ivar url: The recording status callback URL. + :ivar method: The recording status callback method. + :ivar events: The recording status callback events. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.url: Optional[str] = payload.get("url") + self.method: Optional["RecordingInstance.str"] = payload.get("method") + self.events: Optional[List[Enumstr]] = payload.get("events") + + def to_dict(self): + return { + "url": self.url, + "method": self.method, + "events": self.events, + } + + def __init__(self, version: Version, id_or_unique_name: str): + """ + Initialize the RecordingContext + + :param version: Version that contains the resource + :param id_or_unique_name: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id_or_unique_name": id_or_unique_name, + } + self._uri = "/Configurations/Recording/{id_or_unique_name}".format( + **self._solution + ) + + def _delete(self) -> tuple: + """ + Internal helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return self._version.delete_with_response_info( + method="DELETE", uri=self._uri, headers=headers + ) + + def delete(self) -> bool: + """ + Deletes the RecordingInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = self._delete() + return success + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the RecordingInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = self._delete() + return ApiResponse(data=success, status_code=status_code, headers=headers) + + async def _delete_async(self) -> tuple: + """ + Internal async helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return await self._version.delete_with_response_info_async( + method="DELETE", uri=self._uri, headers=headers + ) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the RecordingInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = await self._delete_async() + return success + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the RecordingInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = await self._delete_async() + return ApiResponse(data=success, status_code=status_code, headers=headers) + + 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) -> RecordingInstance: + """ + Fetch the RecordingInstance + + + :returns: The fetched RecordingInstance + """ + payload, _, _ = self._fetch() + return RecordingInstance( + self._version, + payload, + id_or_unique_name=self._solution["id_or_unique_name"], + ) + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the RecordingInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._fetch() + instance = RecordingInstance( + self._version, + payload, + id_or_unique_name=self._solution["id_or_unique_name"], + ) + 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) -> RecordingInstance: + """ + Asynchronous coroutine to fetch the RecordingInstance + + + :returns: The fetched RecordingInstance + """ + payload, _, _ = await self._fetch_async() + return RecordingInstance( + self._version, + payload, + id_or_unique_name=self._solution["id_or_unique_name"], + ) + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to fetch the RecordingInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._fetch_async() + instance = RecordingInstance( + self._version, + payload, + id_or_unique_name=self._solution["id_or_unique_name"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def _update( + self, + voice_v2_configuration_recording_request: Union[ + VoiceV2ConfigurationRecordingRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = voice_v2_configuration_recording_request.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return self._version.update_with_response_info( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + def update( + self, + voice_v2_configuration_recording_request: Union[ + VoiceV2ConfigurationRecordingRequest, object + ] = values.unset, + ) -> RecordingInstance: + """ + Update the RecordingInstance + + :param voice_v2_configuration_recording_request: + + :returns: The updated RecordingInstance + """ + payload, _, _ = self._update( + voice_v2_configuration_recording_request=voice_v2_configuration_recording_request + ) + return RecordingInstance( + self._version, + payload, + id_or_unique_name=self._solution["id_or_unique_name"], + ) + + def update_with_http_info( + self, + voice_v2_configuration_recording_request: Union[ + VoiceV2ConfigurationRecordingRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Update the RecordingInstance and return response metadata + + :param voice_v2_configuration_recording_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._update( + voice_v2_configuration_recording_request=voice_v2_configuration_recording_request + ) + instance = RecordingInstance( + self._version, + payload, + id_or_unique_name=self._solution["id_or_unique_name"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _update_async( + self, + voice_v2_configuration_recording_request: Union[ + VoiceV2ConfigurationRecordingRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal async helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = voice_v2_configuration_recording_request.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return await self._version.update_with_response_info_async( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + async def update_async( + self, + voice_v2_configuration_recording_request: Union[ + VoiceV2ConfigurationRecordingRequest, object + ] = values.unset, + ) -> RecordingInstance: + """ + Asynchronous coroutine to update the RecordingInstance + + :param voice_v2_configuration_recording_request: + + :returns: The updated RecordingInstance + """ + payload, _, _ = await self._update_async( + voice_v2_configuration_recording_request=voice_v2_configuration_recording_request + ) + return RecordingInstance( + self._version, + payload, + id_or_unique_name=self._solution["id_or_unique_name"], + ) + + async def update_with_http_info_async( + self, + voice_v2_configuration_recording_request: Union[ + VoiceV2ConfigurationRecordingRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to update the RecordingInstance and return response metadata + + :param voice_v2_configuration_recording_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._update_async( + voice_v2_configuration_recording_request=voice_v2_configuration_recording_request + ) + instance = RecordingInstance( + self._version, + payload, + id_or_unique_name=self._solution["id_or_unique_name"], + ) + 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 "<Twilio.Voice.V2.RecordingContext {}>".format(context) + + +class RecordingList(ListResource): + + class VoiceV2ConfigurationRecordingCompositionPolicy(object): + """ + :ivar channels: The number of channels to be composed. + :ivar trim: Trim the silence in the recordings. + :ivar track: The audio track to record for the call. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.channels: Optional["RecordingInstance.str"] = payload.get("channels") + self.trim: Optional["RecordingInstance.str"] = payload.get("trim") + self.track: Optional["RecordingInstance.str"] = payload.get("track") + + def to_dict(self): + return { + "channels": self.channels, + "trim": self.trim, + "track": self.track, + } + + class VoiceV2ConfigurationRecordingConfiguration(object): + """ + :ivar configuration_type: The configuration type discriminator. Always \"Recording\" for this resource. + :ivar composition_policy: + :ivar call_recording_status_callback: + :ivar conference_recording_status_callback: + :ivar features: The features to apply to this recording. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.configuration_type: Optional["RecordingInstance.str"] = payload.get( + "configurationType" + ) + self.composition_policy: Optional[ + RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy + ] = payload.get("compositionPolicy") + self.call_recording_status_callback: Optional[ + RecordingList.VoiceV2ConfigurationRecordingStatusCallback + ] = payload.get("callRecordingStatusCallback") + self.conference_recording_status_callback: Optional[ + RecordingList.VoiceV2ConfigurationRecordingStatusCallback + ] = payload.get("conferenceRecordingStatusCallback") + self.features: Optional[ + List[RecordingList.VoiceV2ConfigurationRecordingFeature] + ] = payload.get("features") + + def to_dict(self): + return { + "configurationType": self.configuration_type, + "compositionPolicy": ( + self.composition_policy.to_dict() + if self.composition_policy is not None + else None + ), + "callRecordingStatusCallback": ( + self.call_recording_status_callback.to_dict() + if self.call_recording_status_callback is not None + else None + ), + "conferenceRecordingStatusCallback": ( + self.conference_recording_status_callback.to_dict() + if self.conference_recording_status_callback is not None + else None + ), + "features": ( + [features.to_dict() for features in self.features] + if self.features is not None + else None + ), + } + + class VoiceV2ConfigurationRecordingFeature(object): + """ + :ivar type: The type of feature. + :ivar feature_id: The ID of the feature. + :ivar description: The description of the feature. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.type: Optional["RecordingInstance.str"] = payload.get("type") + self.feature_id: Optional[str] = payload.get("featureId") + self.description: Optional[str] = payload.get("description") + + def to_dict(self): + return { + "type": self.type, + "featureId": self.feature_id, + "description": self.description, + } + + class VoiceV2ConfigurationRecordingRequest(object): + """ + :ivar unique_name: The unique name. + :ivar description: The description. + :ivar configuration: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.unique_name: Optional[str] = payload.get("unique_name") + self.description: Optional[str] = payload.get("description") + self.configuration: Optional[ + RecordingList.VoiceV2ConfigurationRecordingConfiguration + ] = payload.get("configuration") + + def to_dict(self): + return { + "unique_name": self.unique_name, + "description": self.description, + "configuration": ( + self.configuration.to_dict() + if self.configuration is not None + else None + ), + } + + class VoiceV2ConfigurationRecordingStatusCallback(object): + """ + :ivar url: The recording status callback URL. + :ivar method: The recording status callback method. + :ivar events: The recording status callback events. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.url: Optional[str] = payload.get("url") + self.method: Optional["RecordingInstance.str"] = payload.get("method") + self.events: Optional[List[Enumstr]] = payload.get("events") + + def to_dict(self): + return { + "url": self.url, + "method": self.method, + "events": self.events, + } + + def __init__(self, version: Version): + """ + Initialize the RecordingList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Configurations/Recording" + + def _create( + self, + voice_v2_configuration_recording_request: Union[ + VoiceV2ConfigurationRecordingRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = voice_v2_configuration_recording_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, + voice_v2_configuration_recording_request: Union[ + VoiceV2ConfigurationRecordingRequest, object + ] = values.unset, + ) -> RecordingInstance: + """ + Create the RecordingInstance + + :param voice_v2_configuration_recording_request: + + :returns: The created RecordingInstance + """ + payload, _, _ = self._create( + voice_v2_configuration_recording_request=voice_v2_configuration_recording_request + ) + return RecordingInstance(self._version, payload) + + def create_with_http_info( + self, + voice_v2_configuration_recording_request: Union[ + VoiceV2ConfigurationRecordingRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Create the RecordingInstance and return response metadata + + :param voice_v2_configuration_recording_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create( + voice_v2_configuration_recording_request=voice_v2_configuration_recording_request + ) + instance = RecordingInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async( + self, + voice_v2_configuration_recording_request: Union[ + VoiceV2ConfigurationRecordingRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = voice_v2_configuration_recording_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, + voice_v2_configuration_recording_request: Union[ + VoiceV2ConfigurationRecordingRequest, object + ] = values.unset, + ) -> RecordingInstance: + """ + Asynchronously create the RecordingInstance + + :param voice_v2_configuration_recording_request: + + :returns: The created RecordingInstance + """ + payload, _, _ = await self._create_async( + voice_v2_configuration_recording_request=voice_v2_configuration_recording_request + ) + return RecordingInstance(self._version, payload) + + async def create_with_http_info_async( + self, + voice_v2_configuration_recording_request: Union[ + VoiceV2ConfigurationRecordingRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronously create the RecordingInstance and return response metadata + + :param voice_v2_configuration_recording_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async( + voice_v2_configuration_recording_request=voice_v2_configuration_recording_request + ) + instance = RecordingInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def get(self, id_or_unique_name: str) -> RecordingContext: + """ + Constructs a RecordingContext + + :param id_or_unique_name: + """ + return RecordingContext(self._version, id_or_unique_name=id_or_unique_name) + + def __call__(self, id_or_unique_name: str) -> RecordingContext: + """ + Constructs a RecordingContext + + :param id_or_unique_name: + """ + return RecordingContext(self._version, id_or_unique_name=id_or_unique_name) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "<Twilio.Voice.V2.RecordingList>" diff --git a/twilio/rest/voice/v2/transcription.py b/twilio/rest/voice/v2/transcription.py new file mode 100644 index 0000000000..d76c1f421d --- /dev/null +++ b/twilio/rest/voice/v2/transcription.py @@ -0,0 +1,1067 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio API definition for public-api voice + Powers Twilio public-api voice + + 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 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 + + +class TranscriptionInstance(InstanceResource): + + class VoiceV2ConfigurationTranscriptionConfiguration(object): + """ + :ivar configuration_type: The configuration type discriminator. Always \"Transcription\" for this resource. + :ivar transcription_engine: The transcription engine provider. Supported values: 'google', 'deepgram', 'twilio_managed'. When using 'twilio_managed', do not specify a speechModel. + :ivar speech_model: The specific speech model to use for transcription. Valid models depend on transcriptionEngine: For 'google': chirp_2. For 'deepgram': nova-3, nova-2. For 'twilio_managed': twilio_managed. + :ivar language: Controls how the ASR handles language. Can be a supported BCP-47 language code, or 'multi' for multilingual code switching (Deepgram engine only). Supported language codes: en-US, en-GB, en-AU, de-DE, fr-FR, it-IT, es-MX, es-ES, es-US, pt-BR, pt-PT, nl-NL, no-NO, pl-PL, sv-SE, da-DK. + :ivar transcription_status_callback: + :ivar conversation_configuration_id: The ID of the Maestro Conversations Configuration for transcription storage and optional add-ons. + :ivar participant_defaults: Default participant roles and channel mappings for diarization and implicit participant creation. Must include exactly 2 participants mapping audioChannelIndex 1 and 2. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.configuration_type: Optional["TranscriptionInstance.str"] = ( + payload.get("configurationType") + ) + self.transcription_engine: Optional[str] = payload.get( + "transcriptionEngine" + ) + self.speech_model: Optional[str] = payload.get("speechModel") + self.language: Optional[str] = payload.get("language") + self.transcription_status_callback: Optional[ + TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback + ] = payload.get("transcriptionStatusCallback") + self.conversation_configuration_id: Optional[str] = payload.get( + "conversationConfigurationId" + ) + self.participant_defaults: Optional[ + List[ + TranscriptionList.VoiceV2ConfigurationTranscriptionParticipantDefault + ] + ] = payload.get("participantDefaults") + + def to_dict(self): + return { + "configurationType": self.configuration_type, + "transcriptionEngine": self.transcription_engine, + "speechModel": self.speech_model, + "language": self.language, + "transcriptionStatusCallback": ( + self.transcription_status_callback.to_dict() + if self.transcription_status_callback is not None + else None + ), + "conversationConfigurationId": self.conversation_configuration_id, + "participantDefaults": ( + [ + participant_defaults.to_dict() + for participant_defaults in self.participant_defaults + ] + if self.participant_defaults is not None + else None + ), + } + + class VoiceV2ConfigurationTranscriptionParticipantDefault(object): + """ + :ivar audio_channel_index: One-based index of the audio channel in a multi-channel recording associated with this role. + :ivar type: The participant role to apply when inferring participants. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.audio_channel_index: Optional[int] = payload.get("audioChannelIndex") + self.type: Optional["TranscriptionInstance.str"] = payload.get("type") + + def to_dict(self): + return { + "audioChannelIndex": self.audio_channel_index, + "type": self.type, + } + + class VoiceV2ConfigurationTranscriptionRequest(object): + """ + :ivar unique_name: The unique name. + :ivar description: The description. + :ivar configuration: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.unique_name: Optional[str] = payload.get("unique_name") + self.description: Optional[str] = payload.get("description") + self.configuration: Optional[ + TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration + ] = payload.get("configuration") + + def to_dict(self): + return { + "unique_name": self.unique_name, + "description": self.description, + "configuration": ( + self.configuration.to_dict() + if self.configuration is not None + else None + ), + } + + class VoiceV2ConfigurationTranscriptionStatusCallback(object): + """ + :ivar url: The webhook callback URL. + :ivar method: The HTTP method to use for the webhook callback. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.url: Optional[str] = payload.get("url") + self.method: Optional["TranscriptionInstance.str"] = payload.get("method") + + def to_dict(self): + return { + "url": self.url, + "method": self.method, + } + + """ + :ivar id: Configuration Identifier. + :ivar account_sid: Account sid. + :ivar unique_name: The unique name. + :ivar description: The description. + :ivar date_created: + :ivar date_updated: + :ivar configuration: + :ivar message: Error message + :ivar code: Twilio error code + :ivar status: status code + :ivar more_info: More information about the error + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + id_or_unique_name: Optional[str] = None, + ): + super().__init__(version) + + self.id: Optional[str] = payload.get("id") + self.account_sid: Optional[str] = payload.get("account_sid") + self.unique_name: Optional[str] = payload.get("unique_name") + self.description: Optional[str] = payload.get("description") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + self.configuration: Optional[str] = payload.get("configuration") + self.message: Optional[str] = payload.get("message") + self.code: Optional[int] = payload.get("code") + self.status: Optional[int] = payload.get("status") + self.more_info: Optional[str] = payload.get("more_info") + + self._solution = { + "id_or_unique_name": id_or_unique_name or self.id_or_unique_name, + } + + self._context: Optional[TranscriptionContext] = None + + @property + def _proxy(self) -> "TranscriptionContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: TranscriptionContext for this TranscriptionInstance + """ + if self._context is None: + self._context = TranscriptionContext( + self._version, + id_or_unique_name=self._solution["id_or_unique_name"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the TranscriptionInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the TranscriptionInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the TranscriptionInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return self._proxy.delete_with_http_info() + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the TranscriptionInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return await self._proxy.delete_with_http_info_async() + + def fetch(self) -> "TranscriptionInstance": + """ + Fetch the TranscriptionInstance + + + :returns: The fetched TranscriptionInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "TranscriptionInstance": + """ + Asynchronous coroutine to fetch the TranscriptionInstance + + + :returns: The fetched TranscriptionInstance + """ + return await self._proxy.fetch_async() + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the TranscriptionInstance 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 TranscriptionInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.fetch_with_http_info_async() + + def update( + self, + voice_v2_configuration_transcription_request: Union[ + VoiceV2ConfigurationTranscriptionRequest, object + ] = values.unset, + ) -> "TranscriptionInstance": + """ + Update the TranscriptionInstance + + :param voice_v2_configuration_transcription_request: + + :returns: The updated TranscriptionInstance + """ + return self._proxy.update( + voice_v2_configuration_transcription_request=voice_v2_configuration_transcription_request, + ) + + async def update_async( + self, + voice_v2_configuration_transcription_request: Union[ + VoiceV2ConfigurationTranscriptionRequest, object + ] = values.unset, + ) -> "TranscriptionInstance": + """ + Asynchronous coroutine to update the TranscriptionInstance + + :param voice_v2_configuration_transcription_request: + + :returns: The updated TranscriptionInstance + """ + return await self._proxy.update_async( + voice_v2_configuration_transcription_request=voice_v2_configuration_transcription_request, + ) + + def update_with_http_info( + self, + voice_v2_configuration_transcription_request: Union[ + VoiceV2ConfigurationTranscriptionRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Update the TranscriptionInstance with HTTP info + + :param voice_v2_configuration_transcription_request: + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.update_with_http_info( + voice_v2_configuration_transcription_request=voice_v2_configuration_transcription_request, + ) + + async def update_with_http_info_async( + self, + voice_v2_configuration_transcription_request: Union[ + VoiceV2ConfigurationTranscriptionRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to update the TranscriptionInstance with HTTP info + + :param voice_v2_configuration_transcription_request: + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.update_with_http_info_async( + voice_v2_configuration_transcription_request=voice_v2_configuration_transcription_request, + ) + + 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 "<Twilio.Voice.V2.TranscriptionInstance {}>".format(context) + + +class TranscriptionContext(InstanceContext): + + class VoiceV2ConfigurationTranscriptionConfiguration(object): + """ + :ivar configuration_type: The configuration type discriminator. Always \"Transcription\" for this resource. + :ivar transcription_engine: The transcription engine provider. Supported values: 'google', 'deepgram', 'twilio_managed'. When using 'twilio_managed', do not specify a speechModel. + :ivar speech_model: The specific speech model to use for transcription. Valid models depend on transcriptionEngine: For 'google': chirp_2. For 'deepgram': nova-3, nova-2. For 'twilio_managed': twilio_managed. + :ivar language: Controls how the ASR handles language. Can be a supported BCP-47 language code, or 'multi' for multilingual code switching (Deepgram engine only). Supported language codes: en-US, en-GB, en-AU, de-DE, fr-FR, it-IT, es-MX, es-ES, es-US, pt-BR, pt-PT, nl-NL, no-NO, pl-PL, sv-SE, da-DK. + :ivar transcription_status_callback: + :ivar conversation_configuration_id: The ID of the Maestro Conversations Configuration for transcription storage and optional add-ons. + :ivar participant_defaults: Default participant roles and channel mappings for diarization and implicit participant creation. Must include exactly 2 participants mapping audioChannelIndex 1 and 2. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.configuration_type: Optional["TranscriptionInstance.str"] = ( + payload.get("configurationType") + ) + self.transcription_engine: Optional[str] = payload.get( + "transcriptionEngine" + ) + self.speech_model: Optional[str] = payload.get("speechModel") + self.language: Optional[str] = payload.get("language") + self.transcription_status_callback: Optional[ + TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback + ] = payload.get("transcriptionStatusCallback") + self.conversation_configuration_id: Optional[str] = payload.get( + "conversationConfigurationId" + ) + self.participant_defaults: Optional[ + List[ + TranscriptionList.VoiceV2ConfigurationTranscriptionParticipantDefault + ] + ] = payload.get("participantDefaults") + + def to_dict(self): + return { + "configurationType": self.configuration_type, + "transcriptionEngine": self.transcription_engine, + "speechModel": self.speech_model, + "language": self.language, + "transcriptionStatusCallback": ( + self.transcription_status_callback.to_dict() + if self.transcription_status_callback is not None + else None + ), + "conversationConfigurationId": self.conversation_configuration_id, + "participantDefaults": ( + [ + participant_defaults.to_dict() + for participant_defaults in self.participant_defaults + ] + if self.participant_defaults is not None + else None + ), + } + + class VoiceV2ConfigurationTranscriptionParticipantDefault(object): + """ + :ivar audio_channel_index: One-based index of the audio channel in a multi-channel recording associated with this role. + :ivar type: The participant role to apply when inferring participants. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.audio_channel_index: Optional[int] = payload.get("audioChannelIndex") + self.type: Optional["TranscriptionInstance.str"] = payload.get("type") + + def to_dict(self): + return { + "audioChannelIndex": self.audio_channel_index, + "type": self.type, + } + + class VoiceV2ConfigurationTranscriptionRequest(object): + """ + :ivar unique_name: The unique name. + :ivar description: The description. + :ivar configuration: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.unique_name: Optional[str] = payload.get("unique_name") + self.description: Optional[str] = payload.get("description") + self.configuration: Optional[ + TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration + ] = payload.get("configuration") + + def to_dict(self): + return { + "unique_name": self.unique_name, + "description": self.description, + "configuration": ( + self.configuration.to_dict() + if self.configuration is not None + else None + ), + } + + class VoiceV2ConfigurationTranscriptionStatusCallback(object): + """ + :ivar url: The webhook callback URL. + :ivar method: The HTTP method to use for the webhook callback. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.url: Optional[str] = payload.get("url") + self.method: Optional["TranscriptionInstance.str"] = payload.get("method") + + def to_dict(self): + return { + "url": self.url, + "method": self.method, + } + + def __init__(self, version: Version, id_or_unique_name: str): + """ + Initialize the TranscriptionContext + + :param version: Version that contains the resource + :param id_or_unique_name: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id_or_unique_name": id_or_unique_name, + } + self._uri = "/Configurations/Transcription/{id_or_unique_name}".format( + **self._solution + ) + + def _delete(self) -> tuple: + """ + Internal helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return self._version.delete_with_response_info( + method="DELETE", uri=self._uri, headers=headers + ) + + def delete(self) -> bool: + """ + Deletes the TranscriptionInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = self._delete() + return success + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the TranscriptionInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = self._delete() + return ApiResponse(data=success, status_code=status_code, headers=headers) + + async def _delete_async(self) -> tuple: + """ + Internal async helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return await self._version.delete_with_response_info_async( + method="DELETE", uri=self._uri, headers=headers + ) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the TranscriptionInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = await self._delete_async() + return success + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the TranscriptionInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = await self._delete_async() + return ApiResponse(data=success, status_code=status_code, headers=headers) + + 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) -> TranscriptionInstance: + """ + Fetch the TranscriptionInstance + + + :returns: The fetched TranscriptionInstance + """ + payload, _, _ = self._fetch() + return TranscriptionInstance( + self._version, + payload, + id_or_unique_name=self._solution["id_or_unique_name"], + ) + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the TranscriptionInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._fetch() + instance = TranscriptionInstance( + self._version, + payload, + id_or_unique_name=self._solution["id_or_unique_name"], + ) + 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) -> TranscriptionInstance: + """ + Asynchronous coroutine to fetch the TranscriptionInstance + + + :returns: The fetched TranscriptionInstance + """ + payload, _, _ = await self._fetch_async() + return TranscriptionInstance( + self._version, + payload, + id_or_unique_name=self._solution["id_or_unique_name"], + ) + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to fetch the TranscriptionInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._fetch_async() + instance = TranscriptionInstance( + self._version, + payload, + id_or_unique_name=self._solution["id_or_unique_name"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def _update( + self, + voice_v2_configuration_transcription_request: Union[ + VoiceV2ConfigurationTranscriptionRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = voice_v2_configuration_transcription_request.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return self._version.update_with_response_info( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + def update( + self, + voice_v2_configuration_transcription_request: Union[ + VoiceV2ConfigurationTranscriptionRequest, object + ] = values.unset, + ) -> TranscriptionInstance: + """ + Update the TranscriptionInstance + + :param voice_v2_configuration_transcription_request: + + :returns: The updated TranscriptionInstance + """ + payload, _, _ = self._update( + voice_v2_configuration_transcription_request=voice_v2_configuration_transcription_request + ) + return TranscriptionInstance( + self._version, + payload, + id_or_unique_name=self._solution["id_or_unique_name"], + ) + + def update_with_http_info( + self, + voice_v2_configuration_transcription_request: Union[ + VoiceV2ConfigurationTranscriptionRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Update the TranscriptionInstance and return response metadata + + :param voice_v2_configuration_transcription_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._update( + voice_v2_configuration_transcription_request=voice_v2_configuration_transcription_request + ) + instance = TranscriptionInstance( + self._version, + payload, + id_or_unique_name=self._solution["id_or_unique_name"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _update_async( + self, + voice_v2_configuration_transcription_request: Union[ + VoiceV2ConfigurationTranscriptionRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal async helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = voice_v2_configuration_transcription_request.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return await self._version.update_with_response_info_async( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + async def update_async( + self, + voice_v2_configuration_transcription_request: Union[ + VoiceV2ConfigurationTranscriptionRequest, object + ] = values.unset, + ) -> TranscriptionInstance: + """ + Asynchronous coroutine to update the TranscriptionInstance + + :param voice_v2_configuration_transcription_request: + + :returns: The updated TranscriptionInstance + """ + payload, _, _ = await self._update_async( + voice_v2_configuration_transcription_request=voice_v2_configuration_transcription_request + ) + return TranscriptionInstance( + self._version, + payload, + id_or_unique_name=self._solution["id_or_unique_name"], + ) + + async def update_with_http_info_async( + self, + voice_v2_configuration_transcription_request: Union[ + VoiceV2ConfigurationTranscriptionRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to update the TranscriptionInstance and return response metadata + + :param voice_v2_configuration_transcription_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._update_async( + voice_v2_configuration_transcription_request=voice_v2_configuration_transcription_request + ) + instance = TranscriptionInstance( + self._version, + payload, + id_or_unique_name=self._solution["id_or_unique_name"], + ) + 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 "<Twilio.Voice.V2.TranscriptionContext {}>".format(context) + + +class TranscriptionList(ListResource): + + class VoiceV2ConfigurationTranscriptionConfiguration(object): + """ + :ivar configuration_type: The configuration type discriminator. Always \"Transcription\" for this resource. + :ivar transcription_engine: The transcription engine provider. Supported values: 'google', 'deepgram', 'twilio_managed'. When using 'twilio_managed', do not specify a speechModel. + :ivar speech_model: The specific speech model to use for transcription. Valid models depend on transcriptionEngine: For 'google': chirp_2. For 'deepgram': nova-3, nova-2. For 'twilio_managed': twilio_managed. + :ivar language: Controls how the ASR handles language. Can be a supported BCP-47 language code, or 'multi' for multilingual code switching (Deepgram engine only). Supported language codes: en-US, en-GB, en-AU, de-DE, fr-FR, it-IT, es-MX, es-ES, es-US, pt-BR, pt-PT, nl-NL, no-NO, pl-PL, sv-SE, da-DK. + :ivar transcription_status_callback: + :ivar conversation_configuration_id: The ID of the Maestro Conversations Configuration for transcription storage and optional add-ons. + :ivar participant_defaults: Default participant roles and channel mappings for diarization and implicit participant creation. Must include exactly 2 participants mapping audioChannelIndex 1 and 2. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.configuration_type: Optional["TranscriptionInstance.str"] = ( + payload.get("configurationType") + ) + self.transcription_engine: Optional[str] = payload.get( + "transcriptionEngine" + ) + self.speech_model: Optional[str] = payload.get("speechModel") + self.language: Optional[str] = payload.get("language") + self.transcription_status_callback: Optional[ + TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback + ] = payload.get("transcriptionStatusCallback") + self.conversation_configuration_id: Optional[str] = payload.get( + "conversationConfigurationId" + ) + self.participant_defaults: Optional[ + List[ + TranscriptionList.VoiceV2ConfigurationTranscriptionParticipantDefault + ] + ] = payload.get("participantDefaults") + + def to_dict(self): + return { + "configurationType": self.configuration_type, + "transcriptionEngine": self.transcription_engine, + "speechModel": self.speech_model, + "language": self.language, + "transcriptionStatusCallback": ( + self.transcription_status_callback.to_dict() + if self.transcription_status_callback is not None + else None + ), + "conversationConfigurationId": self.conversation_configuration_id, + "participantDefaults": ( + [ + participant_defaults.to_dict() + for participant_defaults in self.participant_defaults + ] + if self.participant_defaults is not None + else None + ), + } + + class VoiceV2ConfigurationTranscriptionParticipantDefault(object): + """ + :ivar audio_channel_index: One-based index of the audio channel in a multi-channel recording associated with this role. + :ivar type: The participant role to apply when inferring participants. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.audio_channel_index: Optional[int] = payload.get("audioChannelIndex") + self.type: Optional["TranscriptionInstance.str"] = payload.get("type") + + def to_dict(self): + return { + "audioChannelIndex": self.audio_channel_index, + "type": self.type, + } + + class VoiceV2ConfigurationTranscriptionRequest(object): + """ + :ivar unique_name: The unique name. + :ivar description: The description. + :ivar configuration: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.unique_name: Optional[str] = payload.get("unique_name") + self.description: Optional[str] = payload.get("description") + self.configuration: Optional[ + TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration + ] = payload.get("configuration") + + def to_dict(self): + return { + "unique_name": self.unique_name, + "description": self.description, + "configuration": ( + self.configuration.to_dict() + if self.configuration is not None + else None + ), + } + + class VoiceV2ConfigurationTranscriptionStatusCallback(object): + """ + :ivar url: The webhook callback URL. + :ivar method: The HTTP method to use for the webhook callback. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.url: Optional[str] = payload.get("url") + self.method: Optional["TranscriptionInstance.str"] = payload.get("method") + + def to_dict(self): + return { + "url": self.url, + "method": self.method, + } + + def __init__(self, version: Version): + """ + Initialize the TranscriptionList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Configurations/Transcription" + + def _create( + self, + voice_v2_configuration_transcription_request: Union[ + VoiceV2ConfigurationTranscriptionRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = voice_v2_configuration_transcription_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, + voice_v2_configuration_transcription_request: Union[ + VoiceV2ConfigurationTranscriptionRequest, object + ] = values.unset, + ) -> TranscriptionInstance: + """ + Create the TranscriptionInstance + + :param voice_v2_configuration_transcription_request: + + :returns: The created TranscriptionInstance + """ + payload, _, _ = self._create( + voice_v2_configuration_transcription_request=voice_v2_configuration_transcription_request + ) + return TranscriptionInstance(self._version, payload) + + def create_with_http_info( + self, + voice_v2_configuration_transcription_request: Union[ + VoiceV2ConfigurationTranscriptionRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Create the TranscriptionInstance and return response metadata + + :param voice_v2_configuration_transcription_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create( + voice_v2_configuration_transcription_request=voice_v2_configuration_transcription_request + ) + instance = TranscriptionInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async( + self, + voice_v2_configuration_transcription_request: Union[ + VoiceV2ConfigurationTranscriptionRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = voice_v2_configuration_transcription_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, + voice_v2_configuration_transcription_request: Union[ + VoiceV2ConfigurationTranscriptionRequest, object + ] = values.unset, + ) -> TranscriptionInstance: + """ + Asynchronously create the TranscriptionInstance + + :param voice_v2_configuration_transcription_request: + + :returns: The created TranscriptionInstance + """ + payload, _, _ = await self._create_async( + voice_v2_configuration_transcription_request=voice_v2_configuration_transcription_request + ) + return TranscriptionInstance(self._version, payload) + + async def create_with_http_info_async( + self, + voice_v2_configuration_transcription_request: Union[ + VoiceV2ConfigurationTranscriptionRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronously create the TranscriptionInstance and return response metadata + + :param voice_v2_configuration_transcription_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async( + voice_v2_configuration_transcription_request=voice_v2_configuration_transcription_request + ) + instance = TranscriptionInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def get(self, id_or_unique_name: str) -> TranscriptionContext: + """ + Constructs a TranscriptionContext + + :param id_or_unique_name: + """ + return TranscriptionContext(self._version, id_or_unique_name=id_or_unique_name) + + def __call__(self, id_or_unique_name: str) -> TranscriptionContext: + """ + Constructs a TranscriptionContext + + :param id_or_unique_name: + """ + return TranscriptionContext(self._version, id_or_unique_name=id_or_unique_name) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "<Twilio.Voice.V2.TranscriptionList>" diff --git a/twilio/rest/voice/v2/type.py b/twilio/rest/voice/v2/type.py new file mode 100644 index 0000000000..36106ff921 --- /dev/null +++ b/twilio/rest/voice/v2/type.py @@ -0,0 +1,683 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio API definition for public-api voice + Powers Twilio public-api voice + + 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, Optional, Union +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 + + +class TypeInstance(InstanceResource): + + class VoiceV2ConfigurationRequest(object): + """ + :ivar unique_name: The unique name + :ivar description: The description + :ivar configuration: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.unique_name: Optional[str] = payload.get("unique_name") + self.description: Optional[str] = payload.get("description") + self.configuration: Optional[Dict[str, object]] = payload.get( + "configuration" + ) + + def to_dict(self): + return { + "unique_name": self.unique_name, + "description": self.description, + "configuration": self.configuration, + } + + """ + :ivar message: Error message + :ivar code: Twilio error code + :ivar status: status code + :ivar more_info: More information about the error + :ivar id: Configuration Identifier + :ivar account_sid: Account sid + :ivar unique_name: The unique name + :ivar description: The description + :ivar date_created: + :ivar date_updated: + :ivar configuration: + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + type: Optional[str] = None, + id_or_unique_name: Optional[str] = None, + ): + super().__init__(version) + + self.message: Optional[str] = payload.get("message") + self.code: Optional[int] = payload.get("code") + self.status: Optional[int] = payload.get("status") + self.more_info: Optional[str] = payload.get("more_info") + self.id: Optional[str] = payload.get("id") + self.account_sid: Optional[str] = payload.get("account_sid") + self.unique_name: Optional[str] = payload.get("unique_name") + self.description: Optional[str] = payload.get("description") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + self.configuration: Optional[Dict[str, object]] = payload.get("configuration") + + self._solution = { + "type": type or self.type, + "id_or_unique_name": id_or_unique_name or self.id_or_unique_name, + } + + self._context: Optional[TypeContext] = None + + @property + def _proxy(self) -> "TypeContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: TypeContext for this TypeInstance + """ + if self._context is None: + self._context = TypeContext( + self._version, + type=self._solution["type"], + id_or_unique_name=self._solution["id_or_unique_name"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the TypeInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the TypeInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the TypeInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return self._proxy.delete_with_http_info() + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the TypeInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return await self._proxy.delete_with_http_info_async() + + def fetch(self) -> "TypeInstance": + """ + Fetch the TypeInstance + + + :returns: The fetched TypeInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "TypeInstance": + """ + Asynchronous coroutine to fetch the TypeInstance + + + :returns: The fetched TypeInstance + """ + return await self._proxy.fetch_async() + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the TypeInstance 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 TypeInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.fetch_with_http_info_async() + + def update( + self, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> "TypeInstance": + """ + Update the TypeInstance + + :param voice_v2_configuration_request: + + :returns: The updated TypeInstance + """ + return self._proxy.update( + voice_v2_configuration_request=voice_v2_configuration_request, + ) + + async def update_async( + self, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> "TypeInstance": + """ + Asynchronous coroutine to update the TypeInstance + + :param voice_v2_configuration_request: + + :returns: The updated TypeInstance + """ + return await self._proxy.update_async( + voice_v2_configuration_request=voice_v2_configuration_request, + ) + + def update_with_http_info( + self, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Update the TypeInstance with HTTP info + + :param voice_v2_configuration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.update_with_http_info( + voice_v2_configuration_request=voice_v2_configuration_request, + ) + + async def update_with_http_info_async( + self, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to update the TypeInstance with HTTP info + + :param voice_v2_configuration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.update_with_http_info_async( + voice_v2_configuration_request=voice_v2_configuration_request, + ) + + 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 "<Twilio.Voice.V2.TypeInstance {}>".format(context) + + +class TypeContext(InstanceContext): + + class VoiceV2ConfigurationRequest(object): + """ + :ivar unique_name: The unique name + :ivar description: The description + :ivar configuration: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.unique_name: Optional[str] = payload.get("unique_name") + self.description: Optional[str] = payload.get("description") + self.configuration: Optional[Dict[str, object]] = payload.get( + "configuration" + ) + + def to_dict(self): + return { + "unique_name": self.unique_name, + "description": self.description, + "configuration": self.configuration, + } + + def __init__(self, version: Version, type: str, id_or_unique_name: str): + """ + Initialize the TypeContext + + :param version: Version that contains the resource + :param type: + :param id_or_unique_name: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "type": type, + "id_or_unique_name": id_or_unique_name, + } + self._uri = "/Configurations/{type}/{id_or_unique_name}".format( + **self._solution + ) + + def _delete(self) -> tuple: + """ + Internal helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return self._version.delete_with_response_info( + method="DELETE", uri=self._uri, headers=headers + ) + + def delete(self) -> bool: + """ + Deletes the TypeInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = self._delete() + return success + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the TypeInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = self._delete() + return ApiResponse(data=success, status_code=status_code, headers=headers) + + async def _delete_async(self) -> tuple: + """ + Internal async helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return await self._version.delete_with_response_info_async( + method="DELETE", uri=self._uri, headers=headers + ) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the TypeInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = await self._delete_async() + return success + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the TypeInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = await self._delete_async() + return ApiResponse(data=success, status_code=status_code, headers=headers) + + 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) -> TypeInstance: + """ + Fetch the TypeInstance + + + :returns: The fetched TypeInstance + """ + payload, _, _ = self._fetch() + return TypeInstance( + self._version, + payload, + type=self._solution["type"], + id_or_unique_name=self._solution["id_or_unique_name"], + ) + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the TypeInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._fetch() + instance = TypeInstance( + self._version, + payload, + type=self._solution["type"], + id_or_unique_name=self._solution["id_or_unique_name"], + ) + 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) -> TypeInstance: + """ + Asynchronous coroutine to fetch the TypeInstance + + + :returns: The fetched TypeInstance + """ + payload, _, _ = await self._fetch_async() + return TypeInstance( + self._version, + payload, + type=self._solution["type"], + id_or_unique_name=self._solution["id_or_unique_name"], + ) + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to fetch the TypeInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._fetch_async() + instance = TypeInstance( + self._version, + payload, + type=self._solution["type"], + id_or_unique_name=self._solution["id_or_unique_name"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def _update( + self, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = voice_v2_configuration_request.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return self._version.update_with_response_info( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + def update( + self, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> TypeInstance: + """ + Update the TypeInstance + + :param voice_v2_configuration_request: + + :returns: The updated TypeInstance + """ + payload, _, _ = self._update( + voice_v2_configuration_request=voice_v2_configuration_request + ) + return TypeInstance( + self._version, + payload, + type=self._solution["type"], + id_or_unique_name=self._solution["id_or_unique_name"], + ) + + def update_with_http_info( + self, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Update the TypeInstance and return response metadata + + :param voice_v2_configuration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._update( + voice_v2_configuration_request=voice_v2_configuration_request + ) + instance = TypeInstance( + self._version, + payload, + type=self._solution["type"], + id_or_unique_name=self._solution["id_or_unique_name"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _update_async( + self, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> tuple: + """ + Internal async helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = voice_v2_configuration_request.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return await self._version.update_with_response_info_async( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + async def update_async( + self, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> TypeInstance: + """ + Asynchronous coroutine to update the TypeInstance + + :param voice_v2_configuration_request: + + :returns: The updated TypeInstance + """ + payload, _, _ = await self._update_async( + voice_v2_configuration_request=voice_v2_configuration_request + ) + return TypeInstance( + self._version, + payload, + type=self._solution["type"], + id_or_unique_name=self._solution["id_or_unique_name"], + ) + + async def update_with_http_info_async( + self, + voice_v2_configuration_request: Union[ + VoiceV2ConfigurationRequest, object + ] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to update the TypeInstance and return response metadata + + :param voice_v2_configuration_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._update_async( + voice_v2_configuration_request=voice_v2_configuration_request + ) + instance = TypeInstance( + self._version, + payload, + type=self._solution["type"], + id_or_unique_name=self._solution["id_or_unique_name"], + ) + 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 "<Twilio.Voice.V2.TypeContext {}>".format(context) + + +class TypeList(ListResource): + + class VoiceV2ConfigurationRequest(object): + """ + :ivar unique_name: The unique name + :ivar description: The description + :ivar configuration: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.unique_name: Optional[str] = payload.get("unique_name") + self.description: Optional[str] = payload.get("description") + self.configuration: Optional[Dict[str, object]] = payload.get( + "configuration" + ) + + def to_dict(self): + return { + "unique_name": self.unique_name, + "description": self.description, + "configuration": self.configuration, + } + + def __init__(self, version: Version): + """ + Initialize the TypeList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, type: str, id_or_unique_name: str) -> TypeContext: + """ + Constructs a TypeContext + + :param type: + :param id_or_unique_name: + """ + return TypeContext( + self._version, type=type, id_or_unique_name=id_or_unique_name + ) + + def __call__(self, type: str, id_or_unique_name: str) -> TypeContext: + """ + Constructs a TypeContext + + :param type: + :param id_or_unique_name: + """ + return TypeContext( + self._version, type=type, id_or_unique_name=id_or_unique_name + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "<Twilio.Voice.V2.TypeList>" diff --git a/twilio/twiml/voice_response.py b/twilio/twiml/voice_response.py index 384c492778..8a5d0029bf 100644 --- a/twilio/twiml/voice_response.py +++ b/twilio/twiml/voice_response.py @@ -52,6 +52,7 @@ def dial( refer_url=None, refer_method=None, events=None, + passports=None, **kwargs ): """ @@ -77,6 +78,7 @@ def dial( :param refer_url: Webhook that will receive future SIP REFER requests :param refer_method: The HTTP method to use for the refer Webhook :param events: Subscription to events + :param passports: Base64-encoded comma-separated identity passports (e.g. shaken, div) :param kwargs: additional attributes :returns: <Dial> element @@ -103,6 +105,7 @@ def dial( refer_url=refer_url, refer_method=refer_method, events=events, + passports=passports, **kwargs ) ) @@ -3011,86 +3014,6 @@ def conversation_relay( ) ) - def assistant( - self, - id=None, - language=None, - tts_language=None, - transcription_language=None, - tts_provider=None, - voice=None, - transcription_provider=None, - speech_model=None, - profanity_filter=None, - dtmf_detection=None, - welcome_greeting=None, - partial_prompts=None, - welcome_greeting_interruptible=None, - interruptible=None, - preemptible=None, - hints=None, - intelligence_service=None, - report_input_during_agent_speech=None, - elevenlabs_text_normalization=None, - interrupt_sensitivity=None, - debug=None, - **kwargs - ): - """ - Create a <Assistant> element - - :param id: The assistant ID of the AI Assistant - :param language: Language to be used for both text-to-speech and transcription - :param tts_language: Language to be used for text-to-speech - :param transcription_language: Language to be used for transcription - :param tts_provider: Provider to be used for text-to-speech - :param voice: Voice to be used for text-to-speech - :param transcription_provider: Provider to be used for transcription - :param speech_model: Speech model to be used for transcription - :param profanity_filter: Whether profanities should be filtered out of the speech transcription - :param dtmf_detection: Whether DTMF tones should be detected and reported in speech transcription - :param welcome_greeting: The sentence to be played automatically when the session is connected - :param partial_prompts: Whether partial prompts should be reported to WebSocket server before the caller finishes speaking - :param welcome_greeting_interruptible: "Whether and how the input from a caller, such as speaking or DTMF can interrupt the welcome greeting - :param interruptible: Whether and how the input from a caller, such as speaking or DTMF can interrupt the play of text-to-speech - :param preemptible: Whether subsequent text-to-speech or play media can interrupt the on-going play of text-to-speech or media - :param hints: Phrases to help better accuracy in speech recognition of these pharases - :param intelligence_service: The Conversational Intelligence Service id or unique name to be used for the session - :param report_input_during_agent_speech: Whether prompts should be reported to WebSocket server when text-to-speech playing and interrupt is disabled - :param elevenlabs_text_normalization: When using ElevenLabs as TTS provider, this parameter allows you to enable or disable its text normalization feature - :param interrupt_sensitivity: Set the sensitivity of the interrupt feature for speech. The value can be low, medium, or high - :param debug: Multiple debug options to be used for troubleshooting - :param kwargs: additional attributes - - :returns: <Assistant> element - """ - return self.nest( - Assistant( - id=id, - language=language, - tts_language=tts_language, - transcription_language=transcription_language, - tts_provider=tts_provider, - voice=voice, - transcription_provider=transcription_provider, - speech_model=speech_model, - profanity_filter=profanity_filter, - dtmf_detection=dtmf_detection, - welcome_greeting=welcome_greeting, - partial_prompts=partial_prompts, - welcome_greeting_interruptible=welcome_greeting_interruptible, - interruptible=interruptible, - preemptible=preemptible, - hints=hints, - intelligence_service=intelligence_service, - report_input_during_agent_speech=report_input_during_agent_speech, - elevenlabs_text_normalization=elevenlabs_text_normalization, - interrupt_sensitivity=interrupt_sensitivity, - debug=debug, - **kwargs - ) - ) - def ai_session(self, ai_connector=None, ai_session_configuration=None, **kwargs): """ Create a <AiSession> element @@ -3146,12 +3069,12 @@ def __init__(self, **kwargs): self.name = "AiSession" -class Assistant(TwiML): - """<Assistant> TwiML Noun""" +class ConversationRelay(TwiML): + """<ConversationRelay> TwiML Noun""" def __init__(self, **kwargs): - super(Assistant, self).__init__(**kwargs) - self.name = "Assistant" + super(ConversationRelay, self).__init__(**kwargs) + self.name = "ConversationRelay" def language( self, @@ -3206,58 +3129,6 @@ def __init__(self, **kwargs): self.name = "Language" -class ConversationRelay(TwiML): - """<ConversationRelay> TwiML Noun""" - - def __init__(self, **kwargs): - super(ConversationRelay, self).__init__(**kwargs) - self.name = "ConversationRelay" - - def language( - self, - code=None, - tts_provider=None, - voice=None, - transcription_provider=None, - speech_model=None, - **kwargs - ): - """ - Create a <Language> element - - :param code: Language code of this language setting is for - :param tts_provider: Provider to be used for text-to-speech of this language - :param voice: Voice to be used for text-to-speech of this language - :param transcription_provider: Provider to be used for transcription of this language - :param speech_model: Speech model to be used for transcription of this language - :param kwargs: additional attributes - - :returns: <Language> element - """ - return self.nest( - Language( - code=code, - tts_provider=tts_provider, - voice=voice, - transcription_provider=transcription_provider, - speech_model=speech_model, - **kwargs - ) - ) - - def parameter(self, name=None, value=None, **kwargs): - """ - Create a <Parameter> element - - :param name: The name of the custom parameter - :param value: The value of the custom parameter - :param kwargs: additional attributes - - :returns: <Parameter> element - """ - return self.nest(Parameter(name=name, value=value, **kwargs)) - - class Conversation(TwiML): """<Conversation> TwiML Noun""" From 7e0ed6727d937e27ff216f0fb058e613ffb9e24d Mon Sep 17 00:00:00 2001 From: Twilio <team_interfaces+github@twilio.com> Date: Tue, 11 Aug 2026 16:01:29 +0530 Subject: [PATCH 2/2] Release 9.11.0 --- setup.py | 2 +- twilio/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 09672cd205..c315083711 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setup( name="twilio", - version="9.10.9", + version="9.11.0", 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 f089e67949..2ef30c7eb0 100644 --- a/twilio/__init__.py +++ b/twilio/__init__.py @@ -1,2 +1,2 @@ -__version_info__ = ("9", "10", "9") +__version_info__ = ("9", "11", "0") __version__ = ".".join(__version_info__)