diff --git a/CHANGES.md b/CHANGES.md index e500308927..c3e678a6a0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,24 @@ twilio-python Changelog Here you can see the full list of changes between each twilio-python release. +[2025-04-07] Version 9.5.2 +-------------------------- +**Studio** +- Add documentation for parent_step_sid field in Step resource + + +[2025-03-20] Version 9.5.1 +-------------------------- +**Accounts** +- Update Safelist API docs as part of prefix supoort + +**Flex** +- Removing `first_name`, `last_name`, and `friendly_name` from the Flex User API + +**Messaging** +- Add missing tests under transaction/phone_numbers and transaction/short_code + + [2025-03-11] Version 9.5.0 -------------------------- **Library - Feature** diff --git a/README.md b/README.md index 24ece99218..e6382a5242 100644 --- a/README.md +++ b/README.md @@ -193,6 +193,8 @@ The library automatically handles paging for you. Collections, such as `calls` a `list` eagerly fetches all records and returns them as a list, whereas `stream` returns an iterator and lazily retrieves pages of records as you iterate over the collection. You can also page manually using the `page` method. +`page_size` as a parameter is used to tell how many records should we get in every page and `limit` parameter is used to limit the max number of records we want to fetch. + #### Use the `list` method ```python @@ -206,6 +208,21 @@ for sms in client.messages.list(): print(sms.to) ``` +```python +client.messages.list(limit=20, page_size=20) +``` +This will make 1 call that will fetch 20 records from backend service. + +```python +client.messages.list(limit=20, page_size=10) +``` +This will make 2 calls that will fetch 10 records each from backend service. + +```python +client.messages.list(limit=20, page_size=100) +``` +This will make 1 call which will fetch 100 records but user will get only 20 records. + ### Asynchronous API Requests By default, the Twilio Client will make synchronous requests to the Twilio API. To allow for asynchronous, non-blocking requests, we've included an optional asynchronous HTTP client. When used with the Client and the accompanying `*_async` methods, requests made to the Twilio API will be performed asynchronously. diff --git a/setup.py b/setup.py index fc58de0ec1..d03f823242 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setup( name="twilio", - version="9.5.0", + version="9.5.2", 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 b2bf5772dd..15e4058354 100644 --- a/twilio/__init__.py +++ b/twilio/__init__.py @@ -1,2 +1,2 @@ -__version_info__ = ("9", "5", "0") +__version_info__ = ("9", "5", "2") __version__ = ".".join(__version_info__) diff --git a/twilio/rest/__init__.py b/twilio/rest/__init__.py index 5838363c52..dc7741180b 100644 --- a/twilio/rest/__init__.py +++ b/twilio/rest/__init__.py @@ -29,6 +29,7 @@ from twilio.rest.insights import Insights from twilio.rest.intelligence import Intelligence from twilio.rest.ip_messaging import IpMessaging + from twilio.rest.knowledge import Knowledge from twilio.rest.lookups import Lookups from twilio.rest.marketplace import Marketplace from twilio.rest.messaging import Messaging @@ -142,6 +143,7 @@ def __init__( self._insights: Optional["Insights"] = None self._intelligence: Optional["Intelligence"] = None self._ip_messaging: Optional["IpMessaging"] = None + self._knowledge: Optional["Knowledge"] = None self._lookups: Optional["Lookups"] = None self._marketplace: Optional["Marketplace"] = None self._messaging: Optional["Messaging"] = None @@ -361,6 +363,19 @@ def ip_messaging(self) -> "IpMessaging": self._ip_messaging = IpMessaging(self) return self._ip_messaging + @property + def knowledge(self) -> "Knowledge": + """ + Access the Knowledge Twilio Domain + + :returns: Knowledge Twilio Domain + """ + if self._knowledge is None: + from twilio.rest.knowledge import Knowledge + + self._knowledge = Knowledge(self) + return self._knowledge + @property def lookups(self) -> "Lookups": """ diff --git a/twilio/rest/accounts/v1/safelist.py b/twilio/rest/accounts/v1/safelist.py index 0bbbb32420..be8fe416af 100644 --- a/twilio/rest/accounts/v1/safelist.py +++ b/twilio/rest/accounts/v1/safelist.py @@ -23,7 +23,7 @@ class SafelistInstance(InstanceResource): """ :ivar sid: The unique string that we created to identify the SafeList resource. - :ivar phone_number: The phone number in SafeList. + :ivar phone_number: The phone number or phone number 1k prefix in SafeList. """ def __init__(self, version: Version, payload: Dict[str, Any]): @@ -59,7 +59,7 @@ def create(self, phone_number: str) -> SafelistInstance: """ Create the SafelistInstance - :param phone_number: The phone number to be added in SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). + :param phone_number: The phone number or phone number 1k prefix to be added in SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). :returns: The created SafelistInstance """ @@ -85,7 +85,7 @@ async def create_async(self, phone_number: str) -> SafelistInstance: """ Asynchronously create the SafelistInstance - :param phone_number: The phone number to be added in SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). + :param phone_number: The phone number or phone number 1k prefix to be added in SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). :returns: The created SafelistInstance """ @@ -111,7 +111,7 @@ def delete(self, phone_number: Union[str, object] = values.unset) -> bool: """ Asynchronously delete the SafelistInstance - :param phone_number: The phone number to be removed from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). + :param phone_number: The phone number or phone number 1k prefix to be removed from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). :returns: True if delete succeeds, False otherwise """ headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) @@ -131,7 +131,7 @@ async def delete_async( """ Asynchronously delete the SafelistInstance - :param phone_number: The phone number to be removed from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). + :param phone_number: The phone number or phone number 1k prefix to be removed from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). :returns: True if delete succeeds, False otherwise """ headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) @@ -151,7 +151,7 @@ def fetch( """ Asynchronously fetch the SafelistInstance - :param phone_number: The phone number to be fetched from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). + :param phone_number: The phone number or phone number 1k prefix to be fetched from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). :returns: The fetched SafelistInstance """ headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) @@ -176,7 +176,7 @@ async def fetch_async( """ Asynchronously fetch the SafelistInstance - :param phone_number: The phone number to be fetched from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). + :param phone_number: The phone number or phone number 1k prefix to be fetched from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). :returns: The fetched SafelistInstance """ headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) diff --git a/twilio/rest/api/v2010/account/conference/__init__.py b/twilio/rest/api/v2010/account/conference/__init__.py index 1ff3289a6c..672d9d0fea 100644 --- a/twilio/rest/api/v2010/account/conference/__init__.py +++ b/twilio/rest/api/v2010/account/conference/__init__.py @@ -51,7 +51,7 @@ class UpdateStatus(object): :ivar date_updated: The date and time in UTC that this resource was last updated, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. :ivar api_version: The API version used to create this conference. :ivar friendly_name: A string that you assigned to describe this conference room. Maximum length is 128 characters. - :ivar region: A string that represents the Twilio Region where the conference audio was mixed. May be `us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, and `jp1`. Basic conference audio will always be mixed in `us1`. Global Conference audio will be mixed nearest to the majority of participants. + :ivar region: A string that represents the Twilio Region where the conference audio was mixed. May be `us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, and `jp1`. Basic conference audio will always be mixed in `us1`. Global Conference audio will be mixed nearest to the majority of participants. :ivar sid: The unique, Twilio-provided string used to identify this Conference resource. :ivar status: :ivar uri: The URI of this resource, relative to `https://api.twilio.com`. diff --git a/twilio/rest/api/v2010/account/conference/participant.py b/twilio/rest/api/v2010/account/conference/participant.py index a93f9f9adc..c6511dadf6 100644 --- a/twilio/rest/api/v2010/account/conference/participant.py +++ b/twilio/rest/api/v2010/account/conference/participant.py @@ -625,7 +625,7 @@ def create( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param recording_status_callback_event: The recording state changes that should generate a call to `recording_status_callback`. Can be: `started`, `in-progress`, `paused`, `resumed`, `stopped`, `completed`, `failed`, and `absent`. Separate multiple values with a space, ex: `'in-progress completed failed'`. @@ -814,7 +814,7 @@ async def create_async( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param recording_status_callback_event: The recording state changes that should generate a call to `recording_status_callback`. Can be: `started`, `in-progress`, `paused`, `resumed`, `stopped`, `completed`, `failed`, and `absent`. Separate multiple values with a space, ex: `'in-progress completed failed'`. diff --git a/twilio/rest/api/v2010/account/message/__init__.py b/twilio/rest/api/v2010/account/message/__init__.py index f41c1c5ad7..d5369d11ce 100644 --- a/twilio/rest/api/v2010/account/message/__init__.py +++ b/twilio/rest/api/v2010/account/message/__init__.py @@ -62,6 +62,9 @@ class Status(object): PARTIALLY_DELIVERED = "partially_delivered" CANCELED = "canceled" + class TrafficType(object): + FREE = "free" + class UpdateStatus(object): CANCELED = "canceled" @@ -505,6 +508,7 @@ def create( ] = values.unset, smart_encoded: Union[bool, object] = values.unset, persistent_action: Union[List[str], object] = values.unset, + traffic_type: Union["MessageInstance.TrafficType", object] = values.unset, shorten_urls: Union[bool, object] = values.unset, schedule_type: Union["MessageInstance.ScheduleType", object] = values.unset, send_at: Union[datetime, object] = values.unset, @@ -532,6 +536,7 @@ def create( :param address_retention: :param smart_encoded: Whether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be: `true` or `false`. :param persistent_action: Rich actions for non-SMS/MMS channels. Used for [sending location in WhatsApp messages](https://www.twilio.com/docs/whatsapp/message-features#location-messages-with-whatsapp). + :param traffic_type: :param shorten_urls: For Messaging Services with [Link Shortening configured](https://www.twilio.com/docs/messaging/features/link-shortening) only: A Boolean indicating whether or not Twilio should shorten links in the `body` of the Message. Default value is `false`. If `true`, the `messaging_service_sid` parameter must also be provided. :param schedule_type: :param send_at: The time that Twilio will send the message. Must be in ISO 8601 format. @@ -561,6 +566,7 @@ def create( "AddressRetention": address_retention, "SmartEncoded": serialize.boolean_to_string(smart_encoded), "PersistentAction": serialize.map(persistent_action, lambda e: e), + "TrafficType": traffic_type, "ShortenUrls": serialize.boolean_to_string(shorten_urls), "ScheduleType": schedule_type, "SendAt": serialize.iso8601_datetime(send_at), @@ -606,6 +612,7 @@ async def create_async( ] = values.unset, smart_encoded: Union[bool, object] = values.unset, persistent_action: Union[List[str], object] = values.unset, + traffic_type: Union["MessageInstance.TrafficType", object] = values.unset, shorten_urls: Union[bool, object] = values.unset, schedule_type: Union["MessageInstance.ScheduleType", object] = values.unset, send_at: Union[datetime, object] = values.unset, @@ -633,6 +640,7 @@ async def create_async( :param address_retention: :param smart_encoded: Whether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be: `true` or `false`. :param persistent_action: Rich actions for non-SMS/MMS channels. Used for [sending location in WhatsApp messages](https://www.twilio.com/docs/whatsapp/message-features#location-messages-with-whatsapp). + :param traffic_type: :param shorten_urls: For Messaging Services with [Link Shortening configured](https://www.twilio.com/docs/messaging/features/link-shortening) only: A Boolean indicating whether or not Twilio should shorten links in the `body` of the Message. Default value is `false`. If `true`, the `messaging_service_sid` parameter must also be provided. :param schedule_type: :param send_at: The time that Twilio will send the message. Must be in ISO 8601 format. @@ -662,6 +670,7 @@ async def create_async( "AddressRetention": address_retention, "SmartEncoded": serialize.boolean_to_string(smart_encoded), "PersistentAction": serialize.map(persistent_action, lambda e: e), + "TrafficType": traffic_type, "ShortenUrls": serialize.boolean_to_string(shorten_urls), "ScheduleType": schedule_type, "SendAt": serialize.iso8601_datetime(send_at), diff --git a/twilio/rest/flex_api/v2/flex_user.py b/twilio/rest/flex_api/v2/flex_user.py index 480a439b85..eb2228d015 100644 --- a/twilio/rest/flex_api/v2/flex_user.py +++ b/twilio/rest/flex_api/v2/flex_user.py @@ -30,11 +30,8 @@ class FlexUserInstance(InstanceResource): :ivar worker_sid: The unique SID identifier of the worker. :ivar workspace_sid: The unique SID identifier of the workspace. :ivar flex_team_sid: The unique SID identifier of the Flex Team. - :ivar first_name: First name of the User. - :ivar last_name: Last name of the User. :ivar username: Username of the User. :ivar email: Email of the User. - :ivar friendly_name: Friendly name of the User. :ivar locale: The locale preference of the user. :ivar roles: The roles of the user. :ivar created_date: The date that this user was created, given in ISO 8601 format. @@ -59,11 +56,8 @@ def __init__( self.worker_sid: Optional[str] = payload.get("worker_sid") self.workspace_sid: Optional[str] = payload.get("workspace_sid") self.flex_team_sid: Optional[str] = payload.get("flex_team_sid") - self.first_name: Optional[str] = payload.get("first_name") - self.last_name: Optional[str] = payload.get("last_name") self.username: Optional[str] = payload.get("username") self.email: Optional[str] = payload.get("email") - self.friendly_name: Optional[str] = payload.get("friendly_name") self.locale: Optional[str] = payload.get("locale") self.roles: Optional[List[str]] = payload.get("roles") self.created_date: Optional[datetime] = deserialize.iso8601_datetime( @@ -117,60 +111,42 @@ async def fetch_async(self) -> "FlexUserInstance": def update( self, - first_name: Union[str, object] = values.unset, - last_name: Union[str, object] = values.unset, email: Union[str, object] = values.unset, - friendly_name: Union[str, object] = values.unset, user_sid: Union[str, object] = values.unset, locale: Union[str, object] = values.unset, ) -> "FlexUserInstance": """ Update the FlexUserInstance - :param first_name: First name of the User. - :param last_name: Last name of the User. :param email: Email of the User. - :param friendly_name: Friendly name of the User. :param user_sid: The unique SID identifier of the Twilio Unified User. :param locale: The locale preference of the user. :returns: The updated FlexUserInstance """ return self._proxy.update( - first_name=first_name, - last_name=last_name, email=email, - friendly_name=friendly_name, user_sid=user_sid, locale=locale, ) async def update_async( self, - first_name: Union[str, object] = values.unset, - last_name: Union[str, object] = values.unset, email: Union[str, object] = values.unset, - friendly_name: Union[str, object] = values.unset, user_sid: Union[str, object] = values.unset, locale: Union[str, object] = values.unset, ) -> "FlexUserInstance": """ Asynchronous coroutine to update the FlexUserInstance - :param first_name: First name of the User. - :param last_name: Last name of the User. :param email: Email of the User. - :param friendly_name: Friendly name of the User. :param user_sid: The unique SID identifier of the Twilio Unified User. :param locale: The locale preference of the user. :returns: The updated FlexUserInstance """ return await self._proxy.update_async( - first_name=first_name, - last_name=last_name, email=email, - friendly_name=friendly_name, user_sid=user_sid, locale=locale, ) @@ -252,20 +228,14 @@ async def fetch_async(self) -> FlexUserInstance: def update( self, - first_name: Union[str, object] = values.unset, - last_name: Union[str, object] = values.unset, email: Union[str, object] = values.unset, - friendly_name: Union[str, object] = values.unset, user_sid: Union[str, object] = values.unset, locale: Union[str, object] = values.unset, ) -> FlexUserInstance: """ Update the FlexUserInstance - :param first_name: First name of the User. - :param last_name: Last name of the User. :param email: Email of the User. - :param friendly_name: Friendly name of the User. :param user_sid: The unique SID identifier of the Twilio Unified User. :param locale: The locale preference of the user. @@ -274,10 +244,7 @@ def update( data = values.of( { - "FirstName": first_name, - "LastName": last_name, "Email": email, - "FriendlyName": friendly_name, "UserSid": user_sid, "Locale": locale, } @@ -301,20 +268,14 @@ def update( async def update_async( self, - first_name: Union[str, object] = values.unset, - last_name: Union[str, object] = values.unset, email: Union[str, object] = values.unset, - friendly_name: Union[str, object] = values.unset, user_sid: Union[str, object] = values.unset, locale: Union[str, object] = values.unset, ) -> FlexUserInstance: """ Asynchronous coroutine to update the FlexUserInstance - :param first_name: First name of the User. - :param last_name: Last name of the User. :param email: Email of the User. - :param friendly_name: Friendly name of the User. :param user_sid: The unique SID identifier of the Twilio Unified User. :param locale: The locale preference of the user. @@ -323,10 +284,7 @@ async def update_async( data = values.of( { - "FirstName": first_name, - "LastName": last_name, "Email": email, - "FriendlyName": friendly_name, "UserSid": user_sid, "Locale": locale, } diff --git a/twilio/rest/iam/v1/__init__.py b/twilio/rest/iam/v1/__init__.py index 0c46947341..08c45435a6 100644 --- a/twilio/rest/iam/v1/__init__.py +++ b/twilio/rest/iam/v1/__init__.py @@ -18,6 +18,7 @@ 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.token import TokenList class V1(Version): @@ -32,6 +33,7 @@ def __init__(self, domain: Domain): self._api_key: Optional[ApiKeyList] = None self._get_api_keys: Optional[GetApiKeysList] = None self._new_api_key: Optional[NewApiKeyList] = None + self._token: Optional[TokenList] = None @property def api_key(self) -> ApiKeyList: @@ -51,6 +53,12 @@ def new_api_key(self) -> NewApiKeyList: self._new_api_key = NewApiKeyList(self) return self._new_api_key + @property + def token(self) -> TokenList: + if self._token is None: + self._token = TokenList(self) + return self._token + def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/iam/v1/token.py b/twilio/rest/iam/v1/token.py new file mode 100644 index 0000000000..50d3d11930 --- /dev/null +++ b/twilio/rest/iam/v1/token.py @@ -0,0 +1,170 @@ +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 typing import Any, Dict, Optional, Union +from twilio.base import values + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class TokenInstance(InstanceResource): + """ + :ivar access_token: Token which carries the necessary information to access a Twilio resource directly. + :ivar refresh_token: Token which carries the information necessary to get a new access token. + :ivar id_token: Token which carries the information necessary of user profile. + :ivar token_type: Token type + :ivar expires_in: + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.access_token: Optional[str] = payload.get("access_token") + self.refresh_token: Optional[str] = payload.get("refresh_token") + self.id_token: Optional[str] = payload.get("id_token") + self.token_type: Optional[str] = payload.get("token_type") + self.expires_in: Optional[int] = payload.get("expires_in") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class TokenList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the TokenList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/token" + + def create( + self, + grant_type: str, + client_id: str, + client_secret: Union[str, object] = values.unset, + code: Union[str, object] = values.unset, + redirect_uri: Union[str, object] = values.unset, + audience: Union[str, object] = values.unset, + refresh_token: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + ) -> TokenInstance: + """ + Create the TokenInstance + + :param grant_type: Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + :param client_id: A 34 character string that uniquely identifies this OAuth App. + :param client_secret: The credential for confidential OAuth App. + :param code: JWT token related to the authorization code grant type. + :param redirect_uri: The redirect uri + :param audience: The targeted audience uri + :param refresh_token: JWT token related to refresh access token. + :param scope: The scope of token + + :returns: The created TokenInstance + """ + + data = values.of( + { + "grant_type": grant_type, + "client_id": client_id, + "client_secret": client_secret, + "code": code, + "redirect_uri": redirect_uri, + "audience": audience, + "refresh_token": refresh_token, + "scope": scope, + } + ) + 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 TokenInstance(self._version, payload) + + async def create_async( + self, + grant_type: str, + client_id: str, + client_secret: Union[str, object] = values.unset, + code: Union[str, object] = values.unset, + redirect_uri: Union[str, object] = values.unset, + audience: Union[str, object] = values.unset, + refresh_token: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + ) -> TokenInstance: + """ + Asynchronously create the TokenInstance + + :param grant_type: Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + :param client_id: A 34 character string that uniquely identifies this OAuth App. + :param client_secret: The credential for confidential OAuth App. + :param code: JWT token related to the authorization code grant type. + :param redirect_uri: The redirect uri + :param audience: The targeted audience uri + :param refresh_token: JWT token related to refresh access token. + :param scope: The scope of token + + :returns: The created TokenInstance + """ + + data = values.of( + { + "grant_type": grant_type, + "client_id": client_id, + "client_secret": client_secret, + "code": code, + "redirect_uri": redirect_uri, + "audience": audience, + "refresh_token": refresh_token, + "scope": scope, + } + ) + 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 TokenInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/insights/v1/room/__init__.py b/twilio/rest/insights/v1/room/__init__.py index 0b987c020a..6fe0c476b5 100644 --- a/twilio/rest/insights/v1/room/__init__.py +++ b/twilio/rest/insights/v1/room/__init__.py @@ -54,6 +54,8 @@ class EndReason(object): class ProcessingState(object): COMPLETE = "complete" IN_PROGRESS = "in_progress" + TIMEOUT = "timeout" + NOT_STARTED = "not_started" class RoomStatus(object): IN_PROGRESS = "in_progress" @@ -77,7 +79,17 @@ class TwilioRealm(object): DE1 = "de1" GLL = "gll" STAGE_US1 = "stage_us1" + STAGE_US2 = "stage_us2" DEV_US1 = "dev_us1" + DEV_US2 = "dev_us2" + STAGE_DE1 = "stage_de1" + STAGE_IN1 = "stage_in1" + STAGE_IE1 = "stage_ie1" + STAGE_BR1 = "stage_br1" + STAGE_AU1 = "stage_au1" + STAGE_SG1 = "stage_sg1" + STAGE_JP1 = "stage_jp1" + OUTSIDE = "outside" """ :ivar account_sid: Account SID associated with this room. diff --git a/twilio/rest/insights/v1/room/participant.py b/twilio/rest/insights/v1/room/participant.py index 0791ec287c..d0d3e592e0 100644 --- a/twilio/rest/insights/v1/room/participant.py +++ b/twilio/rest/insights/v1/room/participant.py @@ -43,7 +43,9 @@ class EdgeLocation(object): class RoomStatus(object): IN_PROGRESS = "in_progress" + CONNECTED = "connected" COMPLETED = "completed" + DISCONNECTED = "disconnected" class TwilioRealm(object): US1 = "us1" @@ -58,6 +60,16 @@ class TwilioRealm(object): GLL = "gll" STAGE_US1 = "stage_us1" DEV_US1 = "dev_us1" + STAGE_AU1 = "stage_au1" + STAGE_SG1 = "stage_sg1" + STAGE_BR1 = "stage_br1" + STAGE_IN1 = "stage_in1" + STAGE_JP1 = "stage_jp1" + STAGE_DE1 = "stage_de1" + STAGE_IE1 = "stage_ie1" + STAGE_US2 = "stage_us2" + DEV_US2 = "dev_us2" + OUTSIDE = "outside" """ :ivar participant_sid: Unique identifier for the participant. diff --git a/twilio/rest/knowledge/KnowledgeBase.py b/twilio/rest/knowledge/KnowledgeBase.py new file mode 100644 index 0000000000..902f0e8b96 --- /dev/null +++ b/twilio/rest/knowledge/KnowledgeBase.py @@ -0,0 +1,44 @@ +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.knowledge.v1 import V1 + + +class KnowledgeBase(Domain): + + def __init__(self, twilio: Client): + """ + Initialize the Knowledge Domain + + :returns: Domain for Knowledge + """ + super().__init__(twilio, "https://knowledge.twilio.com") + self._v1: Optional[V1] = None + + @property + def v1(self) -> V1: + """ + :returns: Versions v1 of Knowledge + """ + 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/preview/sync/__init__.py b/twilio/rest/knowledge/v1/__init__.py similarity index 62% rename from twilio/rest/preview/sync/__init__.py rename to twilio/rest/knowledge/v1/__init__.py index d84c79039b..9609bff951 100644 --- a/twilio/rest/preview/sync/__init__.py +++ b/twilio/rest/knowledge/v1/__init__.py @@ -4,7 +4,7 @@ | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - Twilio - Preview + Twilio - Knowledge This is the public Twilio REST API. NOTE: This class is auto generated by OpenAPI Generator. @@ -15,29 +15,29 @@ from typing import Optional from twilio.base.version import Version from twilio.base.domain import Domain -from twilio.rest.preview.sync.service import ServiceList +from twilio.rest.knowledge.v1.knowledge import KnowledgeList -class Sync(Version): +class V1(Version): def __init__(self, domain: Domain): """ - Initialize the Sync version of Preview + Initialize the V1 version of Knowledge - :param domain: The Twilio.preview domain + :param domain: The Twilio.knowledge domain """ - super().__init__(domain, "Sync") - self._services: Optional[ServiceList] = None + super().__init__(domain, "v1") + self._knowledge: Optional[KnowledgeList] = None @property - def services(self) -> ServiceList: - if self._services is None: - self._services = ServiceList(self) - return self._services + def knowledge(self) -> KnowledgeList: + if self._knowledge is None: + self._knowledge = KnowledgeList(self) + return self._knowledge def __repr__(self) -> str: """ Provide a friendly representation :returns: Machine friendly representation """ - return "" + return "" diff --git a/twilio/rest/knowledge/v1/knowledge/__init__.py b/twilio/rest/knowledge/v1/knowledge/__init__.py new file mode 100644 index 0000000000..8ba6b2c481 --- /dev/null +++ b/twilio/rest/knowledge/v1/knowledge/__init__.py @@ -0,0 +1,935 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Knowledge + 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.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.knowledge.v1.knowledge.chunk import ChunkList +from twilio.rest.knowledge.v1.knowledge.knowledge_status import KnowledgeStatusList + + +class KnowledgeInstance(InstanceResource): + + class KnowledgeV1ServiceCreateKnowledgeRequest(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 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.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.KnowledgeV1ServiceCreatePolicyRequest + ] = 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, + } + + class KnowledgeV1ServiceCreatePolicyRequest(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 KnowledgeV1ServiceUpdateKnowledgeRequest(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.KnowledgeV1ServiceCreatePolicyRequest + ] = 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 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 update( + self, + knowledge_v1_service_update_knowledge_request: Union[ + KnowledgeV1ServiceUpdateKnowledgeRequest, object + ] = values.unset, + ) -> "KnowledgeInstance": + """ + Update the KnowledgeInstance + + :param knowledge_v1_service_update_knowledge_request: + + :returns: The updated KnowledgeInstance + """ + return self._proxy.update( + knowledge_v1_service_update_knowledge_request=knowledge_v1_service_update_knowledge_request, + ) + + async def update_async( + self, + knowledge_v1_service_update_knowledge_request: Union[ + KnowledgeV1ServiceUpdateKnowledgeRequest, object + ] = values.unset, + ) -> "KnowledgeInstance": + """ + Asynchronous coroutine to update the KnowledgeInstance + + :param knowledge_v1_service_update_knowledge_request: + + :returns: The updated KnowledgeInstance + """ + return await self._proxy.update_async( + knowledge_v1_service_update_knowledge_request=knowledge_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 KnowledgeV1ServiceCreateKnowledgeRequest(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 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.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.KnowledgeV1ServiceCreatePolicyRequest + ] = 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, + } + + class KnowledgeV1ServiceCreatePolicyRequest(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 KnowledgeV1ServiceUpdateKnowledgeRequest(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.KnowledgeV1ServiceCreatePolicyRequest + ] = 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) -> bool: + """ + Deletes the KnowledgeInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return self._version.delete(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 + """ + + headers = values.of({}) + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) + + def fetch(self) -> KnowledgeInstance: + """ + Fetch the KnowledgeInstance + + + :returns: The fetched KnowledgeInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return KnowledgeInstance( + self._version, + payload, + id=self._solution["id"], + ) + + async def fetch_async(self) -> KnowledgeInstance: + """ + Asynchronous coroutine to fetch the KnowledgeInstance + + + :returns: The fetched KnowledgeInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return KnowledgeInstance( + self._version, + payload, + id=self._solution["id"], + ) + + def update( + self, + knowledge_v1_service_update_knowledge_request: Union[ + KnowledgeV1ServiceUpdateKnowledgeRequest, object + ] = values.unset, + ) -> KnowledgeInstance: + """ + Update the KnowledgeInstance + + :param knowledge_v1_service_update_knowledge_request: + + :returns: The updated KnowledgeInstance + """ + data = knowledge_v1_service_update_knowledge_request.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = self._version.update( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + return KnowledgeInstance(self._version, payload, id=self._solution["id"]) + + async def update_async( + self, + knowledge_v1_service_update_knowledge_request: Union[ + KnowledgeV1ServiceUpdateKnowledgeRequest, object + ] = values.unset, + ) -> KnowledgeInstance: + """ + Asynchronous coroutine to update the KnowledgeInstance + + :param knowledge_v1_service_update_knowledge_request: + + :returns: The updated KnowledgeInstance + """ + data = knowledge_v1_service_update_knowledge_request.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = await self._version.update_async( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + return KnowledgeInstance(self._version, payload, id=self._solution["id"]) + + @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 KnowledgeV1ServiceCreateKnowledgeRequest(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 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.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.KnowledgeV1ServiceCreatePolicyRequest + ] = 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, + } + + class KnowledgeV1ServiceCreatePolicyRequest(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 KnowledgeV1ServiceUpdateKnowledgeRequest(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.KnowledgeV1ServiceCreatePolicyRequest + ] = 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, + knowledge_v1_service_create_knowledge_request: KnowledgeV1ServiceCreateKnowledgeRequest, + ) -> KnowledgeInstance: + """ + Create the KnowledgeInstance + + :param knowledge_v1_service_create_knowledge_request: + + :returns: The created KnowledgeInstance + """ + data = knowledge_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" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return KnowledgeInstance(self._version, payload) + + async def create_async( + self, + knowledge_v1_service_create_knowledge_request: KnowledgeV1ServiceCreateKnowledgeRequest, + ) -> KnowledgeInstance: + """ + Asynchronously create the KnowledgeInstance + + :param knowledge_v1_service_create_knowledge_request: + + :returns: The created KnowledgeInstance + """ + data = knowledge_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" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return KnowledgeInstance(self._version, payload) + + def stream( + self, + 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 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[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 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 list( + self, + 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 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[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 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 page( + self, + 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 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( + { + "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, + 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 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( + { + "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 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/knowledge/v1/knowledge/chunk.py b/twilio/rest/knowledge/v1/knowledge/chunk.py new file mode 100644 index 0000000000..55c0b1be1a --- /dev/null +++ b/twilio/rest/knowledge/v1/knowledge/chunk.py @@ -0,0 +1,297 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Knowledge + 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.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 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 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, 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, self._solution) + + 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, 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, self._solution) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/knowledge/v1/knowledge/knowledge_status.py b/twilio/rest/knowledge/v1/knowledge/knowledge_status.py new file mode 100644 index 0000000000..984c577aac --- /dev/null +++ b/twilio/rest/knowledge/v1/knowledge/knowledge_status.py @@ -0,0 +1,196 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Knowledge + 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.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 __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) -> KnowledgeStatusInstance: + """ + Fetch the KnowledgeStatusInstance + + + :returns: The fetched KnowledgeStatusInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return KnowledgeStatusInstance( + self._version, + payload, + id=self._solution["id"], + ) + + async def fetch_async(self) -> KnowledgeStatusInstance: + """ + Asynchronous coroutine to fetch the KnowledgeStatusInstance + + + :returns: The fetched KnowledgeStatusInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return KnowledgeStatusInstance( + self._version, + payload, + id=self._solution["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 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/lookups/v1/phone_number.py b/twilio/rest/lookups/v1/phone_number.py index ace46b67bd..304b89ab15 100644 --- a/twilio/rest/lookups/v1/phone_number.py +++ b/twilio/rest/lookups/v1/phone_number.py @@ -78,7 +78,7 @@ def fetch( Fetch the PhoneNumberInstance :param country_code: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the phone number to fetch. This is used to specify the country when the phone number is provided in a national format. - :param type: The type of information to return. Can be: `carrier` or `caller-name`. The default is null. Carrier information costs $0.005 per phone number looked up. Caller Name information is currently available only in the US and costs $0.01 per phone number looked up. To retrieve both types on information, specify this parameter twice; once with `carrier` and once with `caller-name` as the value. + :param type: The type of information to return. Can be: `carrier` or `caller-name`. The default is null. To retrieve both types of information, specify this parameter twice; once with `carrier` and once with `caller-name` as the value. :param add_ons: The `unique_name` of an Add-on you would like to invoke. Can be the `unique_name` of an Add-on that is installed on your account. You can specify multiple instances of this parameter to invoke multiple Add-ons. For more information about Add-ons, see the [Add-ons documentation](https://www.twilio.com/docs/add-ons). :param add_ons_data: Data specific to the add-on you would like to invoke. The content and format of this value depends on the add-on. @@ -102,7 +102,7 @@ async def fetch_async( Asynchronous coroutine to fetch the PhoneNumberInstance :param country_code: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the phone number to fetch. This is used to specify the country when the phone number is provided in a national format. - :param type: The type of information to return. Can be: `carrier` or `caller-name`. The default is null. Carrier information costs $0.005 per phone number looked up. Caller Name information is currently available only in the US and costs $0.01 per phone number looked up. To retrieve both types on information, specify this parameter twice; once with `carrier` and once with `caller-name` as the value. + :param type: The type of information to return. Can be: `carrier` or `caller-name`. The default is null. To retrieve both types of information, specify this parameter twice; once with `carrier` and once with `caller-name` as the value. :param add_ons: The `unique_name` of an Add-on you would like to invoke. Can be the `unique_name` of an Add-on that is installed on your account. You can specify multiple instances of this parameter to invoke multiple Add-ons. For more information about Add-ons, see the [Add-ons documentation](https://www.twilio.com/docs/add-ons). :param add_ons_data: Data specific to the add-on you would like to invoke. The content and format of this value depends on the add-on. @@ -153,7 +153,7 @@ def fetch( Fetch the PhoneNumberInstance :param country_code: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the phone number to fetch. This is used to specify the country when the phone number is provided in a national format. - :param type: The type of information to return. Can be: `carrier` or `caller-name`. The default is null. Carrier information costs $0.005 per phone number looked up. Caller Name information is currently available only in the US and costs $0.01 per phone number looked up. To retrieve both types on information, specify this parameter twice; once with `carrier` and once with `caller-name` as the value. + :param type: The type of information to return. Can be: `carrier` or `caller-name`. The default is null. To retrieve both types of information, specify this parameter twice; once with `carrier` and once with `caller-name` as the value. :param add_ons: The `unique_name` of an Add-on you would like to invoke. Can be the `unique_name` of an Add-on that is installed on your account. You can specify multiple instances of this parameter to invoke multiple Add-ons. For more information about Add-ons, see the [Add-ons documentation](https://www.twilio.com/docs/add-ons). :param add_ons_data: Data specific to the add-on you would like to invoke. The content and format of this value depends on the add-on. @@ -195,7 +195,7 @@ async def fetch_async( Asynchronous coroutine to fetch the PhoneNumberInstance :param country_code: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the phone number to fetch. This is used to specify the country when the phone number is provided in a national format. - :param type: The type of information to return. Can be: `carrier` or `caller-name`. The default is null. Carrier information costs $0.005 per phone number looked up. Caller Name information is currently available only in the US and costs $0.01 per phone number looked up. To retrieve both types on information, specify this parameter twice; once with `carrier` and once with `caller-name` as the value. + :param type: The type of information to return. Can be: `carrier` or `caller-name`. The default is null. To retrieve both types of information, specify this parameter twice; once with `carrier` and once with `caller-name` as the value. :param add_ons: The `unique_name` of an Add-on you would like to invoke. Can be the `unique_name` of an Add-on that is installed on your account. You can specify multiple instances of this parameter to invoke multiple Add-ons. For more information about Add-ons, see the [Add-ons documentation](https://www.twilio.com/docs/add-ons). :param add_ons_data: Data specific to the add-on you would like to invoke. The content and format of this value depends on the add-on. diff --git a/twilio/rest/monitor/v1/event.py b/twilio/rest/monitor/v1/event.py index 31716b8813..61450c872c 100644 --- a/twilio/rest/monitor/v1/event.py +++ b/twilio/rest/monitor/v1/event.py @@ -25,7 +25,7 @@ class EventInstance(InstanceResource): """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Event resource. - :ivar actor_sid: The SID of the actor that caused the event, if available. Can be `null`. + :ivar actor_sid: The SID of the actor that caused the event, if available. This can be either a User ID (matching the pattern `^US[0-9a-fA-F]{32}$`) or an Account SID (matching the pattern `^AC[0-9a-fA-F]{32}$`). If the actor's SID isn't available, this field will be `null`. :ivar actor_type: The type of actor that caused the event. Can be: `user` for a change made by a logged-in user in the Twilio Console, `account` for an event caused by an API request by an authenticating Account, `twilio-admin` for an event caused by a Twilio employee, and so on. :ivar description: A description of the event. Can be `null`. :ivar event_data: An object with additional data about the event. The contents depend on `event_type`. For example, event-types of the form `RESOURCE.updated`, this value contains a `resource_properties` dictionary that describes the previous and updated properties of the resource. diff --git a/twilio/rest/preview/PreviewBase.py b/twilio/rest/preview/PreviewBase.py index 2b44efaf63..dd8317b4c0 100644 --- a/twilio/rest/preview/PreviewBase.py +++ b/twilio/rest/preview/PreviewBase.py @@ -14,7 +14,6 @@ from twilio.base.domain import Domain from twilio.rest import Client from twilio.rest.preview.hosted_numbers import HostedNumbers -from twilio.rest.preview.sync import Sync from twilio.rest.preview.marketplace import Marketplace from twilio.rest.preview.wireless import Wireless @@ -29,7 +28,6 @@ def __init__(self, twilio: Client): """ super().__init__(twilio, "https://preview.twilio.com") self._hosted_numbers: Optional[HostedNumbers] = None - self._sync: Optional[Sync] = None self._marketplace: Optional[Marketplace] = None self._wireless: Optional[Wireless] = None @@ -42,15 +40,6 @@ def hosted_numbers(self) -> HostedNumbers: self._hosted_numbers = HostedNumbers(self) return self._hosted_numbers - @property - def sync(self) -> Sync: - """ - :returns: Versions sync of Preview - """ - if self._sync is None: - self._sync = Sync(self) - return self._sync - @property def marketplace(self) -> Marketplace: """ diff --git a/twilio/rest/preview/sync/service/__init__.py b/twilio/rest/preview/sync/service/__init__.py deleted file mode 100644 index 7b09429375..0000000000 --- a/twilio/rest/preview/sync/service/__init__.py +++ /dev/null @@ -1,741 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Preview - 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, serialize, values -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.preview.sync.service.document import DocumentList -from twilio.rest.preview.sync.service.sync_list import SyncListList -from twilio.rest.preview.sync.service.sync_map import SyncMapList - - -class ServiceInstance(InstanceResource): - """ - :ivar sid: - :ivar account_sid: - :ivar friendly_name: - :ivar date_created: - :ivar date_updated: - :ivar url: - :ivar webhook_url: - :ivar reachability_webhooks_enabled: - :ivar acl_enabled: - :ivar links: - """ - - def __init__( - self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None - ): - super().__init__(version) - - self.sid: Optional[str] = payload.get("sid") - self.account_sid: Optional[str] = payload.get("account_sid") - self.friendly_name: Optional[str] = payload.get("friendly_name") - 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.webhook_url: Optional[str] = payload.get("webhook_url") - self.reachability_webhooks_enabled: Optional[bool] = payload.get( - "reachability_webhooks_enabled" - ) - self.acl_enabled: Optional[bool] = payload.get("acl_enabled") - self.links: Optional[Dict[str, object]] = payload.get("links") - - self._solution = { - "sid": sid or self.sid, - } - self._context: Optional[ServiceContext] = None - - @property - def _proxy(self) -> "ServiceContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: ServiceContext for this ServiceInstance - """ - if self._context is None: - self._context = ServiceContext( - self._version, - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the ServiceInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the ServiceInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "ServiceInstance": - """ - Fetch the ServiceInstance - - - :returns: The fetched ServiceInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "ServiceInstance": - """ - Asynchronous coroutine to fetch the ServiceInstance - - - :returns: The fetched ServiceInstance - """ - return await self._proxy.fetch_async() - - def update( - self, - webhook_url: Union[str, object] = values.unset, - friendly_name: Union[str, object] = values.unset, - reachability_webhooks_enabled: Union[bool, object] = values.unset, - acl_enabled: Union[bool, object] = values.unset, - ) -> "ServiceInstance": - """ - Update the ServiceInstance - - :param webhook_url: - :param friendly_name: - :param reachability_webhooks_enabled: - :param acl_enabled: - - :returns: The updated ServiceInstance - """ - return self._proxy.update( - webhook_url=webhook_url, - friendly_name=friendly_name, - reachability_webhooks_enabled=reachability_webhooks_enabled, - acl_enabled=acl_enabled, - ) - - async def update_async( - self, - webhook_url: Union[str, object] = values.unset, - friendly_name: Union[str, object] = values.unset, - reachability_webhooks_enabled: Union[bool, object] = values.unset, - acl_enabled: Union[bool, object] = values.unset, - ) -> "ServiceInstance": - """ - Asynchronous coroutine to update the ServiceInstance - - :param webhook_url: - :param friendly_name: - :param reachability_webhooks_enabled: - :param acl_enabled: - - :returns: The updated ServiceInstance - """ - return await self._proxy.update_async( - webhook_url=webhook_url, - friendly_name=friendly_name, - reachability_webhooks_enabled=reachability_webhooks_enabled, - acl_enabled=acl_enabled, - ) - - @property - def documents(self) -> DocumentList: - """ - Access the documents - """ - return self._proxy.documents - - @property - def sync_lists(self) -> SyncListList: - """ - Access the sync_lists - """ - return self._proxy.sync_lists - - @property - def sync_maps(self) -> SyncMapList: - """ - Access the sync_maps - """ - return self._proxy.sync_maps - - 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 ServiceContext(InstanceContext): - - def __init__(self, version: Version, sid: str): - """ - Initialize the ServiceContext - - :param version: Version that contains the resource - :param sid: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "sid": sid, - } - self._uri = "/Services/{sid}".format(**self._solution) - - self._documents: Optional[DocumentList] = None - self._sync_lists: Optional[SyncListList] = None - self._sync_maps: Optional[SyncMapList] = None - - def delete(self) -> bool: - """ - Deletes the ServiceInstance - - - :returns: True if delete succeeds, False otherwise - """ - - headers = values.of({}) - - return self._version.delete(method="DELETE", uri=self._uri, headers=headers) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the ServiceInstance - - - :returns: True if delete succeeds, False otherwise - """ - - headers = values.of({}) - - return await self._version.delete_async( - method="DELETE", uri=self._uri, headers=headers - ) - - def fetch(self) -> ServiceInstance: - """ - Fetch the ServiceInstance - - - :returns: The fetched ServiceInstance - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) - - return ServiceInstance( - self._version, - payload, - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> ServiceInstance: - """ - Asynchronous coroutine to fetch the ServiceInstance - - - :returns: The fetched ServiceInstance - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - payload = await self._version.fetch_async( - method="GET", uri=self._uri, headers=headers - ) - - return ServiceInstance( - self._version, - payload, - sid=self._solution["sid"], - ) - - def update( - self, - webhook_url: Union[str, object] = values.unset, - friendly_name: Union[str, object] = values.unset, - reachability_webhooks_enabled: Union[bool, object] = values.unset, - acl_enabled: Union[bool, object] = values.unset, - ) -> ServiceInstance: - """ - Update the ServiceInstance - - :param webhook_url: - :param friendly_name: - :param reachability_webhooks_enabled: - :param acl_enabled: - - :returns: The updated ServiceInstance - """ - - data = values.of( - { - "WebhookUrl": webhook_url, - "FriendlyName": friendly_name, - "ReachabilityWebhooksEnabled": serialize.boolean_to_string( - reachability_webhooks_enabled - ), - "AclEnabled": serialize.boolean_to_string(acl_enabled), - } - ) - headers = values.of({}) - - headers["Content-Type"] = "application/x-www-form-urlencoded" - - headers["Accept"] = "application/json" - - payload = self._version.update( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return ServiceInstance(self._version, payload, sid=self._solution["sid"]) - - async def update_async( - self, - webhook_url: Union[str, object] = values.unset, - friendly_name: Union[str, object] = values.unset, - reachability_webhooks_enabled: Union[bool, object] = values.unset, - acl_enabled: Union[bool, object] = values.unset, - ) -> ServiceInstance: - """ - Asynchronous coroutine to update the ServiceInstance - - :param webhook_url: - :param friendly_name: - :param reachability_webhooks_enabled: - :param acl_enabled: - - :returns: The updated ServiceInstance - """ - - data = values.of( - { - "WebhookUrl": webhook_url, - "FriendlyName": friendly_name, - "ReachabilityWebhooksEnabled": serialize.boolean_to_string( - reachability_webhooks_enabled - ), - "AclEnabled": serialize.boolean_to_string(acl_enabled), - } - ) - headers = values.of({}) - - headers["Content-Type"] = "application/x-www-form-urlencoded" - - headers["Accept"] = "application/json" - - payload = await self._version.update_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return ServiceInstance(self._version, payload, sid=self._solution["sid"]) - - @property - def documents(self) -> DocumentList: - """ - Access the documents - """ - if self._documents is None: - self._documents = DocumentList( - self._version, - self._solution["sid"], - ) - return self._documents - - @property - def sync_lists(self) -> SyncListList: - """ - Access the sync_lists - """ - if self._sync_lists is None: - self._sync_lists = SyncListList( - self._version, - self._solution["sid"], - ) - return self._sync_lists - - @property - def sync_maps(self) -> SyncMapList: - """ - Access the sync_maps - """ - if self._sync_maps is None: - self._sync_maps = SyncMapList( - self._version, - self._solution["sid"], - ) - return self._sync_maps - - 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 ServicePage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> ServiceInstance: - """ - Build an instance of ServiceInstance - - :param payload: Payload response from the API - """ - return ServiceInstance(self._version, payload) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class ServiceList(ListResource): - - def __init__(self, version: Version): - """ - Initialize the ServiceList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/Services" - - def create( - self, - friendly_name: Union[str, object] = values.unset, - webhook_url: Union[str, object] = values.unset, - reachability_webhooks_enabled: Union[bool, object] = values.unset, - acl_enabled: Union[bool, object] = values.unset, - ) -> ServiceInstance: - """ - Create the ServiceInstance - - :param friendly_name: - :param webhook_url: - :param reachability_webhooks_enabled: - :param acl_enabled: - - :returns: The created ServiceInstance - """ - - data = values.of( - { - "FriendlyName": friendly_name, - "WebhookUrl": webhook_url, - "ReachabilityWebhooksEnabled": serialize.boolean_to_string( - reachability_webhooks_enabled - ), - "AclEnabled": serialize.boolean_to_string(acl_enabled), - } - ) - 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 ServiceInstance(self._version, payload) - - async def create_async( - self, - friendly_name: Union[str, object] = values.unset, - webhook_url: Union[str, object] = values.unset, - reachability_webhooks_enabled: Union[bool, object] = values.unset, - acl_enabled: Union[bool, object] = values.unset, - ) -> ServiceInstance: - """ - Asynchronously create the ServiceInstance - - :param friendly_name: - :param webhook_url: - :param reachability_webhooks_enabled: - :param acl_enabled: - - :returns: The created ServiceInstance - """ - - data = values.of( - { - "FriendlyName": friendly_name, - "WebhookUrl": webhook_url, - "ReachabilityWebhooksEnabled": serialize.boolean_to_string( - reachability_webhooks_enabled - ), - "AclEnabled": serialize.boolean_to_string(acl_enabled), - } - ) - 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 ServiceInstance(self._version, payload) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[ServiceInstance]: - """ - Streams ServiceInstance 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[ServiceInstance]: - """ - Asynchronously streams ServiceInstance 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 list( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[ServiceInstance]: - """ - Lists ServiceInstance 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[ServiceInstance]: - """ - Asynchronously lists ServiceInstance 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 page( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> ServicePage: - """ - Retrieve a single page of ServiceInstance 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 ServiceInstance - """ - 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 ServicePage(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, - ) -> ServicePage: - """ - Asynchronously retrieve a single page of ServiceInstance 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 ServiceInstance - """ - 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 ServicePage(self._version, response) - - def get_page(self, target_url: str) -> ServicePage: - """ - Retrieve a specific page of ServiceInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of ServiceInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return ServicePage(self._version, response) - - async def get_page_async(self, target_url: str) -> ServicePage: - """ - Asynchronously retrieve a specific page of ServiceInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of ServiceInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return ServicePage(self._version, response) - - def get(self, sid: str) -> ServiceContext: - """ - Constructs a ServiceContext - - :param sid: - """ - return ServiceContext(self._version, sid=sid) - - def __call__(self, sid: str) -> ServiceContext: - """ - Constructs a ServiceContext - - :param sid: - """ - return ServiceContext(self._version, sid=sid) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/sync/service/document/__init__.py b/twilio/rest/preview/sync/service/document/__init__.py deleted file mode 100644 index ee55186ca4..0000000000 --- a/twilio/rest/preview/sync/service/document/__init__.py +++ /dev/null @@ -1,693 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Preview - 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, serialize, values -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.preview.sync.service.document.document_permission import ( - DocumentPermissionList, -) - - -class DocumentInstance(InstanceResource): - """ - :ivar sid: - :ivar unique_name: - :ivar account_sid: - :ivar service_sid: - :ivar url: - :ivar links: - :ivar revision: - :ivar data: - :ivar date_created: - :ivar date_updated: - :ivar created_by: - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - service_sid: str, - sid: Optional[str] = None, - ): - super().__init__(version) - - self.sid: Optional[str] = payload.get("sid") - self.unique_name: Optional[str] = payload.get("unique_name") - self.account_sid: Optional[str] = payload.get("account_sid") - self.service_sid: Optional[str] = payload.get("service_sid") - self.url: Optional[str] = payload.get("url") - self.links: Optional[Dict[str, object]] = payload.get("links") - self.revision: Optional[str] = payload.get("revision") - self.data: Optional[Dict[str, object]] = payload.get("data") - 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.created_by: Optional[str] = payload.get("created_by") - - self._solution = { - "service_sid": service_sid, - "sid": sid or self.sid, - } - self._context: Optional[DocumentContext] = None - - @property - def _proxy(self) -> "DocumentContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: DocumentContext for this DocumentInstance - """ - if self._context is None: - self._context = DocumentContext( - self._version, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the DocumentInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the DocumentInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "DocumentInstance": - """ - Fetch the DocumentInstance - - - :returns: The fetched DocumentInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "DocumentInstance": - """ - Asynchronous coroutine to fetch the DocumentInstance - - - :returns: The fetched DocumentInstance - """ - return await self._proxy.fetch_async() - - def update( - self, data: object, if_match: Union[str, object] = values.unset - ) -> "DocumentInstance": - """ - Update the DocumentInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated DocumentInstance - """ - return self._proxy.update( - data=data, - if_match=if_match, - ) - - async def update_async( - self, data: object, if_match: Union[str, object] = values.unset - ) -> "DocumentInstance": - """ - Asynchronous coroutine to update the DocumentInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated DocumentInstance - """ - return await self._proxy.update_async( - data=data, - if_match=if_match, - ) - - @property - def document_permissions(self) -> DocumentPermissionList: - """ - Access the document_permissions - """ - return self._proxy.document_permissions - - 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 DocumentContext(InstanceContext): - - def __init__(self, version: Version, service_sid: str, sid: str): - """ - Initialize the DocumentContext - - :param version: Version that contains the resource - :param service_sid: - :param sid: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "sid": sid, - } - self._uri = "/Services/{service_sid}/Documents/{sid}".format(**self._solution) - - self._document_permissions: Optional[DocumentPermissionList] = None - - def delete(self) -> bool: - """ - Deletes the DocumentInstance - - - :returns: True if delete succeeds, False otherwise - """ - - headers = values.of({}) - - return self._version.delete(method="DELETE", uri=self._uri, headers=headers) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the DocumentInstance - - - :returns: True if delete succeeds, False otherwise - """ - - headers = values.of({}) - - return await self._version.delete_async( - method="DELETE", uri=self._uri, headers=headers - ) - - def fetch(self) -> DocumentInstance: - """ - Fetch the DocumentInstance - - - :returns: The fetched DocumentInstance - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) - - return DocumentInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> DocumentInstance: - """ - Asynchronous coroutine to fetch the DocumentInstance - - - :returns: The fetched DocumentInstance - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - payload = await self._version.fetch_async( - method="GET", uri=self._uri, headers=headers - ) - - return DocumentInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) - - def update( - self, data: object, if_match: Union[str, object] = values.unset - ) -> DocumentInstance: - """ - Update the DocumentInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated DocumentInstance - """ - - data = values.of( - { - "Data": serialize.object(data), - } - ) - 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["Content-Type"] = "application/x-www-form-urlencoded" - - headers["Accept"] = "application/json" - - payload = self._version.update( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return DocumentInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) - - async def update_async( - self, data: object, if_match: Union[str, object] = values.unset - ) -> DocumentInstance: - """ - Asynchronous coroutine to update the DocumentInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated DocumentInstance - """ - - data = values.of( - { - "Data": serialize.object(data), - } - ) - 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["Content-Type"] = "application/x-www-form-urlencoded" - - headers["Accept"] = "application/json" - - payload = await self._version.update_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return DocumentInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) - - @property - def document_permissions(self) -> DocumentPermissionList: - """ - Access the document_permissions - """ - if self._document_permissions is None: - self._document_permissions = DocumentPermissionList( - self._version, - self._solution["service_sid"], - self._solution["sid"], - ) - return self._document_permissions - - 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 DocumentPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> DocumentInstance: - """ - Build an instance of DocumentInstance - - :param payload: Payload response from the API - """ - return DocumentInstance( - self._version, payload, service_sid=self._solution["service_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class DocumentList(ListResource): - - def __init__(self, version: Version, service_sid: str): - """ - Initialize the DocumentList - - :param version: Version that contains the resource - :param service_sid: - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - } - self._uri = "/Services/{service_sid}/Documents".format(**self._solution) - - def create( - self, - unique_name: Union[str, object] = values.unset, - data: Union[object, object] = values.unset, - ) -> DocumentInstance: - """ - Create the DocumentInstance - - :param unique_name: - :param data: - - :returns: The created DocumentInstance - """ - - data = values.of( - { - "UniqueName": unique_name, - "Data": serialize.object(data), - } - ) - 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 DocumentInstance( - self._version, payload, service_sid=self._solution["service_sid"] - ) - - async def create_async( - self, - unique_name: Union[str, object] = values.unset, - data: Union[object, object] = values.unset, - ) -> DocumentInstance: - """ - Asynchronously create the DocumentInstance - - :param unique_name: - :param data: - - :returns: The created DocumentInstance - """ - - data = values.of( - { - "UniqueName": unique_name, - "Data": serialize.object(data), - } - ) - 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 DocumentInstance( - self._version, payload, service_sid=self._solution["service_sid"] - ) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[DocumentInstance]: - """ - Streams DocumentInstance 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[DocumentInstance]: - """ - Asynchronously streams DocumentInstance 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 list( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[DocumentInstance]: - """ - Lists DocumentInstance 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[DocumentInstance]: - """ - Asynchronously lists DocumentInstance 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 page( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> DocumentPage: - """ - Retrieve a single page of DocumentInstance 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 DocumentInstance - """ - 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 DocumentPage(self._version, response, 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, - ) -> DocumentPage: - """ - Asynchronously retrieve a single page of DocumentInstance 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 DocumentInstance - """ - 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 DocumentPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> DocumentPage: - """ - Retrieve a specific page of DocumentInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of DocumentInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return DocumentPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> DocumentPage: - """ - Asynchronously retrieve a specific page of DocumentInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of DocumentInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return DocumentPage(self._version, response, self._solution) - - def get(self, sid: str) -> DocumentContext: - """ - Constructs a DocumentContext - - :param sid: - """ - return DocumentContext( - self._version, service_sid=self._solution["service_sid"], sid=sid - ) - - def __call__(self, sid: str) -> DocumentContext: - """ - Constructs a DocumentContext - - :param sid: - """ - return DocumentContext( - self._version, service_sid=self._solution["service_sid"], sid=sid - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/sync/service/document/document_permission.py b/twilio/rest/preview/sync/service/document/document_permission.py deleted file mode 100644 index 676efb569f..0000000000 --- a/twilio/rest/preview/sync/service/document/document_permission.py +++ /dev/null @@ -1,617 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Preview - 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, Union, Iterator, AsyncIterator -from twilio.base import serialize, values -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 DocumentPermissionInstance(InstanceResource): - """ - :ivar account_sid: The unique SID identifier of the Twilio Account. - :ivar service_sid: The unique SID identifier of the Sync Service Instance. - :ivar document_sid: The unique SID identifier of the Sync Document to which the Permission applies. - :ivar identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - :ivar read: Boolean flag specifying whether the identity can read the Sync Document. - :ivar write: Boolean flag specifying whether the identity can update the Sync Document. - :ivar manage: Boolean flag specifying whether the identity can delete the Sync Document. - :ivar url: Contains an absolute URL for this Sync Document Permission. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - service_sid: str, - document_sid: str, - identity: Optional[str] = None, - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.service_sid: Optional[str] = payload.get("service_sid") - self.document_sid: Optional[str] = payload.get("document_sid") - self.identity: Optional[str] = payload.get("identity") - self.read: Optional[bool] = payload.get("read") - self.write: Optional[bool] = payload.get("write") - self.manage: Optional[bool] = payload.get("manage") - self.url: Optional[str] = payload.get("url") - - self._solution = { - "service_sid": service_sid, - "document_sid": document_sid, - "identity": identity or self.identity, - } - self._context: Optional[DocumentPermissionContext] = None - - @property - def _proxy(self) -> "DocumentPermissionContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: DocumentPermissionContext for this DocumentPermissionInstance - """ - if self._context is None: - self._context = DocumentPermissionContext( - self._version, - service_sid=self._solution["service_sid"], - document_sid=self._solution["document_sid"], - identity=self._solution["identity"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the DocumentPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the DocumentPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "DocumentPermissionInstance": - """ - Fetch the DocumentPermissionInstance - - - :returns: The fetched DocumentPermissionInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "DocumentPermissionInstance": - """ - Asynchronous coroutine to fetch the DocumentPermissionInstance - - - :returns: The fetched DocumentPermissionInstance - """ - return await self._proxy.fetch_async() - - def update( - self, read: bool, write: bool, manage: bool - ) -> "DocumentPermissionInstance": - """ - Update the DocumentPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync Document. - :param write: Boolean flag specifying whether the identity can update the Sync Document. - :param manage: Boolean flag specifying whether the identity can delete the Sync Document. - - :returns: The updated DocumentPermissionInstance - """ - return self._proxy.update( - read=read, - write=write, - manage=manage, - ) - - async def update_async( - self, read: bool, write: bool, manage: bool - ) -> "DocumentPermissionInstance": - """ - Asynchronous coroutine to update the DocumentPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync Document. - :param write: Boolean flag specifying whether the identity can update the Sync Document. - :param manage: Boolean flag specifying whether the identity can delete the Sync Document. - - :returns: The updated DocumentPermissionInstance - """ - return await self._proxy.update_async( - read=read, - write=write, - manage=manage, - ) - - 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 DocumentPermissionContext(InstanceContext): - - def __init__( - self, version: Version, service_sid: str, document_sid: str, identity: str - ): - """ - Initialize the DocumentPermissionContext - - :param version: Version that contains the resource - :param service_sid: The unique SID identifier of the Sync Service Instance. - :param document_sid: Identifier of the Sync Document. Either a SID or a unique name. - :param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "document_sid": document_sid, - "identity": identity, - } - self._uri = "/Services/{service_sid}/Documents/{document_sid}/Permissions/{identity}".format( - **self._solution - ) - - def delete(self) -> bool: - """ - Deletes the DocumentPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - - headers = values.of({}) - - return self._version.delete(method="DELETE", uri=self._uri, headers=headers) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the DocumentPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - - headers = values.of({}) - - return await self._version.delete_async( - method="DELETE", uri=self._uri, headers=headers - ) - - def fetch(self) -> DocumentPermissionInstance: - """ - Fetch the DocumentPermissionInstance - - - :returns: The fetched DocumentPermissionInstance - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) - - return DocumentPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - document_sid=self._solution["document_sid"], - identity=self._solution["identity"], - ) - - async def fetch_async(self) -> DocumentPermissionInstance: - """ - Asynchronous coroutine to fetch the DocumentPermissionInstance - - - :returns: The fetched DocumentPermissionInstance - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - payload = await self._version.fetch_async( - method="GET", uri=self._uri, headers=headers - ) - - return DocumentPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - document_sid=self._solution["document_sid"], - identity=self._solution["identity"], - ) - - def update( - self, read: bool, write: bool, manage: bool - ) -> DocumentPermissionInstance: - """ - Update the DocumentPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync Document. - :param write: Boolean flag specifying whether the identity can update the Sync Document. - :param manage: Boolean flag specifying whether the identity can delete the Sync Document. - - :returns: The updated DocumentPermissionInstance - """ - - data = values.of( - { - "Read": serialize.boolean_to_string(read), - "Write": serialize.boolean_to_string(write), - "Manage": serialize.boolean_to_string(manage), - } - ) - headers = values.of({}) - - headers["Content-Type"] = "application/x-www-form-urlencoded" - - headers["Accept"] = "application/json" - - payload = self._version.update( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return DocumentPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - document_sid=self._solution["document_sid"], - identity=self._solution["identity"], - ) - - async def update_async( - self, read: bool, write: bool, manage: bool - ) -> DocumentPermissionInstance: - """ - Asynchronous coroutine to update the DocumentPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync Document. - :param write: Boolean flag specifying whether the identity can update the Sync Document. - :param manage: Boolean flag specifying whether the identity can delete the Sync Document. - - :returns: The updated DocumentPermissionInstance - """ - - data = values.of( - { - "Read": serialize.boolean_to_string(read), - "Write": serialize.boolean_to_string(write), - "Manage": serialize.boolean_to_string(manage), - } - ) - headers = values.of({}) - - headers["Content-Type"] = "application/x-www-form-urlencoded" - - headers["Accept"] = "application/json" - - payload = await self._version.update_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return DocumentPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - document_sid=self._solution["document_sid"], - identity=self._solution["identity"], - ) - - 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 DocumentPermissionPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> DocumentPermissionInstance: - """ - Build an instance of DocumentPermissionInstance - - :param payload: Payload response from the API - """ - return DocumentPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - document_sid=self._solution["document_sid"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class DocumentPermissionList(ListResource): - - def __init__(self, version: Version, service_sid: str, document_sid: str): - """ - Initialize the DocumentPermissionList - - :param version: Version that contains the resource - :param service_sid: - :param document_sid: Identifier of the Sync Document. Either a SID or a unique name. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "document_sid": document_sid, - } - self._uri = ( - "/Services/{service_sid}/Documents/{document_sid}/Permissions".format( - **self._solution - ) - ) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[DocumentPermissionInstance]: - """ - Streams DocumentPermissionInstance 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[DocumentPermissionInstance]: - """ - Asynchronously streams DocumentPermissionInstance 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 list( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[DocumentPermissionInstance]: - """ - Lists DocumentPermissionInstance 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[DocumentPermissionInstance]: - """ - Asynchronously lists DocumentPermissionInstance 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 page( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> DocumentPermissionPage: - """ - Retrieve a single page of DocumentPermissionInstance 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 DocumentPermissionInstance - """ - 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 DocumentPermissionPage(self._version, response, 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, - ) -> DocumentPermissionPage: - """ - Asynchronously retrieve a single page of DocumentPermissionInstance 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 DocumentPermissionInstance - """ - 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 DocumentPermissionPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> DocumentPermissionPage: - """ - Retrieve a specific page of DocumentPermissionInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of DocumentPermissionInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return DocumentPermissionPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> DocumentPermissionPage: - """ - Asynchronously retrieve a specific page of DocumentPermissionInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of DocumentPermissionInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return DocumentPermissionPage(self._version, response, self._solution) - - def get(self, identity: str) -> DocumentPermissionContext: - """ - Constructs a DocumentPermissionContext - - :param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - """ - return DocumentPermissionContext( - self._version, - service_sid=self._solution["service_sid"], - document_sid=self._solution["document_sid"], - identity=identity, - ) - - def __call__(self, identity: str) -> DocumentPermissionContext: - """ - Constructs a DocumentPermissionContext - - :param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - """ - return DocumentPermissionContext( - self._version, - service_sid=self._solution["service_sid"], - document_sid=self._solution["document_sid"], - identity=identity, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/sync/service/sync_list/__init__.py b/twilio/rest/preview/sync/service/sync_list/__init__.py deleted file mode 100644 index 0461f22430..0000000000 --- a/twilio/rest/preview/sync/service/sync_list/__init__.py +++ /dev/null @@ -1,595 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Preview - 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.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.preview.sync.service.sync_list.sync_list_item import SyncListItemList -from twilio.rest.preview.sync.service.sync_list.sync_list_permission import ( - SyncListPermissionList, -) - - -class SyncListInstance(InstanceResource): - """ - :ivar sid: - :ivar unique_name: - :ivar account_sid: - :ivar service_sid: - :ivar url: - :ivar links: - :ivar revision: - :ivar date_created: - :ivar date_updated: - :ivar created_by: - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - service_sid: str, - sid: Optional[str] = None, - ): - super().__init__(version) - - self.sid: Optional[str] = payload.get("sid") - self.unique_name: Optional[str] = payload.get("unique_name") - self.account_sid: Optional[str] = payload.get("account_sid") - self.service_sid: Optional[str] = payload.get("service_sid") - self.url: Optional[str] = payload.get("url") - self.links: Optional[Dict[str, object]] = payload.get("links") - self.revision: Optional[str] = payload.get("revision") - 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.created_by: Optional[str] = payload.get("created_by") - - self._solution = { - "service_sid": service_sid, - "sid": sid or self.sid, - } - self._context: Optional[SyncListContext] = None - - @property - def _proxy(self) -> "SyncListContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: SyncListContext for this SyncListInstance - """ - if self._context is None: - self._context = SyncListContext( - self._version, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the SyncListInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the SyncListInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "SyncListInstance": - """ - Fetch the SyncListInstance - - - :returns: The fetched SyncListInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "SyncListInstance": - """ - Asynchronous coroutine to fetch the SyncListInstance - - - :returns: The fetched SyncListInstance - """ - return await self._proxy.fetch_async() - - @property - def sync_list_items(self) -> SyncListItemList: - """ - Access the sync_list_items - """ - return self._proxy.sync_list_items - - @property - def sync_list_permissions(self) -> SyncListPermissionList: - """ - Access the sync_list_permissions - """ - return self._proxy.sync_list_permissions - - 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 SyncListContext(InstanceContext): - - def __init__(self, version: Version, service_sid: str, sid: str): - """ - Initialize the SyncListContext - - :param version: Version that contains the resource - :param service_sid: - :param sid: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "sid": sid, - } - self._uri = "/Services/{service_sid}/Lists/{sid}".format(**self._solution) - - self._sync_list_items: Optional[SyncListItemList] = None - self._sync_list_permissions: Optional[SyncListPermissionList] = None - - def delete(self) -> bool: - """ - Deletes the SyncListInstance - - - :returns: True if delete succeeds, False otherwise - """ - - headers = values.of({}) - - return self._version.delete(method="DELETE", uri=self._uri, headers=headers) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the SyncListInstance - - - :returns: True if delete succeeds, False otherwise - """ - - headers = values.of({}) - - return await self._version.delete_async( - method="DELETE", uri=self._uri, headers=headers - ) - - def fetch(self) -> SyncListInstance: - """ - Fetch the SyncListInstance - - - :returns: The fetched SyncListInstance - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) - - return SyncListInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> SyncListInstance: - """ - Asynchronous coroutine to fetch the SyncListInstance - - - :returns: The fetched SyncListInstance - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - payload = await self._version.fetch_async( - method="GET", uri=self._uri, headers=headers - ) - - return SyncListInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) - - @property - def sync_list_items(self) -> SyncListItemList: - """ - Access the sync_list_items - """ - if self._sync_list_items is None: - self._sync_list_items = SyncListItemList( - self._version, - self._solution["service_sid"], - self._solution["sid"], - ) - return self._sync_list_items - - @property - def sync_list_permissions(self) -> SyncListPermissionList: - """ - Access the sync_list_permissions - """ - if self._sync_list_permissions is None: - self._sync_list_permissions = SyncListPermissionList( - self._version, - self._solution["service_sid"], - self._solution["sid"], - ) - return self._sync_list_permissions - - 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 SyncListPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> SyncListInstance: - """ - Build an instance of SyncListInstance - - :param payload: Payload response from the API - """ - return SyncListInstance( - self._version, payload, service_sid=self._solution["service_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class SyncListList(ListResource): - - def __init__(self, version: Version, service_sid: str): - """ - Initialize the SyncListList - - :param version: Version that contains the resource - :param service_sid: - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - } - self._uri = "/Services/{service_sid}/Lists".format(**self._solution) - - def create( - self, unique_name: Union[str, object] = values.unset - ) -> SyncListInstance: - """ - Create the SyncListInstance - - :param unique_name: - - :returns: The created SyncListInstance - """ - - data = values.of( - { - "UniqueName": unique_name, - } - ) - 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 SyncListInstance( - self._version, payload, service_sid=self._solution["service_sid"] - ) - - async def create_async( - self, unique_name: Union[str, object] = values.unset - ) -> SyncListInstance: - """ - Asynchronously create the SyncListInstance - - :param unique_name: - - :returns: The created SyncListInstance - """ - - data = values.of( - { - "UniqueName": unique_name, - } - ) - 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 SyncListInstance( - self._version, payload, service_sid=self._solution["service_sid"] - ) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[SyncListInstance]: - """ - Streams SyncListInstance 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[SyncListInstance]: - """ - Asynchronously streams SyncListInstance 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 list( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SyncListInstance]: - """ - Lists SyncListInstance 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[SyncListInstance]: - """ - Asynchronously lists SyncListInstance 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 page( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> SyncListPage: - """ - Retrieve a single page of SyncListInstance 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 SyncListInstance - """ - 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 SyncListPage(self._version, response, 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, - ) -> SyncListPage: - """ - Asynchronously retrieve a single page of SyncListInstance 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 SyncListInstance - """ - 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 SyncListPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> SyncListPage: - """ - Retrieve a specific page of SyncListInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncListInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return SyncListPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> SyncListPage: - """ - Asynchronously retrieve a specific page of SyncListInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncListInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return SyncListPage(self._version, response, self._solution) - - def get(self, sid: str) -> SyncListContext: - """ - Constructs a SyncListContext - - :param sid: - """ - return SyncListContext( - self._version, service_sid=self._solution["service_sid"], sid=sid - ) - - def __call__(self, sid: str) -> SyncListContext: - """ - Constructs a SyncListContext - - :param sid: - """ - return SyncListContext( - self._version, service_sid=self._solution["service_sid"], sid=sid - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/sync/service/sync_list/sync_list_item.py b/twilio/rest/preview/sync/service/sync_list/sync_list_item.py deleted file mode 100644 index 5220aec215..0000000000 --- a/twilio/rest/preview/sync/service/sync_list/sync_list_item.py +++ /dev/null @@ -1,763 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Preview - 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, serialize, values -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 SyncListItemInstance(InstanceResource): - - class QueryFromBoundType(object): - INCLUSIVE = "inclusive" - EXCLUSIVE = "exclusive" - - class QueryResultOrder(object): - ASC = "asc" - DESC = "desc" - - """ - :ivar index: - :ivar account_sid: - :ivar service_sid: - :ivar list_sid: - :ivar url: - :ivar revision: - :ivar data: - :ivar date_created: - :ivar date_updated: - :ivar created_by: - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - service_sid: str, - list_sid: str, - index: Optional[int] = None, - ): - super().__init__(version) - - self.index: Optional[int] = deserialize.integer(payload.get("index")) - self.account_sid: Optional[str] = payload.get("account_sid") - self.service_sid: Optional[str] = payload.get("service_sid") - self.list_sid: Optional[str] = payload.get("list_sid") - self.url: Optional[str] = payload.get("url") - self.revision: Optional[str] = payload.get("revision") - self.data: Optional[Dict[str, object]] = payload.get("data") - 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.created_by: Optional[str] = payload.get("created_by") - - self._solution = { - "service_sid": service_sid, - "list_sid": list_sid, - "index": index or self.index, - } - self._context: Optional[SyncListItemContext] = None - - @property - def _proxy(self) -> "SyncListItemContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: SyncListItemContext for this SyncListItemInstance - """ - if self._context is None: - self._context = SyncListItemContext( - self._version, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - index=self._solution["index"], - ) - return self._context - - def delete(self, if_match: Union[str, object] = values.unset) -> bool: - """ - Deletes the SyncListItemInstance - - :param if_match: The If-Match HTTP request header - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete( - if_match=if_match, - ) - - async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool: - """ - Asynchronous coroutine that deletes the SyncListItemInstance - - :param if_match: The If-Match HTTP request header - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async( - if_match=if_match, - ) - - def fetch(self) -> "SyncListItemInstance": - """ - Fetch the SyncListItemInstance - - - :returns: The fetched SyncListItemInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "SyncListItemInstance": - """ - Asynchronous coroutine to fetch the SyncListItemInstance - - - :returns: The fetched SyncListItemInstance - """ - return await self._proxy.fetch_async() - - def update( - self, data: object, if_match: Union[str, object] = values.unset - ) -> "SyncListItemInstance": - """ - Update the SyncListItemInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated SyncListItemInstance - """ - return self._proxy.update( - data=data, - if_match=if_match, - ) - - async def update_async( - self, data: object, if_match: Union[str, object] = values.unset - ) -> "SyncListItemInstance": - """ - Asynchronous coroutine to update the SyncListItemInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated SyncListItemInstance - """ - return await self._proxy.update_async( - data=data, - if_match=if_match, - ) - - 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 SyncListItemContext(InstanceContext): - - def __init__(self, version: Version, service_sid: str, list_sid: str, index: int): - """ - Initialize the SyncListItemContext - - :param version: Version that contains the resource - :param service_sid: - :param list_sid: - :param index: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "list_sid": list_sid, - "index": index, - } - self._uri = "/Services/{service_sid}/Lists/{list_sid}/Items/{index}".format( - **self._solution - ) - - def delete(self, if_match: Union[str, object] = values.unset) -> bool: - """ - Deletes the SyncListItemInstance - - :param if_match: The If-Match HTTP request header - - :returns: True if delete succeeds, False otherwise - """ - headers = values.of( - { - "If-Match": if_match, - } - ) - - headers = values.of({}) - - return self._version.delete(method="DELETE", uri=self._uri, headers=headers) - - async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool: - """ - Asynchronous coroutine that deletes the SyncListItemInstance - - :param if_match: The If-Match HTTP request header - - :returns: True if delete succeeds, False otherwise - """ - headers = values.of( - { - "If-Match": if_match, - } - ) - - headers = values.of({}) - - return await self._version.delete_async( - method="DELETE", uri=self._uri, headers=headers - ) - - def fetch(self) -> SyncListItemInstance: - """ - Fetch the SyncListItemInstance - - - :returns: The fetched SyncListItemInstance - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) - - return SyncListItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - index=self._solution["index"], - ) - - async def fetch_async(self) -> SyncListItemInstance: - """ - Asynchronous coroutine to fetch the SyncListItemInstance - - - :returns: The fetched SyncListItemInstance - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - payload = await self._version.fetch_async( - method="GET", uri=self._uri, headers=headers - ) - - return SyncListItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - index=self._solution["index"], - ) - - def update( - self, data: object, if_match: Union[str, object] = values.unset - ) -> SyncListItemInstance: - """ - Update the SyncListItemInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated SyncListItemInstance - """ - - data = values.of( - { - "Data": serialize.object(data), - } - ) - 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["Content-Type"] = "application/x-www-form-urlencoded" - - headers["Accept"] = "application/json" - - payload = self._version.update( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return SyncListItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - index=self._solution["index"], - ) - - async def update_async( - self, data: object, if_match: Union[str, object] = values.unset - ) -> SyncListItemInstance: - """ - Asynchronous coroutine to update the SyncListItemInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated SyncListItemInstance - """ - - data = values.of( - { - "Data": serialize.object(data), - } - ) - 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["Content-Type"] = "application/x-www-form-urlencoded" - - headers["Accept"] = "application/json" - - payload = await self._version.update_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return SyncListItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - index=self._solution["index"], - ) - - 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 SyncListItemPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> SyncListItemInstance: - """ - Build an instance of SyncListItemInstance - - :param payload: Payload response from the API - """ - return SyncListItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class SyncListItemList(ListResource): - - def __init__(self, version: Version, service_sid: str, list_sid: str): - """ - Initialize the SyncListItemList - - :param version: Version that contains the resource - :param service_sid: - :param list_sid: - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "list_sid": list_sid, - } - self._uri = "/Services/{service_sid}/Lists/{list_sid}/Items".format( - **self._solution - ) - - def create(self, data: object) -> SyncListItemInstance: - """ - Create the SyncListItemInstance - - :param data: - - :returns: The created SyncListItemInstance - """ - - data = values.of( - { - "Data": serialize.object(data), - } - ) - 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 SyncListItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - ) - - async def create_async(self, data: object) -> SyncListItemInstance: - """ - Asynchronously create the SyncListItemInstance - - :param data: - - :returns: The created SyncListItemInstance - """ - - data = values.of( - { - "Data": serialize.object(data), - } - ) - 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 SyncListItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - ) - - def stream( - self, - order: Union["SyncListItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncListItemInstance.QueryFromBoundType", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[SyncListItemInstance]: - """ - Streams SyncListItemInstance 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 "SyncListItemInstance.QueryResultOrder" order: - :param str from_: - :param "SyncListItemInstance.QueryFromBoundType" bounds: - :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( - order=order, from_=from_, bounds=bounds, page_size=limits["page_size"] - ) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - order: Union["SyncListItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncListItemInstance.QueryFromBoundType", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[SyncListItemInstance]: - """ - Asynchronously streams SyncListItemInstance 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 "SyncListItemInstance.QueryResultOrder" order: - :param str from_: - :param "SyncListItemInstance.QueryFromBoundType" bounds: - :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( - order=order, from_=from_, bounds=bounds, page_size=limits["page_size"] - ) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - order: Union["SyncListItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncListItemInstance.QueryFromBoundType", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SyncListItemInstance]: - """ - Lists SyncListItemInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param "SyncListItemInstance.QueryResultOrder" order: - :param str from_: - :param "SyncListItemInstance.QueryFromBoundType" bounds: - :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( - order=order, - from_=from_, - bounds=bounds, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - order: Union["SyncListItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncListItemInstance.QueryFromBoundType", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SyncListItemInstance]: - """ - Asynchronously lists SyncListItemInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param "SyncListItemInstance.QueryResultOrder" order: - :param str from_: - :param "SyncListItemInstance.QueryFromBoundType" bounds: - :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( - order=order, - from_=from_, - bounds=bounds, - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - order: Union["SyncListItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncListItemInstance.QueryFromBoundType", object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> SyncListItemPage: - """ - Retrieve a single page of SyncListItemInstance records from the API. - Request is executed immediately - - :param order: - :param from_: - :param bounds: - :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 SyncListItemInstance - """ - data = values.of( - { - "Order": order, - "From": from_, - "Bounds": bounds, - "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 SyncListItemPage(self._version, response, self._solution) - - async def page_async( - self, - order: Union["SyncListItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncListItemInstance.QueryFromBoundType", object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> SyncListItemPage: - """ - Asynchronously retrieve a single page of SyncListItemInstance records from the API. - Request is executed immediately - - :param order: - :param from_: - :param bounds: - :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 SyncListItemInstance - """ - data = values.of( - { - "Order": order, - "From": from_, - "Bounds": bounds, - "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 SyncListItemPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> SyncListItemPage: - """ - Retrieve a specific page of SyncListItemInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncListItemInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return SyncListItemPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> SyncListItemPage: - """ - Asynchronously retrieve a specific page of SyncListItemInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncListItemInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return SyncListItemPage(self._version, response, self._solution) - - def get(self, index: int) -> SyncListItemContext: - """ - Constructs a SyncListItemContext - - :param index: - """ - return SyncListItemContext( - self._version, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - index=index, - ) - - def __call__(self, index: int) -> SyncListItemContext: - """ - Constructs a SyncListItemContext - - :param index: - """ - return SyncListItemContext( - self._version, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - index=index, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/sync/service/sync_list/sync_list_permission.py b/twilio/rest/preview/sync/service/sync_list/sync_list_permission.py deleted file mode 100644 index 334b62dd18..0000000000 --- a/twilio/rest/preview/sync/service/sync_list/sync_list_permission.py +++ /dev/null @@ -1,617 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Preview - 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, Union, Iterator, AsyncIterator -from twilio.base import serialize, values -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 SyncListPermissionInstance(InstanceResource): - """ - :ivar account_sid: The unique SID identifier of the Twilio Account. - :ivar service_sid: The unique SID identifier of the Sync Service Instance. - :ivar list_sid: The unique SID identifier of the Sync List to which the Permission applies. - :ivar identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - :ivar read: Boolean flag specifying whether the identity can read the Sync List and its Items. - :ivar write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync List. - :ivar manage: Boolean flag specifying whether the identity can delete the Sync List. - :ivar url: Contains an absolute URL for this Sync List Permission. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - service_sid: str, - list_sid: str, - identity: Optional[str] = None, - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.service_sid: Optional[str] = payload.get("service_sid") - self.list_sid: Optional[str] = payload.get("list_sid") - self.identity: Optional[str] = payload.get("identity") - self.read: Optional[bool] = payload.get("read") - self.write: Optional[bool] = payload.get("write") - self.manage: Optional[bool] = payload.get("manage") - self.url: Optional[str] = payload.get("url") - - self._solution = { - "service_sid": service_sid, - "list_sid": list_sid, - "identity": identity or self.identity, - } - self._context: Optional[SyncListPermissionContext] = None - - @property - def _proxy(self) -> "SyncListPermissionContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: SyncListPermissionContext for this SyncListPermissionInstance - """ - if self._context is None: - self._context = SyncListPermissionContext( - self._version, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - identity=self._solution["identity"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the SyncListPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the SyncListPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "SyncListPermissionInstance": - """ - Fetch the SyncListPermissionInstance - - - :returns: The fetched SyncListPermissionInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "SyncListPermissionInstance": - """ - Asynchronous coroutine to fetch the SyncListPermissionInstance - - - :returns: The fetched SyncListPermissionInstance - """ - return await self._proxy.fetch_async() - - def update( - self, read: bool, write: bool, manage: bool - ) -> "SyncListPermissionInstance": - """ - Update the SyncListPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync List. - :param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync List. - :param manage: Boolean flag specifying whether the identity can delete the Sync List. - - :returns: The updated SyncListPermissionInstance - """ - return self._proxy.update( - read=read, - write=write, - manage=manage, - ) - - async def update_async( - self, read: bool, write: bool, manage: bool - ) -> "SyncListPermissionInstance": - """ - Asynchronous coroutine to update the SyncListPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync List. - :param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync List. - :param manage: Boolean flag specifying whether the identity can delete the Sync List. - - :returns: The updated SyncListPermissionInstance - """ - return await self._proxy.update_async( - read=read, - write=write, - manage=manage, - ) - - 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 SyncListPermissionContext(InstanceContext): - - def __init__( - self, version: Version, service_sid: str, list_sid: str, identity: str - ): - """ - Initialize the SyncListPermissionContext - - :param version: Version that contains the resource - :param service_sid: The unique SID identifier of the Sync Service Instance. - :param list_sid: Identifier of the Sync List. Either a SID or a unique name. - :param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "list_sid": list_sid, - "identity": identity, - } - self._uri = ( - "/Services/{service_sid}/Lists/{list_sid}/Permissions/{identity}".format( - **self._solution - ) - ) - - def delete(self) -> bool: - """ - Deletes the SyncListPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - - headers = values.of({}) - - return self._version.delete(method="DELETE", uri=self._uri, headers=headers) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the SyncListPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - - headers = values.of({}) - - return await self._version.delete_async( - method="DELETE", uri=self._uri, headers=headers - ) - - def fetch(self) -> SyncListPermissionInstance: - """ - Fetch the SyncListPermissionInstance - - - :returns: The fetched SyncListPermissionInstance - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) - - return SyncListPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - identity=self._solution["identity"], - ) - - async def fetch_async(self) -> SyncListPermissionInstance: - """ - Asynchronous coroutine to fetch the SyncListPermissionInstance - - - :returns: The fetched SyncListPermissionInstance - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - payload = await self._version.fetch_async( - method="GET", uri=self._uri, headers=headers - ) - - return SyncListPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - identity=self._solution["identity"], - ) - - def update( - self, read: bool, write: bool, manage: bool - ) -> SyncListPermissionInstance: - """ - Update the SyncListPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync List. - :param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync List. - :param manage: Boolean flag specifying whether the identity can delete the Sync List. - - :returns: The updated SyncListPermissionInstance - """ - - data = values.of( - { - "Read": serialize.boolean_to_string(read), - "Write": serialize.boolean_to_string(write), - "Manage": serialize.boolean_to_string(manage), - } - ) - headers = values.of({}) - - headers["Content-Type"] = "application/x-www-form-urlencoded" - - headers["Accept"] = "application/json" - - payload = self._version.update( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return SyncListPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - identity=self._solution["identity"], - ) - - async def update_async( - self, read: bool, write: bool, manage: bool - ) -> SyncListPermissionInstance: - """ - Asynchronous coroutine to update the SyncListPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync List. - :param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync List. - :param manage: Boolean flag specifying whether the identity can delete the Sync List. - - :returns: The updated SyncListPermissionInstance - """ - - data = values.of( - { - "Read": serialize.boolean_to_string(read), - "Write": serialize.boolean_to_string(write), - "Manage": serialize.boolean_to_string(manage), - } - ) - headers = values.of({}) - - headers["Content-Type"] = "application/x-www-form-urlencoded" - - headers["Accept"] = "application/json" - - payload = await self._version.update_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return SyncListPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - identity=self._solution["identity"], - ) - - 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 SyncListPermissionPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> SyncListPermissionInstance: - """ - Build an instance of SyncListPermissionInstance - - :param payload: Payload response from the API - """ - return SyncListPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class SyncListPermissionList(ListResource): - - def __init__(self, version: Version, service_sid: str, list_sid: str): - """ - Initialize the SyncListPermissionList - - :param version: Version that contains the resource - :param service_sid: - :param list_sid: Identifier of the Sync List. Either a SID or a unique name. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "list_sid": list_sid, - } - self._uri = "/Services/{service_sid}/Lists/{list_sid}/Permissions".format( - **self._solution - ) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[SyncListPermissionInstance]: - """ - Streams SyncListPermissionInstance 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[SyncListPermissionInstance]: - """ - Asynchronously streams SyncListPermissionInstance 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 list( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SyncListPermissionInstance]: - """ - Lists SyncListPermissionInstance 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[SyncListPermissionInstance]: - """ - Asynchronously lists SyncListPermissionInstance 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 page( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> SyncListPermissionPage: - """ - Retrieve a single page of SyncListPermissionInstance 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 SyncListPermissionInstance - """ - 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 SyncListPermissionPage(self._version, response, 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, - ) -> SyncListPermissionPage: - """ - Asynchronously retrieve a single page of SyncListPermissionInstance 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 SyncListPermissionInstance - """ - 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 SyncListPermissionPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> SyncListPermissionPage: - """ - Retrieve a specific page of SyncListPermissionInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncListPermissionInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return SyncListPermissionPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> SyncListPermissionPage: - """ - Asynchronously retrieve a specific page of SyncListPermissionInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncListPermissionInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return SyncListPermissionPage(self._version, response, self._solution) - - def get(self, identity: str) -> SyncListPermissionContext: - """ - Constructs a SyncListPermissionContext - - :param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - """ - return SyncListPermissionContext( - self._version, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - identity=identity, - ) - - def __call__(self, identity: str) -> SyncListPermissionContext: - """ - Constructs a SyncListPermissionContext - - :param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - """ - return SyncListPermissionContext( - self._version, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - identity=identity, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/sync/service/sync_map/__init__.py b/twilio/rest/preview/sync/service/sync_map/__init__.py deleted file mode 100644 index 0ecbb6132f..0000000000 --- a/twilio/rest/preview/sync/service/sync_map/__init__.py +++ /dev/null @@ -1,593 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Preview - 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.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.preview.sync.service.sync_map.sync_map_item import SyncMapItemList -from twilio.rest.preview.sync.service.sync_map.sync_map_permission import ( - SyncMapPermissionList, -) - - -class SyncMapInstance(InstanceResource): - """ - :ivar sid: - :ivar unique_name: - :ivar account_sid: - :ivar service_sid: - :ivar url: - :ivar links: - :ivar revision: - :ivar date_created: - :ivar date_updated: - :ivar created_by: - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - service_sid: str, - sid: Optional[str] = None, - ): - super().__init__(version) - - self.sid: Optional[str] = payload.get("sid") - self.unique_name: Optional[str] = payload.get("unique_name") - self.account_sid: Optional[str] = payload.get("account_sid") - self.service_sid: Optional[str] = payload.get("service_sid") - self.url: Optional[str] = payload.get("url") - self.links: Optional[Dict[str, object]] = payload.get("links") - self.revision: Optional[str] = payload.get("revision") - 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.created_by: Optional[str] = payload.get("created_by") - - self._solution = { - "service_sid": service_sid, - "sid": sid or self.sid, - } - self._context: Optional[SyncMapContext] = None - - @property - def _proxy(self) -> "SyncMapContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: SyncMapContext for this SyncMapInstance - """ - if self._context is None: - self._context = SyncMapContext( - self._version, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the SyncMapInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the SyncMapInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "SyncMapInstance": - """ - Fetch the SyncMapInstance - - - :returns: The fetched SyncMapInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "SyncMapInstance": - """ - Asynchronous coroutine to fetch the SyncMapInstance - - - :returns: The fetched SyncMapInstance - """ - return await self._proxy.fetch_async() - - @property - def sync_map_items(self) -> SyncMapItemList: - """ - Access the sync_map_items - """ - return self._proxy.sync_map_items - - @property - def sync_map_permissions(self) -> SyncMapPermissionList: - """ - Access the sync_map_permissions - """ - return self._proxy.sync_map_permissions - - 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 SyncMapContext(InstanceContext): - - def __init__(self, version: Version, service_sid: str, sid: str): - """ - Initialize the SyncMapContext - - :param version: Version that contains the resource - :param service_sid: - :param sid: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "sid": sid, - } - self._uri = "/Services/{service_sid}/Maps/{sid}".format(**self._solution) - - self._sync_map_items: Optional[SyncMapItemList] = None - self._sync_map_permissions: Optional[SyncMapPermissionList] = None - - def delete(self) -> bool: - """ - Deletes the SyncMapInstance - - - :returns: True if delete succeeds, False otherwise - """ - - headers = values.of({}) - - return self._version.delete(method="DELETE", uri=self._uri, headers=headers) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the SyncMapInstance - - - :returns: True if delete succeeds, False otherwise - """ - - headers = values.of({}) - - return await self._version.delete_async( - method="DELETE", uri=self._uri, headers=headers - ) - - def fetch(self) -> SyncMapInstance: - """ - Fetch the SyncMapInstance - - - :returns: The fetched SyncMapInstance - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) - - return SyncMapInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> SyncMapInstance: - """ - Asynchronous coroutine to fetch the SyncMapInstance - - - :returns: The fetched SyncMapInstance - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - payload = await self._version.fetch_async( - method="GET", uri=self._uri, headers=headers - ) - - return SyncMapInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) - - @property - def sync_map_items(self) -> SyncMapItemList: - """ - Access the sync_map_items - """ - if self._sync_map_items is None: - self._sync_map_items = SyncMapItemList( - self._version, - self._solution["service_sid"], - self._solution["sid"], - ) - return self._sync_map_items - - @property - def sync_map_permissions(self) -> SyncMapPermissionList: - """ - Access the sync_map_permissions - """ - if self._sync_map_permissions is None: - self._sync_map_permissions = SyncMapPermissionList( - self._version, - self._solution["service_sid"], - self._solution["sid"], - ) - return self._sync_map_permissions - - 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 SyncMapPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> SyncMapInstance: - """ - Build an instance of SyncMapInstance - - :param payload: Payload response from the API - """ - return SyncMapInstance( - self._version, payload, service_sid=self._solution["service_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class SyncMapList(ListResource): - - def __init__(self, version: Version, service_sid: str): - """ - Initialize the SyncMapList - - :param version: Version that contains the resource - :param service_sid: - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - } - self._uri = "/Services/{service_sid}/Maps".format(**self._solution) - - def create(self, unique_name: Union[str, object] = values.unset) -> SyncMapInstance: - """ - Create the SyncMapInstance - - :param unique_name: - - :returns: The created SyncMapInstance - """ - - data = values.of( - { - "UniqueName": unique_name, - } - ) - 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 SyncMapInstance( - self._version, payload, service_sid=self._solution["service_sid"] - ) - - async def create_async( - self, unique_name: Union[str, object] = values.unset - ) -> SyncMapInstance: - """ - Asynchronously create the SyncMapInstance - - :param unique_name: - - :returns: The created SyncMapInstance - """ - - data = values.of( - { - "UniqueName": unique_name, - } - ) - 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 SyncMapInstance( - self._version, payload, service_sid=self._solution["service_sid"] - ) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[SyncMapInstance]: - """ - Streams SyncMapInstance 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[SyncMapInstance]: - """ - Asynchronously streams SyncMapInstance 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 list( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SyncMapInstance]: - """ - Lists SyncMapInstance 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[SyncMapInstance]: - """ - Asynchronously lists SyncMapInstance 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 page( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> SyncMapPage: - """ - Retrieve a single page of SyncMapInstance 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 SyncMapInstance - """ - 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 SyncMapPage(self._version, response, 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, - ) -> SyncMapPage: - """ - Asynchronously retrieve a single page of SyncMapInstance 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 SyncMapInstance - """ - 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 SyncMapPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> SyncMapPage: - """ - Retrieve a specific page of SyncMapInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncMapInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return SyncMapPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> SyncMapPage: - """ - Asynchronously retrieve a specific page of SyncMapInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncMapInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return SyncMapPage(self._version, response, self._solution) - - def get(self, sid: str) -> SyncMapContext: - """ - Constructs a SyncMapContext - - :param sid: - """ - return SyncMapContext( - self._version, service_sid=self._solution["service_sid"], sid=sid - ) - - def __call__(self, sid: str) -> SyncMapContext: - """ - Constructs a SyncMapContext - - :param sid: - """ - return SyncMapContext( - self._version, service_sid=self._solution["service_sid"], sid=sid - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/sync/service/sync_map/sync_map_item.py b/twilio/rest/preview/sync/service/sync_map/sync_map_item.py deleted file mode 100644 index 9ddd1d5afe..0000000000 --- a/twilio/rest/preview/sync/service/sync_map/sync_map_item.py +++ /dev/null @@ -1,767 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Preview - 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, serialize, values -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 SyncMapItemInstance(InstanceResource): - - class QueryFromBoundType(object): - INCLUSIVE = "inclusive" - EXCLUSIVE = "exclusive" - - class QueryResultOrder(object): - ASC = "asc" - DESC = "desc" - - """ - :ivar key: - :ivar account_sid: - :ivar service_sid: - :ivar map_sid: - :ivar url: - :ivar revision: - :ivar data: - :ivar date_created: - :ivar date_updated: - :ivar created_by: - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - service_sid: str, - map_sid: str, - key: Optional[str] = None, - ): - super().__init__(version) - - self.key: Optional[str] = payload.get("key") - self.account_sid: Optional[str] = payload.get("account_sid") - self.service_sid: Optional[str] = payload.get("service_sid") - self.map_sid: Optional[str] = payload.get("map_sid") - self.url: Optional[str] = payload.get("url") - self.revision: Optional[str] = payload.get("revision") - self.data: Optional[Dict[str, object]] = payload.get("data") - 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.created_by: Optional[str] = payload.get("created_by") - - self._solution = { - "service_sid": service_sid, - "map_sid": map_sid, - "key": key or self.key, - } - self._context: Optional[SyncMapItemContext] = None - - @property - def _proxy(self) -> "SyncMapItemContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: SyncMapItemContext for this SyncMapItemInstance - """ - if self._context is None: - self._context = SyncMapItemContext( - self._version, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - key=self._solution["key"], - ) - return self._context - - def delete(self, if_match: Union[str, object] = values.unset) -> bool: - """ - Deletes the SyncMapItemInstance - - :param if_match: The If-Match HTTP request header - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete( - if_match=if_match, - ) - - async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool: - """ - Asynchronous coroutine that deletes the SyncMapItemInstance - - :param if_match: The If-Match HTTP request header - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async( - if_match=if_match, - ) - - def fetch(self) -> "SyncMapItemInstance": - """ - Fetch the SyncMapItemInstance - - - :returns: The fetched SyncMapItemInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "SyncMapItemInstance": - """ - Asynchronous coroutine to fetch the SyncMapItemInstance - - - :returns: The fetched SyncMapItemInstance - """ - return await self._proxy.fetch_async() - - def update( - self, data: object, if_match: Union[str, object] = values.unset - ) -> "SyncMapItemInstance": - """ - Update the SyncMapItemInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated SyncMapItemInstance - """ - return self._proxy.update( - data=data, - if_match=if_match, - ) - - async def update_async( - self, data: object, if_match: Union[str, object] = values.unset - ) -> "SyncMapItemInstance": - """ - Asynchronous coroutine to update the SyncMapItemInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated SyncMapItemInstance - """ - return await self._proxy.update_async( - data=data, - if_match=if_match, - ) - - 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 SyncMapItemContext(InstanceContext): - - def __init__(self, version: Version, service_sid: str, map_sid: str, key: str): - """ - Initialize the SyncMapItemContext - - :param version: Version that contains the resource - :param service_sid: - :param map_sid: - :param key: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "map_sid": map_sid, - "key": key, - } - self._uri = "/Services/{service_sid}/Maps/{map_sid}/Items/{key}".format( - **self._solution - ) - - def delete(self, if_match: Union[str, object] = values.unset) -> bool: - """ - Deletes the SyncMapItemInstance - - :param if_match: The If-Match HTTP request header - - :returns: True if delete succeeds, False otherwise - """ - headers = values.of( - { - "If-Match": if_match, - } - ) - - headers = values.of({}) - - return self._version.delete(method="DELETE", uri=self._uri, headers=headers) - - async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool: - """ - Asynchronous coroutine that deletes the SyncMapItemInstance - - :param if_match: The If-Match HTTP request header - - :returns: True if delete succeeds, False otherwise - """ - headers = values.of( - { - "If-Match": if_match, - } - ) - - headers = values.of({}) - - return await self._version.delete_async( - method="DELETE", uri=self._uri, headers=headers - ) - - def fetch(self) -> SyncMapItemInstance: - """ - Fetch the SyncMapItemInstance - - - :returns: The fetched SyncMapItemInstance - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) - - return SyncMapItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - key=self._solution["key"], - ) - - async def fetch_async(self) -> SyncMapItemInstance: - """ - Asynchronous coroutine to fetch the SyncMapItemInstance - - - :returns: The fetched SyncMapItemInstance - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - payload = await self._version.fetch_async( - method="GET", uri=self._uri, headers=headers - ) - - return SyncMapItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - key=self._solution["key"], - ) - - def update( - self, data: object, if_match: Union[str, object] = values.unset - ) -> SyncMapItemInstance: - """ - Update the SyncMapItemInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated SyncMapItemInstance - """ - - data = values.of( - { - "Data": serialize.object(data), - } - ) - 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["Content-Type"] = "application/x-www-form-urlencoded" - - headers["Accept"] = "application/json" - - payload = self._version.update( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return SyncMapItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - key=self._solution["key"], - ) - - async def update_async( - self, data: object, if_match: Union[str, object] = values.unset - ) -> SyncMapItemInstance: - """ - Asynchronous coroutine to update the SyncMapItemInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated SyncMapItemInstance - """ - - data = values.of( - { - "Data": serialize.object(data), - } - ) - 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["Content-Type"] = "application/x-www-form-urlencoded" - - headers["Accept"] = "application/json" - - payload = await self._version.update_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return SyncMapItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - key=self._solution["key"], - ) - - 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 SyncMapItemPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> SyncMapItemInstance: - """ - Build an instance of SyncMapItemInstance - - :param payload: Payload response from the API - """ - return SyncMapItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class SyncMapItemList(ListResource): - - def __init__(self, version: Version, service_sid: str, map_sid: str): - """ - Initialize the SyncMapItemList - - :param version: Version that contains the resource - :param service_sid: - :param map_sid: - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "map_sid": map_sid, - } - self._uri = "/Services/{service_sid}/Maps/{map_sid}/Items".format( - **self._solution - ) - - def create(self, key: str, data: object) -> SyncMapItemInstance: - """ - Create the SyncMapItemInstance - - :param key: - :param data: - - :returns: The created SyncMapItemInstance - """ - - data = values.of( - { - "Key": key, - "Data": serialize.object(data), - } - ) - 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 SyncMapItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - ) - - async def create_async(self, key: str, data: object) -> SyncMapItemInstance: - """ - Asynchronously create the SyncMapItemInstance - - :param key: - :param data: - - :returns: The created SyncMapItemInstance - """ - - data = values.of( - { - "Key": key, - "Data": serialize.object(data), - } - ) - 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 SyncMapItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - ) - - def stream( - self, - order: Union["SyncMapItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncMapItemInstance.QueryFromBoundType", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[SyncMapItemInstance]: - """ - Streams SyncMapItemInstance 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 "SyncMapItemInstance.QueryResultOrder" order: - :param str from_: - :param "SyncMapItemInstance.QueryFromBoundType" bounds: - :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( - order=order, from_=from_, bounds=bounds, page_size=limits["page_size"] - ) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - order: Union["SyncMapItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncMapItemInstance.QueryFromBoundType", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[SyncMapItemInstance]: - """ - Asynchronously streams SyncMapItemInstance 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 "SyncMapItemInstance.QueryResultOrder" order: - :param str from_: - :param "SyncMapItemInstance.QueryFromBoundType" bounds: - :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( - order=order, from_=from_, bounds=bounds, page_size=limits["page_size"] - ) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - order: Union["SyncMapItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncMapItemInstance.QueryFromBoundType", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SyncMapItemInstance]: - """ - Lists SyncMapItemInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param "SyncMapItemInstance.QueryResultOrder" order: - :param str from_: - :param "SyncMapItemInstance.QueryFromBoundType" bounds: - :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( - order=order, - from_=from_, - bounds=bounds, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - order: Union["SyncMapItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncMapItemInstance.QueryFromBoundType", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SyncMapItemInstance]: - """ - Asynchronously lists SyncMapItemInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param "SyncMapItemInstance.QueryResultOrder" order: - :param str from_: - :param "SyncMapItemInstance.QueryFromBoundType" bounds: - :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( - order=order, - from_=from_, - bounds=bounds, - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - order: Union["SyncMapItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncMapItemInstance.QueryFromBoundType", object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> SyncMapItemPage: - """ - Retrieve a single page of SyncMapItemInstance records from the API. - Request is executed immediately - - :param order: - :param from_: - :param bounds: - :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 SyncMapItemInstance - """ - data = values.of( - { - "Order": order, - "From": from_, - "Bounds": bounds, - "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 SyncMapItemPage(self._version, response, self._solution) - - async def page_async( - self, - order: Union["SyncMapItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncMapItemInstance.QueryFromBoundType", object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> SyncMapItemPage: - """ - Asynchronously retrieve a single page of SyncMapItemInstance records from the API. - Request is executed immediately - - :param order: - :param from_: - :param bounds: - :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 SyncMapItemInstance - """ - data = values.of( - { - "Order": order, - "From": from_, - "Bounds": bounds, - "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 SyncMapItemPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> SyncMapItemPage: - """ - Retrieve a specific page of SyncMapItemInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncMapItemInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return SyncMapItemPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> SyncMapItemPage: - """ - Asynchronously retrieve a specific page of SyncMapItemInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncMapItemInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return SyncMapItemPage(self._version, response, self._solution) - - def get(self, key: str) -> SyncMapItemContext: - """ - Constructs a SyncMapItemContext - - :param key: - """ - return SyncMapItemContext( - self._version, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - key=key, - ) - - def __call__(self, key: str) -> SyncMapItemContext: - """ - Constructs a SyncMapItemContext - - :param key: - """ - return SyncMapItemContext( - self._version, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - key=key, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/sync/service/sync_map/sync_map_permission.py b/twilio/rest/preview/sync/service/sync_map/sync_map_permission.py deleted file mode 100644 index 9e19d56a91..0000000000 --- a/twilio/rest/preview/sync/service/sync_map/sync_map_permission.py +++ /dev/null @@ -1,615 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Preview - 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, Union, Iterator, AsyncIterator -from twilio.base import serialize, values -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 SyncMapPermissionInstance(InstanceResource): - """ - :ivar account_sid: The unique SID identifier of the Twilio Account. - :ivar service_sid: The unique SID identifier of the Sync Service Instance. - :ivar map_sid: The unique SID identifier of the Sync Map to which the Permission applies. - :ivar identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - :ivar read: Boolean flag specifying whether the identity can read the Sync Map and its Items. - :ivar write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync Map. - :ivar manage: Boolean flag specifying whether the identity can delete the Sync Map. - :ivar url: Contains an absolute URL for this Sync Map Permission. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - service_sid: str, - map_sid: str, - identity: Optional[str] = None, - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.service_sid: Optional[str] = payload.get("service_sid") - self.map_sid: Optional[str] = payload.get("map_sid") - self.identity: Optional[str] = payload.get("identity") - self.read: Optional[bool] = payload.get("read") - self.write: Optional[bool] = payload.get("write") - self.manage: Optional[bool] = payload.get("manage") - self.url: Optional[str] = payload.get("url") - - self._solution = { - "service_sid": service_sid, - "map_sid": map_sid, - "identity": identity or self.identity, - } - self._context: Optional[SyncMapPermissionContext] = None - - @property - def _proxy(self) -> "SyncMapPermissionContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: SyncMapPermissionContext for this SyncMapPermissionInstance - """ - if self._context is None: - self._context = SyncMapPermissionContext( - self._version, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - identity=self._solution["identity"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the SyncMapPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the SyncMapPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "SyncMapPermissionInstance": - """ - Fetch the SyncMapPermissionInstance - - - :returns: The fetched SyncMapPermissionInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "SyncMapPermissionInstance": - """ - Asynchronous coroutine to fetch the SyncMapPermissionInstance - - - :returns: The fetched SyncMapPermissionInstance - """ - return await self._proxy.fetch_async() - - def update( - self, read: bool, write: bool, manage: bool - ) -> "SyncMapPermissionInstance": - """ - Update the SyncMapPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync Map. - :param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync Map. - :param manage: Boolean flag specifying whether the identity can delete the Sync Map. - - :returns: The updated SyncMapPermissionInstance - """ - return self._proxy.update( - read=read, - write=write, - manage=manage, - ) - - async def update_async( - self, read: bool, write: bool, manage: bool - ) -> "SyncMapPermissionInstance": - """ - Asynchronous coroutine to update the SyncMapPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync Map. - :param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync Map. - :param manage: Boolean flag specifying whether the identity can delete the Sync Map. - - :returns: The updated SyncMapPermissionInstance - """ - return await self._proxy.update_async( - read=read, - write=write, - manage=manage, - ) - - 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 SyncMapPermissionContext(InstanceContext): - - def __init__(self, version: Version, service_sid: str, map_sid: str, identity: str): - """ - Initialize the SyncMapPermissionContext - - :param version: Version that contains the resource - :param service_sid: The unique SID identifier of the Sync Service Instance. - :param map_sid: Identifier of the Sync Map. Either a SID or a unique name. - :param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "map_sid": map_sid, - "identity": identity, - } - self._uri = ( - "/Services/{service_sid}/Maps/{map_sid}/Permissions/{identity}".format( - **self._solution - ) - ) - - def delete(self) -> bool: - """ - Deletes the SyncMapPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - - headers = values.of({}) - - return self._version.delete(method="DELETE", uri=self._uri, headers=headers) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the SyncMapPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - - headers = values.of({}) - - return await self._version.delete_async( - method="DELETE", uri=self._uri, headers=headers - ) - - def fetch(self) -> SyncMapPermissionInstance: - """ - Fetch the SyncMapPermissionInstance - - - :returns: The fetched SyncMapPermissionInstance - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) - - return SyncMapPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - identity=self._solution["identity"], - ) - - async def fetch_async(self) -> SyncMapPermissionInstance: - """ - Asynchronous coroutine to fetch the SyncMapPermissionInstance - - - :returns: The fetched SyncMapPermissionInstance - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - payload = await self._version.fetch_async( - method="GET", uri=self._uri, headers=headers - ) - - return SyncMapPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - identity=self._solution["identity"], - ) - - def update( - self, read: bool, write: bool, manage: bool - ) -> SyncMapPermissionInstance: - """ - Update the SyncMapPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync Map. - :param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync Map. - :param manage: Boolean flag specifying whether the identity can delete the Sync Map. - - :returns: The updated SyncMapPermissionInstance - """ - - data = values.of( - { - "Read": serialize.boolean_to_string(read), - "Write": serialize.boolean_to_string(write), - "Manage": serialize.boolean_to_string(manage), - } - ) - headers = values.of({}) - - headers["Content-Type"] = "application/x-www-form-urlencoded" - - headers["Accept"] = "application/json" - - payload = self._version.update( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return SyncMapPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - identity=self._solution["identity"], - ) - - async def update_async( - self, read: bool, write: bool, manage: bool - ) -> SyncMapPermissionInstance: - """ - Asynchronous coroutine to update the SyncMapPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync Map. - :param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync Map. - :param manage: Boolean flag specifying whether the identity can delete the Sync Map. - - :returns: The updated SyncMapPermissionInstance - """ - - data = values.of( - { - "Read": serialize.boolean_to_string(read), - "Write": serialize.boolean_to_string(write), - "Manage": serialize.boolean_to_string(manage), - } - ) - headers = values.of({}) - - headers["Content-Type"] = "application/x-www-form-urlencoded" - - headers["Accept"] = "application/json" - - payload = await self._version.update_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return SyncMapPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - identity=self._solution["identity"], - ) - - 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 SyncMapPermissionPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> SyncMapPermissionInstance: - """ - Build an instance of SyncMapPermissionInstance - - :param payload: Payload response from the API - """ - return SyncMapPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class SyncMapPermissionList(ListResource): - - def __init__(self, version: Version, service_sid: str, map_sid: str): - """ - Initialize the SyncMapPermissionList - - :param version: Version that contains the resource - :param service_sid: - :param map_sid: Identifier of the Sync Map. Either a SID or a unique name. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "map_sid": map_sid, - } - self._uri = "/Services/{service_sid}/Maps/{map_sid}/Permissions".format( - **self._solution - ) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[SyncMapPermissionInstance]: - """ - Streams SyncMapPermissionInstance 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[SyncMapPermissionInstance]: - """ - Asynchronously streams SyncMapPermissionInstance 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 list( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SyncMapPermissionInstance]: - """ - Lists SyncMapPermissionInstance 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[SyncMapPermissionInstance]: - """ - Asynchronously lists SyncMapPermissionInstance 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 page( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> SyncMapPermissionPage: - """ - Retrieve a single page of SyncMapPermissionInstance 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 SyncMapPermissionInstance - """ - 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 SyncMapPermissionPage(self._version, response, 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, - ) -> SyncMapPermissionPage: - """ - Asynchronously retrieve a single page of SyncMapPermissionInstance 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 SyncMapPermissionInstance - """ - 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 SyncMapPermissionPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> SyncMapPermissionPage: - """ - Retrieve a specific page of SyncMapPermissionInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncMapPermissionInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return SyncMapPermissionPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> SyncMapPermissionPage: - """ - Asynchronously retrieve a specific page of SyncMapPermissionInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncMapPermissionInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return SyncMapPermissionPage(self._version, response, self._solution) - - def get(self, identity: str) -> SyncMapPermissionContext: - """ - Constructs a SyncMapPermissionContext - - :param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - """ - return SyncMapPermissionContext( - self._version, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - identity=identity, - ) - - def __call__(self, identity: str) -> SyncMapPermissionContext: - """ - Constructs a SyncMapPermissionContext - - :param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - """ - return SyncMapPermissionContext( - self._version, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - identity=identity, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/studio/v1/flow/engagement/step/__init__.py b/twilio/rest/studio/v1/flow/engagement/step/__init__.py index d88d0ad0f6..a5017c3313 100644 --- a/twilio/rest/studio/v1/flow/engagement/step/__init__.py +++ b/twilio/rest/studio/v1/flow/engagement/step/__init__.py @@ -31,6 +31,7 @@ class StepInstance(InstanceResource): :ivar engagement_sid: The SID of the Engagement. :ivar name: The event that caused the Flow to transition to the Step. :ivar context: The current state of the Flow's Execution. As a flow executes, we save its state in this context. We save data that your widgets can access as variables in configuration fields or in text areas as variable substitution. + :ivar parent_step_sid: The SID of the parent Step. :ivar transitioned_from: The Widget that preceded the Widget for the Step. :ivar transitioned_to: The Widget that will follow the Widget for the Step. :ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. @@ -55,6 +56,7 @@ def __init__( self.engagement_sid: Optional[str] = payload.get("engagement_sid") self.name: Optional[str] = payload.get("name") self.context: Optional[Dict[str, object]] = payload.get("context") + self.parent_step_sid: Optional[str] = payload.get("parent_step_sid") self.transitioned_from: Optional[str] = payload.get("transitioned_from") self.transitioned_to: Optional[str] = payload.get("transitioned_to") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( diff --git a/twilio/rest/studio/v1/flow/execution/execution_step/__init__.py b/twilio/rest/studio/v1/flow/execution/execution_step/__init__.py index 888506e965..50a1e2371d 100644 --- a/twilio/rest/studio/v1/flow/execution/execution_step/__init__.py +++ b/twilio/rest/studio/v1/flow/execution/execution_step/__init__.py @@ -31,6 +31,7 @@ class ExecutionStepInstance(InstanceResource): :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ExecutionStep resource. :ivar flow_sid: The SID of the Flow. :ivar execution_sid: The SID of the Step's Execution resource. + :ivar parent_step_sid: This field shows the Step SID of the Widget in the parent Flow that started the Subflow. If this Step is not part of a Subflow execution, the value is null. :ivar name: The event that caused the Flow to transition to the Step. :ivar context: The current state of the Flow's Execution. As a flow executes, we save its state in this context. We save data that your widgets can access as variables in configuration fields or in text areas as variable substitution. :ivar transitioned_from: The Widget that preceded the Widget for the Step. @@ -55,6 +56,7 @@ def __init__( self.account_sid: Optional[str] = payload.get("account_sid") self.flow_sid: Optional[str] = payload.get("flow_sid") self.execution_sid: Optional[str] = payload.get("execution_sid") + self.parent_step_sid: Optional[str] = payload.get("parent_step_sid") self.name: Optional[str] = payload.get("name") self.context: Optional[Dict[str, object]] = payload.get("context") self.transitioned_from: Optional[str] = payload.get("transitioned_from") diff --git a/twilio/rest/studio/v2/flow/execution/execution_step/__init__.py b/twilio/rest/studio/v2/flow/execution/execution_step/__init__.py index b088aeab0e..9ffb2502e6 100644 --- a/twilio/rest/studio/v2/flow/execution/execution_step/__init__.py +++ b/twilio/rest/studio/v2/flow/execution/execution_step/__init__.py @@ -31,6 +31,7 @@ class ExecutionStepInstance(InstanceResource): :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ExecutionStep resource. :ivar flow_sid: The SID of the Flow. :ivar execution_sid: The SID of the Step's Execution resource. + :ivar parent_step_sid: The SID of the parent Step. :ivar name: The event that caused the Flow to transition to the Step. :ivar context: The current state of the Flow's Execution. As a flow executes, we save its state in this context. We save data that your widgets can access as variables in configuration fields or in text areas as variable substitution. :ivar transitioned_from: The Widget that preceded the Widget for the Step. @@ -55,6 +56,7 @@ def __init__( self.account_sid: Optional[str] = payload.get("account_sid") self.flow_sid: Optional[str] = payload.get("flow_sid") self.execution_sid: Optional[str] = payload.get("execution_sid") + self.parent_step_sid: Optional[str] = payload.get("parent_step_sid") self.name: Optional[str] = payload.get("name") self.context: Optional[Dict[str, object]] = payload.get("context") self.transitioned_from: Optional[str] = payload.get("transitioned_from") diff --git a/twilio/rest/taskrouter/v1/workspace/task/reservation.py b/twilio/rest/taskrouter/v1/workspace/task/reservation.py index 5318543ea2..28cb03339a 100644 --- a/twilio/rest/taskrouter/v1/workspace/task/reservation.py +++ b/twilio/rest/taskrouter/v1/workspace/task/reservation.py @@ -250,7 +250,7 @@ def update( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. :param dequeue_status_callback_event: The Call progress events sent via webhooks as a result of a Dequeue instruction. @@ -433,7 +433,7 @@ async def update_async( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. :param dequeue_status_callback_event: The Call progress events sent via webhooks as a result of a Dequeue instruction. @@ -697,7 +697,7 @@ def update( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. :param dequeue_status_callback_event: The Call progress events sent via webhooks as a result of a Dequeue instruction. @@ -918,7 +918,7 @@ async def update_async( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. :param dequeue_status_callback_event: The Call progress events sent via webhooks as a result of a Dequeue instruction. diff --git a/twilio/rest/taskrouter/v1/workspace/worker/reservation.py b/twilio/rest/taskrouter/v1/workspace/worker/reservation.py index 11d1ea610d..7f24057806 100644 --- a/twilio/rest/taskrouter/v1/workspace/worker/reservation.py +++ b/twilio/rest/taskrouter/v1/workspace/worker/reservation.py @@ -241,7 +241,7 @@ def update( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. :param dequeue_status_callback_event: The call progress events sent via webhooks as a result of a Dequeue instruction. @@ -416,7 +416,7 @@ async def update_async( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. :param dequeue_status_callback_event: The call progress events sent via webhooks as a result of a Dequeue instruction. @@ -670,7 +670,7 @@ def update( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. :param dequeue_status_callback_event: The call progress events sent via webhooks as a result of a Dequeue instruction. @@ -883,7 +883,7 @@ async def update_async( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. :param dequeue_status_callback_event: The call progress events sent via webhooks as a result of a Dequeue instruction. diff --git a/twilio/rest/video/v1/room/participant/__init__.py b/twilio/rest/video/v1/room/participant/__init__.py index 756a166eae..7e012e8d37 100644 --- a/twilio/rest/video/v1/room/participant/__init__.py +++ b/twilio/rest/video/v1/room/participant/__init__.py @@ -31,6 +31,7 @@ class ParticipantInstance(InstanceResource): class Status(object): CONNECTED = "connected" DISCONNECTED = "disconnected" + RECONNECTING = "reconnecting" """ :ivar sid: The unique string that we created to identify the RoomParticipant resource. diff --git a/twilio/rest/wireless/v1/rate_plan.py b/twilio/rest/wireless/v1/rate_plan.py index 458ade0ad5..23efabe9b0 100644 --- a/twilio/rest/wireless/v1/rate_plan.py +++ b/twilio/rest/wireless/v1/rate_plan.py @@ -23,6 +23,11 @@ class RatePlanInstance(InstanceResource): + + class DataLimitStrategy(object): + BLOCK = "block" + THROTTLE = "throttle" + """ :ivar sid: The unique string that we created to identify the RatePlan resource. :ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource. @@ -382,6 +387,9 @@ def create( international_roaming: Union[List[str], object] = values.unset, national_roaming_data_limit: Union[int, object] = values.unset, international_roaming_data_limit: Union[int, object] = values.unset, + data_limit_strategy: Union[ + "RatePlanInstance.DataLimitStrategy", object + ] = values.unset, ) -> RatePlanInstance: """ Create the RatePlanInstance @@ -397,6 +405,7 @@ def create( :param international_roaming: The list of services that SIMs capable of using GPRS/3G/4G/LTE data connectivity can use outside of the United States. Can contain: `data` and `messaging`. :param national_roaming_data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month on non-home networks in the United States. The metering period begins the day of activation and ends on the same day in the following month. Can be up to 2TB. See [national roaming](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#national-roaming) for more info. :param international_roaming_data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month when roaming outside the United States. Can be up to 2TB. + :param data_limit_strategy: :returns: The created RatePlanInstance """ @@ -418,6 +427,7 @@ def create( ), "NationalRoamingDataLimit": national_roaming_data_limit, "InternationalRoamingDataLimit": international_roaming_data_limit, + "DataLimitStrategy": data_limit_strategy, } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) @@ -445,6 +455,9 @@ async def create_async( international_roaming: Union[List[str], object] = values.unset, national_roaming_data_limit: Union[int, object] = values.unset, international_roaming_data_limit: Union[int, object] = values.unset, + data_limit_strategy: Union[ + "RatePlanInstance.DataLimitStrategy", object + ] = values.unset, ) -> RatePlanInstance: """ Asynchronously create the RatePlanInstance @@ -460,6 +473,7 @@ async def create_async( :param international_roaming: The list of services that SIMs capable of using GPRS/3G/4G/LTE data connectivity can use outside of the United States. Can contain: `data` and `messaging`. :param national_roaming_data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month on non-home networks in the United States. The metering period begins the day of activation and ends on the same day in the following month. Can be up to 2TB. See [national roaming](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#national-roaming) for more info. :param international_roaming_data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month when roaming outside the United States. Can be up to 2TB. + :param data_limit_strategy: :returns: The created RatePlanInstance """ @@ -481,6 +495,7 @@ async def create_async( ), "NationalRoamingDataLimit": national_roaming_data_limit, "InternationalRoamingDataLimit": international_roaming_data_limit, + "DataLimitStrategy": data_limit_strategy, } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"})