diff --git a/CHANGES.md b/CHANGES.md index 3f7e5575a..1225c2aca 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,12 @@ twilio-python Changelog Here you can see the full list of changes between each twilio-python release. +[2025-01-31] Version 9.5.0 +-------------------------- +**Twiml** +- Convert Twiml Attribute `speechModel` of type enum to string **(breaking change)** + + [2025-01-28] Version 9.4.4 -------------------------- **Library - Fix** diff --git a/twilio/rest/content/v1/content/__init__.py b/twilio/rest/content/v1/content/__init__.py index 6223e940b..60a5b0501 100644 --- a/twilio/rest/content/v1/content/__init__.py +++ b/twilio/rest/content/v1/content/__init__.py @@ -525,26 +525,6 @@ def to_dict(self): ), } - class TwilioSchedule(object): - """ - :ivar id: - :ivar title: - :ivar time_slots: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.id: Optional[str] = payload.get("id") - self.title: Optional[str] = payload.get("title") - self.time_slots: Optional[str] = payload.get("time_slots") - - def to_dict(self): - return { - "id": self.id, - "title": self.title, - "time_slots": self.time_slots, - } - class TwilioText(object): """ :ivar body: @@ -571,7 +551,6 @@ class Types(object): :ivar twilio_catalog: :ivar twilio_carousel: :ivar twilio_flows: - :ivar twilio_schedule: :ivar whatsapp_card: :ivar whatsapp_authentication: """ @@ -608,9 +587,6 @@ def __init__(self, payload: Dict[str, Any]): self.twilio_flows: Optional[ContentList.TwilioFlows] = payload.get( "twilio_flows" ) - self.twilio_schedule: Optional[ContentList.TwilioSchedule] = payload.get( - "twilio_schedule" - ) self.whatsapp_card: Optional[ContentList.WhatsappCard] = payload.get( "whatsapp_card" ) @@ -666,11 +642,6 @@ def to_dict(self): if self.twilio_flows is not None else None ), - "twilio_schedule": ( - self.twilio_schedule.to_dict() - if self.twilio_schedule is not None - else None - ), "whatsapp_card": ( self.whatsapp_card.to_dict() if self.whatsapp_card is not None @@ -1384,26 +1355,6 @@ def to_dict(self): ), } - class TwilioSchedule(object): - """ - :ivar id: - :ivar title: - :ivar time_slots: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.id: Optional[str] = payload.get("id") - self.title: Optional[str] = payload.get("title") - self.time_slots: Optional[str] = payload.get("time_slots") - - def to_dict(self): - return { - "id": self.id, - "title": self.title, - "time_slots": self.time_slots, - } - class TwilioText(object): """ :ivar body: @@ -1430,7 +1381,6 @@ class Types(object): :ivar twilio_catalog: :ivar twilio_carousel: :ivar twilio_flows: - :ivar twilio_schedule: :ivar whatsapp_card: :ivar whatsapp_authentication: """ @@ -1467,9 +1417,6 @@ def __init__(self, payload: Dict[str, Any]): self.twilio_flows: Optional[ContentList.TwilioFlows] = payload.get( "twilio_flows" ) - self.twilio_schedule: Optional[ContentList.TwilioSchedule] = payload.get( - "twilio_schedule" - ) self.whatsapp_card: Optional[ContentList.WhatsappCard] = payload.get( "whatsapp_card" ) @@ -1525,11 +1472,6 @@ def to_dict(self): if self.twilio_flows is not None else None ), - "twilio_schedule": ( - self.twilio_schedule.to_dict() - if self.twilio_schedule is not None - else None - ), "whatsapp_card": ( self.whatsapp_card.to_dict() if self.whatsapp_card is not None @@ -2244,26 +2186,6 @@ def to_dict(self): ), } - class TwilioSchedule(object): - """ - :ivar id: - :ivar title: - :ivar time_slots: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.id: Optional[str] = payload.get("id") - self.title: Optional[str] = payload.get("title") - self.time_slots: Optional[str] = payload.get("time_slots") - - def to_dict(self): - return { - "id": self.id, - "title": self.title, - "time_slots": self.time_slots, - } - class TwilioText(object): """ :ivar body: @@ -2290,7 +2212,6 @@ class Types(object): :ivar twilio_catalog: :ivar twilio_carousel: :ivar twilio_flows: - :ivar twilio_schedule: :ivar whatsapp_card: :ivar whatsapp_authentication: """ @@ -2327,9 +2248,6 @@ def __init__(self, payload: Dict[str, Any]): self.twilio_flows: Optional[ContentList.TwilioFlows] = payload.get( "twilio_flows" ) - self.twilio_schedule: Optional[ContentList.TwilioSchedule] = payload.get( - "twilio_schedule" - ) self.whatsapp_card: Optional[ContentList.WhatsappCard] = payload.get( "whatsapp_card" ) @@ -2385,11 +2303,6 @@ def to_dict(self): if self.twilio_flows is not None else None ), - "twilio_schedule": ( - self.twilio_schedule.to_dict() - if self.twilio_schedule is not None - else None - ), "whatsapp_card": ( self.whatsapp_card.to_dict() if self.whatsapp_card is not None diff --git a/twilio/rest/conversations/v1/address_configuration.py b/twilio/rest/conversations/v1/address_configuration.py index 1609d9957..4ebfa47fc 100644 --- a/twilio/rest/conversations/v1/address_configuration.py +++ b/twilio/rest/conversations/v1/address_configuration.py @@ -40,7 +40,6 @@ class Type(object): GBM = "gbm" EMAIL = "email" RCS = "rcs" - APPLE = "apple" """ :ivar sid: A 34 character string that uniquely identifies this resource. diff --git a/twilio/rest/events/v1/subscription/__init__.py b/twilio/rest/events/v1/subscription/__init__.py index e77cf10b5..872c9ed7d 100644 --- a/twilio/rest/events/v1/subscription/__init__.py +++ b/twilio/rest/events/v1/subscription/__init__.py @@ -33,7 +33,6 @@ class SubscriptionInstance(InstanceResource): :ivar sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created. :ivar url: The URL of this resource. :ivar links: Contains a dictionary of URL links to nested resources of this Subscription. - :ivar receive_events_from_subaccounts: Receive events from all children accounts in the parent account subscription. """ def __init__( @@ -53,9 +52,6 @@ def __init__( self.sink_sid: Optional[str] = payload.get("sink_sid") self.url: Optional[str] = payload.get("url") self.links: Optional[Dict[str, object]] = payload.get("links") - self.receive_events_from_subaccounts: Optional[bool] = payload.get( - "receive_events_from_subaccounts" - ) self._solution = { "sid": sid or self.sid, @@ -117,42 +113,36 @@ def update( self, description: Union[str, object] = values.unset, sink_sid: Union[str, object] = values.unset, - receive_events_from_subaccounts: Union[bool, object] = values.unset, ) -> "SubscriptionInstance": """ Update the SubscriptionInstance :param description: A human readable description for the Subscription. :param sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created. - :param receive_events_from_subaccounts: Receive events from all children accounts in the parent account subscription. :returns: The updated SubscriptionInstance """ return self._proxy.update( description=description, sink_sid=sink_sid, - receive_events_from_subaccounts=receive_events_from_subaccounts, ) async def update_async( self, description: Union[str, object] = values.unset, sink_sid: Union[str, object] = values.unset, - receive_events_from_subaccounts: Union[bool, object] = values.unset, ) -> "SubscriptionInstance": """ Asynchronous coroutine to update the SubscriptionInstance :param description: A human readable description for the Subscription. :param sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created. - :param receive_events_from_subaccounts: Receive events from all children accounts in the parent account subscription. :returns: The updated SubscriptionInstance """ return await self._proxy.update_async( description=description, sink_sid=sink_sid, - receive_events_from_subaccounts=receive_events_from_subaccounts, ) @property @@ -263,14 +253,12 @@ def update( self, description: Union[str, object] = values.unset, sink_sid: Union[str, object] = values.unset, - receive_events_from_subaccounts: Union[bool, object] = values.unset, ) -> SubscriptionInstance: """ Update the SubscriptionInstance :param description: A human readable description for the Subscription. :param sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created. - :param receive_events_from_subaccounts: Receive events from all children accounts in the parent account subscription. :returns: The updated SubscriptionInstance """ @@ -279,9 +267,6 @@ def update( { "Description": description, "SinkSid": sink_sid, - "ReceiveEventsFromSubaccounts": serialize.boolean_to_string( - receive_events_from_subaccounts - ), } ) headers = values.of({}) @@ -300,14 +285,12 @@ async def update_async( self, description: Union[str, object] = values.unset, sink_sid: Union[str, object] = values.unset, - receive_events_from_subaccounts: Union[bool, object] = values.unset, ) -> SubscriptionInstance: """ Asynchronous coroutine to update the SubscriptionInstance :param description: A human readable description for the Subscription. :param sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created. - :param receive_events_from_subaccounts: Receive events from all children accounts in the parent account subscription. :returns: The updated SubscriptionInstance """ @@ -316,9 +299,6 @@ async def update_async( { "Description": description, "SinkSid": sink_sid, - "ReceiveEventsFromSubaccounts": serialize.boolean_to_string( - receive_events_from_subaccounts - ), } ) headers = values.of({}) @@ -388,11 +368,7 @@ def __init__(self, version: Version): self._uri = "/Subscriptions" def create( - self, - description: str, - sink_sid: str, - types: List[object], - receive_events_from_subaccounts: Union[bool, object] = values.unset, + self, description: str, sink_sid: str, types: List[object] ) -> SubscriptionInstance: """ Create the SubscriptionInstance @@ -400,7 +376,6 @@ def create( :param description: A human readable description for the Subscription **This value should not contain PII.** :param sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created. :param types: An array of objects containing the subscribed Event Types - :param receive_events_from_subaccounts: Receive events from all children accounts in the parent account subscription. :returns: The created SubscriptionInstance """ @@ -410,9 +385,6 @@ def create( "Description": description, "SinkSid": sink_sid, "Types": serialize.map(types, lambda e: serialize.object(e)), - "ReceiveEventsFromSubaccounts": serialize.boolean_to_string( - receive_events_from_subaccounts - ), } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) @@ -428,11 +400,7 @@ def create( return SubscriptionInstance(self._version, payload) async def create_async( - self, - description: str, - sink_sid: str, - types: List[object], - receive_events_from_subaccounts: Union[bool, object] = values.unset, + self, description: str, sink_sid: str, types: List[object] ) -> SubscriptionInstance: """ Asynchronously create the SubscriptionInstance @@ -440,7 +408,6 @@ async def create_async( :param description: A human readable description for the Subscription **This value should not contain PII.** :param sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created. :param types: An array of objects containing the subscribed Event Types - :param receive_events_from_subaccounts: Receive events from all children accounts in the parent account subscription. :returns: The created SubscriptionInstance """ @@ -450,9 +417,6 @@ async def create_async( "Description": description, "SinkSid": sink_sid, "Types": serialize.map(types, lambda e: serialize.object(e)), - "ReceiveEventsFromSubaccounts": serialize.boolean_to_string( - receive_events_from_subaccounts - ), } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) diff --git a/twilio/rest/iam/v1/__init__.py b/twilio/rest/iam/v1/__init__.py index 0c4694734..408de11ac 100644 --- a/twilio/rest/iam/v1/__init__.py +++ b/twilio/rest/iam/v1/__init__.py @@ -17,7 +17,7 @@ from twilio.base.domain import Domain from twilio.rest.iam.v1.api_key import ApiKeyList from twilio.rest.iam.v1.get_api_keys import GetApiKeysList -from twilio.rest.iam.v1.new_api_key import NewApiKeyList +from twilio.rest.iam.v1.key import KeyList class V1(Version): @@ -31,7 +31,7 @@ def __init__(self, domain: Domain): super().__init__(domain, "v1") self._api_key: Optional[ApiKeyList] = None self._get_api_keys: Optional[GetApiKeysList] = None - self._new_api_key: Optional[NewApiKeyList] = None + self._keys: Optional[KeyList] = None @property def api_key(self) -> ApiKeyList: @@ -46,10 +46,10 @@ def get_api_keys(self) -> GetApiKeysList: return self._get_api_keys @property - def new_api_key(self) -> NewApiKeyList: - if self._new_api_key is None: - self._new_api_key = NewApiKeyList(self) - return self._new_api_key + def keys(self) -> KeyList: + if self._keys is None: + self._keys = KeyList(self) + return self._keys def __repr__(self) -> str: """ diff --git a/twilio/rest/iam/v1/key.py b/twilio/rest/iam/v1/key.py new file mode 100644 index 000000000..cd5556df9 --- /dev/null +++ b/twilio/rest/iam/v1/key.py @@ -0,0 +1,157 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Iam + 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, Union +from twilio.base import deserialize, serialize, values + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class KeyInstance(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. + :ivar date_created: The date and time in GMT that the API Key was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + :ivar date_updated: The date and time in GMT that the new API Key was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + :ivar secret: The secret your application uses to sign Access Tokens and to authenticate to the REST API (you will use this as the basic-auth `password`). **Note that for security reasons, this field is ONLY returned when the API Key is first created.** + :ivar policy: Collection of allow assertions. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.sid: Optional[str] = payload.get("sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.date_created: Optional[datetime] = deserialize.rfc2822_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime( + payload.get("date_updated") + ) + self.secret: Optional[str] = payload.get("secret") + self.policy: Optional[Dict[str, object]] = payload.get("policy") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class KeyList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the KeyList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Keys" + + def create( + self, + account_sid: str, + friendly_name: Union[str, object] = values.unset, + key_type: Union["KeyInstance.Keytype", object] = values.unset, + policy: Union[object, object] = values.unset, + ) -> KeyInstance: + """ + Create the KeyInstance + + :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 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 KeyInstance + """ + + data = values.of( + { + "AccountSid": account_sid, + "FriendlyName": friendly_name, + "KeyType": key_type, + "Policy": serialize.object(policy), + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return KeyInstance(self._version, payload) + + async def create_async( + self, + account_sid: str, + friendly_name: Union[str, object] = values.unset, + key_type: Union["KeyInstance.Keytype", object] = values.unset, + policy: Union[object, object] = values.unset, + ) -> KeyInstance: + """ + Asynchronously create the KeyInstance + + :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 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 KeyInstance + """ + + data = values.of( + { + "AccountSid": account_sid, + "FriendlyName": friendly_name, + "KeyType": key_type, + "Policy": serialize.object(policy), + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return KeyInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/insights/v1/conference/__init__.py b/twilio/rest/insights/v1/conference/__init__.py index a30de54cd..0f9bb118b 100644 --- a/twilio/rest/insights/v1/conference/__init__.py +++ b/twilio/rest/insights/v1/conference/__init__.py @@ -51,7 +51,6 @@ class ProcessingState(object): class Region(object): US1 = "us1" - US2 = "us2" AU1 = "au1" BR1 = "br1" IE1 = "ie1" diff --git a/twilio/rest/lookups/v2/phone_number.py b/twilio/rest/lookups/v2/phone_number.py index fc60eed6d..ac1b3257e 100644 --- a/twilio/rest/lookups/v2/phone_number.py +++ b/twilio/rest/lookups/v2/phone_number.py @@ -124,7 +124,6 @@ def fetch( date_of_birth: Union[str, object] = values.unset, last_verified_date: Union[str, object] = values.unset, verification_sid: Union[str, object] = values.unset, - partner_sub_id: Union[str, object] = values.unset, ) -> "PhoneNumberInstance": """ Fetch the PhoneNumberInstance @@ -143,7 +142,6 @@ def fetch( :param date_of_birth: User’s date of birth, in YYYYMMDD format. This query parameter is only used (optionally) for identity_match package requests. :param last_verified_date: The date you obtained consent to call or text the end-user of the phone number or a date on which you are reasonably certain that the end-user could still be reached at that number. This query parameter is only used (optionally) for reassigned_number package requests. :param verification_sid: The unique identifier associated with a verification process through verify API. This query parameter is only used (optionally) for pre_fill package requests. - :param partner_sub_id: The optional partnerSubId parameter to provide context for your sub-accounts, tenantIDs, sender IDs or other segmentation, enhancing the accuracy of the risk analysis. :returns: The fetched PhoneNumberInstance """ @@ -162,7 +160,6 @@ def fetch( date_of_birth=date_of_birth, last_verified_date=last_verified_date, verification_sid=verification_sid, - partner_sub_id=partner_sub_id, ) async def fetch_async( @@ -181,7 +178,6 @@ async def fetch_async( date_of_birth: Union[str, object] = values.unset, last_verified_date: Union[str, object] = values.unset, verification_sid: Union[str, object] = values.unset, - partner_sub_id: Union[str, object] = values.unset, ) -> "PhoneNumberInstance": """ Asynchronous coroutine to fetch the PhoneNumberInstance @@ -200,7 +196,6 @@ async def fetch_async( :param date_of_birth: User’s date of birth, in YYYYMMDD format. This query parameter is only used (optionally) for identity_match package requests. :param last_verified_date: The date you obtained consent to call or text the end-user of the phone number or a date on which you are reasonably certain that the end-user could still be reached at that number. This query parameter is only used (optionally) for reassigned_number package requests. :param verification_sid: The unique identifier associated with a verification process through verify API. This query parameter is only used (optionally) for pre_fill package requests. - :param partner_sub_id: The optional partnerSubId parameter to provide context for your sub-accounts, tenantIDs, sender IDs or other segmentation, enhancing the accuracy of the risk analysis. :returns: The fetched PhoneNumberInstance """ @@ -219,7 +214,6 @@ async def fetch_async( date_of_birth=date_of_birth, last_verified_date=last_verified_date, verification_sid=verification_sid, - partner_sub_id=partner_sub_id, ) def __repr__(self) -> str: @@ -265,7 +259,6 @@ def fetch( date_of_birth: Union[str, object] = values.unset, last_verified_date: Union[str, object] = values.unset, verification_sid: Union[str, object] = values.unset, - partner_sub_id: Union[str, object] = values.unset, ) -> PhoneNumberInstance: """ Fetch the PhoneNumberInstance @@ -284,7 +277,6 @@ def fetch( :param date_of_birth: User’s date of birth, in YYYYMMDD format. This query parameter is only used (optionally) for identity_match package requests. :param last_verified_date: The date you obtained consent to call or text the end-user of the phone number or a date on which you are reasonably certain that the end-user could still be reached at that number. This query parameter is only used (optionally) for reassigned_number package requests. :param verification_sid: The unique identifier associated with a verification process through verify API. This query parameter is only used (optionally) for pre_fill package requests. - :param partner_sub_id: The optional partnerSubId parameter to provide context for your sub-accounts, tenantIDs, sender IDs or other segmentation, enhancing the accuracy of the risk analysis. :returns: The fetched PhoneNumberInstance """ @@ -305,7 +297,6 @@ def fetch( "DateOfBirth": date_of_birth, "LastVerifiedDate": last_verified_date, "VerificationSid": verification_sid, - "PartnerSubId": partner_sub_id, } ) @@ -339,7 +330,6 @@ async def fetch_async( date_of_birth: Union[str, object] = values.unset, last_verified_date: Union[str, object] = values.unset, verification_sid: Union[str, object] = values.unset, - partner_sub_id: Union[str, object] = values.unset, ) -> PhoneNumberInstance: """ Asynchronous coroutine to fetch the PhoneNumberInstance @@ -358,7 +348,6 @@ async def fetch_async( :param date_of_birth: User’s date of birth, in YYYYMMDD format. This query parameter is only used (optionally) for identity_match package requests. :param last_verified_date: The date you obtained consent to call or text the end-user of the phone number or a date on which you are reasonably certain that the end-user could still be reached at that number. This query parameter is only used (optionally) for reassigned_number package requests. :param verification_sid: The unique identifier associated with a verification process through verify API. This query parameter is only used (optionally) for pre_fill package requests. - :param partner_sub_id: The optional partnerSubId parameter to provide context for your sub-accounts, tenantIDs, sender IDs or other segmentation, enhancing the accuracy of the risk analysis. :returns: The fetched PhoneNumberInstance """ @@ -379,7 +368,6 @@ async def fetch_async( "DateOfBirth": date_of_birth, "LastVerifiedDate": last_verified_date, "VerificationSid": verification_sid, - "PartnerSubId": partner_sub_id, } ) diff --git a/twilio/rest/numbers/v1/__init__.py b/twilio/rest/numbers/v1/__init__.py index 043364c3d..68f078a88 100644 --- a/twilio/rest/numbers/v1/__init__.py +++ b/twilio/rest/numbers/v1/__init__.py @@ -28,12 +28,10 @@ from twilio.rest.numbers.v1.porting_webhook_configuration_delete import ( PortingWebhookConfigurationDeleteList, ) -from twilio.rest.numbers.v1.porting_webhook_configuration_fetch import ( - PortingWebhookConfigurationFetchList, -) from twilio.rest.numbers.v1.signing_request_configuration import ( SigningRequestConfigurationList, ) +from twilio.rest.numbers.v1.webhook import WebhookList class V1(Version): @@ -58,12 +56,10 @@ def __init__(self, domain: Domain): self._porting_webhook_configurations_delete: Optional[ PortingWebhookConfigurationDeleteList ] = None - self._porting_webhook_configuration_fetch: Optional[ - PortingWebhookConfigurationFetchList - ] = None self._signing_request_configurations: Optional[ SigningRequestConfigurationList ] = None + self._webhook: Optional[WebhookList] = None @property def bulk_eligibilities(self) -> BulkEligibilityList: @@ -111,22 +107,18 @@ def porting_webhook_configurations_delete( ) return self._porting_webhook_configurations_delete - @property - def porting_webhook_configuration_fetch( - self, - ) -> PortingWebhookConfigurationFetchList: - if self._porting_webhook_configuration_fetch is None: - self._porting_webhook_configuration_fetch = ( - PortingWebhookConfigurationFetchList(self) - ) - return self._porting_webhook_configuration_fetch - @property def signing_request_configurations(self) -> SigningRequestConfigurationList: if self._signing_request_configurations is None: self._signing_request_configurations = SigningRequestConfigurationList(self) return self._signing_request_configurations + @property + def webhook(self) -> WebhookList: + if self._webhook is None: + self._webhook = WebhookList(self) + return self._webhook + def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/numbers/v1/webhook.py b/twilio/rest/numbers/v1/webhook.py new file mode 100644 index 000000000..69bd55632 --- /dev/null +++ b/twilio/rest/numbers/v1/webhook.py @@ -0,0 +1,109 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Numbers + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, List, Optional +from twilio.base import deserialize, values + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class WebhookInstance(InstanceResource): + """ + :ivar url: The URL of the webhook configuration request + :ivar port_in_target_url: The complete webhook url that will be called when a notification event for port in request or port in phone number happens + :ivar port_out_target_url: The complete webhook url that will be called when a notification event for a port out phone number happens. + :ivar notifications_of: A list to filter what notification events to receive for this account and its sub accounts. If it is an empty list, then it means that there are no filters for the notifications events to send in each webhook and all events will get sent. + :ivar port_in_target_date_created: Creation date for the port in webhook configuration + :ivar port_out_target_date_created: Creation date for the port out webhook configuration + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.url: Optional[str] = payload.get("url") + self.port_in_target_url: Optional[str] = payload.get("port_in_target_url") + self.port_out_target_url: Optional[str] = payload.get("port_out_target_url") + self.notifications_of: Optional[List[str]] = payload.get("notifications_of") + self.port_in_target_date_created: Optional[datetime] = ( + deserialize.iso8601_datetime(payload.get("port_in_target_date_created")) + ) + self.port_out_target_date_created: Optional[datetime] = ( + deserialize.iso8601_datetime(payload.get("port_out_target_date_created")) + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class WebhookList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the WebhookList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Porting/Configuration/Webhook" + + def fetch(self) -> WebhookInstance: + """ + Asynchronously fetch the WebhookInstance + + + :returns: The fetched WebhookInstance + """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return WebhookInstance(self._version, payload) + + async def fetch_async(self) -> WebhookInstance: + """ + Asynchronously fetch the WebhookInstance + + + :returns: The fetched WebhookInstance + """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return WebhookInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return ""