From dd72ebead6ced3eef5c5faf92b2bb2a1d88506ff Mon Sep 17 00:00:00 2001 From: Manisha Singh Date: Mon, 22 Jul 2024 21:32:03 +0530 Subject: [PATCH 01/37] chore: oauth sdk implementation (#804) --- twilio/rest/marketplace/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 twilio/rest/marketplace/__init__.py diff --git a/twilio/rest/marketplace/__init__.py b/twilio/rest/marketplace/__init__.py new file mode 100644 index 000000000..79b10ef6c --- /dev/null +++ b/twilio/rest/marketplace/__init__.py @@ -0,0 +1,10 @@ +from twilio.rest.marketplace.MarketplaceBase import MarketplaceBase + + +class Marketplace(MarketplaceBase): + def available_add_ons(self): + return self.v1.available_add_ons + + def installed_add_ons(self): + return self.v1.installed_add_ons + From 0cd40b58765fc669f8c6093343d08bda605577f3 Mon Sep 17 00:00:00 2001 From: Shubham Date: Fri, 2 Aug 2024 16:13:43 +0530 Subject: [PATCH 02/37] chore: update intersphinx_mapping (#807) * chore: test change * chore: update intersphinx_mapping * chore: fixed quotes * chore: updating docs link --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 405c2e99a..017b35809 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -203,4 +203,4 @@ # -- Options for intersphinx extension --------------------------------------- # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {"https://docs.python.org/": None} +intersphinx_mapping = {"python": ("https://docs.python.org/3", None)} From fdd6edce6310e9bc7dfed866037ec287e3708813 Mon Sep 17 00:00:00 2001 From: Manisha Singh Date: Mon, 12 Aug 2024 11:43:52 +0530 Subject: [PATCH 03/37] chore: preview iam removal (#808) --- twilio/rest/__init__.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/twilio/rest/__init__.py b/twilio/rest/__init__.py index 31d114a6c..2c1aa3b9d 100644 --- a/twilio/rest/__init__.py +++ b/twilio/rest/__init__.py @@ -23,7 +23,6 @@ from twilio.rest.events import Events from twilio.rest.flex_api import FlexApi from twilio.rest.frontline_api import FrontlineApi - from twilio.rest.preview_iam import PreviewIam from twilio.rest.insights import Insights from twilio.rest.intelligence import Intelligence from twilio.rest.ip_messaging import IpMessaging @@ -132,7 +131,6 @@ def __init__( self._events: Optional["Events"] = None self._flex_api: Optional["FlexApi"] = None self._frontline_api: Optional["FrontlineApi"] = None - self._preview_iam: Optional["PreviewIam"] = None self._insights: Optional["Insights"] = None self._intelligence: Optional["Intelligence"] = None self._ip_messaging: Optional["IpMessaging"] = None @@ -277,18 +275,6 @@ def frontline_api(self) -> "FrontlineApi": self._frontline_api = FrontlineApi(self) return self._frontline_api - @property - def preview_iam(self) -> "PreviewIam": - """ - Access the PreviewIam Twilio Domain - - :returns: PreviewIam Twilio Domain - """ - if self._preview_iam is None: - from twilio.rest.preview_iam import PreviewIam - - self._preview_iam = PreviewIam(self) - return self._preview_iam @property def insights(self) -> "Insights": From 2b875ec54e34cfa3bbebc6f439ca6ccfafb3fd75 Mon Sep 17 00:00:00 2001 From: Matthias Schoettle Date: Fri, 23 Aug 2024 12:57:58 -0400 Subject: [PATCH 04/37] chore: add license identifier to project metadata (#810) --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index c8673986e..0df04dde4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,6 +3,7 @@ universal = 1 [metadata] description-file = README.md +license = MIT [flake8] exclude = ./twilio/rest,./twilio/twiml,./tests/integration From f4e7765caccd0063c13eff105f611efa8488422e Mon Sep 17 00:00:00 2001 From: Twilio Date: Mon, 26 Aug 2024 11:18:54 +0000 Subject: [PATCH 05/37] [Librarian] Regenerated @ c8ce9820730ef3b2a48912311d45afb8c26b9ee7 2ee5b1fa49840dd67929ff69952e93618b74425b --- CHANGES.md | 43 + twilio/rest/__init__.py | 1 - .../api/v2010/account/call/transcription.py | 1204 +---------------- .../api/v2010/account/message/__init__.py | 4 +- .../{payload.py => payload/__init__.py} | 25 + .../recording/add_on_result/payload/data.py | 242 ++++ twilio/rest/content/v1/content/__init__.py | 116 +- .../content/v1/content/approval_create.py | 2 +- twilio/rest/flex_api/v2/flex_user.py | 164 ++- twilio/rest/insights/v1/call_summaries.py | 196 ++- twilio/rest/intelligence/v2/operator_type.py | 6 +- .../intelligence/v2/transcript/sentence.py | 30 +- twilio/rest/marketplace/__init__.py | 1 - twilio/rest/marketplace/v1/__init__.py | 8 + .../installed_add_on_usage.py | 30 +- .../marketplace/v1/module_data_management.py | 28 +- .../marketplace/v1/referral_conversion.py | 198 +++ twilio/rest/messaging/v1/external_campaign.py | 18 +- .../messaging/v1/service/channel_sender.py | 94 ++ twilio/rest/numbers/v1/__init__.py | 24 +- twilio/rest/numbers/v1/porting_port_in.py | 16 +- .../v1/porting_port_in_phone_number.py | 38 +- twilio/rest/numbers/v1/porting_portability.py | 22 +- .../v1/porting_webhook_configuration.py | 6 +- .../porting_webhook_configuration_delete.py | 6 +- ...=> porting_webhook_configuration_fetch.py} | 32 +- .../v1/signing_request_configuration.py | 243 +++- twilio/rest/numbers/v2/__init__.py | 8 + twilio/rest/numbers/v2/bundle_clone.py | 268 ++++ .../regulatory_compliance/bundle/__init__.py | 6 + .../taskrouter/v1/workspace/task/__init__.py | 6 +- .../rest/trusthub/v1/compliance_inquiries.py | 26 +- twilio/rest/verify/v2/service/__init__.py | 14 +- 33 files changed, 1767 insertions(+), 1358 deletions(-) rename twilio/rest/api/v2010/account/recording/add_on_result/{payload.py => payload/__init__.py} (96%) create mode 100644 twilio/rest/api/v2010/account/recording/add_on_result/payload/data.py create mode 100644 twilio/rest/marketplace/v1/referral_conversion.py rename twilio/rest/numbers/v1/{webhook.py => porting_webhook_configuration_fetch.py} (64%) create mode 100644 twilio/rest/numbers/v2/bundle_clone.py diff --git a/CHANGES.md b/CHANGES.md index a9e681101..2222dfc4d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,49 @@ twilio-python Changelog Here you can see the full list of changes between each twilio-python release. +[2024-08-26] Version 9.2.4 +-------------------------- +**Library - Chore** +- [PR #810](https://github.com/twilio/twilio-python/pull/810): add license identifier to project metadata. Thanks to [@mschoettle](https://github.com/mschoettle)! +- [PR #808](https://github.com/twilio/twilio-python/pull/808): preview iam removal. Thanks to [@manisha1997](https://github.com/manisha1997)! +- [PR #807](https://github.com/twilio/twilio-python/pull/807): update intersphinx_mapping. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! +- [PR #804](https://github.com/twilio/twilio-python/pull/804): add init file. Thanks to [@manisha1997](https://github.com/manisha1997)! + +**Api** +- Update documentation of `error_code` and `error_message` on the Message resource. +- Remove generic parameters from `transcription` resource +- Added public documentation for Payload Data retrieval API + +**Flex** +- Adding update Flex User api + +**Insights** +- Added 'branded', 'business_profile' and 'voice_integrity' fields in List Call Summary + +**Intelligence** +- Add `words` array information to the Sentences v2 entity. +- Add `X-Rate-Limit-Limit`, `X-Rate-Limit-Remaining`, and `X-Rate-Limit-Config` headers for Operator Results. +- Change the path parameter when fetching an `/OperatorType/{}` from `sid` to `string` to support searching by SID or by name +- Add `X-Rate-Limit-Limit`, `X-Rate-Limit-Remaining`, and `X-Rate-Limit-Config` headers for Transcript and Service endpoints. + +**Messaging** +- Adds two new channel senders api to add/remove channel senders to/from a messaging service +- Extend ERC api to accept an optional attribute in request body to indicate CNP migration for an ERC + +**Numbers** +- Modify visibility to public in bundle clone API +- Add `port_date` field to Port In Request and Port In Phone Numbers Fetch APIs +- Change properties docs for port in phone numbers api +- Add is_test body param to the Bundle Create API +- Change properties docs for port in api + +**Trusthub** +- Add new field in themeSetId in compliance_inquiry. + +**Verify** +- Update `custom_code_enabled` description on verification docs + + [2024-07-02] Version 9.2.3 -------------------------- **Intelligence** diff --git a/twilio/rest/__init__.py b/twilio/rest/__init__.py index 2c1aa3b9d..2dc0a4930 100644 --- a/twilio/rest/__init__.py +++ b/twilio/rest/__init__.py @@ -275,7 +275,6 @@ def frontline_api(self) -> "FrontlineApi": self._frontline_api = FrontlineApi(self) return self._frontline_api - @property def insights(self) -> "Insights": """ diff --git a/twilio/rest/api/v2010/account/call/transcription.py b/twilio/rest/api/v2010/account/call/transcription.py index 96554eaa0..d4aa87e3d 100644 --- a/twilio/rest/api/v2010/account/call/transcription.py +++ b/twilio/rest/api/v2010/account/call/transcription.py @@ -261,204 +261,6 @@ def create( speech_model: Union[str, object] = values.unset, hints: Union[str, object] = values.unset, enable_automatic_punctuation: Union[bool, object] = values.unset, - parameter1_name: Union[str, object] = values.unset, - parameter1_value: Union[str, object] = values.unset, - parameter2_name: Union[str, object] = values.unset, - parameter2_value: Union[str, object] = values.unset, - parameter3_name: Union[str, object] = values.unset, - parameter3_value: Union[str, object] = values.unset, - parameter4_name: Union[str, object] = values.unset, - parameter4_value: Union[str, object] = values.unset, - parameter5_name: Union[str, object] = values.unset, - parameter5_value: Union[str, object] = values.unset, - parameter6_name: Union[str, object] = values.unset, - parameter6_value: Union[str, object] = values.unset, - parameter7_name: Union[str, object] = values.unset, - parameter7_value: Union[str, object] = values.unset, - parameter8_name: Union[str, object] = values.unset, - parameter8_value: Union[str, object] = values.unset, - parameter9_name: Union[str, object] = values.unset, - parameter9_value: Union[str, object] = values.unset, - parameter10_name: Union[str, object] = values.unset, - parameter10_value: Union[str, object] = values.unset, - parameter11_name: Union[str, object] = values.unset, - parameter11_value: Union[str, object] = values.unset, - parameter12_name: Union[str, object] = values.unset, - parameter12_value: Union[str, object] = values.unset, - parameter13_name: Union[str, object] = values.unset, - parameter13_value: Union[str, object] = values.unset, - parameter14_name: Union[str, object] = values.unset, - parameter14_value: Union[str, object] = values.unset, - parameter15_name: Union[str, object] = values.unset, - parameter15_value: Union[str, object] = values.unset, - parameter16_name: Union[str, object] = values.unset, - parameter16_value: Union[str, object] = values.unset, - parameter17_name: Union[str, object] = values.unset, - parameter17_value: Union[str, object] = values.unset, - parameter18_name: Union[str, object] = values.unset, - parameter18_value: Union[str, object] = values.unset, - parameter19_name: Union[str, object] = values.unset, - parameter19_value: Union[str, object] = values.unset, - parameter20_name: Union[str, object] = values.unset, - parameter20_value: Union[str, object] = values.unset, - parameter21_name: Union[str, object] = values.unset, - parameter21_value: Union[str, object] = values.unset, - parameter22_name: Union[str, object] = values.unset, - parameter22_value: Union[str, object] = values.unset, - parameter23_name: Union[str, object] = values.unset, - parameter23_value: Union[str, object] = values.unset, - parameter24_name: Union[str, object] = values.unset, - parameter24_value: Union[str, object] = values.unset, - parameter25_name: Union[str, object] = values.unset, - parameter25_value: Union[str, object] = values.unset, - parameter26_name: Union[str, object] = values.unset, - parameter26_value: Union[str, object] = values.unset, - parameter27_name: Union[str, object] = values.unset, - parameter27_value: Union[str, object] = values.unset, - parameter28_name: Union[str, object] = values.unset, - parameter28_value: Union[str, object] = values.unset, - parameter29_name: Union[str, object] = values.unset, - parameter29_value: Union[str, object] = values.unset, - parameter30_name: Union[str, object] = values.unset, - parameter30_value: Union[str, object] = values.unset, - parameter31_name: Union[str, object] = values.unset, - parameter31_value: Union[str, object] = values.unset, - parameter32_name: Union[str, object] = values.unset, - parameter32_value: Union[str, object] = values.unset, - parameter33_name: Union[str, object] = values.unset, - parameter33_value: Union[str, object] = values.unset, - parameter34_name: Union[str, object] = values.unset, - parameter34_value: Union[str, object] = values.unset, - parameter35_name: Union[str, object] = values.unset, - parameter35_value: Union[str, object] = values.unset, - parameter36_name: Union[str, object] = values.unset, - parameter36_value: Union[str, object] = values.unset, - parameter37_name: Union[str, object] = values.unset, - parameter37_value: Union[str, object] = values.unset, - parameter38_name: Union[str, object] = values.unset, - parameter38_value: Union[str, object] = values.unset, - parameter39_name: Union[str, object] = values.unset, - parameter39_value: Union[str, object] = values.unset, - parameter40_name: Union[str, object] = values.unset, - parameter40_value: Union[str, object] = values.unset, - parameter41_name: Union[str, object] = values.unset, - parameter41_value: Union[str, object] = values.unset, - parameter42_name: Union[str, object] = values.unset, - parameter42_value: Union[str, object] = values.unset, - parameter43_name: Union[str, object] = values.unset, - parameter43_value: Union[str, object] = values.unset, - parameter44_name: Union[str, object] = values.unset, - parameter44_value: Union[str, object] = values.unset, - parameter45_name: Union[str, object] = values.unset, - parameter45_value: Union[str, object] = values.unset, - parameter46_name: Union[str, object] = values.unset, - parameter46_value: Union[str, object] = values.unset, - parameter47_name: Union[str, object] = values.unset, - parameter47_value: Union[str, object] = values.unset, - parameter48_name: Union[str, object] = values.unset, - parameter48_value: Union[str, object] = values.unset, - parameter49_name: Union[str, object] = values.unset, - parameter49_value: Union[str, object] = values.unset, - parameter50_name: Union[str, object] = values.unset, - parameter50_value: Union[str, object] = values.unset, - parameter51_name: Union[str, object] = values.unset, - parameter51_value: Union[str, object] = values.unset, - parameter52_name: Union[str, object] = values.unset, - parameter52_value: Union[str, object] = values.unset, - parameter53_name: Union[str, object] = values.unset, - parameter53_value: Union[str, object] = values.unset, - parameter54_name: Union[str, object] = values.unset, - parameter54_value: Union[str, object] = values.unset, - parameter55_name: Union[str, object] = values.unset, - parameter55_value: Union[str, object] = values.unset, - parameter56_name: Union[str, object] = values.unset, - parameter56_value: Union[str, object] = values.unset, - parameter57_name: Union[str, object] = values.unset, - parameter57_value: Union[str, object] = values.unset, - parameter58_name: Union[str, object] = values.unset, - parameter58_value: Union[str, object] = values.unset, - parameter59_name: Union[str, object] = values.unset, - parameter59_value: Union[str, object] = values.unset, - parameter60_name: Union[str, object] = values.unset, - parameter60_value: Union[str, object] = values.unset, - parameter61_name: Union[str, object] = values.unset, - parameter61_value: Union[str, object] = values.unset, - parameter62_name: Union[str, object] = values.unset, - parameter62_value: Union[str, object] = values.unset, - parameter63_name: Union[str, object] = values.unset, - parameter63_value: Union[str, object] = values.unset, - parameter64_name: Union[str, object] = values.unset, - parameter64_value: Union[str, object] = values.unset, - parameter65_name: Union[str, object] = values.unset, - parameter65_value: Union[str, object] = values.unset, - parameter66_name: Union[str, object] = values.unset, - parameter66_value: Union[str, object] = values.unset, - parameter67_name: Union[str, object] = values.unset, - parameter67_value: Union[str, object] = values.unset, - parameter68_name: Union[str, object] = values.unset, - parameter68_value: Union[str, object] = values.unset, - parameter69_name: Union[str, object] = values.unset, - parameter69_value: Union[str, object] = values.unset, - parameter70_name: Union[str, object] = values.unset, - parameter70_value: Union[str, object] = values.unset, - parameter71_name: Union[str, object] = values.unset, - parameter71_value: Union[str, object] = values.unset, - parameter72_name: Union[str, object] = values.unset, - parameter72_value: Union[str, object] = values.unset, - parameter73_name: Union[str, object] = values.unset, - parameter73_value: Union[str, object] = values.unset, - parameter74_name: Union[str, object] = values.unset, - parameter74_value: Union[str, object] = values.unset, - parameter75_name: Union[str, object] = values.unset, - parameter75_value: Union[str, object] = values.unset, - parameter76_name: Union[str, object] = values.unset, - parameter76_value: Union[str, object] = values.unset, - parameter77_name: Union[str, object] = values.unset, - parameter77_value: Union[str, object] = values.unset, - parameter78_name: Union[str, object] = values.unset, - parameter78_value: Union[str, object] = values.unset, - parameter79_name: Union[str, object] = values.unset, - parameter79_value: Union[str, object] = values.unset, - parameter80_name: Union[str, object] = values.unset, - parameter80_value: Union[str, object] = values.unset, - parameter81_name: Union[str, object] = values.unset, - parameter81_value: Union[str, object] = values.unset, - parameter82_name: Union[str, object] = values.unset, - parameter82_value: Union[str, object] = values.unset, - parameter83_name: Union[str, object] = values.unset, - parameter83_value: Union[str, object] = values.unset, - parameter84_name: Union[str, object] = values.unset, - parameter84_value: Union[str, object] = values.unset, - parameter85_name: Union[str, object] = values.unset, - parameter85_value: Union[str, object] = values.unset, - parameter86_name: Union[str, object] = values.unset, - parameter86_value: Union[str, object] = values.unset, - parameter87_name: Union[str, object] = values.unset, - parameter87_value: Union[str, object] = values.unset, - parameter88_name: Union[str, object] = values.unset, - parameter88_value: Union[str, object] = values.unset, - parameter89_name: Union[str, object] = values.unset, - parameter89_value: Union[str, object] = values.unset, - parameter90_name: Union[str, object] = values.unset, - parameter90_value: Union[str, object] = values.unset, - parameter91_name: Union[str, object] = values.unset, - parameter91_value: Union[str, object] = values.unset, - parameter92_name: Union[str, object] = values.unset, - parameter92_value: Union[str, object] = values.unset, - parameter93_name: Union[str, object] = values.unset, - parameter93_value: Union[str, object] = values.unset, - parameter94_name: Union[str, object] = values.unset, - parameter94_value: Union[str, object] = values.unset, - parameter95_name: Union[str, object] = values.unset, - parameter95_value: Union[str, object] = values.unset, - parameter96_name: Union[str, object] = values.unset, - parameter96_value: Union[str, object] = values.unset, - parameter97_name: Union[str, object] = values.unset, - parameter97_value: Union[str, object] = values.unset, - parameter98_name: Union[str, object] = values.unset, - parameter98_value: Union[str, object] = values.unset, - parameter99_name: Union[str, object] = values.unset, - parameter99_value: Union[str, object] = values.unset, ) -> TranscriptionInstance: """ Create the TranscriptionInstance @@ -469,211 +271,13 @@ def create( :param status_callback_method: The http method for the status_callback (one of GET, POST). :param inbound_track_label: Friendly name given to the Inbound Track :param outbound_track_label: Friendly name given to the Outbound Track - :param partial_results: Indicates if partial results are going to be send to the customer + :param partial_results: Indicates if partial results are going to be sent to the customer :param language_code: Language code used by the transcription engine, specified in [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) format - :param transcription_engine: Definition of the transcription engine to be used, between those supported by Twilio + :param transcription_engine: Definition of the transcription engine to be used, among those supported by Twilio :param profanity_filter: indicates if the server will attempt to filter out profanities, replacing all but the initial character in each filtered word with asterisks - :param speech_model: Recognition model used by the transcription engine, between those supported by the provider + :param speech_model: Recognition model used by the transcription engine, among those supported by the provider :param hints: A Phrase contains words and phrase \\\"hints\\\" so that the speech recognition engine is more likely to recognize them. - :param enable_automatic_punctuation: The provider will adds punctuation to recognition result hypotheses - :param parameter1_name: Parameter name - :param parameter1_value: Parameter value - :param parameter2_name: Parameter name - :param parameter2_value: Parameter value - :param parameter3_name: Parameter name - :param parameter3_value: Parameter value - :param parameter4_name: Parameter name - :param parameter4_value: Parameter value - :param parameter5_name: Parameter name - :param parameter5_value: Parameter value - :param parameter6_name: Parameter name - :param parameter6_value: Parameter value - :param parameter7_name: Parameter name - :param parameter7_value: Parameter value - :param parameter8_name: Parameter name - :param parameter8_value: Parameter value - :param parameter9_name: Parameter name - :param parameter9_value: Parameter value - :param parameter10_name: Parameter name - :param parameter10_value: Parameter value - :param parameter11_name: Parameter name - :param parameter11_value: Parameter value - :param parameter12_name: Parameter name - :param parameter12_value: Parameter value - :param parameter13_name: Parameter name - :param parameter13_value: Parameter value - :param parameter14_name: Parameter name - :param parameter14_value: Parameter value - :param parameter15_name: Parameter name - :param parameter15_value: Parameter value - :param parameter16_name: Parameter name - :param parameter16_value: Parameter value - :param parameter17_name: Parameter name - :param parameter17_value: Parameter value - :param parameter18_name: Parameter name - :param parameter18_value: Parameter value - :param parameter19_name: Parameter name - :param parameter19_value: Parameter value - :param parameter20_name: Parameter name - :param parameter20_value: Parameter value - :param parameter21_name: Parameter name - :param parameter21_value: Parameter value - :param parameter22_name: Parameter name - :param parameter22_value: Parameter value - :param parameter23_name: Parameter name - :param parameter23_value: Parameter value - :param parameter24_name: Parameter name - :param parameter24_value: Parameter value - :param parameter25_name: Parameter name - :param parameter25_value: Parameter value - :param parameter26_name: Parameter name - :param parameter26_value: Parameter value - :param parameter27_name: Parameter name - :param parameter27_value: Parameter value - :param parameter28_name: Parameter name - :param parameter28_value: Parameter value - :param parameter29_name: Parameter name - :param parameter29_value: Parameter value - :param parameter30_name: Parameter name - :param parameter30_value: Parameter value - :param parameter31_name: Parameter name - :param parameter31_value: Parameter value - :param parameter32_name: Parameter name - :param parameter32_value: Parameter value - :param parameter33_name: Parameter name - :param parameter33_value: Parameter value - :param parameter34_name: Parameter name - :param parameter34_value: Parameter value - :param parameter35_name: Parameter name - :param parameter35_value: Parameter value - :param parameter36_name: Parameter name - :param parameter36_value: Parameter value - :param parameter37_name: Parameter name - :param parameter37_value: Parameter value - :param parameter38_name: Parameter name - :param parameter38_value: Parameter value - :param parameter39_name: Parameter name - :param parameter39_value: Parameter value - :param parameter40_name: Parameter name - :param parameter40_value: Parameter value - :param parameter41_name: Parameter name - :param parameter41_value: Parameter value - :param parameter42_name: Parameter name - :param parameter42_value: Parameter value - :param parameter43_name: Parameter name - :param parameter43_value: Parameter value - :param parameter44_name: Parameter name - :param parameter44_value: Parameter value - :param parameter45_name: Parameter name - :param parameter45_value: Parameter value - :param parameter46_name: Parameter name - :param parameter46_value: Parameter value - :param parameter47_name: Parameter name - :param parameter47_value: Parameter value - :param parameter48_name: Parameter name - :param parameter48_value: Parameter value - :param parameter49_name: Parameter name - :param parameter49_value: Parameter value - :param parameter50_name: Parameter name - :param parameter50_value: Parameter value - :param parameter51_name: Parameter name - :param parameter51_value: Parameter value - :param parameter52_name: Parameter name - :param parameter52_value: Parameter value - :param parameter53_name: Parameter name - :param parameter53_value: Parameter value - :param parameter54_name: Parameter name - :param parameter54_value: Parameter value - :param parameter55_name: Parameter name - :param parameter55_value: Parameter value - :param parameter56_name: Parameter name - :param parameter56_value: Parameter value - :param parameter57_name: Parameter name - :param parameter57_value: Parameter value - :param parameter58_name: Parameter name - :param parameter58_value: Parameter value - :param parameter59_name: Parameter name - :param parameter59_value: Parameter value - :param parameter60_name: Parameter name - :param parameter60_value: Parameter value - :param parameter61_name: Parameter name - :param parameter61_value: Parameter value - :param parameter62_name: Parameter name - :param parameter62_value: Parameter value - :param parameter63_name: Parameter name - :param parameter63_value: Parameter value - :param parameter64_name: Parameter name - :param parameter64_value: Parameter value - :param parameter65_name: Parameter name - :param parameter65_value: Parameter value - :param parameter66_name: Parameter name - :param parameter66_value: Parameter value - :param parameter67_name: Parameter name - :param parameter67_value: Parameter value - :param parameter68_name: Parameter name - :param parameter68_value: Parameter value - :param parameter69_name: Parameter name - :param parameter69_value: Parameter value - :param parameter70_name: Parameter name - :param parameter70_value: Parameter value - :param parameter71_name: Parameter name - :param parameter71_value: Parameter value - :param parameter72_name: Parameter name - :param parameter72_value: Parameter value - :param parameter73_name: Parameter name - :param parameter73_value: Parameter value - :param parameter74_name: Parameter name - :param parameter74_value: Parameter value - :param parameter75_name: Parameter name - :param parameter75_value: Parameter value - :param parameter76_name: Parameter name - :param parameter76_value: Parameter value - :param parameter77_name: Parameter name - :param parameter77_value: Parameter value - :param parameter78_name: Parameter name - :param parameter78_value: Parameter value - :param parameter79_name: Parameter name - :param parameter79_value: Parameter value - :param parameter80_name: Parameter name - :param parameter80_value: Parameter value - :param parameter81_name: Parameter name - :param parameter81_value: Parameter value - :param parameter82_name: Parameter name - :param parameter82_value: Parameter value - :param parameter83_name: Parameter name - :param parameter83_value: Parameter value - :param parameter84_name: Parameter name - :param parameter84_value: Parameter value - :param parameter85_name: Parameter name - :param parameter85_value: Parameter value - :param parameter86_name: Parameter name - :param parameter86_value: Parameter value - :param parameter87_name: Parameter name - :param parameter87_value: Parameter value - :param parameter88_name: Parameter name - :param parameter88_value: Parameter value - :param parameter89_name: Parameter name - :param parameter89_value: Parameter value - :param parameter90_name: Parameter name - :param parameter90_value: Parameter value - :param parameter91_name: Parameter name - :param parameter91_value: Parameter value - :param parameter92_name: Parameter name - :param parameter92_value: Parameter value - :param parameter93_name: Parameter name - :param parameter93_value: Parameter value - :param parameter94_name: Parameter name - :param parameter94_value: Parameter value - :param parameter95_name: Parameter name - :param parameter95_value: Parameter value - :param parameter96_name: Parameter name - :param parameter96_value: Parameter value - :param parameter97_name: Parameter name - :param parameter97_value: Parameter value - :param parameter98_name: Parameter name - :param parameter98_value: Parameter value - :param parameter99_name: Parameter name - :param parameter99_value: Parameter value + :param enable_automatic_punctuation: The provider will add punctuation to recognition result :returns: The created TranscriptionInstance """ @@ -695,204 +299,6 @@ def create( "EnableAutomaticPunctuation": serialize.boolean_to_string( enable_automatic_punctuation ), - "Parameter1.Name": parameter1_name, - "Parameter1.Value": parameter1_value, - "Parameter2.Name": parameter2_name, - "Parameter2.Value": parameter2_value, - "Parameter3.Name": parameter3_name, - "Parameter3.Value": parameter3_value, - "Parameter4.Name": parameter4_name, - "Parameter4.Value": parameter4_value, - "Parameter5.Name": parameter5_name, - "Parameter5.Value": parameter5_value, - "Parameter6.Name": parameter6_name, - "Parameter6.Value": parameter6_value, - "Parameter7.Name": parameter7_name, - "Parameter7.Value": parameter7_value, - "Parameter8.Name": parameter8_name, - "Parameter8.Value": parameter8_value, - "Parameter9.Name": parameter9_name, - "Parameter9.Value": parameter9_value, - "Parameter10.Name": parameter10_name, - "Parameter10.Value": parameter10_value, - "Parameter11.Name": parameter11_name, - "Parameter11.Value": parameter11_value, - "Parameter12.Name": parameter12_name, - "Parameter12.Value": parameter12_value, - "Parameter13.Name": parameter13_name, - "Parameter13.Value": parameter13_value, - "Parameter14.Name": parameter14_name, - "Parameter14.Value": parameter14_value, - "Parameter15.Name": parameter15_name, - "Parameter15.Value": parameter15_value, - "Parameter16.Name": parameter16_name, - "Parameter16.Value": parameter16_value, - "Parameter17.Name": parameter17_name, - "Parameter17.Value": parameter17_value, - "Parameter18.Name": parameter18_name, - "Parameter18.Value": parameter18_value, - "Parameter19.Name": parameter19_name, - "Parameter19.Value": parameter19_value, - "Parameter20.Name": parameter20_name, - "Parameter20.Value": parameter20_value, - "Parameter21.Name": parameter21_name, - "Parameter21.Value": parameter21_value, - "Parameter22.Name": parameter22_name, - "Parameter22.Value": parameter22_value, - "Parameter23.Name": parameter23_name, - "Parameter23.Value": parameter23_value, - "Parameter24.Name": parameter24_name, - "Parameter24.Value": parameter24_value, - "Parameter25.Name": parameter25_name, - "Parameter25.Value": parameter25_value, - "Parameter26.Name": parameter26_name, - "Parameter26.Value": parameter26_value, - "Parameter27.Name": parameter27_name, - "Parameter27.Value": parameter27_value, - "Parameter28.Name": parameter28_name, - "Parameter28.Value": parameter28_value, - "Parameter29.Name": parameter29_name, - "Parameter29.Value": parameter29_value, - "Parameter30.Name": parameter30_name, - "Parameter30.Value": parameter30_value, - "Parameter31.Name": parameter31_name, - "Parameter31.Value": parameter31_value, - "Parameter32.Name": parameter32_name, - "Parameter32.Value": parameter32_value, - "Parameter33.Name": parameter33_name, - "Parameter33.Value": parameter33_value, - "Parameter34.Name": parameter34_name, - "Parameter34.Value": parameter34_value, - "Parameter35.Name": parameter35_name, - "Parameter35.Value": parameter35_value, - "Parameter36.Name": parameter36_name, - "Parameter36.Value": parameter36_value, - "Parameter37.Name": parameter37_name, - "Parameter37.Value": parameter37_value, - "Parameter38.Name": parameter38_name, - "Parameter38.Value": parameter38_value, - "Parameter39.Name": parameter39_name, - "Parameter39.Value": parameter39_value, - "Parameter40.Name": parameter40_name, - "Parameter40.Value": parameter40_value, - "Parameter41.Name": parameter41_name, - "Parameter41.Value": parameter41_value, - "Parameter42.Name": parameter42_name, - "Parameter42.Value": parameter42_value, - "Parameter43.Name": parameter43_name, - "Parameter43.Value": parameter43_value, - "Parameter44.Name": parameter44_name, - "Parameter44.Value": parameter44_value, - "Parameter45.Name": parameter45_name, - "Parameter45.Value": parameter45_value, - "Parameter46.Name": parameter46_name, - "Parameter46.Value": parameter46_value, - "Parameter47.Name": parameter47_name, - "Parameter47.Value": parameter47_value, - "Parameter48.Name": parameter48_name, - "Parameter48.Value": parameter48_value, - "Parameter49.Name": parameter49_name, - "Parameter49.Value": parameter49_value, - "Parameter50.Name": parameter50_name, - "Parameter50.Value": parameter50_value, - "Parameter51.Name": parameter51_name, - "Parameter51.Value": parameter51_value, - "Parameter52.Name": parameter52_name, - "Parameter52.Value": parameter52_value, - "Parameter53.Name": parameter53_name, - "Parameter53.Value": parameter53_value, - "Parameter54.Name": parameter54_name, - "Parameter54.Value": parameter54_value, - "Parameter55.Name": parameter55_name, - "Parameter55.Value": parameter55_value, - "Parameter56.Name": parameter56_name, - "Parameter56.Value": parameter56_value, - "Parameter57.Name": parameter57_name, - "Parameter57.Value": parameter57_value, - "Parameter58.Name": parameter58_name, - "Parameter58.Value": parameter58_value, - "Parameter59.Name": parameter59_name, - "Parameter59.Value": parameter59_value, - "Parameter60.Name": parameter60_name, - "Parameter60.Value": parameter60_value, - "Parameter61.Name": parameter61_name, - "Parameter61.Value": parameter61_value, - "Parameter62.Name": parameter62_name, - "Parameter62.Value": parameter62_value, - "Parameter63.Name": parameter63_name, - "Parameter63.Value": parameter63_value, - "Parameter64.Name": parameter64_name, - "Parameter64.Value": parameter64_value, - "Parameter65.Name": parameter65_name, - "Parameter65.Value": parameter65_value, - "Parameter66.Name": parameter66_name, - "Parameter66.Value": parameter66_value, - "Parameter67.Name": parameter67_name, - "Parameter67.Value": parameter67_value, - "Parameter68.Name": parameter68_name, - "Parameter68.Value": parameter68_value, - "Parameter69.Name": parameter69_name, - "Parameter69.Value": parameter69_value, - "Parameter70.Name": parameter70_name, - "Parameter70.Value": parameter70_value, - "Parameter71.Name": parameter71_name, - "Parameter71.Value": parameter71_value, - "Parameter72.Name": parameter72_name, - "Parameter72.Value": parameter72_value, - "Parameter73.Name": parameter73_name, - "Parameter73.Value": parameter73_value, - "Parameter74.Name": parameter74_name, - "Parameter74.Value": parameter74_value, - "Parameter75.Name": parameter75_name, - "Parameter75.Value": parameter75_value, - "Parameter76.Name": parameter76_name, - "Parameter76.Value": parameter76_value, - "Parameter77.Name": parameter77_name, - "Parameter77.Value": parameter77_value, - "Parameter78.Name": parameter78_name, - "Parameter78.Value": parameter78_value, - "Parameter79.Name": parameter79_name, - "Parameter79.Value": parameter79_value, - "Parameter80.Name": parameter80_name, - "Parameter80.Value": parameter80_value, - "Parameter81.Name": parameter81_name, - "Parameter81.Value": parameter81_value, - "Parameter82.Name": parameter82_name, - "Parameter82.Value": parameter82_value, - "Parameter83.Name": parameter83_name, - "Parameter83.Value": parameter83_value, - "Parameter84.Name": parameter84_name, - "Parameter84.Value": parameter84_value, - "Parameter85.Name": parameter85_name, - "Parameter85.Value": parameter85_value, - "Parameter86.Name": parameter86_name, - "Parameter86.Value": parameter86_value, - "Parameter87.Name": parameter87_name, - "Parameter87.Value": parameter87_value, - "Parameter88.Name": parameter88_name, - "Parameter88.Value": parameter88_value, - "Parameter89.Name": parameter89_name, - "Parameter89.Value": parameter89_value, - "Parameter90.Name": parameter90_name, - "Parameter90.Value": parameter90_value, - "Parameter91.Name": parameter91_name, - "Parameter91.Value": parameter91_value, - "Parameter92.Name": parameter92_name, - "Parameter92.Value": parameter92_value, - "Parameter93.Name": parameter93_name, - "Parameter93.Value": parameter93_value, - "Parameter94.Name": parameter94_name, - "Parameter94.Value": parameter94_value, - "Parameter95.Name": parameter95_name, - "Parameter95.Value": parameter95_value, - "Parameter96.Name": parameter96_name, - "Parameter96.Value": parameter96_value, - "Parameter97.Name": parameter97_name, - "Parameter97.Value": parameter97_value, - "Parameter98.Name": parameter98_name, - "Parameter98.Value": parameter98_value, - "Parameter99.Name": parameter99_name, - "Parameter99.Value": parameter99_value, } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) @@ -923,204 +329,6 @@ async def create_async( speech_model: Union[str, object] = values.unset, hints: Union[str, object] = values.unset, enable_automatic_punctuation: Union[bool, object] = values.unset, - parameter1_name: Union[str, object] = values.unset, - parameter1_value: Union[str, object] = values.unset, - parameter2_name: Union[str, object] = values.unset, - parameter2_value: Union[str, object] = values.unset, - parameter3_name: Union[str, object] = values.unset, - parameter3_value: Union[str, object] = values.unset, - parameter4_name: Union[str, object] = values.unset, - parameter4_value: Union[str, object] = values.unset, - parameter5_name: Union[str, object] = values.unset, - parameter5_value: Union[str, object] = values.unset, - parameter6_name: Union[str, object] = values.unset, - parameter6_value: Union[str, object] = values.unset, - parameter7_name: Union[str, object] = values.unset, - parameter7_value: Union[str, object] = values.unset, - parameter8_name: Union[str, object] = values.unset, - parameter8_value: Union[str, object] = values.unset, - parameter9_name: Union[str, object] = values.unset, - parameter9_value: Union[str, object] = values.unset, - parameter10_name: Union[str, object] = values.unset, - parameter10_value: Union[str, object] = values.unset, - parameter11_name: Union[str, object] = values.unset, - parameter11_value: Union[str, object] = values.unset, - parameter12_name: Union[str, object] = values.unset, - parameter12_value: Union[str, object] = values.unset, - parameter13_name: Union[str, object] = values.unset, - parameter13_value: Union[str, object] = values.unset, - parameter14_name: Union[str, object] = values.unset, - parameter14_value: Union[str, object] = values.unset, - parameter15_name: Union[str, object] = values.unset, - parameter15_value: Union[str, object] = values.unset, - parameter16_name: Union[str, object] = values.unset, - parameter16_value: Union[str, object] = values.unset, - parameter17_name: Union[str, object] = values.unset, - parameter17_value: Union[str, object] = values.unset, - parameter18_name: Union[str, object] = values.unset, - parameter18_value: Union[str, object] = values.unset, - parameter19_name: Union[str, object] = values.unset, - parameter19_value: Union[str, object] = values.unset, - parameter20_name: Union[str, object] = values.unset, - parameter20_value: Union[str, object] = values.unset, - parameter21_name: Union[str, object] = values.unset, - parameter21_value: Union[str, object] = values.unset, - parameter22_name: Union[str, object] = values.unset, - parameter22_value: Union[str, object] = values.unset, - parameter23_name: Union[str, object] = values.unset, - parameter23_value: Union[str, object] = values.unset, - parameter24_name: Union[str, object] = values.unset, - parameter24_value: Union[str, object] = values.unset, - parameter25_name: Union[str, object] = values.unset, - parameter25_value: Union[str, object] = values.unset, - parameter26_name: Union[str, object] = values.unset, - parameter26_value: Union[str, object] = values.unset, - parameter27_name: Union[str, object] = values.unset, - parameter27_value: Union[str, object] = values.unset, - parameter28_name: Union[str, object] = values.unset, - parameter28_value: Union[str, object] = values.unset, - parameter29_name: Union[str, object] = values.unset, - parameter29_value: Union[str, object] = values.unset, - parameter30_name: Union[str, object] = values.unset, - parameter30_value: Union[str, object] = values.unset, - parameter31_name: Union[str, object] = values.unset, - parameter31_value: Union[str, object] = values.unset, - parameter32_name: Union[str, object] = values.unset, - parameter32_value: Union[str, object] = values.unset, - parameter33_name: Union[str, object] = values.unset, - parameter33_value: Union[str, object] = values.unset, - parameter34_name: Union[str, object] = values.unset, - parameter34_value: Union[str, object] = values.unset, - parameter35_name: Union[str, object] = values.unset, - parameter35_value: Union[str, object] = values.unset, - parameter36_name: Union[str, object] = values.unset, - parameter36_value: Union[str, object] = values.unset, - parameter37_name: Union[str, object] = values.unset, - parameter37_value: Union[str, object] = values.unset, - parameter38_name: Union[str, object] = values.unset, - parameter38_value: Union[str, object] = values.unset, - parameter39_name: Union[str, object] = values.unset, - parameter39_value: Union[str, object] = values.unset, - parameter40_name: Union[str, object] = values.unset, - parameter40_value: Union[str, object] = values.unset, - parameter41_name: Union[str, object] = values.unset, - parameter41_value: Union[str, object] = values.unset, - parameter42_name: Union[str, object] = values.unset, - parameter42_value: Union[str, object] = values.unset, - parameter43_name: Union[str, object] = values.unset, - parameter43_value: Union[str, object] = values.unset, - parameter44_name: Union[str, object] = values.unset, - parameter44_value: Union[str, object] = values.unset, - parameter45_name: Union[str, object] = values.unset, - parameter45_value: Union[str, object] = values.unset, - parameter46_name: Union[str, object] = values.unset, - parameter46_value: Union[str, object] = values.unset, - parameter47_name: Union[str, object] = values.unset, - parameter47_value: Union[str, object] = values.unset, - parameter48_name: Union[str, object] = values.unset, - parameter48_value: Union[str, object] = values.unset, - parameter49_name: Union[str, object] = values.unset, - parameter49_value: Union[str, object] = values.unset, - parameter50_name: Union[str, object] = values.unset, - parameter50_value: Union[str, object] = values.unset, - parameter51_name: Union[str, object] = values.unset, - parameter51_value: Union[str, object] = values.unset, - parameter52_name: Union[str, object] = values.unset, - parameter52_value: Union[str, object] = values.unset, - parameter53_name: Union[str, object] = values.unset, - parameter53_value: Union[str, object] = values.unset, - parameter54_name: Union[str, object] = values.unset, - parameter54_value: Union[str, object] = values.unset, - parameter55_name: Union[str, object] = values.unset, - parameter55_value: Union[str, object] = values.unset, - parameter56_name: Union[str, object] = values.unset, - parameter56_value: Union[str, object] = values.unset, - parameter57_name: Union[str, object] = values.unset, - parameter57_value: Union[str, object] = values.unset, - parameter58_name: Union[str, object] = values.unset, - parameter58_value: Union[str, object] = values.unset, - parameter59_name: Union[str, object] = values.unset, - parameter59_value: Union[str, object] = values.unset, - parameter60_name: Union[str, object] = values.unset, - parameter60_value: Union[str, object] = values.unset, - parameter61_name: Union[str, object] = values.unset, - parameter61_value: Union[str, object] = values.unset, - parameter62_name: Union[str, object] = values.unset, - parameter62_value: Union[str, object] = values.unset, - parameter63_name: Union[str, object] = values.unset, - parameter63_value: Union[str, object] = values.unset, - parameter64_name: Union[str, object] = values.unset, - parameter64_value: Union[str, object] = values.unset, - parameter65_name: Union[str, object] = values.unset, - parameter65_value: Union[str, object] = values.unset, - parameter66_name: Union[str, object] = values.unset, - parameter66_value: Union[str, object] = values.unset, - parameter67_name: Union[str, object] = values.unset, - parameter67_value: Union[str, object] = values.unset, - parameter68_name: Union[str, object] = values.unset, - parameter68_value: Union[str, object] = values.unset, - parameter69_name: Union[str, object] = values.unset, - parameter69_value: Union[str, object] = values.unset, - parameter70_name: Union[str, object] = values.unset, - parameter70_value: Union[str, object] = values.unset, - parameter71_name: Union[str, object] = values.unset, - parameter71_value: Union[str, object] = values.unset, - parameter72_name: Union[str, object] = values.unset, - parameter72_value: Union[str, object] = values.unset, - parameter73_name: Union[str, object] = values.unset, - parameter73_value: Union[str, object] = values.unset, - parameter74_name: Union[str, object] = values.unset, - parameter74_value: Union[str, object] = values.unset, - parameter75_name: Union[str, object] = values.unset, - parameter75_value: Union[str, object] = values.unset, - parameter76_name: Union[str, object] = values.unset, - parameter76_value: Union[str, object] = values.unset, - parameter77_name: Union[str, object] = values.unset, - parameter77_value: Union[str, object] = values.unset, - parameter78_name: Union[str, object] = values.unset, - parameter78_value: Union[str, object] = values.unset, - parameter79_name: Union[str, object] = values.unset, - parameter79_value: Union[str, object] = values.unset, - parameter80_name: Union[str, object] = values.unset, - parameter80_value: Union[str, object] = values.unset, - parameter81_name: Union[str, object] = values.unset, - parameter81_value: Union[str, object] = values.unset, - parameter82_name: Union[str, object] = values.unset, - parameter82_value: Union[str, object] = values.unset, - parameter83_name: Union[str, object] = values.unset, - parameter83_value: Union[str, object] = values.unset, - parameter84_name: Union[str, object] = values.unset, - parameter84_value: Union[str, object] = values.unset, - parameter85_name: Union[str, object] = values.unset, - parameter85_value: Union[str, object] = values.unset, - parameter86_name: Union[str, object] = values.unset, - parameter86_value: Union[str, object] = values.unset, - parameter87_name: Union[str, object] = values.unset, - parameter87_value: Union[str, object] = values.unset, - parameter88_name: Union[str, object] = values.unset, - parameter88_value: Union[str, object] = values.unset, - parameter89_name: Union[str, object] = values.unset, - parameter89_value: Union[str, object] = values.unset, - parameter90_name: Union[str, object] = values.unset, - parameter90_value: Union[str, object] = values.unset, - parameter91_name: Union[str, object] = values.unset, - parameter91_value: Union[str, object] = values.unset, - parameter92_name: Union[str, object] = values.unset, - parameter92_value: Union[str, object] = values.unset, - parameter93_name: Union[str, object] = values.unset, - parameter93_value: Union[str, object] = values.unset, - parameter94_name: Union[str, object] = values.unset, - parameter94_value: Union[str, object] = values.unset, - parameter95_name: Union[str, object] = values.unset, - parameter95_value: Union[str, object] = values.unset, - parameter96_name: Union[str, object] = values.unset, - parameter96_value: Union[str, object] = values.unset, - parameter97_name: Union[str, object] = values.unset, - parameter97_value: Union[str, object] = values.unset, - parameter98_name: Union[str, object] = values.unset, - parameter98_value: Union[str, object] = values.unset, - parameter99_name: Union[str, object] = values.unset, - parameter99_value: Union[str, object] = values.unset, ) -> TranscriptionInstance: """ Asynchronously create the TranscriptionInstance @@ -1131,211 +339,13 @@ async def create_async( :param status_callback_method: The http method for the status_callback (one of GET, POST). :param inbound_track_label: Friendly name given to the Inbound Track :param outbound_track_label: Friendly name given to the Outbound Track - :param partial_results: Indicates if partial results are going to be send to the customer + :param partial_results: Indicates if partial results are going to be sent to the customer :param language_code: Language code used by the transcription engine, specified in [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) format - :param transcription_engine: Definition of the transcription engine to be used, between those supported by Twilio + :param transcription_engine: Definition of the transcription engine to be used, among those supported by Twilio :param profanity_filter: indicates if the server will attempt to filter out profanities, replacing all but the initial character in each filtered word with asterisks - :param speech_model: Recognition model used by the transcription engine, between those supported by the provider + :param speech_model: Recognition model used by the transcription engine, among those supported by the provider :param hints: A Phrase contains words and phrase \\\"hints\\\" so that the speech recognition engine is more likely to recognize them. - :param enable_automatic_punctuation: The provider will adds punctuation to recognition result hypotheses - :param parameter1_name: Parameter name - :param parameter1_value: Parameter value - :param parameter2_name: Parameter name - :param parameter2_value: Parameter value - :param parameter3_name: Parameter name - :param parameter3_value: Parameter value - :param parameter4_name: Parameter name - :param parameter4_value: Parameter value - :param parameter5_name: Parameter name - :param parameter5_value: Parameter value - :param parameter6_name: Parameter name - :param parameter6_value: Parameter value - :param parameter7_name: Parameter name - :param parameter7_value: Parameter value - :param parameter8_name: Parameter name - :param parameter8_value: Parameter value - :param parameter9_name: Parameter name - :param parameter9_value: Parameter value - :param parameter10_name: Parameter name - :param parameter10_value: Parameter value - :param parameter11_name: Parameter name - :param parameter11_value: Parameter value - :param parameter12_name: Parameter name - :param parameter12_value: Parameter value - :param parameter13_name: Parameter name - :param parameter13_value: Parameter value - :param parameter14_name: Parameter name - :param parameter14_value: Parameter value - :param parameter15_name: Parameter name - :param parameter15_value: Parameter value - :param parameter16_name: Parameter name - :param parameter16_value: Parameter value - :param parameter17_name: Parameter name - :param parameter17_value: Parameter value - :param parameter18_name: Parameter name - :param parameter18_value: Parameter value - :param parameter19_name: Parameter name - :param parameter19_value: Parameter value - :param parameter20_name: Parameter name - :param parameter20_value: Parameter value - :param parameter21_name: Parameter name - :param parameter21_value: Parameter value - :param parameter22_name: Parameter name - :param parameter22_value: Parameter value - :param parameter23_name: Parameter name - :param parameter23_value: Parameter value - :param parameter24_name: Parameter name - :param parameter24_value: Parameter value - :param parameter25_name: Parameter name - :param parameter25_value: Parameter value - :param parameter26_name: Parameter name - :param parameter26_value: Parameter value - :param parameter27_name: Parameter name - :param parameter27_value: Parameter value - :param parameter28_name: Parameter name - :param parameter28_value: Parameter value - :param parameter29_name: Parameter name - :param parameter29_value: Parameter value - :param parameter30_name: Parameter name - :param parameter30_value: Parameter value - :param parameter31_name: Parameter name - :param parameter31_value: Parameter value - :param parameter32_name: Parameter name - :param parameter32_value: Parameter value - :param parameter33_name: Parameter name - :param parameter33_value: Parameter value - :param parameter34_name: Parameter name - :param parameter34_value: Parameter value - :param parameter35_name: Parameter name - :param parameter35_value: Parameter value - :param parameter36_name: Parameter name - :param parameter36_value: Parameter value - :param parameter37_name: Parameter name - :param parameter37_value: Parameter value - :param parameter38_name: Parameter name - :param parameter38_value: Parameter value - :param parameter39_name: Parameter name - :param parameter39_value: Parameter value - :param parameter40_name: Parameter name - :param parameter40_value: Parameter value - :param parameter41_name: Parameter name - :param parameter41_value: Parameter value - :param parameter42_name: Parameter name - :param parameter42_value: Parameter value - :param parameter43_name: Parameter name - :param parameter43_value: Parameter value - :param parameter44_name: Parameter name - :param parameter44_value: Parameter value - :param parameter45_name: Parameter name - :param parameter45_value: Parameter value - :param parameter46_name: Parameter name - :param parameter46_value: Parameter value - :param parameter47_name: Parameter name - :param parameter47_value: Parameter value - :param parameter48_name: Parameter name - :param parameter48_value: Parameter value - :param parameter49_name: Parameter name - :param parameter49_value: Parameter value - :param parameter50_name: Parameter name - :param parameter50_value: Parameter value - :param parameter51_name: Parameter name - :param parameter51_value: Parameter value - :param parameter52_name: Parameter name - :param parameter52_value: Parameter value - :param parameter53_name: Parameter name - :param parameter53_value: Parameter value - :param parameter54_name: Parameter name - :param parameter54_value: Parameter value - :param parameter55_name: Parameter name - :param parameter55_value: Parameter value - :param parameter56_name: Parameter name - :param parameter56_value: Parameter value - :param parameter57_name: Parameter name - :param parameter57_value: Parameter value - :param parameter58_name: Parameter name - :param parameter58_value: Parameter value - :param parameter59_name: Parameter name - :param parameter59_value: Parameter value - :param parameter60_name: Parameter name - :param parameter60_value: Parameter value - :param parameter61_name: Parameter name - :param parameter61_value: Parameter value - :param parameter62_name: Parameter name - :param parameter62_value: Parameter value - :param parameter63_name: Parameter name - :param parameter63_value: Parameter value - :param parameter64_name: Parameter name - :param parameter64_value: Parameter value - :param parameter65_name: Parameter name - :param parameter65_value: Parameter value - :param parameter66_name: Parameter name - :param parameter66_value: Parameter value - :param parameter67_name: Parameter name - :param parameter67_value: Parameter value - :param parameter68_name: Parameter name - :param parameter68_value: Parameter value - :param parameter69_name: Parameter name - :param parameter69_value: Parameter value - :param parameter70_name: Parameter name - :param parameter70_value: Parameter value - :param parameter71_name: Parameter name - :param parameter71_value: Parameter value - :param parameter72_name: Parameter name - :param parameter72_value: Parameter value - :param parameter73_name: Parameter name - :param parameter73_value: Parameter value - :param parameter74_name: Parameter name - :param parameter74_value: Parameter value - :param parameter75_name: Parameter name - :param parameter75_value: Parameter value - :param parameter76_name: Parameter name - :param parameter76_value: Parameter value - :param parameter77_name: Parameter name - :param parameter77_value: Parameter value - :param parameter78_name: Parameter name - :param parameter78_value: Parameter value - :param parameter79_name: Parameter name - :param parameter79_value: Parameter value - :param parameter80_name: Parameter name - :param parameter80_value: Parameter value - :param parameter81_name: Parameter name - :param parameter81_value: Parameter value - :param parameter82_name: Parameter name - :param parameter82_value: Parameter value - :param parameter83_name: Parameter name - :param parameter83_value: Parameter value - :param parameter84_name: Parameter name - :param parameter84_value: Parameter value - :param parameter85_name: Parameter name - :param parameter85_value: Parameter value - :param parameter86_name: Parameter name - :param parameter86_value: Parameter value - :param parameter87_name: Parameter name - :param parameter87_value: Parameter value - :param parameter88_name: Parameter name - :param parameter88_value: Parameter value - :param parameter89_name: Parameter name - :param parameter89_value: Parameter value - :param parameter90_name: Parameter name - :param parameter90_value: Parameter value - :param parameter91_name: Parameter name - :param parameter91_value: Parameter value - :param parameter92_name: Parameter name - :param parameter92_value: Parameter value - :param parameter93_name: Parameter name - :param parameter93_value: Parameter value - :param parameter94_name: Parameter name - :param parameter94_value: Parameter value - :param parameter95_name: Parameter name - :param parameter95_value: Parameter value - :param parameter96_name: Parameter name - :param parameter96_value: Parameter value - :param parameter97_name: Parameter name - :param parameter97_value: Parameter value - :param parameter98_name: Parameter name - :param parameter98_value: Parameter value - :param parameter99_name: Parameter name - :param parameter99_value: Parameter value + :param enable_automatic_punctuation: The provider will add punctuation to recognition result :returns: The created TranscriptionInstance """ @@ -1357,204 +367,6 @@ async def create_async( "EnableAutomaticPunctuation": serialize.boolean_to_string( enable_automatic_punctuation ), - "Parameter1.Name": parameter1_name, - "Parameter1.Value": parameter1_value, - "Parameter2.Name": parameter2_name, - "Parameter2.Value": parameter2_value, - "Parameter3.Name": parameter3_name, - "Parameter3.Value": parameter3_value, - "Parameter4.Name": parameter4_name, - "Parameter4.Value": parameter4_value, - "Parameter5.Name": parameter5_name, - "Parameter5.Value": parameter5_value, - "Parameter6.Name": parameter6_name, - "Parameter6.Value": parameter6_value, - "Parameter7.Name": parameter7_name, - "Parameter7.Value": parameter7_value, - "Parameter8.Name": parameter8_name, - "Parameter8.Value": parameter8_value, - "Parameter9.Name": parameter9_name, - "Parameter9.Value": parameter9_value, - "Parameter10.Name": parameter10_name, - "Parameter10.Value": parameter10_value, - "Parameter11.Name": parameter11_name, - "Parameter11.Value": parameter11_value, - "Parameter12.Name": parameter12_name, - "Parameter12.Value": parameter12_value, - "Parameter13.Name": parameter13_name, - "Parameter13.Value": parameter13_value, - "Parameter14.Name": parameter14_name, - "Parameter14.Value": parameter14_value, - "Parameter15.Name": parameter15_name, - "Parameter15.Value": parameter15_value, - "Parameter16.Name": parameter16_name, - "Parameter16.Value": parameter16_value, - "Parameter17.Name": parameter17_name, - "Parameter17.Value": parameter17_value, - "Parameter18.Name": parameter18_name, - "Parameter18.Value": parameter18_value, - "Parameter19.Name": parameter19_name, - "Parameter19.Value": parameter19_value, - "Parameter20.Name": parameter20_name, - "Parameter20.Value": parameter20_value, - "Parameter21.Name": parameter21_name, - "Parameter21.Value": parameter21_value, - "Parameter22.Name": parameter22_name, - "Parameter22.Value": parameter22_value, - "Parameter23.Name": parameter23_name, - "Parameter23.Value": parameter23_value, - "Parameter24.Name": parameter24_name, - "Parameter24.Value": parameter24_value, - "Parameter25.Name": parameter25_name, - "Parameter25.Value": parameter25_value, - "Parameter26.Name": parameter26_name, - "Parameter26.Value": parameter26_value, - "Parameter27.Name": parameter27_name, - "Parameter27.Value": parameter27_value, - "Parameter28.Name": parameter28_name, - "Parameter28.Value": parameter28_value, - "Parameter29.Name": parameter29_name, - "Parameter29.Value": parameter29_value, - "Parameter30.Name": parameter30_name, - "Parameter30.Value": parameter30_value, - "Parameter31.Name": parameter31_name, - "Parameter31.Value": parameter31_value, - "Parameter32.Name": parameter32_name, - "Parameter32.Value": parameter32_value, - "Parameter33.Name": parameter33_name, - "Parameter33.Value": parameter33_value, - "Parameter34.Name": parameter34_name, - "Parameter34.Value": parameter34_value, - "Parameter35.Name": parameter35_name, - "Parameter35.Value": parameter35_value, - "Parameter36.Name": parameter36_name, - "Parameter36.Value": parameter36_value, - "Parameter37.Name": parameter37_name, - "Parameter37.Value": parameter37_value, - "Parameter38.Name": parameter38_name, - "Parameter38.Value": parameter38_value, - "Parameter39.Name": parameter39_name, - "Parameter39.Value": parameter39_value, - "Parameter40.Name": parameter40_name, - "Parameter40.Value": parameter40_value, - "Parameter41.Name": parameter41_name, - "Parameter41.Value": parameter41_value, - "Parameter42.Name": parameter42_name, - "Parameter42.Value": parameter42_value, - "Parameter43.Name": parameter43_name, - "Parameter43.Value": parameter43_value, - "Parameter44.Name": parameter44_name, - "Parameter44.Value": parameter44_value, - "Parameter45.Name": parameter45_name, - "Parameter45.Value": parameter45_value, - "Parameter46.Name": parameter46_name, - "Parameter46.Value": parameter46_value, - "Parameter47.Name": parameter47_name, - "Parameter47.Value": parameter47_value, - "Parameter48.Name": parameter48_name, - "Parameter48.Value": parameter48_value, - "Parameter49.Name": parameter49_name, - "Parameter49.Value": parameter49_value, - "Parameter50.Name": parameter50_name, - "Parameter50.Value": parameter50_value, - "Parameter51.Name": parameter51_name, - "Parameter51.Value": parameter51_value, - "Parameter52.Name": parameter52_name, - "Parameter52.Value": parameter52_value, - "Parameter53.Name": parameter53_name, - "Parameter53.Value": parameter53_value, - "Parameter54.Name": parameter54_name, - "Parameter54.Value": parameter54_value, - "Parameter55.Name": parameter55_name, - "Parameter55.Value": parameter55_value, - "Parameter56.Name": parameter56_name, - "Parameter56.Value": parameter56_value, - "Parameter57.Name": parameter57_name, - "Parameter57.Value": parameter57_value, - "Parameter58.Name": parameter58_name, - "Parameter58.Value": parameter58_value, - "Parameter59.Name": parameter59_name, - "Parameter59.Value": parameter59_value, - "Parameter60.Name": parameter60_name, - "Parameter60.Value": parameter60_value, - "Parameter61.Name": parameter61_name, - "Parameter61.Value": parameter61_value, - "Parameter62.Name": parameter62_name, - "Parameter62.Value": parameter62_value, - "Parameter63.Name": parameter63_name, - "Parameter63.Value": parameter63_value, - "Parameter64.Name": parameter64_name, - "Parameter64.Value": parameter64_value, - "Parameter65.Name": parameter65_name, - "Parameter65.Value": parameter65_value, - "Parameter66.Name": parameter66_name, - "Parameter66.Value": parameter66_value, - "Parameter67.Name": parameter67_name, - "Parameter67.Value": parameter67_value, - "Parameter68.Name": parameter68_name, - "Parameter68.Value": parameter68_value, - "Parameter69.Name": parameter69_name, - "Parameter69.Value": parameter69_value, - "Parameter70.Name": parameter70_name, - "Parameter70.Value": parameter70_value, - "Parameter71.Name": parameter71_name, - "Parameter71.Value": parameter71_value, - "Parameter72.Name": parameter72_name, - "Parameter72.Value": parameter72_value, - "Parameter73.Name": parameter73_name, - "Parameter73.Value": parameter73_value, - "Parameter74.Name": parameter74_name, - "Parameter74.Value": parameter74_value, - "Parameter75.Name": parameter75_name, - "Parameter75.Value": parameter75_value, - "Parameter76.Name": parameter76_name, - "Parameter76.Value": parameter76_value, - "Parameter77.Name": parameter77_name, - "Parameter77.Value": parameter77_value, - "Parameter78.Name": parameter78_name, - "Parameter78.Value": parameter78_value, - "Parameter79.Name": parameter79_name, - "Parameter79.Value": parameter79_value, - "Parameter80.Name": parameter80_name, - "Parameter80.Value": parameter80_value, - "Parameter81.Name": parameter81_name, - "Parameter81.Value": parameter81_value, - "Parameter82.Name": parameter82_name, - "Parameter82.Value": parameter82_value, - "Parameter83.Name": parameter83_name, - "Parameter83.Value": parameter83_value, - "Parameter84.Name": parameter84_name, - "Parameter84.Value": parameter84_value, - "Parameter85.Name": parameter85_name, - "Parameter85.Value": parameter85_value, - "Parameter86.Name": parameter86_name, - "Parameter86.Value": parameter86_value, - "Parameter87.Name": parameter87_name, - "Parameter87.Value": parameter87_value, - "Parameter88.Name": parameter88_name, - "Parameter88.Value": parameter88_value, - "Parameter89.Name": parameter89_name, - "Parameter89.Value": parameter89_value, - "Parameter90.Name": parameter90_name, - "Parameter90.Value": parameter90_value, - "Parameter91.Name": parameter91_name, - "Parameter91.Value": parameter91_value, - "Parameter92.Name": parameter92_name, - "Parameter92.Value": parameter92_value, - "Parameter93.Name": parameter93_name, - "Parameter93.Value": parameter93_value, - "Parameter94.Name": parameter94_name, - "Parameter94.Value": parameter94_value, - "Parameter95.Name": parameter95_name, - "Parameter95.Value": parameter95_value, - "Parameter96.Name": parameter96_name, - "Parameter96.Value": parameter96_value, - "Parameter97.Name": parameter97_name, - "Parameter97.Value": parameter97_value, - "Parameter98.Name": parameter98_name, - "Parameter98.Value": parameter98_value, - "Parameter99.Name": parameter99_name, - "Parameter99.Value": parameter99_value, } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) diff --git a/twilio/rest/api/v2010/account/message/__init__.py b/twilio/rest/api/v2010/account/message/__init__.py index 7eb11d388..1b6d3aea8 100644 --- a/twilio/rest/api/v2010/account/message/__init__.py +++ b/twilio/rest/api/v2010/account/message/__init__.py @@ -73,7 +73,7 @@ class UpdateStatus(object): :ivar to: The recipient's phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format) or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g. `whatsapp:+15552229999`) :ivar date_updated: The [RFC 2822](https://datatracker.ietf.org/doc/html/rfc2822#section-3.3) timestamp (in GMT) of when the Message resource was last updated :ivar price: The amount billed for the message in the currency specified by `price_unit`. The `price` is populated after the message has been sent/received, and may not be immediately availalble. View the [Pricing page](https://www.twilio.com/en-us/pricing) for more details. - :ivar error_message: The description of the `error_code` if the Message `status` is `failed` or `undelivered`. If no error was encountered, the value is `null`. + :ivar error_message: The description of the `error_code` if the Message `status` is `failed` or `undelivered`. If no error was encountered, the value is `null`. The value returned in this field for a specific error cause is subject to change as Twilio improves errors. Users should not use the `error_code` and `error_message` fields programmatically. :ivar uri: The URI of the Message resource, relative to `https://api.twilio.com`. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) associated with the Message resource :ivar num_media: The number of media files associated with the Message resource. @@ -82,7 +82,7 @@ class UpdateStatus(object): :ivar sid: The unique, Twilio-provided string that identifies the Message resource. :ivar date_sent: The [RFC 2822](https://datatracker.ietf.org/doc/html/rfc2822#section-3.3) timestamp (in GMT) of when the Message was sent. For an outgoing message, this is when Twilio sent the message. For an incoming message, this is when Twilio sent the HTTP request to your incoming message webhook URL. :ivar date_created: The [RFC 2822](https://datatracker.ietf.org/doc/html/rfc2822#section-3.3) timestamp (in GMT) of when the Message resource was created - :ivar error_code: The [error code](https://www.twilio.com/docs/api/errors) returned if the Message `status` is `failed` or `undelivered`. If no error was encountered, the value is `null`. + :ivar error_code: The [error code](https://www.twilio.com/docs/api/errors) returned if the Message `status` is `failed` or `undelivered`. If no error was encountered, the value is `null`. The value returned in this field for a specific error cause is subject to change as Twilio improves errors. Users should not use the `error_code` and `error_message` fields programmatically. :ivar price_unit: The currency in which `price` is measured, in [ISO 4127](https://www.iso.org/iso/home/standards/currency_codes.htm) format (e.g. `usd`, `eur`, `jpy`). :ivar api_version: The API version used to process the Message :ivar subresource_uris: A list of related resources identified by their URIs relative to `https://api.twilio.com` diff --git a/twilio/rest/api/v2010/account/recording/add_on_result/payload.py b/twilio/rest/api/v2010/account/recording/add_on_result/payload/__init__.py similarity index 96% rename from twilio/rest/api/v2010/account/recording/add_on_result/payload.py rename to twilio/rest/api/v2010/account/recording/add_on_result/payload/__init__.py index 1dc26e1d7..9008f6a68 100644 --- a/twilio/rest/api/v2010/account/recording/add_on_result/payload.py +++ b/twilio/rest/api/v2010/account/recording/add_on_result/payload/__init__.py @@ -20,6 +20,7 @@ from twilio.base.list_resource import ListResource from twilio.base.version import Version from twilio.base.page import Page +from twilio.rest.api.v2010.account.recording.add_on_result.payload.data import DataList class PayloadInstance(InstanceResource): @@ -130,6 +131,13 @@ async def fetch_async(self) -> "PayloadInstance": """ return await self._proxy.fetch_async() + @property + def data(self) -> DataList: + """ + Access the data + """ + return self._proxy.data + def __repr__(self) -> str: """ Provide a friendly representation @@ -172,6 +180,8 @@ def __init__( **self._solution ) + self._data: Optional[DataList] = None + def delete(self) -> bool: """ Deletes the PayloadInstance @@ -240,6 +250,21 @@ async def fetch_async(self) -> PayloadInstance: sid=self._solution["sid"], ) + @property + def data(self) -> DataList: + """ + Access the data + """ + if self._data is None: + self._data = DataList( + self._version, + self._solution["account_sid"], + self._solution["reference_sid"], + self._solution["add_on_result_sid"], + self._solution["sid"], + ) + return self._data + def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/api/v2010/account/recording/add_on_result/payload/data.py b/twilio/rest/api/v2010/account/recording/add_on_result/payload/data.py new file mode 100644 index 000000000..1cc931a69 --- /dev/null +++ b/twilio/rest/api/v2010/account/recording/add_on_result/payload/data.py @@ -0,0 +1,242 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Api + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, Optional +from twilio.base.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 DataInstance(InstanceResource): + """ + :ivar redirect_to: The URL to redirect to to get the data returned by the AddOn that was previously stored. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + account_sid: str, + reference_sid: str, + add_on_result_sid: str, + payload_sid: str, + ): + super().__init__(version) + + self.redirect_to: Optional[str] = payload.get("redirect_to") + + self._solution = { + "account_sid": account_sid, + "reference_sid": reference_sid, + "add_on_result_sid": add_on_result_sid, + "payload_sid": payload_sid, + } + self._context: Optional[DataContext] = None + + @property + def _proxy(self) -> "DataContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: DataContext for this DataInstance + """ + if self._context is None: + self._context = DataContext( + self._version, + account_sid=self._solution["account_sid"], + reference_sid=self._solution["reference_sid"], + add_on_result_sid=self._solution["add_on_result_sid"], + payload_sid=self._solution["payload_sid"], + ) + return self._context + + def fetch(self) -> "DataInstance": + """ + Fetch the DataInstance + + + :returns: The fetched DataInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "DataInstance": + """ + Asynchronous coroutine to fetch the DataInstance + + + :returns: The fetched DataInstance + """ + 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 DataContext(InstanceContext): + + def __init__( + self, + version: Version, + account_sid: str, + reference_sid: str, + add_on_result_sid: str, + payload_sid: str, + ): + """ + Initialize the DataContext + + :param version: Version that contains the resource + :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording AddOnResult Payload resource to fetch. + :param reference_sid: The SID of the recording to which the AddOnResult resource that contains the payload to fetch belongs. + :param add_on_result_sid: The SID of the AddOnResult to which the payload to fetch belongs. + :param payload_sid: The Twilio-provided string that uniquely identifies the Recording AddOnResult Payload resource to fetch. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "account_sid": account_sid, + "reference_sid": reference_sid, + "add_on_result_sid": add_on_result_sid, + "payload_sid": payload_sid, + } + self._uri = "/Accounts/{account_sid}/Recordings/{reference_sid}/AddOnResults/{add_on_result_sid}/Payloads/{payload_sid}/Data.json".format( + **self._solution + ) + + def fetch(self) -> DataInstance: + """ + Fetch the DataInstance + + + :returns: The fetched DataInstance + """ + + payload = self._version.fetch( + method="GET", + uri=self._uri, + ) + + return DataInstance( + self._version, + payload, + account_sid=self._solution["account_sid"], + reference_sid=self._solution["reference_sid"], + add_on_result_sid=self._solution["add_on_result_sid"], + payload_sid=self._solution["payload_sid"], + ) + + async def fetch_async(self) -> DataInstance: + """ + Asynchronous coroutine to fetch the DataInstance + + + :returns: The fetched DataInstance + """ + + payload = await self._version.fetch_async( + method="GET", + uri=self._uri, + ) + + return DataInstance( + self._version, + payload, + account_sid=self._solution["account_sid"], + reference_sid=self._solution["reference_sid"], + add_on_result_sid=self._solution["add_on_result_sid"], + payload_sid=self._solution["payload_sid"], + ) + + 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 DataList(ListResource): + + def __init__( + self, + version: Version, + account_sid: str, + reference_sid: str, + add_on_result_sid: str, + payload_sid: str, + ): + """ + Initialize the DataList + + :param version: Version that contains the resource + :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording AddOnResult Payload resource to fetch. + :param reference_sid: The SID of the recording to which the AddOnResult resource that contains the payload to fetch belongs. + :param add_on_result_sid: The SID of the AddOnResult to which the payload to fetch belongs. + :param payload_sid: The Twilio-provided string that uniquely identifies the Recording AddOnResult Payload resource to fetch. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "account_sid": account_sid, + "reference_sid": reference_sid, + "add_on_result_sid": add_on_result_sid, + "payload_sid": payload_sid, + } + + def get(self) -> DataContext: + """ + Constructs a DataContext + + """ + return DataContext( + self._version, + account_sid=self._solution["account_sid"], + reference_sid=self._solution["reference_sid"], + add_on_result_sid=self._solution["add_on_result_sid"], + payload_sid=self._solution["payload_sid"], + ) + + def __call__(self) -> DataContext: + """ + Constructs a DataContext + + """ + return DataContext( + self._version, + account_sid=self._solution["account_sid"], + reference_sid=self._solution["reference_sid"], + add_on_result_sid=self._solution["add_on_result_sid"], + payload_sid=self._solution["payload_sid"], + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/content/v1/content/__init__.py b/twilio/rest/content/v1/content/__init__.py index 0fcbd1c19..f2dec1276 100644 --- a/twilio/rest/content/v1/content/__init__.py +++ b/twilio/rest/content/v1/content/__init__.py @@ -38,6 +38,11 @@ class CardActionType(object): PHONE_NUMBER = "PHONE_NUMBER" QUICK_REPLY = "QUICK_REPLY" + class CarouselActionType(object): + URL = "URL" + PHONE_NUMBER = "PHONE_NUMBER" + QUICK_REPLY = "QUICK_REPLY" + class QuickReplyActionType(object): QUICK_REPLY = "QUICK_REPLY" @@ -297,7 +302,7 @@ class AuthenticationAction(object): :ivar copy_code_text: """ - def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + def __init__(self, payload: Dict[str, Any]): self.type: Optional["ContentInstance.AuthenticationActionType"] = ( payload.get("type") @@ -319,7 +324,7 @@ class CallToActionAction(object): :ivar id: """ - def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + def __init__(self, payload: Dict[str, Any]): self.type: Optional["ContentInstance.CallToActionActionType"] = payload.get( "type" @@ -347,7 +352,7 @@ class CardAction(object): :ivar id: """ - def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + def __init__(self, payload: Dict[str, Any]): self.type: Optional["ContentInstance.CardActionType"] = payload.get("type") self.title: Optional[str] = payload.get("title") @@ -364,6 +369,59 @@ def to_dict(self): "id": self.id, } + class CarouselAction(object): + """ + :ivar type: + :ivar title: + :ivar url: + :ivar phone: + :ivar id: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.type: Optional["ContentInstance.CarouselActionType"] = payload.get( + "type" + ) + self.title: Optional[str] = payload.get("title") + self.url: Optional[str] = payload.get("url") + self.phone: Optional[str] = payload.get("phone") + self.id: Optional[str] = payload.get("id") + + def to_dict(self): + return { + "type": self.type, + "title": self.title, + "url": self.url, + "phone": self.phone, + "id": self.id, + } + + class CarouselCard(object): + """ + :ivar title: + :ivar body: + :ivar media: + :ivar actions: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.title: Optional[str] = payload.get("title") + self.body: Optional[str] = payload.get("body") + self.media: Optional[str] = payload.get("media") + self.actions: Optional[List[ContentList.CarouselAction]] = payload.get( + "actions" + ) + + def to_dict(self): + return { + "title": self.title, + "body": self.body, + "media": self.media, + "actions": [actions.to_dict() for actions in self.actions], + } + class CatalogItem(object): """ :ivar id: @@ -374,7 +432,7 @@ class CatalogItem(object): :ivar description: """ - def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + def __init__(self, payload: Dict[str, Any]): self.id: Optional[str] = payload.get("id") self.section_title: Optional[str] = payload.get("section_title") @@ -401,7 +459,7 @@ class ContentCreateRequest(object): :ivar types: """ - def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + def __init__(self, payload: Dict[str, Any]): self.friendly_name: Optional[str] = payload.get("friendly_name") self.variables: Optional[dict[str, str]] = payload.get("variables") @@ -423,7 +481,7 @@ class ListItem(object): :ivar description: """ - def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + def __init__(self, payload: Dict[str, Any]): self.id: Optional[str] = payload.get("id") self.item: Optional[str] = payload.get("item") @@ -443,7 +501,7 @@ class QuickReplyAction(object): :ivar id: """ - def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + def __init__(self, payload: Dict[str, Any]): self.type: Optional["ContentInstance.QuickReplyActionType"] = payload.get( "type" @@ -464,7 +522,7 @@ class TwilioCallToAction(object): :ivar actions: """ - def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") self.actions: Optional[List[ContentList.CallToActionAction]] = payload.get( @@ -485,7 +543,7 @@ class TwilioCard(object): :ivar actions: """ - def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + def __init__(self, payload: Dict[str, Any]): self.title: Optional[str] = payload.get("title") self.subtitle: Optional[str] = payload.get("subtitle") @@ -502,6 +560,23 @@ def to_dict(self): "actions": [actions.to_dict() for actions in self.actions], } + class TwilioCarousel(object): + """ + :ivar body: + :ivar cards: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.body: Optional[str] = payload.get("body") + self.cards: Optional[List[ContentList.CarouselCard]] = payload.get("cards") + + def to_dict(self): + return { + "body": self.body, + "cards": [cards.to_dict() for cards in self.cards], + } + class TwilioCatalog(object): """ :ivar title: @@ -512,7 +587,7 @@ class TwilioCatalog(object): :ivar dynamic_items: """ - def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + def __init__(self, payload: Dict[str, Any]): self.title: Optional[str] = payload.get("title") self.body: Optional[str] = payload.get("body") @@ -538,7 +613,7 @@ class TwilioListPicker(object): :ivar items: """ - def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") self.button: Optional[str] = payload.get("button") @@ -558,7 +633,7 @@ class TwilioLocation(object): :ivar label: """ - def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + def __init__(self, payload: Dict[str, Any]): self.latitude: Optional[float] = payload.get("latitude") self.longitude: Optional[float] = payload.get("longitude") @@ -577,7 +652,7 @@ class TwilioMedia(object): :ivar media: """ - def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") self.media: Optional[List[str]] = payload.get("media") @@ -594,7 +669,7 @@ class TwilioQuickReply(object): :ivar actions: """ - def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") self.actions: Optional[List[ContentList.QuickReplyAction]] = payload.get( @@ -612,7 +687,7 @@ class TwilioText(object): :ivar body: """ - def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") @@ -631,11 +706,12 @@ class Types(object): :ivar twilio_quick_reply: :ivar twilio_card: :ivar twilio_catalog: + :ivar twilio_carousel: :ivar whatsapp_card: :ivar whatsapp_authentication: """ - def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + def __init__(self, payload: Dict[str, Any]): self.twilio_text: Optional[ContentList.TwilioText] = payload.get( "twilio_text" @@ -661,6 +737,9 @@ def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): self.twilio_catalog: Optional[ContentList.TwilioCatalog] = payload.get( "twilio_catalog" ) + self.twilio_carousel: Optional[ContentList.TwilioCarousel] = payload.get( + "twilio_carousel" + ) self.whatsapp_card: Optional[ContentList.WhatsappCard] = payload.get( "whatsapp_card" ) @@ -678,6 +757,7 @@ def to_dict(self): "twilio_quick_reply": self.twilio_quick_reply.to_dict(), "twilio_card": self.twilio_card.to_dict(), "twilio_catalog": self.twilio_catalog.to_dict(), + "twilio_carousel": self.twilio_carousel.to_dict(), "whatsapp_card": self.whatsapp_card.to_dict(), "whatsapp_authentication": self.whatsapp_authentication.to_dict(), } @@ -689,7 +769,7 @@ class WhatsappAuthentication(object): :ivar actions: """ - def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + def __init__(self, payload: Dict[str, Any]): self.add_security_recommendation: Optional[bool] = payload.get( "add_security_recommendation" @@ -717,7 +797,7 @@ class WhatsappCard(object): :ivar actions: """ - def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + def __init__(self, payload: Dict[str, Any]): self.body: Optional[str] = payload.get("body") self.footer: Optional[str] = payload.get("footer") diff --git a/twilio/rest/content/v1/content/approval_create.py b/twilio/rest/content/v1/content/approval_create.py index 6e28052e0..4f22f2df1 100644 --- a/twilio/rest/content/v1/content/approval_create.py +++ b/twilio/rest/content/v1/content/approval_create.py @@ -64,7 +64,7 @@ class ContentApprovalRequest(object): :ivar category: A WhatsApp recognized template category. """ - def __init__(self, payload: Dict[str, Any], content_sid: str): + def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.category: Optional[str] = payload.get("category") diff --git a/twilio/rest/flex_api/v2/flex_user.py b/twilio/rest/flex_api/v2/flex_user.py index 1acc75a8a..0f5b1571f 100644 --- a/twilio/rest/flex_api/v2/flex_user.py +++ b/twilio/rest/flex_api/v2/flex_user.py @@ -13,8 +13,8 @@ """ from datetime import datetime -from typing import Any, Dict, Optional -from twilio.base import deserialize +from typing import Any, Dict, List, Optional, Union +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 @@ -35,6 +35,8 @@ class FlexUserInstance(InstanceResource): :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. :ivar updated_date: The date that this user was updated, given in ISO 8601 format. :ivar version: The current version of the user. @@ -62,6 +64,8 @@ def __init__( 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( payload.get("created_date") ) @@ -111,6 +115,66 @@ async def fetch_async(self) -> "FlexUserInstance": """ return await self._proxy.fetch_async() + 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, + ) + def __repr__(self) -> str: """ Provide a friendly representation @@ -129,7 +193,7 @@ def __init__(self, version: Version, instance_sid: str, flex_user_sid: str): :param version: Version that contains the resource :param instance_sid: The unique ID created by Twilio to identify a Flex instance. - :param flex_user_sid: The unique id for the flex user to be retrieved. + :param flex_user_sid: The unique id for the flex user. """ super().__init__(version) @@ -182,6 +246,96 @@ async def fetch_async(self) -> FlexUserInstance: flex_user_sid=self._solution["flex_user_sid"], ) + 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 + """ + data = values.of( + { + "FirstName": first_name, + "LastName": last_name, + "Email": email, + "FriendlyName": friendly_name, + "UserSid": user_sid, + "Locale": locale, + } + ) + + payload = self._version.update( + method="POST", + uri=self._uri, + data=data, + ) + + return FlexUserInstance( + self._version, + payload, + instance_sid=self._solution["instance_sid"], + flex_user_sid=self._solution["flex_user_sid"], + ) + + 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 + """ + data = values.of( + { + "FirstName": first_name, + "LastName": last_name, + "Email": email, + "FriendlyName": friendly_name, + "UserSid": user_sid, + "Locale": locale, + } + ) + + payload = await self._version.update_async( + method="POST", + uri=self._uri, + data=data, + ) + + return FlexUserInstance( + self._version, + payload, + instance_sid=self._solution["instance_sid"], + flex_user_sid=self._solution["flex_user_sid"], + ) + def __repr__(self) -> str: """ Provide a friendly representation @@ -208,7 +362,7 @@ def get(self, instance_sid: str, flex_user_sid: str) -> FlexUserContext: Constructs a FlexUserContext :param instance_sid: The unique ID created by Twilio to identify a Flex instance. - :param flex_user_sid: The unique id for the flex user to be retrieved. + :param flex_user_sid: The unique id for the flex user. """ return FlexUserContext( self._version, instance_sid=instance_sid, flex_user_sid=flex_user_sid @@ -219,7 +373,7 @@ def __call__(self, instance_sid: str, flex_user_sid: str) -> FlexUserContext: Constructs a FlexUserContext :param instance_sid: The unique ID created by Twilio to identify a Flex instance. - :param flex_user_sid: The unique id for the flex user to be retrieved. + :param flex_user_sid: The unique id for the flex user. """ return FlexUserContext( self._version, instance_sid=instance_sid, flex_user_sid=flex_user_sid diff --git a/twilio/rest/insights/v1/call_summaries.py b/twilio/rest/insights/v1/call_summaries.py index f68744eef..35cf41aa4 100644 --- a/twilio/rest/insights/v1/call_summaries.py +++ b/twilio/rest/insights/v1/call_summaries.py @@ -182,7 +182,6 @@ def stream( to_carrier: Union[str, object] = values.unset, from_country_code: Union[str, object] = values.unset, to_country_code: Union[str, object] = values.unset, - branded: Union[bool, object] = values.unset, verified_caller: Union[bool, object] = values.unset, has_tag: Union[bool, object] = values.unset, start_time: Union[str, object] = values.unset, @@ -202,6 +201,15 @@ def stream( quality_issue_annotation: Union[str, object] = values.unset, spam_annotation: Union[bool, object] = values.unset, call_score_annotation: Union[str, object] = values.unset, + branded_enabled: Union[bool, object] = values.unset, + voice_integrity_enabled: Union[bool, object] = values.unset, + branded_bundle_sid: Union[str, object] = values.unset, + voice_integrity_bundle_sid: Union[str, object] = values.unset, + voice_integrity_use_case: Union[str, object] = values.unset, + business_profile_identity: Union[str, object] = values.unset, + business_profile_industry: Union[str, object] = values.unset, + business_profile_bundle_sid: Union[str, object] = values.unset, + business_profile_type: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> Iterator[CallSummariesInstance]: @@ -217,8 +225,7 @@ def stream( :param str to_carrier: A destination carrier. :param str from_country_code: A source country code based on phone number in From. :param str to_country_code: A destination country code. Based on phone number in To. - :param bool branded: A boolean flag indicating whether or not the calls were branded using Twilio Branded Calls. - :param bool verified_caller: A boolean flag indicating whether or not the caller was verified using SHAKEN/STIR. + :param bool verified_caller: A boolean flag indicating whether or not the caller was verified using SHAKEN/STIR.One of 'true' or 'false'. :param bool has_tag: A boolean flag indicating the presence of one or more [Voice Insights Call Tags](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-tags). :param str start_time: A Start time of the calls. xm (x minutes), xh (x hours), xd (x days), 1w, 30m, 3d, 4w or datetime-ISO. Defaults to 4h. :param str end_time: An End Time of the calls. xm (x minutes), xh (x hours), xd (x days), 1w, 30m, 3d, 4w or datetime-ISO. Defaults to 0m. @@ -235,6 +242,15 @@ def stream( :param str quality_issue_annotation: A subjective Quality Issue with the calls. One of `no_quality_issue`, `low_volume`, `choppy_robotic`, `echo`, `dtmf`, `latency`, `owa`, `static_noise`. :param bool spam_annotation: A boolean flag indicating spam calls. :param str call_score_annotation: A Call Score of the calls. Use a range of 1-5 to indicate the call experience score, with the following mapping as a reference for the rated call [5: Excellent, 4: Good, 3 : Fair, 2 : Poor, 1: Bad]. + :param bool branded_enabled: A boolean flag indicating whether or not the calls were branded using Twilio Branded Calls. One of 'true' or 'false' + :param bool voice_integrity_enabled: A boolean flag indicating whether or not the phone number had voice integrity enabled.One of 'true' or 'false' + :param str branded_bundle_sid: A unique SID identifier of the Branded Call. + :param str voice_integrity_bundle_sid: A unique SID identifier of the Voice Integrity Profile. + :param str voice_integrity_use_case: A Voice Integrity Use Case . Is of type enum. One of 'abandoned_cart', 'appointment_reminders', 'appointment_scheduling', 'asset_management', 'automated_support', 'call_tracking', 'click_to_call', 'contact_tracing', 'contactless_delivery', 'customer_support', 'dating/social', 'delivery_notifications', 'distance_learning', 'emergency_notifications', 'employee_notifications', 'exam_proctoring', 'field_notifications', 'first_responder', 'fraud_alerts', 'group_messaging', 'identify_&_verification', 'intelligent_routing', 'lead_alerts', 'lead_distribution', 'lead_generation', 'lead_management', 'lead_nurturing', 'marketing_events', 'mass_alerts', 'meetings/collaboration', 'order_notifications', 'outbound_dialer', 'pharmacy', 'phone_system', 'purchase_confirmation', 'remote_appointments', 'rewards_program', 'self-service', 'service_alerts', 'shift_management', 'survey/research', 'telehealth', 'telemarketing', 'therapy_(individual+group)'. + :param str business_profile_identity: A Business Identity of the calls. Is of type enum. One of 'direct_customer', 'isv_reseller_or_partner'. + :param str business_profile_industry: A Business Industry of the calls. Is of type enum. One of 'automotive', 'agriculture', 'banking', 'consumer', 'construction', 'education', 'engineering', 'energy', 'oil_and_gas', 'fast_moving_consumer_goods', 'financial', 'fintech', 'food_and_beverage', 'government', 'healthcare', 'hospitality', 'insurance', 'legal', 'manufacturing', 'media', 'online', 'professional_services', 'raw_materials', 'real_estate', 'religion', 'retail', 'jewelry', 'technology', 'telecommunications', 'transportation', 'travel', 'electronics', 'not_for_profit' + :param str business_profile_bundle_sid: A unique SID identifier of the Business Profile. + :param str business_profile_type: A Business Profile Type of the calls. Is of type enum. One of 'primary', 'secondary'. :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 @@ -252,7 +268,6 @@ def stream( to_carrier=to_carrier, from_country_code=from_country_code, to_country_code=to_country_code, - branded=branded, verified_caller=verified_caller, has_tag=has_tag, start_time=start_time, @@ -270,6 +285,15 @@ def stream( quality_issue_annotation=quality_issue_annotation, spam_annotation=spam_annotation, call_score_annotation=call_score_annotation, + branded_enabled=branded_enabled, + voice_integrity_enabled=voice_integrity_enabled, + branded_bundle_sid=branded_bundle_sid, + voice_integrity_bundle_sid=voice_integrity_bundle_sid, + voice_integrity_use_case=voice_integrity_use_case, + business_profile_identity=business_profile_identity, + business_profile_industry=business_profile_industry, + business_profile_bundle_sid=business_profile_bundle_sid, + business_profile_type=business_profile_type, page_size=limits["page_size"], ) @@ -283,7 +307,6 @@ async def stream_async( to_carrier: Union[str, object] = values.unset, from_country_code: Union[str, object] = values.unset, to_country_code: Union[str, object] = values.unset, - branded: Union[bool, object] = values.unset, verified_caller: Union[bool, object] = values.unset, has_tag: Union[bool, object] = values.unset, start_time: Union[str, object] = values.unset, @@ -303,6 +326,15 @@ async def stream_async( quality_issue_annotation: Union[str, object] = values.unset, spam_annotation: Union[bool, object] = values.unset, call_score_annotation: Union[str, object] = values.unset, + branded_enabled: Union[bool, object] = values.unset, + voice_integrity_enabled: Union[bool, object] = values.unset, + branded_bundle_sid: Union[str, object] = values.unset, + voice_integrity_bundle_sid: Union[str, object] = values.unset, + voice_integrity_use_case: Union[str, object] = values.unset, + business_profile_identity: Union[str, object] = values.unset, + business_profile_industry: Union[str, object] = values.unset, + business_profile_bundle_sid: Union[str, object] = values.unset, + business_profile_type: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> AsyncIterator[CallSummariesInstance]: @@ -318,8 +350,7 @@ async def stream_async( :param str to_carrier: A destination carrier. :param str from_country_code: A source country code based on phone number in From. :param str to_country_code: A destination country code. Based on phone number in To. - :param bool branded: A boolean flag indicating whether or not the calls were branded using Twilio Branded Calls. - :param bool verified_caller: A boolean flag indicating whether or not the caller was verified using SHAKEN/STIR. + :param bool verified_caller: A boolean flag indicating whether or not the caller was verified using SHAKEN/STIR.One of 'true' or 'false'. :param bool has_tag: A boolean flag indicating the presence of one or more [Voice Insights Call Tags](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-tags). :param str start_time: A Start time of the calls. xm (x minutes), xh (x hours), xd (x days), 1w, 30m, 3d, 4w or datetime-ISO. Defaults to 4h. :param str end_time: An End Time of the calls. xm (x minutes), xh (x hours), xd (x days), 1w, 30m, 3d, 4w or datetime-ISO. Defaults to 0m. @@ -336,6 +367,15 @@ async def stream_async( :param str quality_issue_annotation: A subjective Quality Issue with the calls. One of `no_quality_issue`, `low_volume`, `choppy_robotic`, `echo`, `dtmf`, `latency`, `owa`, `static_noise`. :param bool spam_annotation: A boolean flag indicating spam calls. :param str call_score_annotation: A Call Score of the calls. Use a range of 1-5 to indicate the call experience score, with the following mapping as a reference for the rated call [5: Excellent, 4: Good, 3 : Fair, 2 : Poor, 1: Bad]. + :param bool branded_enabled: A boolean flag indicating whether or not the calls were branded using Twilio Branded Calls. One of 'true' or 'false' + :param bool voice_integrity_enabled: A boolean flag indicating whether or not the phone number had voice integrity enabled.One of 'true' or 'false' + :param str branded_bundle_sid: A unique SID identifier of the Branded Call. + :param str voice_integrity_bundle_sid: A unique SID identifier of the Voice Integrity Profile. + :param str voice_integrity_use_case: A Voice Integrity Use Case . Is of type enum. One of 'abandoned_cart', 'appointment_reminders', 'appointment_scheduling', 'asset_management', 'automated_support', 'call_tracking', 'click_to_call', 'contact_tracing', 'contactless_delivery', 'customer_support', 'dating/social', 'delivery_notifications', 'distance_learning', 'emergency_notifications', 'employee_notifications', 'exam_proctoring', 'field_notifications', 'first_responder', 'fraud_alerts', 'group_messaging', 'identify_&_verification', 'intelligent_routing', 'lead_alerts', 'lead_distribution', 'lead_generation', 'lead_management', 'lead_nurturing', 'marketing_events', 'mass_alerts', 'meetings/collaboration', 'order_notifications', 'outbound_dialer', 'pharmacy', 'phone_system', 'purchase_confirmation', 'remote_appointments', 'rewards_program', 'self-service', 'service_alerts', 'shift_management', 'survey/research', 'telehealth', 'telemarketing', 'therapy_(individual+group)'. + :param str business_profile_identity: A Business Identity of the calls. Is of type enum. One of 'direct_customer', 'isv_reseller_or_partner'. + :param str business_profile_industry: A Business Industry of the calls. Is of type enum. One of 'automotive', 'agriculture', 'banking', 'consumer', 'construction', 'education', 'engineering', 'energy', 'oil_and_gas', 'fast_moving_consumer_goods', 'financial', 'fintech', 'food_and_beverage', 'government', 'healthcare', 'hospitality', 'insurance', 'legal', 'manufacturing', 'media', 'online', 'professional_services', 'raw_materials', 'real_estate', 'religion', 'retail', 'jewelry', 'technology', 'telecommunications', 'transportation', 'travel', 'electronics', 'not_for_profit' + :param str business_profile_bundle_sid: A unique SID identifier of the Business Profile. + :param str business_profile_type: A Business Profile Type of the calls. Is of type enum. One of 'primary', 'secondary'. :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 @@ -353,7 +393,6 @@ async def stream_async( to_carrier=to_carrier, from_country_code=from_country_code, to_country_code=to_country_code, - branded=branded, verified_caller=verified_caller, has_tag=has_tag, start_time=start_time, @@ -371,6 +410,15 @@ async def stream_async( quality_issue_annotation=quality_issue_annotation, spam_annotation=spam_annotation, call_score_annotation=call_score_annotation, + branded_enabled=branded_enabled, + voice_integrity_enabled=voice_integrity_enabled, + branded_bundle_sid=branded_bundle_sid, + voice_integrity_bundle_sid=voice_integrity_bundle_sid, + voice_integrity_use_case=voice_integrity_use_case, + business_profile_identity=business_profile_identity, + business_profile_industry=business_profile_industry, + business_profile_bundle_sid=business_profile_bundle_sid, + business_profile_type=business_profile_type, page_size=limits["page_size"], ) @@ -384,7 +432,6 @@ def list( to_carrier: Union[str, object] = values.unset, from_country_code: Union[str, object] = values.unset, to_country_code: Union[str, object] = values.unset, - branded: Union[bool, object] = values.unset, verified_caller: Union[bool, object] = values.unset, has_tag: Union[bool, object] = values.unset, start_time: Union[str, object] = values.unset, @@ -404,6 +451,15 @@ def list( quality_issue_annotation: Union[str, object] = values.unset, spam_annotation: Union[bool, object] = values.unset, call_score_annotation: Union[str, object] = values.unset, + branded_enabled: Union[bool, object] = values.unset, + voice_integrity_enabled: Union[bool, object] = values.unset, + branded_bundle_sid: Union[str, object] = values.unset, + voice_integrity_bundle_sid: Union[str, object] = values.unset, + voice_integrity_use_case: Union[str, object] = values.unset, + business_profile_identity: Union[str, object] = values.unset, + business_profile_industry: Union[str, object] = values.unset, + business_profile_bundle_sid: Union[str, object] = values.unset, + business_profile_type: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> List[CallSummariesInstance]: @@ -418,8 +474,7 @@ def list( :param str to_carrier: A destination carrier. :param str from_country_code: A source country code based on phone number in From. :param str to_country_code: A destination country code. Based on phone number in To. - :param bool branded: A boolean flag indicating whether or not the calls were branded using Twilio Branded Calls. - :param bool verified_caller: A boolean flag indicating whether or not the caller was verified using SHAKEN/STIR. + :param bool verified_caller: A boolean flag indicating whether or not the caller was verified using SHAKEN/STIR.One of 'true' or 'false'. :param bool has_tag: A boolean flag indicating the presence of one or more [Voice Insights Call Tags](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-tags). :param str start_time: A Start time of the calls. xm (x minutes), xh (x hours), xd (x days), 1w, 30m, 3d, 4w or datetime-ISO. Defaults to 4h. :param str end_time: An End Time of the calls. xm (x minutes), xh (x hours), xd (x days), 1w, 30m, 3d, 4w or datetime-ISO. Defaults to 0m. @@ -436,6 +491,15 @@ def list( :param str quality_issue_annotation: A subjective Quality Issue with the calls. One of `no_quality_issue`, `low_volume`, `choppy_robotic`, `echo`, `dtmf`, `latency`, `owa`, `static_noise`. :param bool spam_annotation: A boolean flag indicating spam calls. :param str call_score_annotation: A Call Score of the calls. Use a range of 1-5 to indicate the call experience score, with the following mapping as a reference for the rated call [5: Excellent, 4: Good, 3 : Fair, 2 : Poor, 1: Bad]. + :param bool branded_enabled: A boolean flag indicating whether or not the calls were branded using Twilio Branded Calls. One of 'true' or 'false' + :param bool voice_integrity_enabled: A boolean flag indicating whether or not the phone number had voice integrity enabled.One of 'true' or 'false' + :param str branded_bundle_sid: A unique SID identifier of the Branded Call. + :param str voice_integrity_bundle_sid: A unique SID identifier of the Voice Integrity Profile. + :param str voice_integrity_use_case: A Voice Integrity Use Case . Is of type enum. One of 'abandoned_cart', 'appointment_reminders', 'appointment_scheduling', 'asset_management', 'automated_support', 'call_tracking', 'click_to_call', 'contact_tracing', 'contactless_delivery', 'customer_support', 'dating/social', 'delivery_notifications', 'distance_learning', 'emergency_notifications', 'employee_notifications', 'exam_proctoring', 'field_notifications', 'first_responder', 'fraud_alerts', 'group_messaging', 'identify_&_verification', 'intelligent_routing', 'lead_alerts', 'lead_distribution', 'lead_generation', 'lead_management', 'lead_nurturing', 'marketing_events', 'mass_alerts', 'meetings/collaboration', 'order_notifications', 'outbound_dialer', 'pharmacy', 'phone_system', 'purchase_confirmation', 'remote_appointments', 'rewards_program', 'self-service', 'service_alerts', 'shift_management', 'survey/research', 'telehealth', 'telemarketing', 'therapy_(individual+group)'. + :param str business_profile_identity: A Business Identity of the calls. Is of type enum. One of 'direct_customer', 'isv_reseller_or_partner'. + :param str business_profile_industry: A Business Industry of the calls. Is of type enum. One of 'automotive', 'agriculture', 'banking', 'consumer', 'construction', 'education', 'engineering', 'energy', 'oil_and_gas', 'fast_moving_consumer_goods', 'financial', 'fintech', 'food_and_beverage', 'government', 'healthcare', 'hospitality', 'insurance', 'legal', 'manufacturing', 'media', 'online', 'professional_services', 'raw_materials', 'real_estate', 'religion', 'retail', 'jewelry', 'technology', 'telecommunications', 'transportation', 'travel', 'electronics', 'not_for_profit' + :param str business_profile_bundle_sid: A unique SID identifier of the Business Profile. + :param str business_profile_type: A Business Profile Type of the calls. Is of type enum. One of 'primary', 'secondary'. :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 @@ -453,7 +517,6 @@ def list( to_carrier=to_carrier, from_country_code=from_country_code, to_country_code=to_country_code, - branded=branded, verified_caller=verified_caller, has_tag=has_tag, start_time=start_time, @@ -471,6 +534,15 @@ def list( quality_issue_annotation=quality_issue_annotation, spam_annotation=spam_annotation, call_score_annotation=call_score_annotation, + branded_enabled=branded_enabled, + voice_integrity_enabled=voice_integrity_enabled, + branded_bundle_sid=branded_bundle_sid, + voice_integrity_bundle_sid=voice_integrity_bundle_sid, + voice_integrity_use_case=voice_integrity_use_case, + business_profile_identity=business_profile_identity, + business_profile_industry=business_profile_industry, + business_profile_bundle_sid=business_profile_bundle_sid, + business_profile_type=business_profile_type, limit=limit, page_size=page_size, ) @@ -484,7 +556,6 @@ async def list_async( to_carrier: Union[str, object] = values.unset, from_country_code: Union[str, object] = values.unset, to_country_code: Union[str, object] = values.unset, - branded: Union[bool, object] = values.unset, verified_caller: Union[bool, object] = values.unset, has_tag: Union[bool, object] = values.unset, start_time: Union[str, object] = values.unset, @@ -504,6 +575,15 @@ async def list_async( quality_issue_annotation: Union[str, object] = values.unset, spam_annotation: Union[bool, object] = values.unset, call_score_annotation: Union[str, object] = values.unset, + branded_enabled: Union[bool, object] = values.unset, + voice_integrity_enabled: Union[bool, object] = values.unset, + branded_bundle_sid: Union[str, object] = values.unset, + voice_integrity_bundle_sid: Union[str, object] = values.unset, + voice_integrity_use_case: Union[str, object] = values.unset, + business_profile_identity: Union[str, object] = values.unset, + business_profile_industry: Union[str, object] = values.unset, + business_profile_bundle_sid: Union[str, object] = values.unset, + business_profile_type: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> List[CallSummariesInstance]: @@ -518,8 +598,7 @@ async def list_async( :param str to_carrier: A destination carrier. :param str from_country_code: A source country code based on phone number in From. :param str to_country_code: A destination country code. Based on phone number in To. - :param bool branded: A boolean flag indicating whether or not the calls were branded using Twilio Branded Calls. - :param bool verified_caller: A boolean flag indicating whether or not the caller was verified using SHAKEN/STIR. + :param bool verified_caller: A boolean flag indicating whether or not the caller was verified using SHAKEN/STIR.One of 'true' or 'false'. :param bool has_tag: A boolean flag indicating the presence of one or more [Voice Insights Call Tags](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-tags). :param str start_time: A Start time of the calls. xm (x minutes), xh (x hours), xd (x days), 1w, 30m, 3d, 4w or datetime-ISO. Defaults to 4h. :param str end_time: An End Time of the calls. xm (x minutes), xh (x hours), xd (x days), 1w, 30m, 3d, 4w or datetime-ISO. Defaults to 0m. @@ -536,6 +615,15 @@ async def list_async( :param str quality_issue_annotation: A subjective Quality Issue with the calls. One of `no_quality_issue`, `low_volume`, `choppy_robotic`, `echo`, `dtmf`, `latency`, `owa`, `static_noise`. :param bool spam_annotation: A boolean flag indicating spam calls. :param str call_score_annotation: A Call Score of the calls. Use a range of 1-5 to indicate the call experience score, with the following mapping as a reference for the rated call [5: Excellent, 4: Good, 3 : Fair, 2 : Poor, 1: Bad]. + :param bool branded_enabled: A boolean flag indicating whether or not the calls were branded using Twilio Branded Calls. One of 'true' or 'false' + :param bool voice_integrity_enabled: A boolean flag indicating whether or not the phone number had voice integrity enabled.One of 'true' or 'false' + :param str branded_bundle_sid: A unique SID identifier of the Branded Call. + :param str voice_integrity_bundle_sid: A unique SID identifier of the Voice Integrity Profile. + :param str voice_integrity_use_case: A Voice Integrity Use Case . Is of type enum. One of 'abandoned_cart', 'appointment_reminders', 'appointment_scheduling', 'asset_management', 'automated_support', 'call_tracking', 'click_to_call', 'contact_tracing', 'contactless_delivery', 'customer_support', 'dating/social', 'delivery_notifications', 'distance_learning', 'emergency_notifications', 'employee_notifications', 'exam_proctoring', 'field_notifications', 'first_responder', 'fraud_alerts', 'group_messaging', 'identify_&_verification', 'intelligent_routing', 'lead_alerts', 'lead_distribution', 'lead_generation', 'lead_management', 'lead_nurturing', 'marketing_events', 'mass_alerts', 'meetings/collaboration', 'order_notifications', 'outbound_dialer', 'pharmacy', 'phone_system', 'purchase_confirmation', 'remote_appointments', 'rewards_program', 'self-service', 'service_alerts', 'shift_management', 'survey/research', 'telehealth', 'telemarketing', 'therapy_(individual+group)'. + :param str business_profile_identity: A Business Identity of the calls. Is of type enum. One of 'direct_customer', 'isv_reseller_or_partner'. + :param str business_profile_industry: A Business Industry of the calls. Is of type enum. One of 'automotive', 'agriculture', 'banking', 'consumer', 'construction', 'education', 'engineering', 'energy', 'oil_and_gas', 'fast_moving_consumer_goods', 'financial', 'fintech', 'food_and_beverage', 'government', 'healthcare', 'hospitality', 'insurance', 'legal', 'manufacturing', 'media', 'online', 'professional_services', 'raw_materials', 'real_estate', 'religion', 'retail', 'jewelry', 'technology', 'telecommunications', 'transportation', 'travel', 'electronics', 'not_for_profit' + :param str business_profile_bundle_sid: A unique SID identifier of the Business Profile. + :param str business_profile_type: A Business Profile Type of the calls. Is of type enum. One of 'primary', 'secondary'. :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 @@ -554,7 +642,6 @@ async def list_async( to_carrier=to_carrier, from_country_code=from_country_code, to_country_code=to_country_code, - branded=branded, verified_caller=verified_caller, has_tag=has_tag, start_time=start_time, @@ -572,6 +659,15 @@ async def list_async( quality_issue_annotation=quality_issue_annotation, spam_annotation=spam_annotation, call_score_annotation=call_score_annotation, + branded_enabled=branded_enabled, + voice_integrity_enabled=voice_integrity_enabled, + branded_bundle_sid=branded_bundle_sid, + voice_integrity_bundle_sid=voice_integrity_bundle_sid, + voice_integrity_use_case=voice_integrity_use_case, + business_profile_identity=business_profile_identity, + business_profile_industry=business_profile_industry, + business_profile_bundle_sid=business_profile_bundle_sid, + business_profile_type=business_profile_type, limit=limit, page_size=page_size, ) @@ -585,7 +681,6 @@ def page( to_carrier: Union[str, object] = values.unset, from_country_code: Union[str, object] = values.unset, to_country_code: Union[str, object] = values.unset, - branded: Union[bool, object] = values.unset, verified_caller: Union[bool, object] = values.unset, has_tag: Union[bool, object] = values.unset, start_time: Union[str, object] = values.unset, @@ -605,6 +700,15 @@ def page( quality_issue_annotation: Union[str, object] = values.unset, spam_annotation: Union[bool, object] = values.unset, call_score_annotation: Union[str, object] = values.unset, + branded_enabled: Union[bool, object] = values.unset, + voice_integrity_enabled: Union[bool, object] = values.unset, + branded_bundle_sid: Union[str, object] = values.unset, + voice_integrity_bundle_sid: Union[str, object] = values.unset, + voice_integrity_use_case: Union[str, object] = values.unset, + business_profile_identity: Union[str, object] = values.unset, + business_profile_industry: Union[str, object] = values.unset, + business_profile_bundle_sid: Union[str, object] = values.unset, + business_profile_type: Union[str, object] = values.unset, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, page_size: Union[int, object] = values.unset, @@ -619,8 +723,7 @@ def page( :param to_carrier: A destination carrier. :param from_country_code: A source country code based on phone number in From. :param to_country_code: A destination country code. Based on phone number in To. - :param branded: A boolean flag indicating whether or not the calls were branded using Twilio Branded Calls. - :param verified_caller: A boolean flag indicating whether or not the caller was verified using SHAKEN/STIR. + :param verified_caller: A boolean flag indicating whether or not the caller was verified using SHAKEN/STIR.One of 'true' or 'false'. :param has_tag: A boolean flag indicating the presence of one or more [Voice Insights Call Tags](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-tags). :param start_time: A Start time of the calls. xm (x minutes), xh (x hours), xd (x days), 1w, 30m, 3d, 4w or datetime-ISO. Defaults to 4h. :param end_time: An End Time of the calls. xm (x minutes), xh (x hours), xd (x days), 1w, 30m, 3d, 4w or datetime-ISO. Defaults to 0m. @@ -637,6 +740,15 @@ def page( :param quality_issue_annotation: A subjective Quality Issue with the calls. One of `no_quality_issue`, `low_volume`, `choppy_robotic`, `echo`, `dtmf`, `latency`, `owa`, `static_noise`. :param spam_annotation: A boolean flag indicating spam calls. :param call_score_annotation: A Call Score of the calls. Use a range of 1-5 to indicate the call experience score, with the following mapping as a reference for the rated call [5: Excellent, 4: Good, 3 : Fair, 2 : Poor, 1: Bad]. + :param branded_enabled: A boolean flag indicating whether or not the calls were branded using Twilio Branded Calls. One of 'true' or 'false' + :param voice_integrity_enabled: A boolean flag indicating whether or not the phone number had voice integrity enabled.One of 'true' or 'false' + :param branded_bundle_sid: A unique SID identifier of the Branded Call. + :param voice_integrity_bundle_sid: A unique SID identifier of the Voice Integrity Profile. + :param voice_integrity_use_case: A Voice Integrity Use Case . Is of type enum. One of 'abandoned_cart', 'appointment_reminders', 'appointment_scheduling', 'asset_management', 'automated_support', 'call_tracking', 'click_to_call', 'contact_tracing', 'contactless_delivery', 'customer_support', 'dating/social', 'delivery_notifications', 'distance_learning', 'emergency_notifications', 'employee_notifications', 'exam_proctoring', 'field_notifications', 'first_responder', 'fraud_alerts', 'group_messaging', 'identify_&_verification', 'intelligent_routing', 'lead_alerts', 'lead_distribution', 'lead_generation', 'lead_management', 'lead_nurturing', 'marketing_events', 'mass_alerts', 'meetings/collaboration', 'order_notifications', 'outbound_dialer', 'pharmacy', 'phone_system', 'purchase_confirmation', 'remote_appointments', 'rewards_program', 'self-service', 'service_alerts', 'shift_management', 'survey/research', 'telehealth', 'telemarketing', 'therapy_(individual+group)'. + :param business_profile_identity: A Business Identity of the calls. Is of type enum. One of 'direct_customer', 'isv_reseller_or_partner'. + :param business_profile_industry: A Business Industry of the calls. Is of type enum. One of 'automotive', 'agriculture', 'banking', 'consumer', 'construction', 'education', 'engineering', 'energy', 'oil_and_gas', 'fast_moving_consumer_goods', 'financial', 'fintech', 'food_and_beverage', 'government', 'healthcare', 'hospitality', 'insurance', 'legal', 'manufacturing', 'media', 'online', 'professional_services', 'raw_materials', 'real_estate', 'religion', 'retail', 'jewelry', 'technology', 'telecommunications', 'transportation', 'travel', 'electronics', 'not_for_profit' + :param business_profile_bundle_sid: A unique SID identifier of the Business Profile. + :param business_profile_type: A Business Profile Type of the calls. Is of type enum. One of 'primary', 'secondary'. :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 @@ -651,7 +763,6 @@ def page( "ToCarrier": to_carrier, "FromCountryCode": from_country_code, "ToCountryCode": to_country_code, - "Branded": serialize.boolean_to_string(branded), "VerifiedCaller": serialize.boolean_to_string(verified_caller), "HasTag": serialize.boolean_to_string(has_tag), "StartTime": start_time, @@ -669,6 +780,17 @@ def page( "QualityIssueAnnotation": quality_issue_annotation, "SpamAnnotation": serialize.boolean_to_string(spam_annotation), "CallScoreAnnotation": call_score_annotation, + "BrandedEnabled": serialize.boolean_to_string(branded_enabled), + "VoiceIntegrityEnabled": serialize.boolean_to_string( + voice_integrity_enabled + ), + "BrandedBundleSid": branded_bundle_sid, + "VoiceIntegrityBundleSid": voice_integrity_bundle_sid, + "VoiceIntegrityUseCase": voice_integrity_use_case, + "BusinessProfileIdentity": business_profile_identity, + "BusinessProfileIndustry": business_profile_industry, + "BusinessProfileBundleSid": business_profile_bundle_sid, + "BusinessProfileType": business_profile_type, "PageToken": page_token, "Page": page_number, "PageSize": page_size, @@ -686,7 +808,6 @@ async def page_async( to_carrier: Union[str, object] = values.unset, from_country_code: Union[str, object] = values.unset, to_country_code: Union[str, object] = values.unset, - branded: Union[bool, object] = values.unset, verified_caller: Union[bool, object] = values.unset, has_tag: Union[bool, object] = values.unset, start_time: Union[str, object] = values.unset, @@ -706,6 +827,15 @@ async def page_async( quality_issue_annotation: Union[str, object] = values.unset, spam_annotation: Union[bool, object] = values.unset, call_score_annotation: Union[str, object] = values.unset, + branded_enabled: Union[bool, object] = values.unset, + voice_integrity_enabled: Union[bool, object] = values.unset, + branded_bundle_sid: Union[str, object] = values.unset, + voice_integrity_bundle_sid: Union[str, object] = values.unset, + voice_integrity_use_case: Union[str, object] = values.unset, + business_profile_identity: Union[str, object] = values.unset, + business_profile_industry: Union[str, object] = values.unset, + business_profile_bundle_sid: Union[str, object] = values.unset, + business_profile_type: Union[str, object] = values.unset, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, page_size: Union[int, object] = values.unset, @@ -720,8 +850,7 @@ async def page_async( :param to_carrier: A destination carrier. :param from_country_code: A source country code based on phone number in From. :param to_country_code: A destination country code. Based on phone number in To. - :param branded: A boolean flag indicating whether or not the calls were branded using Twilio Branded Calls. - :param verified_caller: A boolean flag indicating whether or not the caller was verified using SHAKEN/STIR. + :param verified_caller: A boolean flag indicating whether or not the caller was verified using SHAKEN/STIR.One of 'true' or 'false'. :param has_tag: A boolean flag indicating the presence of one or more [Voice Insights Call Tags](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-tags). :param start_time: A Start time of the calls. xm (x minutes), xh (x hours), xd (x days), 1w, 30m, 3d, 4w or datetime-ISO. Defaults to 4h. :param end_time: An End Time of the calls. xm (x minutes), xh (x hours), xd (x days), 1w, 30m, 3d, 4w or datetime-ISO. Defaults to 0m. @@ -738,6 +867,15 @@ async def page_async( :param quality_issue_annotation: A subjective Quality Issue with the calls. One of `no_quality_issue`, `low_volume`, `choppy_robotic`, `echo`, `dtmf`, `latency`, `owa`, `static_noise`. :param spam_annotation: A boolean flag indicating spam calls. :param call_score_annotation: A Call Score of the calls. Use a range of 1-5 to indicate the call experience score, with the following mapping as a reference for the rated call [5: Excellent, 4: Good, 3 : Fair, 2 : Poor, 1: Bad]. + :param branded_enabled: A boolean flag indicating whether or not the calls were branded using Twilio Branded Calls. One of 'true' or 'false' + :param voice_integrity_enabled: A boolean flag indicating whether or not the phone number had voice integrity enabled.One of 'true' or 'false' + :param branded_bundle_sid: A unique SID identifier of the Branded Call. + :param voice_integrity_bundle_sid: A unique SID identifier of the Voice Integrity Profile. + :param voice_integrity_use_case: A Voice Integrity Use Case . Is of type enum. One of 'abandoned_cart', 'appointment_reminders', 'appointment_scheduling', 'asset_management', 'automated_support', 'call_tracking', 'click_to_call', 'contact_tracing', 'contactless_delivery', 'customer_support', 'dating/social', 'delivery_notifications', 'distance_learning', 'emergency_notifications', 'employee_notifications', 'exam_proctoring', 'field_notifications', 'first_responder', 'fraud_alerts', 'group_messaging', 'identify_&_verification', 'intelligent_routing', 'lead_alerts', 'lead_distribution', 'lead_generation', 'lead_management', 'lead_nurturing', 'marketing_events', 'mass_alerts', 'meetings/collaboration', 'order_notifications', 'outbound_dialer', 'pharmacy', 'phone_system', 'purchase_confirmation', 'remote_appointments', 'rewards_program', 'self-service', 'service_alerts', 'shift_management', 'survey/research', 'telehealth', 'telemarketing', 'therapy_(individual+group)'. + :param business_profile_identity: A Business Identity of the calls. Is of type enum. One of 'direct_customer', 'isv_reseller_or_partner'. + :param business_profile_industry: A Business Industry of the calls. Is of type enum. One of 'automotive', 'agriculture', 'banking', 'consumer', 'construction', 'education', 'engineering', 'energy', 'oil_and_gas', 'fast_moving_consumer_goods', 'financial', 'fintech', 'food_and_beverage', 'government', 'healthcare', 'hospitality', 'insurance', 'legal', 'manufacturing', 'media', 'online', 'professional_services', 'raw_materials', 'real_estate', 'religion', 'retail', 'jewelry', 'technology', 'telecommunications', 'transportation', 'travel', 'electronics', 'not_for_profit' + :param business_profile_bundle_sid: A unique SID identifier of the Business Profile. + :param business_profile_type: A Business Profile Type of the calls. Is of type enum. One of 'primary', 'secondary'. :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 @@ -752,7 +890,6 @@ async def page_async( "ToCarrier": to_carrier, "FromCountryCode": from_country_code, "ToCountryCode": to_country_code, - "Branded": serialize.boolean_to_string(branded), "VerifiedCaller": serialize.boolean_to_string(verified_caller), "HasTag": serialize.boolean_to_string(has_tag), "StartTime": start_time, @@ -770,6 +907,17 @@ async def page_async( "QualityIssueAnnotation": quality_issue_annotation, "SpamAnnotation": serialize.boolean_to_string(spam_annotation), "CallScoreAnnotation": call_score_annotation, + "BrandedEnabled": serialize.boolean_to_string(branded_enabled), + "VoiceIntegrityEnabled": serialize.boolean_to_string( + voice_integrity_enabled + ), + "BrandedBundleSid": branded_bundle_sid, + "VoiceIntegrityBundleSid": voice_integrity_bundle_sid, + "VoiceIntegrityUseCase": voice_integrity_use_case, + "BusinessProfileIdentity": business_profile_identity, + "BusinessProfileIndustry": business_profile_industry, + "BusinessProfileBundleSid": business_profile_bundle_sid, + "BusinessProfileType": business_profile_type, "PageToken": page_token, "Page": page_number, "PageSize": page_size, diff --git a/twilio/rest/intelligence/v2/operator_type.py b/twilio/rest/intelligence/v2/operator_type.py index 9884df0ae..ff2403b1c 100644 --- a/twilio/rest/intelligence/v2/operator_type.py +++ b/twilio/rest/intelligence/v2/operator_type.py @@ -145,7 +145,7 @@ def __init__(self, version: Version, sid: str): Initialize the OperatorTypeContext :param version: Version that contains the resource - :param sid: A 34 character string that uniquely identifies this Operator Type. + :param sid: Either a 34 character string that uniquely identifies this Operator Type or the unique name that references an Operator Type. """ super().__init__(version) @@ -422,7 +422,7 @@ def get(self, sid: str) -> OperatorTypeContext: """ Constructs a OperatorTypeContext - :param sid: A 34 character string that uniquely identifies this Operator Type. + :param sid: Either a 34 character string that uniquely identifies this Operator Type or the unique name that references an Operator Type. """ return OperatorTypeContext(self._version, sid=sid) @@ -430,7 +430,7 @@ def __call__(self, sid: str) -> OperatorTypeContext: """ Constructs a OperatorTypeContext - :param sid: A 34 character string that uniquely identifies this Operator Type. + :param sid: Either a 34 character string that uniquely identifies this Operator Type or the unique name that references an Operator Type. """ return OperatorTypeContext(self._version, sid=sid) diff --git a/twilio/rest/intelligence/v2/transcript/sentence.py b/twilio/rest/intelligence/v2/transcript/sentence.py index 5bdd18b00..4a2229b8a 100644 --- a/twilio/rest/intelligence/v2/transcript/sentence.py +++ b/twilio/rest/intelligence/v2/transcript/sentence.py @@ -30,6 +30,7 @@ class SentenceInstance(InstanceResource): :ivar transcript: Transcript text. :ivar sid: A 34 character string that uniquely identifies this Sentence. :ivar confidence: + :ivar words: Detailed information for each of the words of the given Sentence. """ def __init__(self, version: Version, payload: Dict[str, Any], transcript_sid: str): @@ -50,6 +51,7 @@ def __init__(self, version: Version, payload: Dict[str, Any], transcript_sid: st self.confidence: Optional[float] = deserialize.decimal( payload.get("confidence") ) + self.words: Optional[List[Dict[str, object]]] = payload.get("words") self._solution = { "transcript_sid": transcript_sid, @@ -107,6 +109,7 @@ def __init__(self, version: Version, transcript_sid: str): def stream( self, redacted: Union[bool, object] = values.unset, + word_timestamps: Union[bool, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> Iterator[SentenceInstance]: @@ -117,6 +120,7 @@ def stream( The results are returned as a generator, so this operation is memory efficient. :param bool redacted: Grant access to PII Redacted/Unredacted Sentences. If redaction is enabled, the default is `true` to access redacted sentences. + :param bool word_timestamps: Returns word level timestamps information, if word_timestamps is enabled. The default is `false`. :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 @@ -127,13 +131,18 @@ def stream( :returns: Generator that will yield up to limit results """ limits = self._version.read_limits(limit, page_size) - page = self.page(redacted=redacted, page_size=limits["page_size"]) + page = self.page( + redacted=redacted, + word_timestamps=word_timestamps, + page_size=limits["page_size"], + ) return self._version.stream(page, limits["limit"]) async def stream_async( self, redacted: Union[bool, object] = values.unset, + word_timestamps: Union[bool, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> AsyncIterator[SentenceInstance]: @@ -144,6 +153,7 @@ async def stream_async( The results are returned as a generator, so this operation is memory efficient. :param bool redacted: Grant access to PII Redacted/Unredacted Sentences. If redaction is enabled, the default is `true` to access redacted sentences. + :param bool word_timestamps: Returns word level timestamps information, if word_timestamps is enabled. The default is `false`. :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 @@ -154,13 +164,18 @@ async def stream_async( :returns: Generator that will yield up to limit results """ limits = self._version.read_limits(limit, page_size) - page = await self.page_async(redacted=redacted, page_size=limits["page_size"]) + page = await self.page_async( + redacted=redacted, + word_timestamps=word_timestamps, + page_size=limits["page_size"], + ) return self._version.stream_async(page, limits["limit"]) def list( self, redacted: Union[bool, object] = values.unset, + word_timestamps: Union[bool, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> List[SentenceInstance]: @@ -170,6 +185,7 @@ def list( memory before returning. :param bool redacted: Grant access to PII Redacted/Unredacted Sentences. If redaction is enabled, the default is `true` to access redacted sentences. + :param bool word_timestamps: Returns word level timestamps information, if word_timestamps is enabled. The default is `false`. :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 @@ -182,6 +198,7 @@ def list( return list( self.stream( redacted=redacted, + word_timestamps=word_timestamps, limit=limit, page_size=page_size, ) @@ -190,6 +207,7 @@ def list( async def list_async( self, redacted: Union[bool, object] = values.unset, + word_timestamps: Union[bool, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> List[SentenceInstance]: @@ -199,6 +217,7 @@ async def list_async( memory before returning. :param bool redacted: Grant access to PII Redacted/Unredacted Sentences. If redaction is enabled, the default is `true` to access redacted sentences. + :param bool word_timestamps: Returns word level timestamps information, if word_timestamps is enabled. The default is `false`. :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 @@ -212,6 +231,7 @@ async def list_async( record async for record in await self.stream_async( redacted=redacted, + word_timestamps=word_timestamps, limit=limit, page_size=page_size, ) @@ -220,6 +240,7 @@ async def list_async( def page( self, redacted: Union[bool, object] = values.unset, + word_timestamps: Union[bool, object] = values.unset, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, page_size: Union[int, object] = values.unset, @@ -229,6 +250,7 @@ def page( Request is executed immediately :param redacted: Grant access to PII Redacted/Unredacted Sentences. If redaction is enabled, the default is `true` to access redacted sentences. + :param word_timestamps: Returns word level timestamps information, if word_timestamps is enabled. The default is `false`. :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 @@ -238,6 +260,7 @@ def page( data = values.of( { "Redacted": serialize.boolean_to_string(redacted), + "WordTimestamps": serialize.boolean_to_string(word_timestamps), "PageToken": page_token, "Page": page_number, "PageSize": page_size, @@ -250,6 +273,7 @@ def page( async def page_async( self, redacted: Union[bool, object] = values.unset, + word_timestamps: Union[bool, object] = values.unset, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, page_size: Union[int, object] = values.unset, @@ -259,6 +283,7 @@ async def page_async( Request is executed immediately :param redacted: Grant access to PII Redacted/Unredacted Sentences. If redaction is enabled, the default is `true` to access redacted sentences. + :param word_timestamps: Returns word level timestamps information, if word_timestamps is enabled. The default is `false`. :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 @@ -268,6 +293,7 @@ async def page_async( data = values.of( { "Redacted": serialize.boolean_to_string(redacted), + "WordTimestamps": serialize.boolean_to_string(word_timestamps), "PageToken": page_token, "Page": page_number, "PageSize": page_size, diff --git a/twilio/rest/marketplace/__init__.py b/twilio/rest/marketplace/__init__.py index 79b10ef6c..f0276a8f8 100644 --- a/twilio/rest/marketplace/__init__.py +++ b/twilio/rest/marketplace/__init__.py @@ -7,4 +7,3 @@ def available_add_ons(self): def installed_add_ons(self): return self.v1.installed_add_ons - diff --git a/twilio/rest/marketplace/v1/__init__.py b/twilio/rest/marketplace/v1/__init__.py index 49fc49039..9a29e0b69 100644 --- a/twilio/rest/marketplace/v1/__init__.py +++ b/twilio/rest/marketplace/v1/__init__.py @@ -18,6 +18,7 @@ from twilio.rest.marketplace.v1.available_add_on import AvailableAddOnList from twilio.rest.marketplace.v1.installed_add_on import InstalledAddOnList from twilio.rest.marketplace.v1.module_data_management import ModuleDataManagementList +from twilio.rest.marketplace.v1.referral_conversion import ReferralConversionList class V1(Version): @@ -32,6 +33,7 @@ def __init__(self, domain: Domain): self._available_add_ons: Optional[AvailableAddOnList] = None self._installed_add_ons: Optional[InstalledAddOnList] = None self._module_data_management: Optional[ModuleDataManagementList] = None + self._referral_conversion: Optional[ReferralConversionList] = None @property def available_add_ons(self) -> AvailableAddOnList: @@ -51,6 +53,12 @@ def module_data_management(self) -> ModuleDataManagementList: self._module_data_management = ModuleDataManagementList(self) return self._module_data_management + @property + def referral_conversion(self) -> ReferralConversionList: + if self._referral_conversion is None: + self._referral_conversion = ReferralConversionList(self) + return self._referral_conversion + def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_usage.py b/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_usage.py index 3f9415ed4..7e44ac4e0 100644 --- a/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_usage.py +++ b/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_usage.py @@ -52,15 +52,17 @@ def __repr__(self) -> str: class InstalledAddOnUsageList(ListResource): - class CreateBillingUsageRequest(object): + class MarketplaceV1InstalledAddOnInstalledAddOnUsage(object): """ :ivar billable_items: """ - def __init__(self, payload: Dict[str, Any], installed_add_on_sid: str): + def __init__(self, payload: Dict[str, Any]): self.billable_items: Optional[ - List[InstalledAddOnUsageList.CreateBillingUsageRequestBillableItems] + List[ + InstalledAddOnUsageList.MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems + ] ] = payload.get("billable_items") def to_dict(self): @@ -70,13 +72,13 @@ def to_dict(self): ], } - class CreateBillingUsageRequestBillableItems(object): + class MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems(object): """ - :ivar quantity: - :ivar sid: + :ivar quantity: Any floating number greater than 0. + :ivar sid: BillingSid to use for billing. """ - def __init__(self, payload: Dict[str, Any], installed_add_on_sid: str): + def __init__(self, payload: Dict[str, Any]): self.quantity: Optional[float] = payload.get("quantity") self.sid: Optional[str] = payload.get("sid") @@ -106,16 +108,17 @@ def __init__(self, version: Version, installed_add_on_sid: str): ) def create( - self, create_billing_usage_request: CreateBillingUsageRequest + self, + marketplace_v1_installed_add_on_installed_add_on_usage: MarketplaceV1InstalledAddOnInstalledAddOnUsage, ) -> InstalledAddOnUsageInstance: """ Create the InstalledAddOnUsageInstance - :param create_billing_usage_request: + :param marketplace_v1_installed_add_on_installed_add_on_usage: :returns: The created InstalledAddOnUsageInstance """ - data = create_billing_usage_request.to_dict() + data = marketplace_v1_installed_add_on_installed_add_on_usage.to_dict() headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) headers["Content-Type"] = "application/json" @@ -131,16 +134,17 @@ def create( ) async def create_async( - self, create_billing_usage_request: CreateBillingUsageRequest + self, + marketplace_v1_installed_add_on_installed_add_on_usage: MarketplaceV1InstalledAddOnInstalledAddOnUsage, ) -> InstalledAddOnUsageInstance: """ Asynchronously create the InstalledAddOnUsageInstance - :param create_billing_usage_request: + :param marketplace_v1_installed_add_on_installed_add_on_usage: :returns: The created InstalledAddOnUsageInstance """ - data = create_billing_usage_request.to_dict() + data = marketplace_v1_installed_add_on_installed_add_on_usage.to_dict() headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) headers["Content-Type"] = "application/json" diff --git a/twilio/rest/marketplace/v1/module_data_management.py b/twilio/rest/marketplace/v1/module_data_management.py index 079a1a334..837f5fc3f 100644 --- a/twilio/rest/marketplace/v1/module_data_management.py +++ b/twilio/rest/marketplace/v1/module_data_management.py @@ -22,13 +22,14 @@ class ModuleDataManagementInstance(InstanceResource): """ - :ivar url: - :ivar sid: - :ivar description: - :ivar support: - :ivar policies: - :ivar module_info: - :ivar documentation: + :ivar url: URL to query the subresource. + :ivar sid: ModuleSid that identifies this Listing. + :ivar description: A JSON object describing the module and is displayed under the Description tab of the Module detail page. You can define the main body of the description, highlight key features or aspects of the module and if applicable, provide code samples for developers + :ivar support: A JSON object containing information on how customers can obtain support for the module. Use this parameter to provide details such as contact information and support description. + :ivar policies: A JSON object describing the module's privacy and legal policies and is displayed under the Policies tab of the Module detail page. The maximum file size for Policies is 5MB + :ivar module_info: A JSON object containing essential attributes that define a module. This information is presented on the Module detail page in the Twilio Marketplace Catalog. You can pass the following attributes in the JSON object + :ivar documentation: A JSON object for providing comprehensive information, instructions, and resources related to the module + :ivar configuration: A JSON object for providing listing specific configuration. Contains button setup, notification url, among others. """ def __init__( @@ -43,6 +44,7 @@ def __init__( self.policies: Optional[Dict[str, object]] = payload.get("policies") self.module_info: Optional[Dict[str, object]] = payload.get("module_info") self.documentation: Optional[Dict[str, object]] = payload.get("documentation") + self.configuration: Optional[Dict[str, object]] = payload.get("configuration") self._solution = { "sid": sid or self.sid, @@ -89,6 +91,7 @@ def update( documentation: Union[str, object] = values.unset, policies: Union[str, object] = values.unset, support: Union[str, object] = values.unset, + configuration: Union[str, object] = values.unset, ) -> "ModuleDataManagementInstance": """ Update the ModuleDataManagementInstance @@ -98,6 +101,7 @@ def update( :param documentation: :param policies: :param support: + :param configuration: :returns: The updated ModuleDataManagementInstance """ @@ -107,6 +111,7 @@ def update( documentation=documentation, policies=policies, support=support, + configuration=configuration, ) async def update_async( @@ -116,6 +121,7 @@ async def update_async( documentation: Union[str, object] = values.unset, policies: Union[str, object] = values.unset, support: Union[str, object] = values.unset, + configuration: Union[str, object] = values.unset, ) -> "ModuleDataManagementInstance": """ Asynchronous coroutine to update the ModuleDataManagementInstance @@ -125,6 +131,7 @@ async def update_async( :param documentation: :param policies: :param support: + :param configuration: :returns: The updated ModuleDataManagementInstance """ @@ -134,6 +141,7 @@ async def update_async( documentation=documentation, policies=policies, support=support, + configuration=configuration, ) def __repr__(self) -> str: @@ -208,6 +216,7 @@ def update( documentation: Union[str, object] = values.unset, policies: Union[str, object] = values.unset, support: Union[str, object] = values.unset, + configuration: Union[str, object] = values.unset, ) -> ModuleDataManagementInstance: """ Update the ModuleDataManagementInstance @@ -217,6 +226,7 @@ def update( :param documentation: :param policies: :param support: + :param configuration: :returns: The updated ModuleDataManagementInstance """ @@ -227,6 +237,7 @@ def update( "Documentation": documentation, "Policies": policies, "Support": support, + "Configuration": configuration, } ) @@ -247,6 +258,7 @@ async def update_async( documentation: Union[str, object] = values.unset, policies: Union[str, object] = values.unset, support: Union[str, object] = values.unset, + configuration: Union[str, object] = values.unset, ) -> ModuleDataManagementInstance: """ Asynchronous coroutine to update the ModuleDataManagementInstance @@ -256,6 +268,7 @@ async def update_async( :param documentation: :param policies: :param support: + :param configuration: :returns: The updated ModuleDataManagementInstance """ @@ -266,6 +279,7 @@ async def update_async( "Documentation": documentation, "Policies": policies, "Support": support, + "Configuration": configuration, } ) diff --git a/twilio/rest/marketplace/v1/referral_conversion.py b/twilio/rest/marketplace/v1/referral_conversion.py new file mode 100644 index 000000000..62d6ad84f --- /dev/null +++ b/twilio/rest/marketplace/v1/referral_conversion.py @@ -0,0 +1,198 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Marketplace + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, Optional +from twilio.base import values +from twilio.base.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 ReferralConversionInstance(InstanceResource): + """ + :ivar converted_account_sid: + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.converted_account_sid: Optional[str] = payload.get("converted_account_sid") + + self._context: Optional[ReferralConversionContext] = None + + @property + def _proxy(self) -> "ReferralConversionContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: ReferralConversionContext for this ReferralConversionInstance + """ + if self._context is None: + self._context = ReferralConversionContext( + self._version, + ) + return self._context + + def create( + self, create_referral_conversion_request: CreateReferralConversionRequest + ) -> "ReferralConversionInstance": + """ + Create the ReferralConversionInstance + + :param create_referral_conversion_request: + + :returns: The created ReferralConversionInstance + """ + return self._proxy.create( + create_referral_conversion_request, + ) + + async def create_async( + self, create_referral_conversion_request: CreateReferralConversionRequest + ) -> "ReferralConversionInstance": + """ + Asynchronous coroutine to create the ReferralConversionInstance + + :param create_referral_conversion_request: + + :returns: The created ReferralConversionInstance + """ + return await self._proxy.create_async( + create_referral_conversion_request, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class ReferralConversionContext(InstanceContext): + + def __init__(self, version: Version): + """ + Initialize the ReferralConversionContext + + :param version: Version that contains the resource + """ + super().__init__(version) + + self._uri = "/ReferralConversion" + + def create( + self, create_referral_conversion_request: CreateReferralConversionRequest + ) -> ReferralConversionInstance: + """ + Create the ReferralConversionInstance + + :param create_referral_conversion_request: + + :returns: The created ReferralConversionInstance + """ + data = values.of( + { + "CreateReferralConversionRequest": create_referral_conversion_request, + } + ) + + payload = self._version.create(method="POST", uri=self._uri, data=data) + + return ReferralConversionInstance(self._version, payload) + + async def create_async( + self, create_referral_conversion_request: CreateReferralConversionRequest + ) -> ReferralConversionInstance: + """ + Asynchronous coroutine to create the ReferralConversionInstance + + :param create_referral_conversion_request: + + :returns: The created ReferralConversionInstance + """ + data = values.of( + { + "CreateReferralConversionRequest": create_referral_conversion_request, + } + ) + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data + ) + + return ReferralConversionInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class ReferralConversionList(ListResource): + + class CreateReferralConversionRequest(object): + """ + :ivar referral_account_sid: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.referral_account_sid: Optional[str] = payload.get( + "referral_account_sid" + ) + + def to_dict(self): + return { + "referral_account_sid": self.referral_account_sid, + } + + def __init__(self, version: Version): + """ + Initialize the ReferralConversionList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self) -> ReferralConversionContext: + """ + Constructs a ReferralConversionContext + + """ + return ReferralConversionContext(self._version) + + def __call__(self) -> ReferralConversionContext: + """ + Constructs a ReferralConversionContext + + """ + return ReferralConversionContext(self._version) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/messaging/v1/external_campaign.py b/twilio/rest/messaging/v1/external_campaign.py index 88262f978..ebc115ee7 100644 --- a/twilio/rest/messaging/v1/external_campaign.py +++ b/twilio/rest/messaging/v1/external_campaign.py @@ -13,8 +13,8 @@ """ from datetime import datetime -from typing import Any, Dict, Optional -from twilio.base import deserialize, values +from typing import Any, Dict, Optional, Union +from twilio.base import deserialize, serialize, values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource @@ -65,13 +65,17 @@ def __init__(self, version: Version): self._uri = "/Services/PreregisteredUsa2p" def create( - self, campaign_id: str, messaging_service_sid: str + self, + campaign_id: str, + messaging_service_sid: str, + cnp_migration: Union[bool, object] = values.unset, ) -> ExternalCampaignInstance: """ Create the ExternalCampaignInstance :param campaign_id: ID of the preregistered campaign. :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) that the resource is associated with. + :param cnp_migration: Customers should use this flag during the ERC registration process to indicate to Twilio that the campaign being registered is undergoing CNP migration. It is important for the user to first trigger the CNP migration process for said campaign in their CSP portal and have Twilio accept the sharing request, before making this api call. :returns: The created ExternalCampaignInstance """ @@ -80,6 +84,7 @@ def create( { "CampaignId": campaign_id, "MessagingServiceSid": messaging_service_sid, + "CnpMigration": serialize.boolean_to_string(cnp_migration), } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) @@ -91,13 +96,17 @@ def create( return ExternalCampaignInstance(self._version, payload) async def create_async( - self, campaign_id: str, messaging_service_sid: str + self, + campaign_id: str, + messaging_service_sid: str, + cnp_migration: Union[bool, object] = values.unset, ) -> ExternalCampaignInstance: """ Asynchronously create the ExternalCampaignInstance :param campaign_id: ID of the preregistered campaign. :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) that the resource is associated with. + :param cnp_migration: Customers should use this flag during the ERC registration process to indicate to Twilio that the campaign being registered is undergoing CNP migration. It is important for the user to first trigger the CNP migration process for said campaign in their CSP portal and have Twilio accept the sharing request, before making this api call. :returns: The created ExternalCampaignInstance """ @@ -106,6 +115,7 @@ async def create_async( { "CampaignId": campaign_id, "MessagingServiceSid": messaging_service_sid, + "CnpMigration": serialize.boolean_to_string(cnp_migration), } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) diff --git a/twilio/rest/messaging/v1/service/channel_sender.py b/twilio/rest/messaging/v1/service/channel_sender.py index a8de3d0cf..0a0d5c98d 100644 --- a/twilio/rest/messaging/v1/service/channel_sender.py +++ b/twilio/rest/messaging/v1/service/channel_sender.py @@ -80,6 +80,24 @@ def _proxy(self) -> "ChannelSenderContext": ) return self._context + def delete(self) -> bool: + """ + Deletes the ChannelSenderInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the ChannelSenderInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + def fetch(self) -> "ChannelSenderInstance": """ Fetch the ChannelSenderInstance @@ -129,6 +147,30 @@ def __init__(self, version: Version, messaging_service_sid: str, sid: str): **self._solution ) + def delete(self) -> bool: + """ + Deletes the ChannelSenderInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._version.delete( + method="DELETE", + uri=self._uri, + ) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the ChannelSenderInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._version.delete_async( + method="DELETE", + uri=self._uri, + ) + def fetch(self) -> ChannelSenderInstance: """ Fetch the ChannelSenderInstance @@ -222,6 +264,58 @@ def __init__(self, version: Version, messaging_service_sid: str): **self._solution ) + def create(self, sid: str) -> ChannelSenderInstance: + """ + Create the ChannelSenderInstance + + :param sid: The SID of the Channel Sender being added to the Service. + + :returns: The created ChannelSenderInstance + """ + + data = values.of( + { + "Sid": sid, + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ChannelSenderInstance( + self._version, + payload, + messaging_service_sid=self._solution["messaging_service_sid"], + ) + + async def create_async(self, sid: str) -> ChannelSenderInstance: + """ + Asynchronously create the ChannelSenderInstance + + :param sid: The SID of the Channel Sender being added to the Service. + + :returns: The created ChannelSenderInstance + """ + + data = values.of( + { + "Sid": sid, + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ChannelSenderInstance( + self._version, + payload, + messaging_service_sid=self._solution["messaging_service_sid"], + ) + def stream( self, limit: Optional[int] = None, diff --git a/twilio/rest/numbers/v1/__init__.py b/twilio/rest/numbers/v1/__init__.py index 68f078a88..043364c3d 100644 --- a/twilio/rest/numbers/v1/__init__.py +++ b/twilio/rest/numbers/v1/__init__.py @@ -28,10 +28,12 @@ from twilio.rest.numbers.v1.porting_webhook_configuration_delete import ( PortingWebhookConfigurationDeleteList, ) +from twilio.rest.numbers.v1.porting_webhook_configuration_fetch import ( + PortingWebhookConfigurationFetchList, +) from twilio.rest.numbers.v1.signing_request_configuration import ( SigningRequestConfigurationList, ) -from twilio.rest.numbers.v1.webhook import WebhookList class V1(Version): @@ -56,10 +58,12 @@ def __init__(self, domain: Domain): self._porting_webhook_configurations_delete: Optional[ PortingWebhookConfigurationDeleteList ] = None + self._porting_webhook_configuration_fetch: Optional[ + PortingWebhookConfigurationFetchList + ] = None self._signing_request_configurations: Optional[ SigningRequestConfigurationList ] = None - self._webhook: Optional[WebhookList] = None @property def bulk_eligibilities(self) -> BulkEligibilityList: @@ -107,18 +111,22 @@ def porting_webhook_configurations_delete( ) return self._porting_webhook_configurations_delete + @property + def porting_webhook_configuration_fetch( + self, + ) -> PortingWebhookConfigurationFetchList: + if self._porting_webhook_configuration_fetch is None: + self._porting_webhook_configuration_fetch = ( + PortingWebhookConfigurationFetchList(self) + ) + return self._porting_webhook_configuration_fetch + @property def signing_request_configurations(self) -> SigningRequestConfigurationList: if self._signing_request_configurations is None: self._signing_request_configurations = SigningRequestConfigurationList(self) return self._signing_request_configurations - @property - def webhook(self) -> WebhookList: - if self._webhook is None: - self._webhook = WebhookList(self) - return self._webhook - def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/numbers/v1/porting_port_in.py b/twilio/rest/numbers/v1/porting_port_in.py index 50b3e328e..9ce6b7b4c 100644 --- a/twilio/rest/numbers/v1/porting_port_in.py +++ b/twilio/rest/numbers/v1/porting_port_in.py @@ -25,15 +25,15 @@ class PortingPortInInstance(InstanceResource): """ :ivar port_in_request_sid: The SID of the Port In request. This is a unique identifier of the port in request. :ivar url: The URL of this Port In request - :ivar account_sid: The Account SID that the numbers will be added to after they are ported into Twilio. - :ivar notification_emails: List of emails for getting notifications about the LOA signing process. Allowed Max 10 emails. - :ivar target_port_in_date: Minimum number of days in the future (at least 2 days) needs to be established with the Ops team for validation. - :ivar target_port_in_time_range_start: Minimum hour in the future needs to be established with the Ops team for validation. - :ivar target_port_in_time_range_end: Maximum hour in the future needs to be established with the Ops team for validation. + :ivar account_sid: Account Sid or subaccount where the phone number(s) will be Ported + :ivar notification_emails: Additional emails to send a copy of the signed LOA to. + :ivar target_port_in_date: Target date to port the number. We cannot guarantee that this date will be honored by the other carriers, please work with Ops to get a confirmation of the firm order commitment (FOC) date. Expected format is ISO Local Date, example: ‘2011-12-03`. This date must be at least 7 days in the future for US ports and 10 days in the future for Japanese ports. (This value is only available for custom porting customers.) + :ivar target_port_in_time_range_start: The earliest time that the port should occur on the target port in date. Expected format is ISO Offset Time, example: ‘10:15:00-08:00'. (This value is only available for custom porting customers.) + :ivar target_port_in_time_range_end: The latest time that the port should occur on the target port in date. Expected format is ISO Offset Time, example: ‘10:15:00-08:00'. (This value is only available for custom porting customers.) :ivar port_in_request_status: The status of the port in request. The possible values are: In progress, Completed, Expired, In review, Waiting for Signature, Action Required, and Canceled. - :ivar losing_carrier_information: The information for the losing carrier. - :ivar phone_numbers: The list of phone numbers to Port in. Phone numbers are in E.164 format (e.g. +16175551212). - :ivar documents: The list of documents SID referencing a utility bills + :ivar losing_carrier_information: Details regarding the customer’s information with the losing carrier. These values will be used to generate the letter of authorization and should match the losing carrier’s data as closely as possible to ensure the port is accepted. + :ivar phone_numbers: + :ivar documents: List of document SIDs for all phone numbers included in the port in request. At least one document SID referring to a document of the type Utility Bill is required. :ivar date_created: """ diff --git a/twilio/rest/numbers/v1/porting_port_in_phone_number.py b/twilio/rest/numbers/v1/porting_port_in_phone_number.py index f5d881a65..c494961ef 100644 --- a/twilio/rest/numbers/v1/porting_port_in_phone_number.py +++ b/twilio/rest/numbers/v1/porting_port_in_phone_number.py @@ -23,23 +23,24 @@ class PortingPortInPhoneNumberInstance(InstanceResource): """ - :ivar port_in_request_sid: The SID of the Port In request. This is a unique identifier of the port in request. - :ivar phone_number_sid: The SID of the Port In request phone number. This is a unique identifier of the phone number. - :ivar url: - :ivar account_sid: The SID of the account that the phone number belongs to. - :ivar phone_number_type: The type of the phone number. - :ivar date_created: The date when the phone number was created. - :ivar country: The country of the phone number. - :ivar missing_required_fields: The phone number is missing required fields. - :ivar last_updated: The timestamp when the status was last updated. - :ivar phone_number: The phone number. - :ivar portable: The phone number is portable. - :ivar not_portability_reason: The reason why the phone number is not portable. - :ivar not_portability_reason_code: The code of the reason why the phone number is not portable. - :ivar port_in_phone_number_status: The status of the phone number in the port in request. - :ivar port_out_pin: The pin required for the losing carrier to port out the phone number. - :ivar rejection_reason: The rejection reason returned by the vendor. - :ivar rejection_reason_code: The rejection reason code returned by the vendor. + :ivar port_in_request_sid: The unique identifier for the port in request that this phone number is associated with. + :ivar phone_number_sid: The unique identifier for this phone number associated with this port in request. + :ivar url: URL reference for this resource. + :ivar account_sid: Account Sid or subaccount where the phone number(s) will be Ported. + :ivar phone_number_type: The number type of the phone number. This can be: toll-free, local, mobile or unknown. This field may be null if the number is not portable or if the portability for a number has not yet been evaluated. + :ivar date_created: The timestamp for when this port in phone number was created. + :ivar country: The ISO country code that this number is associated with. This field may be null if the number is not portable or if the portability for a number has not yet been evaluated. + :ivar missing_required_fields: Indicates if the phone number is missing required fields such as a PIN or account number. This field may be null if the number is not portable or if the portability for a number has not yet been evaluated. + :ivar last_updated: Timestamp indicating when the Port In Phone Number resource was last modified. + :ivar phone_number: Phone number to be ported. This will be in the E164 Format. + :ivar portable: If the number is portable by Twilio or not. This field may be null if the number portability has not yet been evaluated. If a number is not portable reference the `not_portability_reason_code` and `not_portability_reason` fields for more details + :ivar not_portability_reason: The not portability reason code description. This field may be null if the number is portable or if the portability for a number has not yet been evaluated. + :ivar not_portability_reason_code: The not portability reason code. This field may be null if the number is portable or if the portability for a number has not yet been evaluated. + :ivar port_in_phone_number_status: The status of the port in phone number. + :ivar port_out_pin: The pin required by the losing carrier to do the port out. + :ivar rejection_reason: The description of the rejection reason provided by the losing carrier. This field may be null if the number has not been rejected by the losing carrier. + :ivar rejection_reason_code: The code for the rejection reason provided by the losing carrier. This field may be null if the number has not been rejected by the losing carrier. + :ivar port_date: The timestamp the phone number will be ported. This will only be set once a port date has been confirmed. Not all carriers can guarantee a specific time on the port date. Twilio will try its best to get the port completed by this time on the port date. Please subscribe to webhooks for confirmation on when a port has actually been completed. """ def __init__( @@ -84,6 +85,9 @@ def __init__( self.rejection_reason_code: Optional[int] = deserialize.integer( payload.get("rejection_reason_code") ) + self.port_date: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("port_date") + ) self._solution = { "port_in_request_sid": port_in_request_sid or self.port_in_request_sid, diff --git a/twilio/rest/numbers/v1/porting_portability.py b/twilio/rest/numbers/v1/porting_portability.py index d4f92ba7d..1f0fc210a 100644 --- a/twilio/rest/numbers/v1/porting_portability.py +++ b/twilio/rest/numbers/v1/porting_portability.py @@ -30,11 +30,11 @@ class NumberType(object): """ :ivar phone_number: The phone number which portability is to be checked. Phone numbers are in E.164 format (e.g. +16175551212). - :ivar account_sid: The target account sid to which the number will be ported - :ivar portable: Boolean flag specifying if phone number is portable or not. - :ivar pin_and_account_number_required: Boolean flag specifying if PIN and account number is required for the phone number. + :ivar account_sid: Account Sid that the phone number belongs to in Twilio. This is only returned for phone numbers that already exist in Twilio’s inventory and belong to your account or sub account. + :ivar portable: Boolean flag indicates if the phone number can be ported into Twilio through the Porting API or not. + :ivar pin_and_account_number_required: Indicates if the port in process will require a personal identification number (PIN) and an account number for this phone number. If this is true you will be required to submit both a PIN and account number from the losing carrier for this number when opening a port in request. These fields will be required in order to complete the port in process to Twilio. :ivar not_portable_reason: Reason why the phone number cannot be ported into Twilio, `null` otherwise. - :ivar not_portable_reason_code: The Portability Reason Code for the phone number if it cannot be ported into Twilio, `null` otherwise. One of `22131`, `22132`, `22130`, `22133`, `22102` or `22135`. + :ivar not_portable_reason_code: The Portability Reason Code for the phone number if it cannot be ported into Twilio, `null` otherwise. :ivar number_type: :ivar country: Country the phone number belongs to. :ivar url: This is the url of the request that you're trying to reach out to locate the resource. @@ -90,7 +90,7 @@ def fetch( """ Fetch the PortingPortabilityInstance - :param target_account_sid: The SID of the account where the phone number(s) will be ported. + :param target_account_sid: Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account. :returns: The fetched PortingPortabilityInstance """ @@ -104,7 +104,7 @@ async def fetch_async( """ Asynchronous coroutine to fetch the PortingPortabilityInstance - :param target_account_sid: The SID of the account where the phone number(s) will be ported. + :param target_account_sid: Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account. :returns: The fetched PortingPortabilityInstance """ @@ -129,7 +129,7 @@ def __init__(self, version: Version, phone_number: str): Initialize the PortingPortabilityContext :param version: Version that contains the resource - :param phone_number: The phone number which portability is to be checked. Phone numbers are in E.164 format (e.g. +16175551212). + :param phone_number: Phone number to check portability in e164 format. """ super().__init__(version) @@ -147,7 +147,7 @@ def fetch( """ Fetch the PortingPortabilityInstance - :param target_account_sid: The SID of the account where the phone number(s) will be ported. + :param target_account_sid: Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account. :returns: The fetched PortingPortabilityInstance """ @@ -172,7 +172,7 @@ async def fetch_async( """ Asynchronous coroutine to fetch the PortingPortabilityInstance - :param target_account_sid: The SID of the account where the phone number(s) will be ported. + :param target_account_sid: Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account. :returns: The fetched PortingPortabilityInstance """ @@ -218,7 +218,7 @@ def get(self, phone_number: str) -> PortingPortabilityContext: """ Constructs a PortingPortabilityContext - :param phone_number: The phone number which portability is to be checked. Phone numbers are in E.164 format (e.g. +16175551212). + :param phone_number: Phone number to check portability in e164 format. """ return PortingPortabilityContext(self._version, phone_number=phone_number) @@ -226,7 +226,7 @@ def __call__(self, phone_number: str) -> PortingPortabilityContext: """ Constructs a PortingPortabilityContext - :param phone_number: The phone number which portability is to be checked. Phone numbers are in E.164 format (e.g. +16175551212). + :param phone_number: Phone number to check portability in e164 format. """ return PortingPortabilityContext(self._version, phone_number=phone_number) diff --git a/twilio/rest/numbers/v1/porting_webhook_configuration.py b/twilio/rest/numbers/v1/porting_webhook_configuration.py index ea6d9bd2e..ec36777a6 100644 --- a/twilio/rest/numbers/v1/porting_webhook_configuration.py +++ b/twilio/rest/numbers/v1/porting_webhook_configuration.py @@ -23,9 +23,9 @@ class PortingWebhookConfigurationInstance(InstanceResource): """ :ivar url: The URL of the webhook configuration request - :ivar port_in_target_url: Webhook URL to send a request when a port in request or port in phone number event happens - :ivar port_out_target_url: Webhook URL to send a request when a port out phone number event happens - :ivar notifications_of: List of notification events to send a request to the webhook URL + :ivar port_in_target_url: The complete webhook url that will be called when a notification event for port in request or port in phone number happens + :ivar port_out_target_url: The complete webhook url that will be called when a notification event for a port out phone number happens. + :ivar notifications_of: A list to filter what notification events to receive for this account and its sub accounts. If it is an empty list, then it means that there are no filters for the notifications events to send in each webhook and all events will get sent. """ def __init__(self, version: Version, payload: Dict[str, Any]): diff --git a/twilio/rest/numbers/v1/porting_webhook_configuration_delete.py b/twilio/rest/numbers/v1/porting_webhook_configuration_delete.py index beb011128..73d347797 100644 --- a/twilio/rest/numbers/v1/porting_webhook_configuration_delete.py +++ b/twilio/rest/numbers/v1/porting_webhook_configuration_delete.py @@ -29,7 +29,7 @@ def __init__( Initialize the PortingWebhookConfigurationDeleteContext :param version: Version that contains the resource - :param webhook_type: The of the webhook type of the configuration to be deleted + :param webhook_type: The webhook type for the configuration to be delete. `PORT_IN`, `PORT_OUT` """ super().__init__(version) @@ -94,7 +94,7 @@ def get( """ Constructs a PortingWebhookConfigurationDeleteContext - :param webhook_type: The of the webhook type of the configuration to be deleted + :param webhook_type: The webhook type for the configuration to be delete. `PORT_IN`, `PORT_OUT` """ return PortingWebhookConfigurationDeleteContext( self._version, webhook_type=webhook_type @@ -106,7 +106,7 @@ def __call__( """ Constructs a PortingWebhookConfigurationDeleteContext - :param webhook_type: The of the webhook type of the configuration to be deleted + :param webhook_type: The webhook type for the configuration to be delete. `PORT_IN`, `PORT_OUT` """ return PortingWebhookConfigurationDeleteContext( self._version, webhook_type=webhook_type diff --git a/twilio/rest/numbers/v1/webhook.py b/twilio/rest/numbers/v1/porting_webhook_configuration_fetch.py similarity index 64% rename from twilio/rest/numbers/v1/webhook.py rename to twilio/rest/numbers/v1/porting_webhook_configuration_fetch.py index 0986db12f..89b8064bd 100644 --- a/twilio/rest/numbers/v1/webhook.py +++ b/twilio/rest/numbers/v1/porting_webhook_configuration_fetch.py @@ -21,12 +21,12 @@ from twilio.base.version import Version -class WebhookInstance(InstanceResource): +class PortingWebhookConfigurationFetchInstance(InstanceResource): """ :ivar url: The URL of the webhook configuration request - :ivar port_in_target_url: Webhook URL to send a request when a port in request or port in phone number event happens - :ivar port_out_target_url: Webhook URL to send a request when a port out phone number event happens - :ivar notifications_of: List of notification events to send a request to the webhook URL + :ivar port_in_target_url: The complete webhook url that will be called when a notification event for port in request or port in phone number happens + :ivar port_out_target_url: The complete webhook url that will be called when a notification event for a port out phone number happens. + :ivar notifications_of: A list to filter what notification events to receive for this account and its sub accounts. If it is an empty list, then it means that there are no filters for the notifications events to send in each webhook and all events will get sent. :ivar port_in_target_date_created: Creation date for the port in webhook configuration :ivar port_out_target_date_created: Creation date for the port out webhook configuration """ @@ -52,14 +52,14 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" -class WebhookList(ListResource): +class PortingWebhookConfigurationFetchList(ListResource): def __init__(self, version: Version): """ - Initialize the WebhookList + Initialize the PortingWebhookConfigurationFetchList :param version: Version that contains the resource @@ -68,25 +68,25 @@ def __init__(self, version: Version): self._uri = "/Porting/Configuration/Webhook" - def fetch(self) -> WebhookInstance: + def fetch(self) -> PortingWebhookConfigurationFetchInstance: """ - Asynchronously fetch the WebhookInstance + Asynchronously fetch the PortingWebhookConfigurationFetchInstance - :returns: The fetched WebhookInstance + :returns: The fetched PortingWebhookConfigurationFetchInstance """ headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) - return WebhookInstance(self._version, payload) + return PortingWebhookConfigurationFetchInstance(self._version, payload) - async def fetch_async(self) -> WebhookInstance: + async def fetch_async(self) -> PortingWebhookConfigurationFetchInstance: """ - Asynchronously fetch the WebhookInstance + Asynchronously fetch the PortingWebhookConfigurationFetchInstance - :returns: The fetched WebhookInstance + :returns: The fetched PortingWebhookConfigurationFetchInstance """ headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) @@ -94,7 +94,7 @@ async def fetch_async(self) -> WebhookInstance: method="GET", uri=self._uri, headers=headers ) - return WebhookInstance(self._version, payload) + return PortingWebhookConfigurationFetchInstance(self._version, payload) def __repr__(self) -> str: """ @@ -102,4 +102,4 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" diff --git a/twilio/rest/numbers/v1/signing_request_configuration.py b/twilio/rest/numbers/v1/signing_request_configuration.py index 541062ec6..a144a09fe 100644 --- a/twilio/rest/numbers/v1/signing_request_configuration.py +++ b/twilio/rest/numbers/v1/signing_request_configuration.py @@ -12,12 +12,13 @@ Do not edit the class manually. """ -from typing import Any, Dict, Optional, Union +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator 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 +from twilio.base.page import Page class SigningRequestConfigurationInstance(InstanceResource): @@ -54,6 +55,27 @@ def __repr__(self) -> str: return "" +class SigningRequestConfigurationPage(Page): + + def get_instance( + self, payload: Dict[str, Any] + ) -> SigningRequestConfigurationInstance: + """ + Build an instance of SigningRequestConfigurationInstance + + :param payload: Payload response from the API + """ + return SigningRequestConfigurationInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + class SigningRequestConfigurationList(ListResource): def __init__(self, version: Version): @@ -109,6 +131,225 @@ async def create_async( return SigningRequestConfigurationInstance(self._version, payload) + def stream( + self, + country: Union[str, object] = values.unset, + product: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[SigningRequestConfigurationInstance]: + """ + Streams SigningRequestConfigurationInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param str country: The country ISO code to apply this configuration, this is an optional field, Example: US, MX + :param str product: The product or service for which is requesting the signature, this is an optional field, Example: Porting, Hosting + :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( + country=country, product=product, page_size=limits["page_size"] + ) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + country: Union[str, object] = values.unset, + product: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[SigningRequestConfigurationInstance]: + """ + Asynchronously streams SigningRequestConfigurationInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param str country: The country ISO code to apply this configuration, this is an optional field, Example: US, MX + :param str product: The product or service for which is requesting the signature, this is an optional field, Example: Porting, Hosting + :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( + country=country, product=product, page_size=limits["page_size"] + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + country: Union[str, object] = values.unset, + product: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[SigningRequestConfigurationInstance]: + """ + Lists SigningRequestConfigurationInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str country: The country ISO code to apply this configuration, this is an optional field, Example: US, MX + :param str product: The product or service for which is requesting the signature, this is an optional field, Example: Porting, Hosting + :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( + country=country, + product=product, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + country: Union[str, object] = values.unset, + product: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[SigningRequestConfigurationInstance]: + """ + Asynchronously lists SigningRequestConfigurationInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str country: The country ISO code to apply this configuration, this is an optional field, Example: US, MX + :param str product: The product or service for which is requesting the signature, this is an optional field, Example: Porting, Hosting + :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( + country=country, + product=product, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + country: Union[str, object] = values.unset, + product: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> SigningRequestConfigurationPage: + """ + Retrieve a single page of SigningRequestConfigurationInstance records from the API. + Request is executed immediately + + :param country: The country ISO code to apply this configuration, this is an optional field, Example: US, MX + :param product: The product or service for which is requesting the signature, this is an optional field, Example: Porting, Hosting + :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 SigningRequestConfigurationInstance + """ + data = values.of( + { + "Country": country, + "Product": product, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = self._version.page(method="GET", uri=self._uri, params=data) + return SigningRequestConfigurationPage(self._version, response) + + async def page_async( + self, + country: Union[str, object] = values.unset, + product: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> SigningRequestConfigurationPage: + """ + Asynchronously retrieve a single page of SigningRequestConfigurationInstance records from the API. + Request is executed immediately + + :param country: The country ISO code to apply this configuration, this is an optional field, Example: US, MX + :param product: The product or service for which is requesting the signature, this is an optional field, Example: Porting, Hosting + :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 SigningRequestConfigurationInstance + """ + data = values.of( + { + "Country": country, + "Product": product, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data + ) + return SigningRequestConfigurationPage(self._version, response) + + def get_page(self, target_url: str) -> SigningRequestConfigurationPage: + """ + Retrieve a specific page of SigningRequestConfigurationInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of SigningRequestConfigurationInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return SigningRequestConfigurationPage(self._version, response) + + async def get_page_async(self, target_url: str) -> SigningRequestConfigurationPage: + """ + Asynchronously retrieve a specific page of SigningRequestConfigurationInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of SigningRequestConfigurationInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return SigningRequestConfigurationPage(self._version, response) + def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/numbers/v2/__init__.py b/twilio/rest/numbers/v2/__init__.py index 9b5b50154..04b303486 100644 --- a/twilio/rest/numbers/v2/__init__.py +++ b/twilio/rest/numbers/v2/__init__.py @@ -17,6 +17,7 @@ from twilio.base.domain import Domain from twilio.rest.numbers.v2.authorization_document import AuthorizationDocumentList from twilio.rest.numbers.v2.bulk_hosted_number_order import BulkHostedNumberOrderList +from twilio.rest.numbers.v2.bundle_clone import BundleCloneList from twilio.rest.numbers.v2.hosted_number_order import HostedNumberOrderList from twilio.rest.numbers.v2.regulatory_compliance import RegulatoryComplianceList @@ -32,6 +33,7 @@ def __init__(self, domain: Domain): super().__init__(domain, "v2") self._authorization_documents: Optional[AuthorizationDocumentList] = None self._bulk_hosted_number_orders: Optional[BulkHostedNumberOrderList] = None + self._bundle_clone: Optional[BundleCloneList] = None self._hosted_number_orders: Optional[HostedNumberOrderList] = None self._regulatory_compliance: Optional[RegulatoryComplianceList] = None @@ -47,6 +49,12 @@ def bulk_hosted_number_orders(self) -> BulkHostedNumberOrderList: self._bulk_hosted_number_orders = BulkHostedNumberOrderList(self) return self._bulk_hosted_number_orders + @property + def bundle_clone(self) -> BundleCloneList: + if self._bundle_clone is None: + self._bundle_clone = BundleCloneList(self) + return self._bundle_clone + @property def hosted_number_orders(self) -> HostedNumberOrderList: if self._hosted_number_orders is None: diff --git a/twilio/rest/numbers/v2/bundle_clone.py b/twilio/rest/numbers/v2/bundle_clone.py new file mode 100644 index 000000000..ff24e2906 --- /dev/null +++ b/twilio/rest/numbers/v2/bundle_clone.py @@ -0,0 +1,268 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Numbers + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, Optional, Union +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 + + +class BundleCloneInstance(InstanceResource): + + class Status(object): + DRAFT = "draft" + PENDING_REVIEW = "pending-review" + IN_REVIEW = "in-review" + TWILIO_REJECTED = "twilio-rejected" + TWILIO_APPROVED = "twilio-approved" + PROVISIONALLY_APPROVED = "provisionally-approved" + + """ + :ivar bundle_sid: The unique string that we created to identify the Bundle resource. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Bundle resource. + :ivar regulation_sid: The unique string of a regulation that is associated to the Bundle resource. + :ivar friendly_name: The string that you assigned to describe the resource. + :ivar status: + :ivar valid_until: The date and time in GMT in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format when the resource will be valid until. + :ivar email: The email address that will receive updates when the Bundle resource changes status. + :ivar status_callback: The URL we call to inform your application of status changes. + :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. + :ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar url: The URL of this resource. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + bundle_sid: Optional[str] = None, + ): + super().__init__(version) + + self.bundle_sid: Optional[str] = payload.get("bundle_sid") + self.account_sid: Optional[str] = payload.get("account_sid") + self.regulation_sid: Optional[str] = payload.get("regulation_sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.status: Optional["BundleCloneInstance.Status"] = payload.get("status") + self.valid_until: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("valid_until") + ) + self.email: Optional[str] = payload.get("email") + self.status_callback: Optional[str] = payload.get("status_callback") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + self.url: Optional[str] = payload.get("url") + + self._solution = { + "bundle_sid": bundle_sid or self.bundle_sid, + } + self._context: Optional[BundleCloneContext] = None + + @property + def _proxy(self) -> "BundleCloneContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: BundleCloneContext for this BundleCloneInstance + """ + if self._context is None: + self._context = BundleCloneContext( + self._version, + bundle_sid=self._solution["bundle_sid"], + ) + return self._context + + def create( + self, + target_account_sid: str, + move_to_draft: Union[bool, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> "BundleCloneInstance": + """ + Create the BundleCloneInstance + + :param target_account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) where the bundle needs to be cloned. + :param move_to_draft: This is to determine whether the cloned bundle needs to be in draft state or not. + :param friendly_name: The string that you assigned to describe the cloned bundle. + + :returns: The created BundleCloneInstance + """ + return self._proxy.create( + target_account_sid, + move_to_draft=move_to_draft, + friendly_name=friendly_name, + ) + + async def create_async( + self, + target_account_sid: str, + move_to_draft: Union[bool, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> "BundleCloneInstance": + """ + Asynchronous coroutine to create the BundleCloneInstance + + :param target_account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) where the bundle needs to be cloned. + :param move_to_draft: This is to determine whether the cloned bundle needs to be in draft state or not. + :param friendly_name: The string that you assigned to describe the cloned bundle. + + :returns: The created BundleCloneInstance + """ + return await self._proxy.create_async( + target_account_sid, + move_to_draft=move_to_draft, + friendly_name=friendly_name, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class BundleCloneContext(InstanceContext): + + def __init__(self, version: Version, bundle_sid: str): + """ + Initialize the BundleCloneContext + + :param version: Version that contains the resource + :param bundle_sid: The unique string that identifies the Bundle to be cloned. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "bundle_sid": bundle_sid, + } + self._uri = "/RegulatoryCompliance/Bundles/{bundle_sid}/Clones".format( + **self._solution + ) + + def create( + self, + target_account_sid: str, + move_to_draft: Union[bool, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> BundleCloneInstance: + """ + Create the BundleCloneInstance + + :param target_account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) where the bundle needs to be cloned. + :param move_to_draft: This is to determine whether the cloned bundle needs to be in draft state or not. + :param friendly_name: The string that you assigned to describe the cloned bundle. + + :returns: The created BundleCloneInstance + """ + data = values.of( + { + "TargetAccountSid": target_account_sid, + "MoveToDraft": serialize.boolean_to_string(move_to_draft), + "FriendlyName": friendly_name, + } + ) + + payload = self._version.create(method="POST", uri=self._uri, data=data) + + return BundleCloneInstance( + self._version, payload, bundle_sid=self._solution["bundle_sid"] + ) + + async def create_async( + self, + target_account_sid: str, + move_to_draft: Union[bool, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> BundleCloneInstance: + """ + Asynchronous coroutine to create the BundleCloneInstance + + :param target_account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) where the bundle needs to be cloned. + :param move_to_draft: This is to determine whether the cloned bundle needs to be in draft state or not. + :param friendly_name: The string that you assigned to describe the cloned bundle. + + :returns: The created BundleCloneInstance + """ + data = values.of( + { + "TargetAccountSid": target_account_sid, + "MoveToDraft": serialize.boolean_to_string(move_to_draft), + "FriendlyName": friendly_name, + } + ) + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data + ) + + return BundleCloneInstance( + self._version, payload, bundle_sid=self._solution["bundle_sid"] + ) + + 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 BundleCloneList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the BundleCloneList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, bundle_sid: str) -> BundleCloneContext: + """ + Constructs a BundleCloneContext + + :param bundle_sid: The unique string that identifies the Bundle to be cloned. + """ + return BundleCloneContext(self._version, bundle_sid=bundle_sid) + + def __call__(self, bundle_sid: str) -> BundleCloneContext: + """ + Constructs a BundleCloneContext + + :param bundle_sid: The unique string that identifies the Bundle to be cloned. + """ + return BundleCloneContext(self._version, bundle_sid=bundle_sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v2/regulatory_compliance/bundle/__init__.py b/twilio/rest/numbers/v2/regulatory_compliance/bundle/__init__.py index ccdcbb3f3..5c8b48f11 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/bundle/__init__.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/bundle/__init__.py @@ -488,6 +488,7 @@ def create( iso_country: Union[str, object] = values.unset, end_user_type: Union["BundleInstance.EndUserType", object] = values.unset, number_type: Union[str, object] = values.unset, + is_test: Union[bool, object] = values.unset, ) -> BundleInstance: """ Create the BundleInstance @@ -499,6 +500,7 @@ def create( :param iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Bundle's phone number country ownership request. :param end_user_type: :param number_type: The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll free`. + :param is_test: Indicates that Bundle is a Test Bundle and will be Auto-Rejected :returns: The created BundleInstance """ @@ -512,6 +514,7 @@ def create( "IsoCountry": iso_country, "EndUserType": end_user_type, "NumberType": number_type, + "IsTest": serialize.boolean_to_string(is_test), } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) @@ -531,6 +534,7 @@ async def create_async( iso_country: Union[str, object] = values.unset, end_user_type: Union["BundleInstance.EndUserType", object] = values.unset, number_type: Union[str, object] = values.unset, + is_test: Union[bool, object] = values.unset, ) -> BundleInstance: """ Asynchronously create the BundleInstance @@ -542,6 +546,7 @@ async def create_async( :param iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Bundle's phone number country ownership request. :param end_user_type: :param number_type: The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll free`. + :param is_test: Indicates that Bundle is a Test Bundle and will be Auto-Rejected :returns: The created BundleInstance """ @@ -555,6 +560,7 @@ async def create_async( "IsoCountry": iso_country, "EndUserType": end_user_type, "NumberType": number_type, + "IsTest": serialize.boolean_to_string(is_test), } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) diff --git a/twilio/rest/taskrouter/v1/workspace/task/__init__.py b/twilio/rest/taskrouter/v1/workspace/task/__init__.py index f71c4bd68..631b8f8bd 100644 --- a/twilio/rest/taskrouter/v1/workspace/task/__init__.py +++ b/twilio/rest/taskrouter/v1/workspace/task/__init__.py @@ -56,7 +56,7 @@ class Status(object): :ivar url: The absolute URL of the Task resource. :ivar links: The URLs of related resources. :ivar virtual_start_time: The date and time in GMT indicating the ordering for routing of the Task specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - :ivar ignore_capacity: A boolean indicating if a new task should respect a worker's capacity during assignment + :ivar ignore_capacity: A boolean that indicates if the Task should respect a Worker's capacity and availability during assignment. This field can only be used when the `RoutingTarget` field is set to a Worker SID. By setting `IgnoreCapacity` to a value of `true`, `1`, or `yes`, the Task will be routed to the Worker without respecting their capacity and availability. Any other value will enforce the Worker's capacity and availability. The default value of `IgnoreCapacity` is `true` when the `RoutingTarget` is set to a Worker SID. :ivar routing_target: A SID of a Worker, Queue, or Workflow to route a Task to """ @@ -536,7 +536,7 @@ def create( :param attributes: A URL-encoded JSON string with the attributes of the new task. This value is passed to the Workflow's `assignment_callback_url` when the Task is assigned to a Worker. For example: `{ \\\"task_type\\\": \\\"call\\\", \\\"twilio_call_sid\\\": \\\"CAxxx\\\", \\\"customer_ticket_number\\\": \\\"12345\\\" }`. :param virtual_start_time: The virtual start time to assign the new task and override the default. When supplied, the new task will have this virtual start time. When not supplied, the new task will have the virtual start time equal to `date_created`. Value can't be in the future. :param routing_target: A SID of a Worker, Queue, or Workflow to route a Task to - :param ignore_capacity: A boolean indicating if a new task should respect a worker's capacity during assignment + :param ignore_capacity: A boolean that indicates if the Task should respect a Worker's capacity and availability during assignment. This field can only be used when the `RoutingTarget` field is set to a Worker SID. By setting `IgnoreCapacity` to a value of `true`, `1`, or `yes`, the Task will be routed to the Worker without respecting their capacity and availability. Any other value will enforce the Worker's capacity and availability. The default value of `IgnoreCapacity` is `true` when the `RoutingTarget` is set to a Worker SID. :param task_queue_sid: The SID of the TaskQueue in which the Task belongs :returns: The created TaskInstance @@ -587,7 +587,7 @@ async def create_async( :param attributes: A URL-encoded JSON string with the attributes of the new task. This value is passed to the Workflow's `assignment_callback_url` when the Task is assigned to a Worker. For example: `{ \\\"task_type\\\": \\\"call\\\", \\\"twilio_call_sid\\\": \\\"CAxxx\\\", \\\"customer_ticket_number\\\": \\\"12345\\\" }`. :param virtual_start_time: The virtual start time to assign the new task and override the default. When supplied, the new task will have this virtual start time. When not supplied, the new task will have the virtual start time equal to `date_created`. Value can't be in the future. :param routing_target: A SID of a Worker, Queue, or Workflow to route a Task to - :param ignore_capacity: A boolean indicating if a new task should respect a worker's capacity during assignment + :param ignore_capacity: A boolean that indicates if the Task should respect a Worker's capacity and availability during assignment. This field can only be used when the `RoutingTarget` field is set to a Worker SID. By setting `IgnoreCapacity` to a value of `true`, `1`, or `yes`, the Task will be routed to the Worker without respecting their capacity and availability. Any other value will enforce the Worker's capacity and availability. The default value of `IgnoreCapacity` is `true` when the `RoutingTarget` is set to a Worker SID. :param task_queue_sid: The SID of the TaskQueue in which the Task belongs :returns: The created TaskInstance diff --git a/twilio/rest/trusthub/v1/compliance_inquiries.py b/twilio/rest/trusthub/v1/compliance_inquiries.py index 6fe6c297b..fe83b8630 100644 --- a/twilio/rest/trusthub/v1/compliance_inquiries.py +++ b/twilio/rest/trusthub/v1/compliance_inquiries.py @@ -61,30 +61,36 @@ def _proxy(self) -> "ComplianceInquiriesContext": ) return self._context - def update(self, primary_profile_sid: str) -> "ComplianceInquiriesInstance": + def update( + self, primary_profile_sid: str, theme_set_id: Union[str, object] = values.unset + ) -> "ComplianceInquiriesInstance": """ Update the ComplianceInquiriesInstance :param primary_profile_sid: The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile. + :param theme_set_id: Theme id for styling the inquiry form. :returns: The updated ComplianceInquiriesInstance """ return self._proxy.update( primary_profile_sid=primary_profile_sid, + theme_set_id=theme_set_id, ) async def update_async( - self, primary_profile_sid: str + self, primary_profile_sid: str, theme_set_id: Union[str, object] = values.unset ) -> "ComplianceInquiriesInstance": """ Asynchronous coroutine to update the ComplianceInquiriesInstance :param primary_profile_sid: The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile. + :param theme_set_id: Theme id for styling the inquiry form. :returns: The updated ComplianceInquiriesInstance """ return await self._proxy.update_async( primary_profile_sid=primary_profile_sid, + theme_set_id=theme_set_id, ) def __repr__(self) -> str: @@ -116,17 +122,21 @@ def __init__(self, version: Version, customer_id: str): **self._solution ) - def update(self, primary_profile_sid: str) -> ComplianceInquiriesInstance: + def update( + self, primary_profile_sid: str, theme_set_id: Union[str, object] = values.unset + ) -> ComplianceInquiriesInstance: """ Update the ComplianceInquiriesInstance :param primary_profile_sid: The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile. + :param theme_set_id: Theme id for styling the inquiry form. :returns: The updated ComplianceInquiriesInstance """ data = values.of( { "PrimaryProfileSid": primary_profile_sid, + "ThemeSetId": theme_set_id, } ) @@ -141,18 +151,20 @@ def update(self, primary_profile_sid: str) -> ComplianceInquiriesInstance: ) async def update_async( - self, primary_profile_sid: str + self, primary_profile_sid: str, theme_set_id: Union[str, object] = values.unset ) -> ComplianceInquiriesInstance: """ Asynchronous coroutine to update the ComplianceInquiriesInstance :param primary_profile_sid: The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile. + :param theme_set_id: Theme id for styling the inquiry form. :returns: The updated ComplianceInquiriesInstance """ data = values.of( { "PrimaryProfileSid": primary_profile_sid, + "ThemeSetId": theme_set_id, } ) @@ -193,12 +205,14 @@ def create( self, primary_profile_sid: str, notification_email: Union[str, object] = values.unset, + theme_set_id: Union[str, object] = values.unset, ) -> ComplianceInquiriesInstance: """ Create the ComplianceInquiriesInstance :param primary_profile_sid: The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile. :param notification_email: The email address that approval status updates will be sent to. If not specified, the email address associated with your primary customer profile will be used. + :param theme_set_id: Theme id for styling the inquiry form. :returns: The created ComplianceInquiriesInstance """ @@ -207,6 +221,7 @@ def create( { "PrimaryProfileSid": primary_profile_sid, "NotificationEmail": notification_email, + "ThemeSetId": theme_set_id, } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) @@ -221,12 +236,14 @@ async def create_async( self, primary_profile_sid: str, notification_email: Union[str, object] = values.unset, + theme_set_id: Union[str, object] = values.unset, ) -> ComplianceInquiriesInstance: """ Asynchronously create the ComplianceInquiriesInstance :param primary_profile_sid: The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile. :param notification_email: The email address that approval status updates will be sent to. If not specified, the email address associated with your primary customer profile will be used. + :param theme_set_id: Theme id for styling the inquiry form. :returns: The created ComplianceInquiriesInstance """ @@ -235,6 +252,7 @@ async def create_async( { "PrimaryProfileSid": primary_profile_sid, "NotificationEmail": notification_email, + "ThemeSetId": theme_set_id, } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) diff --git a/twilio/rest/verify/v2/service/__init__.py b/twilio/rest/verify/v2/service/__init__.py index 69a6cf853..9b8b4b4da 100644 --- a/twilio/rest/verify/v2/service/__init__.py +++ b/twilio/rest/verify/v2/service/__init__.py @@ -43,7 +43,7 @@ class ServiceInstance(InstanceResource): :ivar dtmf_input_required: Whether to ask the user to press a number before delivering the verify code in a phone call. :ivar tts_name: The name of an alternative text-to-speech service to use in phone calls. Applies only to TTS languages. :ivar do_not_share_warning_enabled: Whether to add a security warning at the end of an SMS verification body. Disabled by default and applies only to SMS. Example SMS body: `Your AppName verification code is: 1234. Don’t share this code with anyone; our employees will never ask for the code` - :ivar custom_code_enabled: Whether to allow sending verifications with a custom code instead of a randomly generated one. Not available for all customers. + :ivar custom_code_enabled: Whether to allow sending verifications with a custom code instead of a randomly generated one. :ivar push: Configurations for the Push factors (channel) created under this Service. :ivar totp: Configurations for the TOTP factors (channel) created under this Service. :ivar default_template_sid: @@ -183,7 +183,7 @@ def update( :param tts_name: The name of an alternative text-to-speech service to use in phone calls. Applies only to TTS languages. :param psd2_enabled: Whether to pass PSD2 transaction parameters when starting a verification. :param do_not_share_warning_enabled: Whether to add a privacy warning at the end of an SMS. **Disabled by default and applies only for SMS.** - :param custom_code_enabled: Whether to allow sending verifications with a custom code instead of a randomly generated one. Not available for all customers. + :param custom_code_enabled: Whether to allow sending verifications with a custom code instead of a randomly generated one. :param push_include_date: Optional configuration for the Push factors. If true, include the date in the Challenge's response. Otherwise, the date is omitted from the response. See [Challenge](https://www.twilio.com/docs/verify/api/challenge) resource’s details parameter for more info. Default: false. **Deprecated** do not use this parameter. :param push_apn_credential_sid: Optional configuration for the Push factors. Set the APN Credential for this service. This will allow to send push notifications to iOS devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) :param push_fcm_credential_sid: Optional configuration for the Push factors. Set the FCM Credential for this service. This will allow to send push notifications to Android devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) @@ -255,7 +255,7 @@ async def update_async( :param tts_name: The name of an alternative text-to-speech service to use in phone calls. Applies only to TTS languages. :param psd2_enabled: Whether to pass PSD2 transaction parameters when starting a verification. :param do_not_share_warning_enabled: Whether to add a privacy warning at the end of an SMS. **Disabled by default and applies only for SMS.** - :param custom_code_enabled: Whether to allow sending verifications with a custom code instead of a randomly generated one. Not available for all customers. + :param custom_code_enabled: Whether to allow sending verifications with a custom code instead of a randomly generated one. :param push_include_date: Optional configuration for the Push factors. If true, include the date in the Challenge's response. Otherwise, the date is omitted from the response. See [Challenge](https://www.twilio.com/docs/verify/api/challenge) resource’s details parameter for more info. Default: false. **Deprecated** do not use this parameter. :param push_apn_credential_sid: Optional configuration for the Push factors. Set the APN Credential for this service. This will allow to send push notifications to iOS devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) :param push_fcm_credential_sid: Optional configuration for the Push factors. Set the FCM Credential for this service. This will allow to send push notifications to Android devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) @@ -473,7 +473,7 @@ def update( :param tts_name: The name of an alternative text-to-speech service to use in phone calls. Applies only to TTS languages. :param psd2_enabled: Whether to pass PSD2 transaction parameters when starting a verification. :param do_not_share_warning_enabled: Whether to add a privacy warning at the end of an SMS. **Disabled by default and applies only for SMS.** - :param custom_code_enabled: Whether to allow sending verifications with a custom code instead of a randomly generated one. Not available for all customers. + :param custom_code_enabled: Whether to allow sending verifications with a custom code instead of a randomly generated one. :param push_include_date: Optional configuration for the Push factors. If true, include the date in the Challenge's response. Otherwise, the date is omitted from the response. See [Challenge](https://www.twilio.com/docs/verify/api/challenge) resource’s details parameter for more info. Default: false. **Deprecated** do not use this parameter. :param push_apn_credential_sid: Optional configuration for the Push factors. Set the APN Credential for this service. This will allow to send push notifications to iOS devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) :param push_fcm_credential_sid: Optional configuration for the Push factors. Set the FCM Credential for this service. This will allow to send push notifications to Android devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) @@ -561,7 +561,7 @@ async def update_async( :param tts_name: The name of an alternative text-to-speech service to use in phone calls. Applies only to TTS languages. :param psd2_enabled: Whether to pass PSD2 transaction parameters when starting a verification. :param do_not_share_warning_enabled: Whether to add a privacy warning at the end of an SMS. **Disabled by default and applies only for SMS.** - :param custom_code_enabled: Whether to allow sending verifications with a custom code instead of a randomly generated one. Not available for all customers. + :param custom_code_enabled: Whether to allow sending verifications with a custom code instead of a randomly generated one. :param push_include_date: Optional configuration for the Push factors. If true, include the date in the Challenge's response. Otherwise, the date is omitted from the response. See [Challenge](https://www.twilio.com/docs/verify/api/challenge) resource’s details parameter for more info. Default: false. **Deprecated** do not use this parameter. :param push_apn_credential_sid: Optional configuration for the Push factors. Set the APN Credential for this service. This will allow to send push notifications to iOS devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) :param push_fcm_credential_sid: Optional configuration for the Push factors. Set the FCM Credential for this service. This will allow to send push notifications to Android devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) @@ -775,7 +775,7 @@ def create( :param tts_name: The name of an alternative text-to-speech service to use in phone calls. Applies only to TTS languages. :param psd2_enabled: Whether to pass PSD2 transaction parameters when starting a verification. :param do_not_share_warning_enabled: Whether to add a security warning at the end of an SMS verification body. Disabled by default and applies only to SMS. Example SMS body: `Your AppName verification code is: 1234. Don’t share this code with anyone; our employees will never ask for the code` - :param custom_code_enabled: Whether to allow sending verifications with a custom code instead of a randomly generated one. Not available for all customers. + :param custom_code_enabled: Whether to allow sending verifications with a custom code instead of a randomly generated one. :param push_include_date: Optional configuration for the Push factors. If true, include the date in the Challenge's response. Otherwise, the date is omitted from the response. See [Challenge](https://www.twilio.com/docs/verify/api/challenge) resource’s details parameter for more info. Default: false. **Deprecated** do not use this parameter. This timestamp value is the same one as the one found in `date_created`, please use that one instead. :param push_apn_credential_sid: Optional configuration for the Push factors. Set the APN Credential for this service. This will allow to send push notifications to iOS devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) :param push_fcm_credential_sid: Optional configuration for the Push factors. Set the FCM Credential for this service. This will allow to send push notifications to Android devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) @@ -863,7 +863,7 @@ async def create_async( :param tts_name: The name of an alternative text-to-speech service to use in phone calls. Applies only to TTS languages. :param psd2_enabled: Whether to pass PSD2 transaction parameters when starting a verification. :param do_not_share_warning_enabled: Whether to add a security warning at the end of an SMS verification body. Disabled by default and applies only to SMS. Example SMS body: `Your AppName verification code is: 1234. Don’t share this code with anyone; our employees will never ask for the code` - :param custom_code_enabled: Whether to allow sending verifications with a custom code instead of a randomly generated one. Not available for all customers. + :param custom_code_enabled: Whether to allow sending verifications with a custom code instead of a randomly generated one. :param push_include_date: Optional configuration for the Push factors. If true, include the date in the Challenge's response. Otherwise, the date is omitted from the response. See [Challenge](https://www.twilio.com/docs/verify/api/challenge) resource’s details parameter for more info. Default: false. **Deprecated** do not use this parameter. This timestamp value is the same one as the one found in `date_created`, please use that one instead. :param push_apn_credential_sid: Optional configuration for the Push factors. Set the APN Credential for this service. This will allow to send push notifications to iOS devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) :param push_fcm_credential_sid: Optional configuration for the Push factors. Set the FCM Credential for this service. This will allow to send push notifications to Android devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) From e848451ed378cf12bba443051d8f04d19e9c0153 Mon Sep 17 00:00:00 2001 From: Twilio Date: Mon, 26 Aug 2024 11:23:30 +0000 Subject: [PATCH 06/37] Release 9.2.4 --- setup.py | 2 +- twilio/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 8fee9aa18..c775b6c76 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setup( name="twilio", - version="9.2.3", + version="9.2.4", 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 bb8cd36f5..17b3d8825 100644 --- a/twilio/__init__.py +++ b/twilio/__init__.py @@ -1,2 +1,2 @@ -__version_info__ = ("9", "2", "3") +__version_info__ = ("9", "2", "4") __version__ = ".".join(__version_info__) From ba7da14775a5271accbf8fa2841d008b356287ce Mon Sep 17 00:00:00 2001 From: Twilio Date: Thu, 5 Sep 2024 12:55:48 +0000 Subject: [PATCH 07/37] [Librarian] Regenerated @ 78bf2bbef74e4846ca8353fbdee038a6b8080c59 2250ef3ba08540233f688bf6aaa55e9c94febf3b --- CHANGES.md | 10 + twilio/rest/__init__.py | 15 + twilio/rest/content/v1/content/__init__.py | 117 ++++++- twilio/rest/iam/IamBase.py | 44 +++ twilio/rest/iam/v1/__init__.py | 59 ++++ twilio/rest/iam/v1/api_key.py | 328 ++++++++++++++++++ twilio/rest/iam/v1/get_api_keys.py | 294 ++++++++++++++++ twilio/rest/iam/v1/new_api_key.py | 149 ++++++++ twilio/rest/numbers/v1/porting_port_in.py | 4 +- .../supporting_document.py | 2 + .../task_queue_real_time_statistics.py | 2 +- 11 files changed, 1018 insertions(+), 6 deletions(-) create mode 100644 twilio/rest/iam/IamBase.py create mode 100644 twilio/rest/iam/v1/__init__.py create mode 100644 twilio/rest/iam/v1/api_key.py create mode 100644 twilio/rest/iam/v1/get_api_keys.py create mode 100644 twilio/rest/iam/v1/new_api_key.py diff --git a/CHANGES.md b/CHANGES.md index 2222dfc4d..ad840949f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,16 @@ twilio-python Changelog Here you can see the full list of changes between each twilio-python release. +[2024-09-05] Version 9.3.0 +-------------------------- +**Iam** +- updated library_visibility public for new public apikeys + +**Numbers** +- Add new field in Error Codes for Regulatory Compliance. +- Change typing of Port In Request date_created field to date_time instead of date **(breaking change)** + + [2024-08-26] Version 9.2.4 -------------------------- **Library - Chore** diff --git a/twilio/rest/__init__.py b/twilio/rest/__init__.py index 2dc0a4930..35c57385a 100644 --- a/twilio/rest/__init__.py +++ b/twilio/rest/__init__.py @@ -23,6 +23,7 @@ from twilio.rest.events import Events from twilio.rest.flex_api import FlexApi from twilio.rest.frontline_api import FrontlineApi + from twilio.rest.iam import Iam from twilio.rest.insights import Insights from twilio.rest.intelligence import Intelligence from twilio.rest.ip_messaging import IpMessaging @@ -131,6 +132,7 @@ def __init__( self._events: Optional["Events"] = None self._flex_api: Optional["FlexApi"] = None self._frontline_api: Optional["FrontlineApi"] = None + self._iam: Optional["Iam"] = None self._insights: Optional["Insights"] = None self._intelligence: Optional["Intelligence"] = None self._ip_messaging: Optional["IpMessaging"] = None @@ -275,6 +277,19 @@ def frontline_api(self) -> "FrontlineApi": self._frontline_api = FrontlineApi(self) return self._frontline_api + @property + def iam(self) -> "Iam": + """ + Access the Iam Twilio Domain + + :returns: Iam Twilio Domain + """ + if self._iam is None: + from twilio.rest.iam import Iam + + self._iam = Iam(self) + return self._iam + @property def insights(self) -> "Insights": """ diff --git a/twilio/rest/content/v1/content/__init__.py b/twilio/rest/content/v1/content/__init__.py index f2dec1276..3ddc8b926 100644 --- a/twilio/rest/content/v1/content/__init__.py +++ b/twilio/rest/content/v1/content/__init__.py @@ -32,11 +32,15 @@ class AuthenticationActionType(object): class CallToActionActionType(object): URL = "URL" PHONE_NUMBER = "PHONE_NUMBER" + COPY_CODE = "COPY_CODE" + VOICE_CALL = "VOICE_CALL" class CardActionType(object): URL = "URL" PHONE_NUMBER = "PHONE_NUMBER" QUICK_REPLY = "QUICK_REPLY" + COPY_CODE = "COPY_CODE" + VOICE_CALL = "VOICE_CALL" class CarouselActionType(object): URL = "URL" @@ -321,7 +325,7 @@ class CallToActionAction(object): :ivar title: :ivar url: :ivar phone: - :ivar id: + :ivar code: """ def __init__(self, payload: Dict[str, Any]): @@ -332,7 +336,7 @@ def __init__(self, payload: Dict[str, Any]): self.title: Optional[str] = payload.get("title") self.url: Optional[str] = payload.get("url") self.phone: Optional[str] = payload.get("phone") - self.id: Optional[str] = payload.get("id") + self.code: Optional[str] = payload.get("code") def to_dict(self): return { @@ -340,7 +344,7 @@ def to_dict(self): "title": self.title, "url": self.url, "phone": self.phone, - "id": self.id, + "code": self.code, } class CardAction(object): @@ -350,6 +354,7 @@ class CardAction(object): :ivar url: :ivar phone: :ivar id: + :ivar code: """ def __init__(self, payload: Dict[str, Any]): @@ -359,6 +364,7 @@ def __init__(self, payload: Dict[str, Any]): self.url: Optional[str] = payload.get("url") self.phone: Optional[str] = payload.get("phone") self.id: Optional[str] = payload.get("id") + self.code: Optional[str] = payload.get("code") def to_dict(self): return { @@ -367,6 +373,7 @@ def to_dict(self): "url": self.url, "phone": self.phone, "id": self.id, + "code": self.code, } class CarouselAction(object): @@ -474,6 +481,76 @@ def to_dict(self): "types": self.types.to_dict(), } + class FlowsPage(object): + """ + :ivar id: + :ivar next_page_id: + :ivar title: + :ivar subtitle: + :ivar layout: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.id: Optional[str] = payload.get("id") + self.next_page_id: Optional[str] = payload.get("next_page_id") + self.title: Optional[str] = payload.get("title") + self.subtitle: Optional[str] = payload.get("subtitle") + self.layout: Optional[List[ContentList.FlowsPageComponent]] = payload.get( + "layout" + ) + + def to_dict(self): + return { + "id": self.id, + "next_page_id": self.next_page_id, + "title": self.title, + "subtitle": self.subtitle, + "layout": [layout.to_dict() for layout in self.layout], + } + + class FlowsPageComponent(object): + """ + :ivar label: + :ivar type: + :ivar text: + :ivar options: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.label: Optional[str] = payload.get("label") + self.type: Optional[str] = payload.get("type") + self.text: Optional[str] = payload.get("text") + self.options: Optional[List[ContentList.FlowsPageComponentSelectItem]] = ( + payload.get("options") + ) + + def to_dict(self): + return { + "label": self.label, + "type": self.type, + "text": self.text, + "options": [options.to_dict() for options in self.options], + } + + class FlowsPageComponentSelectItem(object): + """ + :ivar id: + :ivar title: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.id: Optional[str] = payload.get("id") + self.title: Optional[str] = payload.get("title") + + def to_dict(self): + return { + "id": self.id, + "title": self.title, + } + class ListItem(object): """ :ivar id: @@ -606,6 +683,35 @@ def to_dict(self): "dynamic_items": self.dynamic_items, } + class TwilioFlows(object): + """ + :ivar body: + :ivar button_text: + :ivar subtitle: + :ivar media_url: + :ivar pages: + :ivar type: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.body: Optional[str] = payload.get("body") + self.button_text: Optional[str] = payload.get("button_text") + self.subtitle: Optional[str] = payload.get("subtitle") + self.media_url: Optional[str] = payload.get("media_url") + self.pages: Optional[List[ContentList.FlowsPage]] = payload.get("pages") + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "body": self.body, + "button_text": self.button_text, + "subtitle": self.subtitle, + "media_url": self.media_url, + "pages": [pages.to_dict() for pages in self.pages], + "type": self.type, + } + class TwilioListPicker(object): """ :ivar body: @@ -707,6 +813,7 @@ class Types(object): :ivar twilio_card: :ivar twilio_catalog: :ivar twilio_carousel: + :ivar twilio_flows: :ivar whatsapp_card: :ivar whatsapp_authentication: """ @@ -740,6 +847,9 @@ def __init__(self, payload: Dict[str, Any]): self.twilio_carousel: Optional[ContentList.TwilioCarousel] = payload.get( "twilio_carousel" ) + self.twilio_flows: Optional[ContentList.TwilioFlows] = payload.get( + "twilio_flows" + ) self.whatsapp_card: Optional[ContentList.WhatsappCard] = payload.get( "whatsapp_card" ) @@ -758,6 +868,7 @@ def to_dict(self): "twilio_card": self.twilio_card.to_dict(), "twilio_catalog": self.twilio_catalog.to_dict(), "twilio_carousel": self.twilio_carousel.to_dict(), + "twilio_flows": self.twilio_flows.to_dict(), "whatsapp_card": self.whatsapp_card.to_dict(), "whatsapp_authentication": self.whatsapp_authentication.to_dict(), } diff --git a/twilio/rest/iam/IamBase.py b/twilio/rest/iam/IamBase.py new file mode 100644 index 000000000..2882ec145 --- /dev/null +++ b/twilio/rest/iam/IamBase.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.iam.v1 import V1 + + +class IamBase(Domain): + + def __init__(self, twilio: Client): + """ + Initialize the Iam Domain + + :returns: Domain for Iam + """ + super().__init__(twilio, "https://iam.twilio.com") + self._v1: Optional[V1] = None + + @property + def v1(self) -> V1: + """ + :returns: Versions v1 of Iam + """ + if self._v1 is None: + self._v1 = V1(self) + return self._v1 + + def __repr__(self) -> str: + """ + Provide a friendly representation + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/iam/v1/__init__.py b/twilio/rest/iam/v1/__init__.py new file mode 100644 index 000000000..0c4694734 --- /dev/null +++ b/twilio/rest/iam/v1/__init__.py @@ -0,0 +1,59 @@ +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 Optional +from twilio.base.version import Version +from twilio.base.domain import Domain +from twilio.rest.iam.v1.api_key import ApiKeyList +from twilio.rest.iam.v1.get_api_keys import GetApiKeysList +from twilio.rest.iam.v1.new_api_key import NewApiKeyList + + +class V1(Version): + + def __init__(self, domain: Domain): + """ + Initialize the V1 version of Iam + + :param domain: The Twilio.iam domain + """ + super().__init__(domain, "v1") + self._api_key: Optional[ApiKeyList] = None + self._get_api_keys: Optional[GetApiKeysList] = None + self._new_api_key: Optional[NewApiKeyList] = None + + @property + def api_key(self) -> ApiKeyList: + if self._api_key is None: + self._api_key = ApiKeyList(self) + return self._api_key + + @property + def get_api_keys(self) -> GetApiKeysList: + if self._get_api_keys is None: + self._get_api_keys = GetApiKeysList(self) + return self._get_api_keys + + @property + def new_api_key(self) -> NewApiKeyList: + if self._new_api_key is None: + self._new_api_key = NewApiKeyList(self) + return self._new_api_key + + def __repr__(self) -> str: + """ + Provide a friendly representation + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/iam/v1/api_key.py b/twilio/rest/iam/v1/api_key.py new file mode 100644 index 000000000..b94889fcc --- /dev/null +++ b/twilio/rest/iam/v1/api_key.py @@ -0,0 +1,328 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Iam + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, Optional, Union +from twilio.base import deserialize, serialize, values +from twilio.base.instance_context import InstanceContext +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class ApiKeyInstance(InstanceResource): + """ + :ivar sid: The unique string that we created to identify the Key resource. + :ivar friendly_name: The string that you assigned to describe the resource. + :ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + :ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + :ivar policy: The \\`Policy\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys). + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None + ): + super().__init__(version) + + self.sid: Optional[str] = payload.get("sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.date_created: Optional[datetime] = deserialize.rfc2822_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime( + payload.get("date_updated") + ) + self.policy: Optional[Dict[str, object]] = payload.get("policy") + + self._solution = { + "sid": sid or self.sid, + } + self._context: Optional[ApiKeyContext] = None + + @property + def _proxy(self) -> "ApiKeyContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: ApiKeyContext for this ApiKeyInstance + """ + if self._context is None: + self._context = ApiKeyContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the ApiKeyInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the ApiKeyInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def fetch(self) -> "ApiKeyInstance": + """ + Fetch the ApiKeyInstance + + + :returns: The fetched ApiKeyInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "ApiKeyInstance": + """ + Asynchronous coroutine to fetch the ApiKeyInstance + + + :returns: The fetched ApiKeyInstance + """ + return await self._proxy.fetch_async() + + def update( + self, + friendly_name: Union[str, object] = values.unset, + policy: Union[object, object] = values.unset, + ) -> "ApiKeyInstance": + """ + Update the ApiKeyInstance + + :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long. + :param policy: The \\\\`Policy\\\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys). + + :returns: The updated ApiKeyInstance + """ + return self._proxy.update( + friendly_name=friendly_name, + policy=policy, + ) + + async def update_async( + self, + friendly_name: Union[str, object] = values.unset, + policy: Union[object, object] = values.unset, + ) -> "ApiKeyInstance": + """ + Asynchronous coroutine to update the ApiKeyInstance + + :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long. + :param policy: The \\\\`Policy\\\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys). + + :returns: The updated ApiKeyInstance + """ + return await self._proxy.update_async( + friendly_name=friendly_name, + policy=policy, + ) + + 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 ApiKeyContext(InstanceContext): + + def __init__(self, version: Version, sid: str): + """ + Initialize the ApiKeyContext + + :param version: Version that contains the resource + :param sid: The Twilio-provided string that uniquely identifies the Key resource to update. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/Keys/{sid}".format(**self._solution) + + def delete(self) -> bool: + """ + Deletes the ApiKeyInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._version.delete( + method="DELETE", + uri=self._uri, + ) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the ApiKeyInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._version.delete_async( + method="DELETE", + uri=self._uri, + ) + + def fetch(self) -> ApiKeyInstance: + """ + Fetch the ApiKeyInstance + + + :returns: The fetched ApiKeyInstance + """ + + payload = self._version.fetch( + method="GET", + uri=self._uri, + ) + + return ApiKeyInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + async def fetch_async(self) -> ApiKeyInstance: + """ + Asynchronous coroutine to fetch the ApiKeyInstance + + + :returns: The fetched ApiKeyInstance + """ + + payload = await self._version.fetch_async( + method="GET", + uri=self._uri, + ) + + return ApiKeyInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + def update( + self, + friendly_name: Union[str, object] = values.unset, + policy: Union[object, object] = values.unset, + ) -> ApiKeyInstance: + """ + Update the ApiKeyInstance + + :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long. + :param policy: The \\\\`Policy\\\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys). + + :returns: The updated ApiKeyInstance + """ + data = values.of( + { + "FriendlyName": friendly_name, + "Policy": serialize.object(policy), + } + ) + + payload = self._version.update( + method="POST", + uri=self._uri, + data=data, + ) + + return ApiKeyInstance(self._version, payload, sid=self._solution["sid"]) + + async def update_async( + self, + friendly_name: Union[str, object] = values.unset, + policy: Union[object, object] = values.unset, + ) -> ApiKeyInstance: + """ + Asynchronous coroutine to update the ApiKeyInstance + + :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long. + :param policy: The \\\\`Policy\\\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys). + + :returns: The updated ApiKeyInstance + """ + data = values.of( + { + "FriendlyName": friendly_name, + "Policy": serialize.object(policy), + } + ) + + payload = await self._version.update_async( + method="POST", + uri=self._uri, + data=data, + ) + + return ApiKeyInstance(self._version, payload, sid=self._solution["sid"]) + + 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 ApiKeyList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the ApiKeyList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, sid: str) -> ApiKeyContext: + """ + Constructs a ApiKeyContext + + :param sid: The Twilio-provided string that uniquely identifies the Key resource to update. + """ + return ApiKeyContext(self._version, sid=sid) + + def __call__(self, sid: str) -> ApiKeyContext: + """ + Constructs a ApiKeyContext + + :param sid: The Twilio-provided string that uniquely identifies the Key resource to update. + """ + return ApiKeyContext(self._version, sid=sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/iam/v1/get_api_keys.py b/twilio/rest/iam/v1/get_api_keys.py new file mode 100644 index 000000000..3a3e9bda7 --- /dev/null +++ b/twilio/rest/iam/v1/get_api_keys.py @@ -0,0 +1,294 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Iam + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, 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 GetApiKeysInstance(InstanceResource): + """ + :ivar sid: The unique string that we created to identify the Key resource. + :ivar friendly_name: The string that you assigned to describe the resource. + :ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + :ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.sid: Optional[str] = payload.get("sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.date_created: Optional[datetime] = deserialize.rfc2822_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime( + payload.get("date_updated") + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class GetApiKeysPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> GetApiKeysInstance: + """ + Build an instance of GetApiKeysInstance + + :param payload: Payload response from the API + """ + return GetApiKeysInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class GetApiKeysList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the GetApiKeysList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Keys" + + def stream( + self, + account_sid: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[GetApiKeysInstance]: + """ + Streams GetApiKeysInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param str account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource. + :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(account_sid=account_sid, page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + account_sid: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[GetApiKeysInstance]: + """ + Asynchronously streams GetApiKeysInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param str account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource. + :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( + account_sid=account_sid, page_size=limits["page_size"] + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + account_sid: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[GetApiKeysInstance]: + """ + Lists GetApiKeysInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource. + :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( + account_sid=account_sid, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + account_sid: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[GetApiKeysInstance]: + """ + Asynchronously lists GetApiKeysInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource. + :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( + account_sid=account_sid, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + account_sid: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> GetApiKeysPage: + """ + Retrieve a single page of GetApiKeysInstance records from the API. + Request is executed immediately + + :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource. + :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 GetApiKeysInstance + """ + data = values.of( + { + "AccountSid": account_sid, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = self._version.page(method="GET", uri=self._uri, params=data) + return GetApiKeysPage(self._version, response) + + async def page_async( + self, + account_sid: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> GetApiKeysPage: + """ + Asynchronously retrieve a single page of GetApiKeysInstance records from the API. + Request is executed immediately + + :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource. + :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 GetApiKeysInstance + """ + data = values.of( + { + "AccountSid": account_sid, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data + ) + return GetApiKeysPage(self._version, response) + + def get_page(self, target_url: str) -> GetApiKeysPage: + """ + Retrieve a specific page of GetApiKeysInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of GetApiKeysInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return GetApiKeysPage(self._version, response) + + async def get_page_async(self, target_url: str) -> GetApiKeysPage: + """ + Asynchronously retrieve a specific page of GetApiKeysInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of GetApiKeysInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return GetApiKeysPage(self._version, response) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/iam/v1/new_api_key.py b/twilio/rest/iam/v1/new_api_key.py new file mode 100644 index 000000000..e3f9fa05a --- /dev/null +++ b/twilio/rest/iam/v1/new_api_key.py @@ -0,0 +1,149 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Iam + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, Optional, Union +from twilio.base import deserialize, serialize, values + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class NewApiKeyInstance(InstanceResource): + + class Keytype(object): + RESTRICTED = "restricted" + + """ + :ivar sid: The unique string that that we created to identify the NewKey resource. You will use this as the basic-auth `user` when authenticating to the API. + :ivar friendly_name: The string that you assigned to describe the resource. + :ivar date_created: The date and time in GMT that the API Key was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + :ivar date_updated: The date and time in GMT that the new API Key was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + :ivar secret: The secret your application uses to sign Access Tokens and to authenticate to the REST API (you will use this as the basic-auth `password`). **Note that for security reasons, this field is ONLY returned when the API Key is first created.** + :ivar policy: Collection of allow assertions. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.sid: Optional[str] = payload.get("sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.date_created: Optional[datetime] = deserialize.rfc2822_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime( + payload.get("date_updated") + ) + self.secret: Optional[str] = payload.get("secret") + self.policy: Optional[Dict[str, object]] = payload.get("policy") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class NewApiKeyList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the NewApiKeyList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Keys" + + def create( + self, + account_sid: str, + friendly_name: Union[str, object] = values.unset, + key_type: Union["NewApiKeyInstance.Keytype", object] = values.unset, + policy: Union[object, object] = values.unset, + ) -> NewApiKeyInstance: + """ + Create the NewApiKeyInstance + + :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource. + :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long. + :param key_type: + :param policy: The \\\\`Policy\\\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys). + + :returns: The created NewApiKeyInstance + """ + + data = values.of( + { + "AccountSid": account_sid, + "FriendlyName": friendly_name, + "KeyType": key_type, + "Policy": serialize.object(policy), + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return NewApiKeyInstance(self._version, payload) + + async def create_async( + self, + account_sid: str, + friendly_name: Union[str, object] = values.unset, + key_type: Union["NewApiKeyInstance.Keytype", object] = values.unset, + policy: Union[object, object] = values.unset, + ) -> NewApiKeyInstance: + """ + Asynchronously create the NewApiKeyInstance + + :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource. + :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long. + :param key_type: + :param policy: The \\\\`Policy\\\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys). + + :returns: The created NewApiKeyInstance + """ + + data = values.of( + { + "AccountSid": account_sid, + "FriendlyName": friendly_name, + "KeyType": key_type, + "Policy": serialize.object(policy), + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return NewApiKeyInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v1/porting_port_in.py b/twilio/rest/numbers/v1/porting_port_in.py index 9ce6b7b4c..02844a09b 100644 --- a/twilio/rest/numbers/v1/porting_port_in.py +++ b/twilio/rest/numbers/v1/porting_port_in.py @@ -12,7 +12,7 @@ Do not edit the class manually. """ -from datetime import date +from datetime import date, datetime from typing import Any, Dict, List, Optional, Union from twilio.base import deserialize, values from twilio.base.instance_context import InstanceContext @@ -70,7 +70,7 @@ def __init__( "phone_numbers" ) self.documents: Optional[List[str]] = payload.get("documents") - self.date_created: Optional[date] = deserialize.iso8601_date( + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) diff --git a/twilio/rest/numbers/v2/regulatory_compliance/supporting_document.py b/twilio/rest/numbers/v2/regulatory_compliance/supporting_document.py index afa6579a1..c343e91ed 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/supporting_document.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/supporting_document.py @@ -39,6 +39,7 @@ class Status(object): :ivar mime_type: The image type uploaded in the Supporting Document container. :ivar status: :ivar failure_reason: The failure reason of the Supporting Document Resource. + :ivar errors: A list of errors that occurred during the registering RC Bundle :ivar type: The type of the Supporting Document. :ivar attributes: The set of parameters that are the attributes of the Supporting Documents resource which are listed in the Supporting Document Types. :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. @@ -59,6 +60,7 @@ def __init__( "status" ) self.failure_reason: Optional[str] = payload.get("failure_reason") + self.errors: Optional[List[Dict[str, object]]] = payload.get("errors") self.type: Optional[str] = payload.get("type") self.attributes: Optional[Dict[str, object]] = payload.get("attributes") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( diff --git a/twilio/rest/taskrouter/v1/workspace/task_queue/task_queue_real_time_statistics.py b/twilio/rest/taskrouter/v1/workspace/task_queue/task_queue_real_time_statistics.py index faca80470..4d4198ac8 100644 --- a/twilio/rest/taskrouter/v1/workspace/task_queue/task_queue_real_time_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/task_queue/task_queue_real_time_statistics.py @@ -31,7 +31,7 @@ class TaskQueueRealTimeStatisticsInstance(InstanceResource): :ivar task_queue_sid: The SID of the TaskQueue from which these statistics were calculated. :ivar tasks_by_priority: The number of Tasks by priority. For example: `{\"0\": \"10\", \"99\": \"5\"}` shows 10 Tasks at priority 0 and 5 at priority 99. :ivar tasks_by_status: The number of Tasks by their current status. For example: `{\"pending\": \"1\", \"reserved\": \"3\", \"assigned\": \"2\", \"completed\": \"5\"}`. - :ivar total_available_workers: The total number of Workers available for Tasks in the TaskQueue. + :ivar total_available_workers: The total number of Workers in the TaskQueue with an `available` status. Workers with an `available` status may already have active interactions or may have none. :ivar total_eligible_workers: The total number of Workers eligible for Tasks in the TaskQueue, independent of their Activity state. :ivar total_tasks: The total number of Tasks. :ivar workspace_sid: The SID of the Workspace that contains the TaskQueue. From 74b506ec8e7207ffbbeabd5c0e71b47ce41a70b4 Mon Sep 17 00:00:00 2001 From: Twilio Date: Thu, 5 Sep 2024 13:00:28 +0000 Subject: [PATCH 08/37] Release 9.3.0 --- setup.py | 2 +- twilio/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index c775b6c76..6366ea68e 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setup( name="twilio", - version="9.2.4", + version="9.3.0", description="Twilio API client and TwiML generator", author="Twilio", help_center="https://www.twilio.com/help/contact", diff --git a/twilio/__init__.py b/twilio/__init__.py index 17b3d8825..529960ecb 100644 --- a/twilio/__init__.py +++ b/twilio/__init__.py @@ -1,2 +1,2 @@ -__version_info__ = ("9", "2", "4") +__version_info__ = ("9", "3", "0") __version__ = ".".join(__version_info__) From 3e246e452b668024609a995af44b02922f79145a Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 17 Sep 2024 16:26:15 +0530 Subject: [PATCH 09/37] Python Orgs Api Changes --- tests/cluster/test_cluster.py | 9 + tests/cluster/test_webhook.py | 156 +++--- twilio/base/client_base.py | 30 +- twilio/base/domain.py | 2 +- twilio/base/exceptions.py | 3 +- twilio/base/oauth_token_base.py | 27 +- twilio/base/version.py | 24 +- twilio/http/token_manager_initializer.py | 4 +- twilio/rest/__init__.py | 14 - twilio/rest/preview_iam/PreviewIamBase.py | 37 +- twilio/rest/preview_iam/__init__.py | 57 ++ .../preview_iam/organizations/__init__.py | 58 ++ .../rest/preview_iam/organizations/account.py | 422 ++++++++++++++ .../organizations/role_assignment.py | 525 ++++++++++++++++++ twilio/rest/preview_iam/v1/__init__.py | 51 ++ twilio/rest/preview_iam/v1/authorize.py | 126 +++++ .../{organizations => v1}/token.py | 140 ++--- 17 files changed, 1488 insertions(+), 197 deletions(-) create mode 100644 twilio/rest/preview_iam/__init__.py create mode 100644 twilio/rest/preview_iam/organizations/__init__.py create mode 100644 twilio/rest/preview_iam/organizations/account.py create mode 100644 twilio/rest/preview_iam/organizations/role_assignment.py create mode 100644 twilio/rest/preview_iam/v1/__init__.py create mode 100644 twilio/rest/preview_iam/v1/authorize.py rename twilio/rest/preview_iam/{organizations => v1}/token.py (59%) diff --git a/tests/cluster/test_cluster.py b/tests/cluster/test_cluster.py index 556fa8da7..76a6f85d0 100644 --- a/tests/cluster/test_cluster.py +++ b/tests/cluster/test_cluster.py @@ -19,6 +19,15 @@ def setUp(self): ) self.voice_twiml = VoiceResponse() + + def test_token_fetch(self): + token = self.client.preview_iam.token.create( + grant_type = GRANT_TYPE, + client_id = CLIENT_ID, + client_secret = CLIENT_SECRET) + print(f'{token}') + + def test_send_text_message(self): msg = self.client.messages.create( to=self.to_number, from_=self.from_number, body="hello world" diff --git a/tests/cluster/test_webhook.py b/tests/cluster/test_webhook.py index 307cf3d39..7cf8fbac8 100644 --- a/tests/cluster/test_webhook.py +++ b/tests/cluster/test_webhook.py @@ -29,81 +29,81 @@ def process_request(self): ) -# class WebhookTest(unittest.TestCase): -# def setUp(self): -# api_key = os.environ["TWILIO_API_KEY"] -# api_secret = os.environ["TWILIO_API_SECRET"] -# account_sid = os.environ["TWILIO_ACCOUNT_SID"] -# self.client = Client(api_key, api_secret, account_sid) -# -# portNumber = 7777 -# self.validation_server = HTTPServer(("", portNumber), RequestHandler) -# self.tunnel = ngrok.connect(portNumber) -# self.flow_sid = "" -# _thread.start_new_thread(self.start_http_server, ()) -# -# def start_http_server(self): -# self.validation_server.serve_forever() -# -# def tearDown(self): -# self.client.studio.v2.flows(self.flow_sid).delete() -# ngrok.kill() -# self.validation_server.shutdown() -# self.validation_server.server_close() -# -# def create_studio_flow(self, url, method): -# flow = self.client.studio.v2.flows.create( -# friendly_name="Python Cluster Test Flow", -# status="published", -# definition={ -# "description": "Studio Flow", -# "states": [ -# { -# "name": "Trigger", -# "type": "trigger", -# "transitions": [ -# { -# "next": "httpRequest", -# "event": "incomingRequest", -# }, -# ], -# "properties": {}, -# }, -# { -# "name": "httpRequest", -# "type": "make-http-request", -# "transitions": [], -# "properties": { -# "method": method, -# "content_type": "application/x-www-form-urlencoded;charset=utf-8", -# "url": url, -# }, -# }, -# ], -# "initial_state": "Trigger", -# "flags": { -# "allow_concurrent_calls": True, -# }, -# }, -# ) -# return flow -# -# def validate(self, method): -# flow = self.create_studio_flow(url=self.tunnel.public_url, method=method) -# self.flow_sid = flow.sid -# time.sleep(5) -# self.client.studio.v2.flows(self.flow_sid).executions.create( -# to="to", from_="from" -# ) -# -# def test_get(self): -# time.sleep(5) -# self.validate("GET") -# time.sleep(5) -# self.assertEqual(RequestHandler.is_request_valid, True) -# -# def test_post(self): -# time.sleep(5) -# self.validate("POST") -# time.sleep(5) -# self.assertEqual(RequestHandler.is_request_valid, True) +class WebhookTest(unittest.TestCase): + def setUp(self): + api_key = os.environ["TWILIO_API_KEY"] + api_secret = os.environ["TWILIO_API_SECRET"] + account_sid = os.environ["TWILIO_ACCOUNT_SID"] + self.client = Client(api_key, api_secret, account_sid) + + portNumber = 7777 + self.validation_server = HTTPServer(("", portNumber), RequestHandler) + self.tunnel = ngrok.connect(portNumber) + self.flow_sid = "" + _thread.start_new_thread(self.start_http_server, ()) + + def start_http_server(self): + self.validation_server.serve_forever() + + def tearDown(self): + self.client.studio.v2.flows(self.flow_sid).delete() + ngrok.kill() + self.validation_server.shutdown() + self.validation_server.server_close() + + def create_studio_flow(self, url, method): + flow = self.client.studio.v2.flows.create( + friendly_name="Python Cluster Test Flow", + status="published", + definition={ + "description": "Studio Flow", + "states": [ + { + "name": "Trigger", + "type": "trigger", + "transitions": [ + { + "next": "httpRequest", + "event": "incomingRequest", + }, + ], + "properties": {}, + }, + { + "name": "httpRequest", + "type": "make-http-request", + "transitions": [], + "properties": { + "method": method, + "content_type": "application/x-www-form-urlencoded;charset=utf-8", + "url": url, + }, + }, + ], + "initial_state": "Trigger", + "flags": { + "allow_concurrent_calls": True, + }, + }, + ) + return flow + + def validate(self, method): + flow = self.create_studio_flow(url=self.tunnel.public_url, method=method) + self.flow_sid = flow.sid + time.sleep(5) + self.client.studio.v2.flows(self.flow_sid).executions.create( + to="to", from_="from" + ) + + def test_get(self): + time.sleep(5) + self.validate("GET") + time.sleep(5) + self.assertEqual(RequestHandler.is_request_valid, True) + + def test_post(self): + time.sleep(5) + self.validate("POST") + time.sleep(5) + self.assertEqual(RequestHandler.is_request_valid, True) diff --git a/twilio/base/client_base.py b/twilio/base/client_base.py index 700e420ad..1bee0f613 100644 --- a/twilio/base/client_base.py +++ b/twilio/base/client_base.py @@ -70,7 +70,7 @@ def request( timeout: Optional[float] = None, allow_redirects: bool = False, is_oauth: bool = False, - domain: Optional[str] = None + domain: Optional[str] = None, ) -> Response: """ Makes a request to the Twilio API using the configured http client @@ -87,15 +87,21 @@ def request( :returns: Response from the Twilio API """ + + print('*****') if not is_oauth: auth = self.get_auth(auth) headers = self.get_headers(method, headers) uri = self.get_hostname(uri) if is_oauth: - OauthTokenBase = dynamic_import("twilio.base.oauth_token_base", "OauthTokenBase") - token = OauthTokenBase().get_oauth_token(domain, "v1", self.username, self.password) - headers['Authorization'] = f'Bearer {token}' - headers.get('Authorization') + OauthTokenBase = dynamic_import( + "twilio.base.oauth_token_base", "OauthTokenBase" + ) + token = OauthTokenBase().get_oauth_token( + domain, "v1", self.username, self.password + ) + headers["Authorization"] = f"Bearer {token}" + headers.get("Authorization") return self.http_client.request( method, @@ -145,10 +151,14 @@ async def request_async( headers = self.get_headers(method, headers) uri = self.get_hostname(uri) if is_oauth: - OauthTokenBase = dynamic_import("twilio.base.oauth_token_base", "OauthTokenBase") - token = OauthTokenBase().get_oauth_token(domain, "v1", self.username, self.password) - headers['Authorization'] = f'Bearer {token}' - headers.get('Authorization') + OauthTokenBase = dynamic_import( + "twilio.base.oauth_token_base", "OauthTokenBase" + ) + token = OauthTokenBase().get_oauth_token( + domain, "v1", self.username, self.password + ) + headers["Authorization"] = f"Bearer {token}" + headers.get("Authorization") return await self.http_client.request( method, @@ -247,7 +257,9 @@ def __repr__(self) -> str: """ return "".format(self.account_sid) + def dynamic_import(module_name, class_name): from importlib import import_module + module = import_module(module_name) return getattr(module, class_name) diff --git a/twilio/base/domain.py b/twilio/base/domain.py index 02f498685..72724aa9d 100644 --- a/twilio/base/domain.py +++ b/twilio/base/domain.py @@ -94,5 +94,5 @@ async def request_async( auth=auth, timeout=timeout, allow_redirects=allow_redirects, - is_oauth=is_oauth + is_oauth=is_oauth, ) diff --git a/twilio/base/exceptions.py b/twilio/base/exceptions.py index 8f3b7cc7a..05a7c96e8 100644 --- a/twilio/base/exceptions.py +++ b/twilio/base/exceptions.py @@ -62,7 +62,8 @@ def get_uri(code: int) -> str: "\n\n{twilio_returned}\n\n{message}\n".format( red_error=red("HTTP Error"), request_was=white("Your request was:"), - http_line=teal("%s %s" % (self.method, self.uri)), + http_line=teal("%s %s" % (self.method, self.uri, self.data, self.uri)), + http_line=teal("%s %s" % (self.data, self.headers)), twilio_returned=white("Twilio returned the following information:"), message=blue(str(self.msg)), ) diff --git a/twilio/base/oauth_token_base.py b/twilio/base/oauth_token_base.py index 91e6d5191..f58a143c8 100644 --- a/twilio/base/oauth_token_base.py +++ b/twilio/base/oauth_token_base.py @@ -1,24 +1,37 @@ from twilio.http.token_manager_initializer import TokenManagerInitializer + # Dynamic import utility function def dynamic_import(module_name, class_name): from importlib import import_module + module = import_module(module_name) return getattr(module, class_name) + class OauthTokenBase: def get_oauth_token(self, domain: str, version: str, username: str, password: str): Domain = dynamic_import("twilio.base.domain", "Domain") Version = dynamic_import("twilio.base.version", "Version") - BearerTokenHTTPClient = dynamic_import("twilio.http.bearer_token_http_client", "BearerTokenHTTPClient") - OrgTokenManager = dynamic_import("twilio.http.orgs_token_manager", "OrgTokenManager") + BearerTokenHTTPClient = dynamic_import( + "twilio.http.bearer_token_http_client", "BearerTokenHTTPClient" + ) + OrgTokenManager = dynamic_import( + "twilio.http.orgs_token_manager", "OrgTokenManager" + ) Client = dynamic_import("twilio.rest", "Client") try: orgs_token_manager = TokenManagerInitializer.get_token_manager() - return BearerTokenHTTPClient(orgs_token_manager).get_access_token(Version(Domain(Client(username, password), domain), version)) + return BearerTokenHTTPClient(orgs_token_manager).get_access_token( + Version(Domain(Client(username, password), domain), version) + ) except Exception: - orgs_token_manager = OrgTokenManager(grant_type='client_credentials', - client_id=username, - client_secret=password) + orgs_token_manager = OrgTokenManager( + grant_type="client_credentials", + client_id=username, + client_secret=password, + ) TokenManagerInitializer().set_token_manager(orgs_token_manager) - return BearerTokenHTTPClient(orgs_token_manager).get_access_token(Version(Domain(Client(username, password), domain), version)) \ No newline at end of file + return BearerTokenHTTPClient(orgs_token_manager).get_access_token( + Version(Domain(Client(username, password), domain), version) + ) diff --git a/twilio/base/version.py b/twilio/base/version.py index e7ddaff6c..58fc809af 100644 --- a/twilio/base/version.py +++ b/twilio/base/version.py @@ -44,6 +44,7 @@ def request( """ Make an HTTP request. """ + print('88888') url = self.relative_uri(uri) return self.domain.request( method, @@ -54,7 +55,7 @@ def request( auth=auth, timeout=timeout, allow_redirects=allow_redirects, - is_oauth=is_oauth + is_oauth=is_oauth, ) async def request_async( @@ -82,7 +83,7 @@ async def request_async( auth=auth, timeout=timeout, allow_redirects=allow_redirects, - is_oauth=is_oauth + is_oauth=is_oauth, ) @classmethod @@ -141,7 +142,7 @@ def fetch( auth=auth, timeout=timeout, allow_redirects=allow_redirects, - is_oauth=is_oauth + is_oauth=is_oauth, ) return self._parse_fetch(method, uri, response) @@ -170,7 +171,7 @@ async def fetch_async( auth=auth, timeout=timeout, allow_redirects=allow_redirects, - is_oauth=is_oauth + is_oauth=is_oauth, ) return self._parse_fetch(method, uri, response) @@ -236,7 +237,7 @@ async def update_async( auth=auth, timeout=timeout, allow_redirects=allow_redirects, - is_oauth=is_oauth + is_oauth=is_oauth, ) return self._parse_update(method, uri, response) @@ -302,7 +303,7 @@ async def delete_async( auth=auth, timeout=timeout, allow_redirects=allow_redirects, - is_oauth=is_oauth + is_oauth=is_oauth, ) return self._parse_delete(method, uri, response) @@ -375,7 +376,7 @@ async def page_async( auth=auth, timeout=timeout, allow_redirects=allow_redirects, - is_oauth=is_oauth + is_oauth=is_oauth, ) def stream( @@ -448,6 +449,7 @@ def _parse_create(self, method: str, uri: str, response: Response) -> Any: """ Parse create response JSON """ + print('99999') if response.status_code < 200 or response.status_code >= 300: raise self.exception(method, uri, response, "Unable to create record") @@ -468,6 +470,7 @@ def create( """ Create a resource instance. """ + print('******') response = self.request( method, uri, @@ -478,7 +481,7 @@ def create( timeout=timeout, allow_redirects=allow_redirects, ) - + print('******') return self._parse_create(method, uri, response) async def create_async( @@ -496,6 +499,7 @@ async def create_async( """ Asynchronously create a resource instance. """ + print('******') response = await self.request_async( method, uri, @@ -505,7 +509,7 @@ async def create_async( auth=auth, timeout=timeout, allow_redirects=allow_redirects, - is_oauth=is_oauth + is_oauth=is_oauth, ) - + print('******') return self._parse_create(method, uri, response) diff --git a/twilio/http/token_manager_initializer.py b/twilio/http/token_manager_initializer.py index d4836d68a..36ee83f1a 100644 --- a/twilio/http/token_manager_initializer.py +++ b/twilio/http/token_manager_initializer.py @@ -12,5 +12,5 @@ def set_token_manager(cls, token_manager: TokenManager): @classmethod def get_token_manager(cls): if cls.org_token_manager is None: - raise Exception('Token Manager not initialized') - return cls.org_token_manager \ No newline at end of file + raise Exception("Token Manager not initialized") + return cls.org_token_manager diff --git a/twilio/rest/__init__.py b/twilio/rest/__init__.py index 6da8da4a1..9c71ce2bb 100644 --- a/twilio/rest/__init__.py +++ b/twilio/rest/__init__.py @@ -132,7 +132,6 @@ def __init__( self._events: Optional["Events"] = None self._flex_api: Optional["FlexApi"] = None self._frontline_api: Optional["FrontlineApi"] = None - self._preview_iam: Optional["PreviewIam"] = None self._insights: Optional["Insights"] = None self._intelligence: Optional["Intelligence"] = None self._ip_messaging: Optional["IpMessaging"] = None @@ -447,19 +446,6 @@ def preview(self) -> "Preview": self._preview = Preview(self) return self._preview - @property - def preview_iam(self) -> "PreviewIam": - """ - Access the Preview Twilio Domain - - :returns: Preview Twilio Domain - """ - if self._preview_iam is None: - from twilio.rest.preview_iam import PreviewIam - - self._preview = PreviewIam(self) - return self._preview_iam - @property def pricing(self) -> "Pricing": """ diff --git a/twilio/rest/preview_iam/PreviewIamBase.py b/twilio/rest/preview_iam/PreviewIamBase.py index 9cf1f3bac..bcabdda5b 100644 --- a/twilio/rest/preview_iam/PreviewIamBase.py +++ b/twilio/rest/preview_iam/PreviewIamBase.py @@ -8,13 +8,14 @@ https://openapi-generator.tech Do not edit the class manually. """ + from twilio.base.domain import Domain +from typing import Optional from twilio.rest import Client -from twilio.rest.preview_iam.organizations_openapi.token import Token -from twilio.rest.preview_iam.organizations_openapi.account import Account -from twilio.rest.preview_iam.organizations_openapi.authorize import AuthorizeList -from twilio.rest.preview_iam.organizations_openapi.resource_type import ResourceTypeList -from twilio.rest.preview_iam.organizations_openapi.role_assignment import RoleAssignmentList + +from twilio.rest.preview_iam.organizations import Organizations +from twilio.rest.preview_iam.v1 import V1 + class PreviewIamBase(Domain): def __init__(self, twilio: Client): @@ -24,6 +25,26 @@ def __init__(self, twilio: Client): :returns: Domain for PreviewIam """ super().__init__(twilio, "https://preview.twilio.com/iam") - self._token: Optional[TokenList] = None - self._service_accounts: Optional[ServiceAccounts] = None - self._service_roles: Optional[ServiceRoles] = None \ No newline at end of file + self._organizations: Optional[Organizations] = None + self._v1: Optional[V1] = None + # self._token: Optional[TokenList] = None + # self._service_accounts: Optional[ServiceAccounts] = None + # self._service_roles: Optional[ServiceRoles] = None + + @property + def organizations(self) -> Organizations: + """ + :returns: Organizations of PreviewIam + """ + if self._organizations is None: + self._organizations = Organizations(self) + return self._organizations + + @property + def v1(self) -> V1: + """ + :returns: Organizations of PreviewIam + """ + if self._v1 is None: + self._v1 = V1(self) + return self._v1 diff --git a/twilio/rest/preview_iam/__init__.py b/twilio/rest/preview_iam/__init__.py new file mode 100644 index 000000000..f4f47f863 --- /dev/null +++ b/twilio/rest/preview_iam/__init__.py @@ -0,0 +1,57 @@ + +from warnings import warn +from twilio.rest.preview_iam.PreviewIamBase import PreviewIamBase +from twilio.rest.preview_iam.organizations.account import AccountList +from twilio.rest.preview_iam.organizations.role_assignment import RoleAssignmentList + +# from twilio.rest.preview_iam.organizations.user import UserList +from twilio.rest.preview_iam.v1.token import TokenList +from twilio.rest.preview_iam.v1.authorize import AuthorizeList + + +class PreviewIam(PreviewIamBase): + + @property + def accounts(self) -> AccountList: + warn( + "accounts is deprecated. Use organizations.accounts instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.organizations.accounts + + @property + def role_assignments(self) -> RoleAssignmentList: + warn( + "role_assignments is deprecated. Use organizations.role_assignments instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.organizations.role_assignments + + # @property + # def users(self) -> UserList: + # warn( + # "users is deprecated. Use organizations.users instead.", + # DeprecationWarning, + # stacklevel=2, + # ) + # return self.organizations.users + + @property + def token(self) -> TokenList: + warn( + "token is deprecated. Use v1.token instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.v1.token + + @property + def authorize(self) -> AuthorizeList: + warn( + "authorize is deprecated. Use v1.authorize instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.v1.authorize diff --git a/twilio/rest/preview_iam/organizations/__init__.py b/twilio/rest/preview_iam/organizations/__init__.py new file mode 100644 index 000000000..73b726d2e --- /dev/null +++ b/twilio/rest/preview_iam/organizations/__init__.py @@ -0,0 +1,58 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Organization Public API + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Optional +from twilio.base.version import Version +from twilio.base.domain import Domain +from twilio.rest.preview_iam.organizations.account import AccountList +from twilio.rest.preview_iam.organizations.role_assignment import RoleAssignmentList + + +class Organizations(Version): + + def __init__(self, domain: Domain): + """ + Initialize the Organizations version of PreviewIam + + :param domain: The Twilio.preview_iam domain + """ + super().__init__(domain, "Organizations") + self._accounts: Optional[AccountList] = None + self._role_assignments: Optional[RoleAssignmentList] = None + self._users: Optional[UserList] = None + + @property + def accounts(self) -> AccountList: + if self._accounts is None: + self._accounts = AccountList(self) + return self._accounts + + @property + def role_assignments(self) -> RoleAssignmentList: + if self._role_assignments is None: + self._role_assignments = RoleAssignmentList(self) + return self._role_assignments + + # @property + # def users(self) -> UserList: + # if self._users is None: + # self._users = UserList(self) + # return self._users + + def __repr__(self) -> str: + """ + Provide a friendly representation + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/preview_iam/organizations/account.py b/twilio/rest/preview_iam/organizations/account.py new file mode 100644 index 000000000..1b92f6641 --- /dev/null +++ b/twilio/rest/preview_iam/organizations/account.py @@ -0,0 +1,422 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Organization Public API + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + 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 + + +class AccountInstance(InstanceResource): + """ + :ivar account_sid: Twilio account sid + :ivar friendly_name: Account friendly name + :ivar status: Account status + :ivar owner_sid: Twilio account sid + :ivar date_created: The date and time when the account was created in the system + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + organization_sid: Optional[str] = None, + account_sid: Optional[str] = None, + ): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.status: Optional[str] = payload.get("status") + self.owner_sid: Optional[str] = payload.get("owner_sid") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + + self._solution = { + "organization_sid": organization_sid or self.organization_sid, + "account_sid": account_sid or self.account_sid, + } + self._context: Optional[AccountContext] = None + + @property + def _proxy(self) -> "AccountContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: AccountContext for this AccountInstance + """ + if self._context is None: + self._context = AccountContext( + self._version, + organization_sid=self._solution["organization_sid"], + account_sid=self._solution["account_sid"], + ) + return self._context + + def fetch(self) -> "AccountInstance": + """ + Fetch the AccountInstance + + + :returns: The fetched AccountInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "AccountInstance": + """ + Asynchronous coroutine to fetch the AccountInstance + + + :returns: The fetched AccountInstance + """ + 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 AccountContext(InstanceContext): + + def __init__(self, version: Version, organization_sid: str, account_sid: str): + """ + Initialize the AccountContext + + :param version: Version that contains the resource + :param organization_sid: + :param account_sid: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "organization_sid": organization_sid, + "account_sid": account_sid, + } + self._uri = "/{organization_sid}/Accounts/{account_sid}".format( + **self._solution + ) + + def fetch(self) -> AccountInstance: + """ + Fetch the AccountInstance + + + :returns: The fetched AccountInstance + """ + + payload = self._version.fetch( + method="GET", + uri=self._uri, + ) + + return AccountInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + account_sid=self._solution["account_sid"], + ) + + async def fetch_async(self) -> AccountInstance: + """ + Asynchronous coroutine to fetch the AccountInstance + + + :returns: The fetched AccountInstance + """ + + payload = await self._version.fetch_async( + method="GET", + uri=self._uri, + ) + + return AccountInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + account_sid=self._solution["account_sid"], + ) + + 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 AccountPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> AccountInstance: + """ + Build an instance of AccountInstance + + :param payload: Payload response from the API + """ + return AccountInstance( + self._version, payload, organization_sid=self._solution["organization_sid"] + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class AccountList(ListResource): + + def __init__(self, version: Version, organization_sid: str): + """ + Initialize the AccountList + + :param version: Version that contains the resource + :param organization_sid: + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "organization_sid": organization_sid, + } + self._uri = "/{organization_sid}/Accounts".format(**self._solution) + + def stream( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[AccountInstance]: + """ + Streams AccountInstance 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[AccountInstance]: + """ + Asynchronously streams AccountInstance 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[AccountInstance]: + """ + Lists AccountInstance 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[AccountInstance]: + """ + Asynchronously lists AccountInstance 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, + ) -> AccountPage: + """ + Retrieve a single page of AccountInstance 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 AccountInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = self._version.page(method="GET", uri=self._uri, params=data) + return AccountPage(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, + ) -> AccountPage: + """ + Asynchronously retrieve a single page of AccountInstance 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 AccountInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data + ) + return AccountPage(self._version, response, self._solution) + + def get_page(self, target_url: str) -> AccountPage: + """ + Retrieve a specific page of AccountInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of AccountInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return AccountPage(self._version, response, self._solution) + + async def get_page_async(self, target_url: str) -> AccountPage: + """ + Asynchronously retrieve a specific page of AccountInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of AccountInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return AccountPage(self._version, response, self._solution) + + def get(self, organization_sid: str, account_sid: str) -> AccountContext: + """ + Constructs a AccountContext + + :param organization_sid: + :param account_sid: + """ + return AccountContext( + self._version, organization_sid=organization_sid, account_sid=account_sid + ) + + def __call__(self, organization_sid: str, account_sid: str) -> AccountContext: + """ + Constructs a AccountContext + + :param organization_sid: + :param account_sid: + """ + return AccountContext( + self._version, organization_sid=organization_sid, account_sid=account_sid + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/preview_iam/organizations/role_assignment.py b/twilio/rest/preview_iam/organizations/role_assignment.py new file mode 100644 index 000000000..03f9b26ee --- /dev/null +++ b/twilio/rest/preview_iam/organizations/role_assignment.py @@ -0,0 +1,525 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Organization Public API + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + 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 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 RoleAssignmentInstance(InstanceResource): + """ + :ivar sid: Twilio Role Assignment Sid representing this role assignment + :ivar role_sid: Twilio Role Sid representing assigned role + :ivar scope: Twilio Sid representing identity of this assignment + :ivar identity: Twilio Sid representing scope of this assignment + :ivar code: Twilio-specific error code + :ivar message: Error message + :ivar more_info: Link to Error Code References + :ivar status: HTTP response status code + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + organization_sid: Optional[str] = None, + role_assignment_sid: Optional[str] = None, + ): + super().__init__(version) + + self.sid: Optional[str] = payload.get("sid") + self.role_sid: Optional[str] = payload.get("role_sid") + self.scope: Optional[str] = payload.get("scope") + self.identity: Optional[str] = payload.get("identity") + self.code: Optional[int] = payload.get("code") + self.message: Optional[str] = payload.get("message") + self.more_info: Optional[str] = payload.get("moreInfo") + self.status: Optional[int] = payload.get("status") + + self._solution = { + "organization_sid": organization_sid or self.organization_sid, + "role_assignment_sid": role_assignment_sid or self.role_assignment_sid, + } + self._context: Optional[RoleAssignmentContext] = None + + @property + def _proxy(self) -> "RoleAssignmentContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: RoleAssignmentContext for this RoleAssignmentInstance + """ + if self._context is None: + self._context = RoleAssignmentContext( + self._version, + organization_sid=self._solution["organization_sid"], + role_assignment_sid=self._solution["role_assignment_sid"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the RoleAssignmentInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the RoleAssignmentInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_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 RoleAssignmentContext(InstanceContext): + + def __init__( + self, version: Version, organization_sid: str, role_assignment_sid: str + ): + """ + Initialize the RoleAssignmentContext + + :param version: Version that contains the resource + :param organization_sid: + :param role_assignment_sid: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "organization_sid": organization_sid, + "role_assignment_sid": role_assignment_sid, + } + self._uri = "/{organization_sid}/RoleAssignments/{role_assignment_sid}".format( + **self._solution + ) + + def delete(self) -> bool: + """ + Deletes the RoleAssignmentInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._version.delete( + method="DELETE", + uri=self._uri, + ) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the RoleAssignmentInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._version.delete_async( + method="DELETE", + uri=self._uri, + ) + + 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 RoleAssignmentPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> RoleAssignmentInstance: + """ + Build an instance of RoleAssignmentInstance + + :param payload: Payload response from the API + """ + return RoleAssignmentInstance( + self._version, payload, organization_sid=self._solution["organization_sid"] + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class RoleAssignmentList(ListResource): + + class PublicApiCreateRoleAssignmentRequest(object): + """ + :ivar role_sid: Twilio Role Sid representing assigned role + :ivar scope: Twilio Sid representing scope of this assignment + :ivar identity: Twilio Sid representing identity of this assignment + """ + + def __init__(self, payload: Dict[str, Any]): + + self.role_sid: Optional[str] = payload.get("role_sid") + self.scope: Optional[str] = payload.get("scope") + self.identity: Optional[str] = payload.get("identity") + + def to_dict(self): + return { + "role_sid": self.role_sid, + "scope": self.scope, + "identity": self.identity, + } + + def __init__(self, version: Version, organization_sid: str): + """ + Initialize the RoleAssignmentList + + :param version: Version that contains the resource + :param organization_sid: + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "organization_sid": organization_sid, + } + self._uri = "/{organization_sid}/RoleAssignments".format(**self._solution) + + def create( + self, + public_api_create_role_assignment_request: PublicApiCreateRoleAssignmentRequest, + ) -> RoleAssignmentInstance: + """ + Create the RoleAssignmentInstance + + :param public_api_create_role_assignment_request: + + :returns: The created RoleAssignmentInstance + """ + data = public_api_create_role_assignment_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return RoleAssignmentInstance( + self._version, payload, organization_sid=self._solution["organization_sid"] + ) + + async def create_async( + self, + public_api_create_role_assignment_request: PublicApiCreateRoleAssignmentRequest, + ) -> RoleAssignmentInstance: + """ + Asynchronously create the RoleAssignmentInstance + + :param public_api_create_role_assignment_request: + + :returns: The created RoleAssignmentInstance + """ + data = public_api_create_role_assignment_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return RoleAssignmentInstance( + self._version, payload, organization_sid=self._solution["organization_sid"] + ) + + def stream( + self, + identity: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[RoleAssignmentInstance]: + """ + Streams RoleAssignmentInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param str identity: + :param str scope: + :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(identity=identity, scope=scope, page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + identity: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[RoleAssignmentInstance]: + """ + Asynchronously streams RoleAssignmentInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param str identity: + :param str scope: + :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( + identity=identity, scope=scope, page_size=limits["page_size"] + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + identity: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[RoleAssignmentInstance]: + """ + Lists RoleAssignmentInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str identity: + :param str scope: + :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( + identity=identity, + scope=scope, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + identity: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[RoleAssignmentInstance]: + """ + Asynchronously lists RoleAssignmentInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str identity: + :param str scope: + :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( + identity=identity, + scope=scope, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + identity: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> RoleAssignmentPage: + """ + Retrieve a single page of RoleAssignmentInstance records from the API. + Request is executed immediately + + :param identity: + :param scope: + :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 RoleAssignmentInstance + """ + data = values.of( + { + "Identity": identity, + "Scope": scope, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = self._version.page(method="GET", uri=self._uri, params=data) + return RoleAssignmentPage(self._version, response, self._solution) + + async def page_async( + self, + identity: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> RoleAssignmentPage: + """ + Asynchronously retrieve a single page of RoleAssignmentInstance records from the API. + Request is executed immediately + + :param identity: + :param scope: + :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 RoleAssignmentInstance + """ + data = values.of( + { + "Identity": identity, + "Scope": scope, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data + ) + return RoleAssignmentPage(self._version, response, self._solution) + + def get_page(self, target_url: str) -> RoleAssignmentPage: + """ + Retrieve a specific page of RoleAssignmentInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of RoleAssignmentInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return RoleAssignmentPage(self._version, response, self._solution) + + async def get_page_async(self, target_url: str) -> RoleAssignmentPage: + """ + Asynchronously retrieve a specific page of RoleAssignmentInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of RoleAssignmentInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return RoleAssignmentPage(self._version, response, self._solution) + + def get( + self, organization_sid: str, role_assignment_sid: str + ) -> RoleAssignmentContext: + """ + Constructs a RoleAssignmentContext + + :param organization_sid: + :param role_assignment_sid: + """ + return RoleAssignmentContext( + self._version, + organization_sid=organization_sid, + role_assignment_sid=role_assignment_sid, + ) + + def __call__( + self, organization_sid: str, role_assignment_sid: str + ) -> RoleAssignmentContext: + """ + Constructs a RoleAssignmentContext + + :param organization_sid: + :param role_assignment_sid: + """ + return RoleAssignmentContext( + self._version, + organization_sid=organization_sid, + role_assignment_sid=role_assignment_sid, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/preview_iam/v1/__init__.py b/twilio/rest/preview_iam/v1/__init__.py new file mode 100644 index 000000000..881bd44f6 --- /dev/null +++ b/twilio/rest/preview_iam/v1/__init__.py @@ -0,0 +1,51 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + V1 Public API + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Optional +from twilio.base.version import Version +from twilio.base.domain import Domain +from twilio.rest.preview_iam.v1.token import TokenList +from twilio.rest.preview_iam.v1.authorize import AuthorizeList + + +class V1(Version): + + def __init__(self, domain: Domain): + """ + Initialize the V1 version of PreviewIam + + :param domain: The Twilio.preview_iam domain + """ + super().__init__(domain, "V1") + self._token: Optional[TokenList] = None + self._authorize: Optional[AuthorizeList] = None + + @property + def token(self) -> TokenList: + if self._token is None: + self._token = TokenList(self) + return self._token + + @property + def authorize(self) -> AuthorizeList: + if self._authorize is None: + self._authorize = AuthorizeList(self) + return self._authorize + + def __repr__(self) -> str: + """ + Provide a friendly representation + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/preview_iam/v1/authorize.py b/twilio/rest/preview_iam/v1/authorize.py new file mode 100644 index 000000000..051f13a8e --- /dev/null +++ b/twilio/rest/preview_iam/v1/authorize.py @@ -0,0 +1,126 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Organization Public API + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + 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 AuthorizeInstance(InstanceResource): + """ + :ivar redirect_to: The callback URL + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.redirect_to: Optional[str] = payload.get("redirect_to") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class AuthorizeList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the AuthorizeList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/authorize" + + def fetch( + self, + response_type: Union[str, object] = values.unset, + client_id: Union[str, object] = values.unset, + redirect_uri: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + state: Union[str, object] = values.unset, + ) -> AuthorizeInstance: + """ + Asynchronously fetch the AuthorizeInstance + + :param response_type: Response Type:param client_id: The Client Identifier:param redirect_uri: The url to which response will be redirected to:param scope: The scope of the access request:param state: An opaque value which can be used to maintain state between the request and callback + :returns: The fetched AuthorizeInstance + """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + params = values.of( + { + "response_type": response_type, + "client_id": client_id, + "redirect_uri": redirect_uri, + "scope": scope, + "state": state, + } + ) + + payload = self._version.fetch( + method="GET", uri=self._uri, headers=headers, params=params + ) + + return AuthorizeInstance(self._version, payload) + + async def fetch_async( + self, + response_type: Union[str, object] = values.unset, + client_id: Union[str, object] = values.unset, + redirect_uri: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + state: Union[str, object] = values.unset, + ) -> AuthorizeInstance: + """ + Asynchronously fetch the AuthorizeInstance + + :param response_type: Response Type:param client_id: The Client Identifier:param redirect_uri: The url to which response will be redirected to:param scope: The scope of the access request:param state: An opaque value which can be used to maintain state between the request and callback + :returns: The fetched AuthorizeInstance + """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + params = values.of( + { + "response_type": response_type, + "client_id": client_id, + "redirect_uri": redirect_uri, + "scope": scope, + "state": state, + } + ) + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers, params=params + ) + + return AuthorizeInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/preview_iam/organizations/token.py b/twilio/rest/preview_iam/v1/token.py similarity index 59% rename from twilio/rest/preview_iam/organizations/token.py rename to twilio/rest/preview_iam/v1/token.py index fc28287e8..9dc953ff3 100644 --- a/twilio/rest/preview_iam/organizations/token.py +++ b/twilio/rest/preview_iam/v1/token.py @@ -12,70 +12,66 @@ Do not edit the class manually. """ - -from datetime import date, datetime -from decimal import Decimal -from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator -from twilio.base import deserialize, serialize, values +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: + :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 '' - + 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: + self._uri = "https://preview-iam.twilio.com/v1/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 @@ -87,31 +83,45 @@ def create(self, grant_type: str, client_id: str, client_secret: Union[str, obje :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' - }) - - - - payload = self._version.create(method='POST', uri=self._uri, data=data, headers=headers) + 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"}) + print('.......') + print(f'{data}') + print('.......') + print(f'{headers}') + print('.......') + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + print('rest method output...') 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: + 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 @@ -123,32 +133,29 @@ async def create_async(self, grant_type: str, client_id: str, client_secret: Uni :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' - }) - - - - payload = await self._version.create_async(method='POST', uri=self._uri, data=data, headers=headers) - - return TokenInstance(self._version, payload) - + 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"}) + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + return TokenInstance(self._version, payload) def __repr__(self) -> str: """ @@ -156,5 +163,4 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return '' - + return "" From 83954872bab75b1ef4664a70595e7cb47d9f861e Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 17 Sep 2024 16:28:36 +0530 Subject: [PATCH 10/37] removing unwanted logs --- twilio/base/version.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/twilio/base/version.py b/twilio/base/version.py index 58fc809af..9e40fe90b 100644 --- a/twilio/base/version.py +++ b/twilio/base/version.py @@ -470,7 +470,6 @@ def create( """ Create a resource instance. """ - print('******') response = self.request( method, uri, @@ -481,7 +480,6 @@ def create( timeout=timeout, allow_redirects=allow_redirects, ) - print('******') return self._parse_create(method, uri, response) async def create_async( @@ -499,7 +497,6 @@ async def create_async( """ Asynchronously create a resource instance. """ - print('******') response = await self.request_async( method, uri, @@ -511,5 +508,4 @@ async def create_async( allow_redirects=allow_redirects, is_oauth=is_oauth, ) - print('******') return self._parse_create(method, uri, response) From bc5c16b691c5702246b31fbbfb2652694285cd1e Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 17 Sep 2024 16:29:41 +0530 Subject: [PATCH 11/37] removing unwanted logs --- twilio/base/version.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/twilio/base/version.py b/twilio/base/version.py index 9e40fe90b..68cf5ca30 100644 --- a/twilio/base/version.py +++ b/twilio/base/version.py @@ -44,7 +44,6 @@ def request( """ Make an HTTP request. """ - print('88888') url = self.relative_uri(uri) return self.domain.request( method, @@ -449,7 +448,6 @@ def _parse_create(self, method: str, uri: str, response: Response) -> Any: """ Parse create response JSON """ - print('99999') if response.status_code < 200 or response.status_code >= 300: raise self.exception(method, uri, response, "Unable to create record") From a66f9e9d1fd0735c8c6a9959afe1cf047660b469 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 17 Sep 2024 16:30:41 +0530 Subject: [PATCH 12/37] removing unwanted logs --- tests/cluster/test_webhook.py | 156 +++++++++++++++++----------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/tests/cluster/test_webhook.py b/tests/cluster/test_webhook.py index 7cf8fbac8..307cf3d39 100644 --- a/tests/cluster/test_webhook.py +++ b/tests/cluster/test_webhook.py @@ -29,81 +29,81 @@ def process_request(self): ) -class WebhookTest(unittest.TestCase): - def setUp(self): - api_key = os.environ["TWILIO_API_KEY"] - api_secret = os.environ["TWILIO_API_SECRET"] - account_sid = os.environ["TWILIO_ACCOUNT_SID"] - self.client = Client(api_key, api_secret, account_sid) - - portNumber = 7777 - self.validation_server = HTTPServer(("", portNumber), RequestHandler) - self.tunnel = ngrok.connect(portNumber) - self.flow_sid = "" - _thread.start_new_thread(self.start_http_server, ()) - - def start_http_server(self): - self.validation_server.serve_forever() - - def tearDown(self): - self.client.studio.v2.flows(self.flow_sid).delete() - ngrok.kill() - self.validation_server.shutdown() - self.validation_server.server_close() - - def create_studio_flow(self, url, method): - flow = self.client.studio.v2.flows.create( - friendly_name="Python Cluster Test Flow", - status="published", - definition={ - "description": "Studio Flow", - "states": [ - { - "name": "Trigger", - "type": "trigger", - "transitions": [ - { - "next": "httpRequest", - "event": "incomingRequest", - }, - ], - "properties": {}, - }, - { - "name": "httpRequest", - "type": "make-http-request", - "transitions": [], - "properties": { - "method": method, - "content_type": "application/x-www-form-urlencoded;charset=utf-8", - "url": url, - }, - }, - ], - "initial_state": "Trigger", - "flags": { - "allow_concurrent_calls": True, - }, - }, - ) - return flow - - def validate(self, method): - flow = self.create_studio_flow(url=self.tunnel.public_url, method=method) - self.flow_sid = flow.sid - time.sleep(5) - self.client.studio.v2.flows(self.flow_sid).executions.create( - to="to", from_="from" - ) - - def test_get(self): - time.sleep(5) - self.validate("GET") - time.sleep(5) - self.assertEqual(RequestHandler.is_request_valid, True) - - def test_post(self): - time.sleep(5) - self.validate("POST") - time.sleep(5) - self.assertEqual(RequestHandler.is_request_valid, True) +# class WebhookTest(unittest.TestCase): +# def setUp(self): +# api_key = os.environ["TWILIO_API_KEY"] +# api_secret = os.environ["TWILIO_API_SECRET"] +# account_sid = os.environ["TWILIO_ACCOUNT_SID"] +# self.client = Client(api_key, api_secret, account_sid) +# +# portNumber = 7777 +# self.validation_server = HTTPServer(("", portNumber), RequestHandler) +# self.tunnel = ngrok.connect(portNumber) +# self.flow_sid = "" +# _thread.start_new_thread(self.start_http_server, ()) +# +# def start_http_server(self): +# self.validation_server.serve_forever() +# +# def tearDown(self): +# self.client.studio.v2.flows(self.flow_sid).delete() +# ngrok.kill() +# self.validation_server.shutdown() +# self.validation_server.server_close() +# +# def create_studio_flow(self, url, method): +# flow = self.client.studio.v2.flows.create( +# friendly_name="Python Cluster Test Flow", +# status="published", +# definition={ +# "description": "Studio Flow", +# "states": [ +# { +# "name": "Trigger", +# "type": "trigger", +# "transitions": [ +# { +# "next": "httpRequest", +# "event": "incomingRequest", +# }, +# ], +# "properties": {}, +# }, +# { +# "name": "httpRequest", +# "type": "make-http-request", +# "transitions": [], +# "properties": { +# "method": method, +# "content_type": "application/x-www-form-urlencoded;charset=utf-8", +# "url": url, +# }, +# }, +# ], +# "initial_state": "Trigger", +# "flags": { +# "allow_concurrent_calls": True, +# }, +# }, +# ) +# return flow +# +# def validate(self, method): +# flow = self.create_studio_flow(url=self.tunnel.public_url, method=method) +# self.flow_sid = flow.sid +# time.sleep(5) +# self.client.studio.v2.flows(self.flow_sid).executions.create( +# to="to", from_="from" +# ) +# +# def test_get(self): +# time.sleep(5) +# self.validate("GET") +# time.sleep(5) +# self.assertEqual(RequestHandler.is_request_valid, True) +# +# def test_post(self): +# time.sleep(5) +# self.validate("POST") +# time.sleep(5) +# self.assertEqual(RequestHandler.is_request_valid, True) From b5a649032052daef3f1b9231f04c860b90de1b92 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 17 Sep 2024 16:31:37 +0530 Subject: [PATCH 13/37] removing unwanted logs --- twilio/rest/preview_iam/v1/token.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/twilio/rest/preview_iam/v1/token.py b/twilio/rest/preview_iam/v1/token.py index 9dc953ff3..ac0a198ce 100644 --- a/twilio/rest/preview_iam/v1/token.py +++ b/twilio/rest/preview_iam/v1/token.py @@ -100,11 +100,8 @@ def create( } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - print('.......') print(f'{data}') - print('.......') print(f'{headers}') - print('.......') payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) From fac26eec4e513160d579e706fdd55802ad6f7e0b Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 17 Sep 2024 19:17:33 +0530 Subject: [PATCH 14/37] Fixing token fetch flow --- twilio/http/orgs_token_manager.py | 2 +- twilio/rest/preview_iam/PreviewIamBase.py | 2 +- twilio/rest/preview_iam/__init__.py | 25 ------------------- .../preview_iam/organizations/__init__.py | 2 +- twilio/rest/preview_iam/v1/__init__.py | 2 +- twilio/rest/preview_iam/v1/token.py | 5 +--- 6 files changed, 5 insertions(+), 33 deletions(-) diff --git a/twilio/http/orgs_token_manager.py b/twilio/http/orgs_token_manager.py index fbde521a3..1929f21a5 100644 --- a/twilio/http/orgs_token_manager.py +++ b/twilio/http/orgs_token_manager.py @@ -1,6 +1,6 @@ from twilio.base.version import Version from twilio.http.token_manager import TokenManager -from twilio.rest.preview_iam.organizations.token import TokenList +from twilio.rest.preview_iam.v1.token import TokenList class OrgTokenManager(TokenManager): diff --git a/twilio/rest/preview_iam/PreviewIamBase.py b/twilio/rest/preview_iam/PreviewIamBase.py index bcabdda5b..c46b0463d 100644 --- a/twilio/rest/preview_iam/PreviewIamBase.py +++ b/twilio/rest/preview_iam/PreviewIamBase.py @@ -24,7 +24,7 @@ def __init__(self, twilio: Client): :returns: Domain for PreviewIam """ - super().__init__(twilio, "https://preview.twilio.com/iam") + super().__init__(twilio, "https://preview-iam.twilio.com") self._organizations: Optional[Organizations] = None self._v1: Optional[V1] = None # self._token: Optional[TokenList] = None diff --git a/twilio/rest/preview_iam/__init__.py b/twilio/rest/preview_iam/__init__.py index f4f47f863..7ae6b65ab 100644 --- a/twilio/rest/preview_iam/__init__.py +++ b/twilio/rest/preview_iam/__init__.py @@ -13,45 +13,20 @@ class PreviewIam(PreviewIamBase): @property def accounts(self) -> AccountList: - warn( - "accounts is deprecated. Use organizations.accounts instead.", - DeprecationWarning, - stacklevel=2, - ) return self.organizations.accounts @property def role_assignments(self) -> RoleAssignmentList: - warn( - "role_assignments is deprecated. Use organizations.role_assignments instead.", - DeprecationWarning, - stacklevel=2, - ) return self.organizations.role_assignments # @property # def users(self) -> UserList: - # warn( - # "users is deprecated. Use organizations.users instead.", - # DeprecationWarning, - # stacklevel=2, - # ) # return self.organizations.users @property def token(self) -> TokenList: - warn( - "token is deprecated. Use v1.token instead.", - DeprecationWarning, - stacklevel=2, - ) return self.v1.token @property def authorize(self) -> AuthorizeList: - warn( - "authorize is deprecated. Use v1.authorize instead.", - DeprecationWarning, - stacklevel=2, - ) return self.v1.authorize diff --git a/twilio/rest/preview_iam/organizations/__init__.py b/twilio/rest/preview_iam/organizations/__init__.py index 73b726d2e..9cd6cd7a6 100644 --- a/twilio/rest/preview_iam/organizations/__init__.py +++ b/twilio/rest/preview_iam/organizations/__init__.py @@ -27,7 +27,7 @@ def __init__(self, domain: Domain): :param domain: The Twilio.preview_iam domain """ - super().__init__(domain, "Organizations") + super().__init__(domain, "organizations") self._accounts: Optional[AccountList] = None self._role_assignments: Optional[RoleAssignmentList] = None self._users: Optional[UserList] = None diff --git a/twilio/rest/preview_iam/v1/__init__.py b/twilio/rest/preview_iam/v1/__init__.py index 881bd44f6..396dc40c6 100644 --- a/twilio/rest/preview_iam/v1/__init__.py +++ b/twilio/rest/preview_iam/v1/__init__.py @@ -27,7 +27,7 @@ def __init__(self, domain: Domain): :param domain: The Twilio.preview_iam domain """ - super().__init__(domain, "V1") + super().__init__(domain, "v1") self._token: Optional[TokenList] = None self._authorize: Optional[AuthorizeList] = None diff --git a/twilio/rest/preview_iam/v1/token.py b/twilio/rest/preview_iam/v1/token.py index ac0a198ce..50e37b9ea 100644 --- a/twilio/rest/preview_iam/v1/token.py +++ b/twilio/rest/preview_iam/v1/token.py @@ -59,7 +59,7 @@ def __init__(self, version: Version): """ super().__init__(version) - self._uri = "https://preview-iam.twilio.com/v1/token" + self._uri = "/token" def create( self, @@ -100,12 +100,9 @@ def create( } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - print(f'{data}') - print(f'{headers}') payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) - print('rest method output...') return TokenInstance(self._version, payload) async def create_async( From 3eacd66d8d93a0da044e2db21a71267539f49f6d Mon Sep 17 00:00:00 2001 From: Shubham Date: Wed, 18 Sep 2024 16:58:48 +0530 Subject: [PATCH 15/37] chore: add static init file to iam domain (#813) --- twilio/rest/iam/__init__.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 twilio/rest/iam/__init__.py diff --git a/twilio/rest/iam/__init__.py b/twilio/rest/iam/__init__.py new file mode 100644 index 000000000..7a7819bcc --- /dev/null +++ b/twilio/rest/iam/__init__.py @@ -0,0 +1,35 @@ +from warnings import warn + +from twilio.rest.iam.IamBase import IamBase +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 + + +class Accounts(IamBase): + @property + def api_key(self) -> ApiKeyList: + warn( + "api_key is deprecated. Use v1.api_key instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.v1.api_key + + @property + def get_api_keys(self) -> GetApiKeysList: + warn( + "get_api_keys is deprecated. Use v1.get_api_keys instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.v1.get_api_keys + + @property + def new_api_key(self) -> NewApiKeyList: + warn( + "new_api_key is deprecated. Use v1.new_api_key instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.v1.new_api_key From e595e2863574bd10caa29247693daab60963bad6 Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 18 Sep 2024 13:18:47 +0000 Subject: [PATCH 16/37] [Librarian] Regenerated @ 1b6718f23da76f150eac392860c66a26de9af713 ceb130295f80bc623f22496076e3dd57e27da2fb --- CHANGES.md | 13 + twilio/rest/__init__.py | 15 + twilio/rest/assistants/AssistantsBase.py | 44 ++ twilio/rest/assistants/v1/__init__.py | 75 ++ .../rest/assistants/v1/assistant/__init__.py | 706 +++++++++++++++++ .../rest/assistants/v1/assistant/feedback.py | 364 +++++++++ .../rest/assistants/v1/knowledge/__init__.py | 712 ++++++++++++++++++ twilio/rest/assistants/v1/knowledge/chunk.py | 287 +++++++ twilio/rest/assistants/v1/policy.py | 322 ++++++++ twilio/rest/assistants/v1/session/__init__.py | 425 +++++++++++ twilio/rest/assistants/v1/session/message.py | 299 ++++++++ twilio/rest/assistants/v1/tool.py | 639 ++++++++++++++++ .../rest/content/v1/content/approval_fetch.py | 32 +- twilio/rest/intelligence/v2/operator_type.py | 3 +- .../installed_add_on_usage.py | 30 +- .../marketplace/v1/module_data_management.py | 68 +- twilio/rest/numbers/v2/bundle_clone.py | 8 +- .../regulatory_compliance/bundle/__init__.py | 16 +- 18 files changed, 3980 insertions(+), 78 deletions(-) create mode 100644 twilio/rest/assistants/AssistantsBase.py create mode 100644 twilio/rest/assistants/v1/__init__.py create mode 100644 twilio/rest/assistants/v1/assistant/__init__.py create mode 100644 twilio/rest/assistants/v1/assistant/feedback.py create mode 100644 twilio/rest/assistants/v1/knowledge/__init__.py create mode 100644 twilio/rest/assistants/v1/knowledge/chunk.py create mode 100644 twilio/rest/assistants/v1/policy.py create mode 100644 twilio/rest/assistants/v1/session/__init__.py create mode 100644 twilio/rest/assistants/v1/session/message.py create mode 100644 twilio/rest/assistants/v1/tool.py diff --git a/CHANGES.md b/CHANGES.md index ad840949f..e8d674865 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,19 @@ twilio-python Changelog Here you can see the full list of changes between each twilio-python release. +[2024-09-18] Version 9.3.1 +-------------------------- +**Library - Chore** +- [PR #813](https://github.com/twilio/twilio-python/pull/813): add static init file to iam domain. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! + +**Intelligence** +- Remove public from operator_type +- Update operator_type to include general-availablity and deprecated + +**Numbers** +- Remove beta flag for bundle clone API + + [2024-09-05] Version 9.3.0 -------------------------- **Iam** diff --git a/twilio/rest/__init__.py b/twilio/rest/__init__.py index 35c57385a..5c8f3ebcf 100644 --- a/twilio/rest/__init__.py +++ b/twilio/rest/__init__.py @@ -16,6 +16,7 @@ if TYPE_CHECKING: from twilio.rest.accounts import Accounts from twilio.rest.api import Api + from twilio.rest.assistants import Assistants from twilio.rest.bulkexports import Bulkexports from twilio.rest.chat import Chat from twilio.rest.content import Content @@ -125,6 +126,7 @@ def __init__( # Domains self._accounts: Optional["Accounts"] = None self._api: Optional["Api"] = None + self._assistants: Optional["Assistants"] = None self._bulkexports: Optional["Bulkexports"] = None self._chat: Optional["Chat"] = None self._content: Optional["Content"] = None @@ -186,6 +188,19 @@ def api(self) -> "Api": self._api = Api(self) return self._api + @property + def assistants(self) -> "Assistants": + """ + Access the Assistants Twilio Domain + + :returns: Assistants Twilio Domain + """ + if self._assistants is None: + from twilio.rest.assistants import Assistants + + self._assistants = Assistants(self) + return self._assistants + @property def bulkexports(self) -> "Bulkexports": """ diff --git a/twilio/rest/assistants/AssistantsBase.py b/twilio/rest/assistants/AssistantsBase.py new file mode 100644 index 000000000..a9c9e9afc --- /dev/null +++ b/twilio/rest/assistants/AssistantsBase.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.assistants.v1 import V1 + + +class AssistantsBase(Domain): + + def __init__(self, twilio: Client): + """ + Initialize the Assistants Domain + + :returns: Domain for Assistants + """ + super().__init__(twilio, "https://assistants.twilio.com") + self._v1: Optional[V1] = None + + @property + def v1(self) -> V1: + """ + :returns: Versions v1 of Assistants + """ + if self._v1 is None: + self._v1 = V1(self) + return self._v1 + + def __repr__(self) -> str: + """ + Provide a friendly representation + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/assistants/v1/__init__.py b/twilio/rest/assistants/v1/__init__.py new file mode 100644 index 000000000..546ad1455 --- /dev/null +++ b/twilio/rest/assistants/v1/__init__.py @@ -0,0 +1,75 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Assistants + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Optional +from twilio.base.version import Version +from twilio.base.domain import Domain +from twilio.rest.assistants.v1.assistant import AssistantList +from twilio.rest.assistants.v1.knowledge import KnowledgeList +from twilio.rest.assistants.v1.policy import PolicyList +from twilio.rest.assistants.v1.session import SessionList +from twilio.rest.assistants.v1.tool import ToolList + + +class V1(Version): + + def __init__(self, domain: Domain): + """ + Initialize the V1 version of Assistants + + :param domain: The Twilio.assistants domain + """ + super().__init__(domain, "v1") + self._assistants: Optional[AssistantList] = None + self._knowledge: Optional[KnowledgeList] = None + self._policies: Optional[PolicyList] = None + self._sessions: Optional[SessionList] = None + self._tools: Optional[ToolList] = None + + @property + def assistants(self) -> AssistantList: + if self._assistants is None: + self._assistants = AssistantList(self) + return self._assistants + + @property + def knowledge(self) -> KnowledgeList: + if self._knowledge is None: + self._knowledge = KnowledgeList(self) + return self._knowledge + + @property + def policies(self) -> PolicyList: + if self._policies is None: + self._policies = PolicyList(self) + return self._policies + + @property + def sessions(self) -> SessionList: + if self._sessions is None: + self._sessions = SessionList(self) + return self._sessions + + @property + def tools(self) -> ToolList: + if self._tools is None: + self._tools = ToolList(self) + return self._tools + + def __repr__(self) -> str: + """ + Provide a friendly representation + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/assistants/v1/assistant/__init__.py b/twilio/rest/assistants/v1/assistant/__init__.py new file mode 100644 index 000000000..10e90c474 --- /dev/null +++ b/twilio/rest/assistants/v1/assistant/__init__.py @@ -0,0 +1,706 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Assistants + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import deserialize, values +from twilio.base.instance_context import InstanceContext +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version +from twilio.base.page import Page +from twilio.rest.assistants.v1.assistant.feedback import FeedbackList + + +class AssistantInstance(InstanceResource): + """ + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Assistant resource. + :ivar customer_ai: The Personalization and Perception Engine settings. + :ivar id: The Assistant ID. + :ivar model: The default model used by the assistant. + :ivar name: The name of the assistant. + :ivar owner: The owner/company of the assistant. + :ivar personality_prompt: The personality prompt to be used for assistant. + :ivar date_created: The date and time in GMT when the Assistant was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar date_updated: The date and time in GMT when the Assistant was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar knowledge: The list of knowledge sources associated with the assistant. + :ivar tools: The list of tools associated with the assistant. + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], id: Optional[str] = None + ): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.customer_ai: Optional[Dict[str, object]] = payload.get("customer_ai") + self.id: Optional[str] = payload.get("id") + self.model: Optional[str] = payload.get("model") + self.name: Optional[str] = payload.get("name") + self.owner: Optional[str] = payload.get("owner") + self.personality_prompt: Optional[str] = payload.get("personality_prompt") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + self.knowledge: Optional[List[str]] = payload.get("knowledge") + self.tools: Optional[List[str]] = payload.get("tools") + + self._solution = { + "id": id or self.id, + } + self._context: Optional[AssistantContext] = None + + @property + def _proxy(self) -> "AssistantContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: AssistantContext for this AssistantInstance + """ + if self._context is None: + self._context = AssistantContext( + self._version, + id=self._solution["id"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the AssistantInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the AssistantInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def fetch(self) -> "AssistantInstance": + """ + Fetch the AssistantInstance + + + :returns: The fetched AssistantInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "AssistantInstance": + """ + Asynchronous coroutine to fetch the AssistantInstance + + + :returns: The fetched AssistantInstance + """ + return await self._proxy.fetch_async() + + def update( + self, + assistants_v1_service_update_assistant_request: Union[ + AssistantsV1ServiceUpdateAssistantRequest, object + ] = values.unset, + ) -> "AssistantInstance": + """ + Update the AssistantInstance + + :param assistants_v1_service_update_assistant_request: + + :returns: The updated AssistantInstance + """ + return self._proxy.update( + assistants_v1_service_update_assistant_request=assistants_v1_service_update_assistant_request, + ) + + async def update_async( + self, + assistants_v1_service_update_assistant_request: Union[ + AssistantsV1ServiceUpdateAssistantRequest, object + ] = values.unset, + ) -> "AssistantInstance": + """ + Asynchronous coroutine to update the AssistantInstance + + :param assistants_v1_service_update_assistant_request: + + :returns: The updated AssistantInstance + """ + return await self._proxy.update_async( + assistants_v1_service_update_assistant_request=assistants_v1_service_update_assistant_request, + ) + + @property + def feedbacks(self) -> FeedbackList: + """ + Access the feedbacks + """ + return self._proxy.feedbacks + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class AssistantContext(InstanceContext): + + def __init__(self, version: Version, id: str): + """ + Initialize the AssistantContext + + :param version: Version that contains the resource + :param id: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id": id, + } + self._uri = "/Assistants/{id}".format(**self._solution) + + self._feedbacks: Optional[FeedbackList] = None + + def delete(self) -> bool: + """ + Deletes the AssistantInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._version.delete( + method="DELETE", + uri=self._uri, + ) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the AssistantInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._version.delete_async( + method="DELETE", + uri=self._uri, + ) + + def fetch(self) -> AssistantInstance: + """ + Fetch the AssistantInstance + + + :returns: The fetched AssistantInstance + """ + + payload = self._version.fetch( + method="GET", + uri=self._uri, + ) + + return AssistantInstance( + self._version, + payload, + id=self._solution["id"], + ) + + async def fetch_async(self) -> AssistantInstance: + """ + Asynchronous coroutine to fetch the AssistantInstance + + + :returns: The fetched AssistantInstance + """ + + payload = await self._version.fetch_async( + method="GET", + uri=self._uri, + ) + + return AssistantInstance( + self._version, + payload, + id=self._solution["id"], + ) + + def update( + self, + assistants_v1_service_update_assistant_request: Union[ + AssistantsV1ServiceUpdateAssistantRequest, object + ] = values.unset, + ) -> AssistantInstance: + """ + Update the AssistantInstance + + :param assistants_v1_service_update_assistant_request: + + :returns: The updated AssistantInstance + """ + data = values.of({}) + headers = values.of( + { + "AssistantsV1ServiceUpdateAssistantRequest": assistants_v1_service_update_assistant_request, + } + ) + + payload = self._version.update( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + return AssistantInstance(self._version, payload, id=self._solution["id"]) + + async def update_async( + self, + assistants_v1_service_update_assistant_request: Union[ + AssistantsV1ServiceUpdateAssistantRequest, object + ] = values.unset, + ) -> AssistantInstance: + """ + Asynchronous coroutine to update the AssistantInstance + + :param assistants_v1_service_update_assistant_request: + + :returns: The updated AssistantInstance + """ + data = values.of({}) + headers = values.of( + { + "AssistantsV1ServiceUpdateAssistantRequest": assistants_v1_service_update_assistant_request, + } + ) + + payload = await self._version.update_async( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + return AssistantInstance(self._version, payload, id=self._solution["id"]) + + @property + def feedbacks(self) -> FeedbackList: + """ + Access the feedbacks + """ + if self._feedbacks is None: + self._feedbacks = FeedbackList( + self._version, + self._solution["id"], + ) + return self._feedbacks + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class AssistantPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> AssistantInstance: + """ + Build an instance of AssistantInstance + + :param payload: Payload response from the API + """ + return AssistantInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class AssistantList(ListResource): + + class AssistantsV1ServiceCreateAssistantRequest(object): + """ + :ivar customer_ai: + :ivar name: The name of the assistant. + :ivar owner: The owner/company of the assistant. + :ivar personality_prompt: The personality prompt to be used for assistant. + :ivar segment_credential: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.customer_ai: Optional[AssistantList.AssistantsV1ServiceCustomerAi] = ( + payload.get("customer_ai") + ) + self.name: Optional[str] = payload.get("name") + self.owner: Optional[str] = payload.get("owner") + self.personality_prompt: Optional[str] = payload.get("personality_prompt") + self.segment_credential: Optional[ + AssistantList.AssistantsV1ServiceSegmentCredential + ] = payload.get("segment_credential") + + def to_dict(self): + return { + "customer_ai": self.customer_ai.to_dict(), + "name": self.name, + "owner": self.owner, + "personality_prompt": self.personality_prompt, + "segment_credential": self.segment_credential.to_dict(), + } + + class AssistantsV1ServiceCustomerAi(object): + """ + :ivar perception_engine_enabled: True if the perception engine is enabled. + :ivar personalization_engine_enabled: True if the personalization engine is enabled. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.perception_engine_enabled: Optional[bool] = payload.get( + "perception_engine_enabled" + ) + self.personalization_engine_enabled: Optional[bool] = payload.get( + "personalization_engine_enabled" + ) + + def to_dict(self): + return { + "perception_engine_enabled": self.perception_engine_enabled, + "personalization_engine_enabled": self.personalization_engine_enabled, + } + + class AssistantsV1ServiceSegmentCredential(object): + """ + :ivar profile_api_key: The profile API key. + :ivar space_id: The space ID. + :ivar write_key: The write key. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.profile_api_key: Optional[str] = payload.get("profile_api_key") + self.space_id: Optional[str] = payload.get("space_id") + self.write_key: Optional[str] = payload.get("write_key") + + def to_dict(self): + return { + "profile_api_key": self.profile_api_key, + "space_id": self.space_id, + "write_key": self.write_key, + } + + class AssistantsV1ServiceUpdateAssistantRequest(object): + """ + :ivar customer_ai: + :ivar name: The name of the assistant. + :ivar owner: The owner/company of the assistant. + :ivar personality_prompt: The personality prompt to be used for assistant. + :ivar segment_credential: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.customer_ai: Optional[AssistantList.AssistantsV1ServiceCustomerAi] = ( + payload.get("customer_ai") + ) + self.name: Optional[str] = payload.get("name") + self.owner: Optional[str] = payload.get("owner") + self.personality_prompt: Optional[str] = payload.get("personality_prompt") + self.segment_credential: Optional[ + AssistantList.AssistantsV1ServiceSegmentCredential + ] = payload.get("segment_credential") + + def to_dict(self): + return { + "customer_ai": self.customer_ai.to_dict(), + "name": self.name, + "owner": self.owner, + "personality_prompt": self.personality_prompt, + "segment_credential": self.segment_credential.to_dict(), + } + + def __init__(self, version: Version): + """ + Initialize the AssistantList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Assistants" + + def create( + self, + assistants_v1_service_create_assistant_request: AssistantsV1ServiceCreateAssistantRequest, + ) -> AssistantInstance: + """ + Create the AssistantInstance + + :param assistants_v1_service_create_assistant_request: + + :returns: The created AssistantInstance + """ + data = assistants_v1_service_create_assistant_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return AssistantInstance(self._version, payload) + + async def create_async( + self, + assistants_v1_service_create_assistant_request: AssistantsV1ServiceCreateAssistantRequest, + ) -> AssistantInstance: + """ + Asynchronously create the AssistantInstance + + :param assistants_v1_service_create_assistant_request: + + :returns: The created AssistantInstance + """ + data = assistants_v1_service_create_assistant_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return AssistantInstance(self._version, payload) + + def stream( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[AssistantInstance]: + """ + Streams AssistantInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = self.page(page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[AssistantInstance]: + """ + Asynchronously streams AssistantInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = await self.page_async(page_size=limits["page_size"]) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[AssistantInstance]: + """ + Lists AssistantInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return list( + self.stream( + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[AssistantInstance]: + """ + Asynchronously lists AssistantInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return [ + record + async for record in await self.stream_async( + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> AssistantPage: + """ + Retrieve a single page of AssistantInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of AssistantInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = self._version.page(method="GET", uri=self._uri, params=data) + return AssistantPage(self._version, response) + + async def page_async( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> AssistantPage: + """ + Asynchronously retrieve a single page of AssistantInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of AssistantInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data + ) + return AssistantPage(self._version, response) + + def get_page(self, target_url: str) -> AssistantPage: + """ + Retrieve a specific page of AssistantInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of AssistantInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return AssistantPage(self._version, response) + + async def get_page_async(self, target_url: str) -> AssistantPage: + """ + Asynchronously retrieve a specific page of AssistantInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of AssistantInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return AssistantPage(self._version, response) + + def get(self, id: str) -> AssistantContext: + """ + Constructs a AssistantContext + + :param id: + """ + return AssistantContext(self._version, id=id) + + def __call__(self, id: str) -> AssistantContext: + """ + Constructs a AssistantContext + + :param id: + """ + return AssistantContext(self._version, id=id) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/assistants/v1/assistant/feedback.py b/twilio/rest/assistants/v1/assistant/feedback.py new file mode 100644 index 000000000..63a6d3b6b --- /dev/null +++ b/twilio/rest/assistants/v1/assistant/feedback.py @@ -0,0 +1,364 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Assistants + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import deserialize, values + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version +from twilio.base.page import Page + + +class FeedbackInstance(InstanceResource): + """ + :ivar assistant_id: The Assistant ID. + :ivar id: The Feedback ID. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Feedback. + :ivar user_sid: The SID of the User created the Feedback. + :ivar message_id: The Message ID. + :ivar score: The Score to provide as Feedback (0-1) + :ivar session_id: The Session ID. + :ivar text: The text to be given as feedback. + :ivar date_created: The date and time in GMT when the Feedback was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar date_updated: The date and time in GMT when the Feedback was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + """ + + def __init__(self, version: Version, payload: Dict[str, Any], id: str): + super().__init__(version) + + self.assistant_id: Optional[str] = payload.get("assistant_id") + self.id: Optional[str] = payload.get("id") + self.account_sid: Optional[str] = payload.get("account_sid") + self.user_sid: Optional[str] = payload.get("user_sid") + self.message_id: Optional[str] = payload.get("message_id") + self.score: Optional[float] = payload.get("score") + self.session_id: Optional[str] = payload.get("session_id") + self.text: Optional[str] = payload.get("text") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + + self._solution = { + "id": id, + } + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class FeedbackPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> FeedbackInstance: + """ + Build an instance of FeedbackInstance + + :param payload: Payload response from the API + """ + return FeedbackInstance(self._version, payload, id=self._solution["id"]) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class FeedbackList(ListResource): + + class AssistantsV1ServiceCreateFeedbackRequest(object): + """ + :ivar message_id: The message ID. + :ivar score: The score to be given(0-1). + :ivar session_id: The Session ID. + :ivar text: The text to be given as feedback. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.message_id: Optional[str] = payload.get("message_id") + self.score: Optional[float] = payload.get("score") + self.session_id: Optional[str] = payload.get("session_id") + self.text: Optional[str] = payload.get("text") + + def to_dict(self): + return { + "message_id": self.message_id, + "score": self.score, + "session_id": self.session_id, + "text": self.text, + } + + def __init__(self, version: Version, id: str): + """ + Initialize the FeedbackList + + :param version: Version that contains the resource + :param id: The assistant ID. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id": id, + } + self._uri = "/Assistants/{id}/Feedbacks".format(**self._solution) + + def create( + self, + assistants_v1_service_create_feedback_request: AssistantsV1ServiceCreateFeedbackRequest, + ) -> FeedbackInstance: + """ + Create the FeedbackInstance + + :param assistants_v1_service_create_feedback_request: + + :returns: The created FeedbackInstance + """ + data = assistants_v1_service_create_feedback_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return FeedbackInstance(self._version, payload, id=self._solution["id"]) + + async def create_async( + self, + assistants_v1_service_create_feedback_request: AssistantsV1ServiceCreateFeedbackRequest, + ) -> FeedbackInstance: + """ + Asynchronously create the FeedbackInstance + + :param assistants_v1_service_create_feedback_request: + + :returns: The created FeedbackInstance + """ + data = assistants_v1_service_create_feedback_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return FeedbackInstance(self._version, payload, id=self._solution["id"]) + + def stream( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[FeedbackInstance]: + """ + Streams FeedbackInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = self.page(page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[FeedbackInstance]: + """ + Asynchronously streams FeedbackInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = await self.page_async(page_size=limits["page_size"]) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[FeedbackInstance]: + """ + Lists FeedbackInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return list( + self.stream( + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[FeedbackInstance]: + """ + Asynchronously lists FeedbackInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return [ + record + async for record in await self.stream_async( + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> FeedbackPage: + """ + Retrieve a single page of FeedbackInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of FeedbackInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = self._version.page(method="GET", uri=self._uri, params=data) + return FeedbackPage(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, + ) -> FeedbackPage: + """ + Asynchronously retrieve a single page of FeedbackInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of FeedbackInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data + ) + return FeedbackPage(self._version, response, self._solution) + + def get_page(self, target_url: str) -> FeedbackPage: + """ + Retrieve a specific page of FeedbackInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of FeedbackInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return FeedbackPage(self._version, response, self._solution) + + async def get_page_async(self, target_url: str) -> FeedbackPage: + """ + Asynchronously retrieve a specific page of FeedbackInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of FeedbackInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return FeedbackPage(self._version, response, self._solution) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/assistants/v1/knowledge/__init__.py b/twilio/rest/assistants/v1/knowledge/__init__.py new file mode 100644 index 000000000..32b17e235 --- /dev/null +++ b/twilio/rest/assistants/v1/knowledge/__init__.py @@ -0,0 +1,712 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Assistants + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import deserialize, values +from twilio.base.instance_context import InstanceContext +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version +from twilio.base.page import Page +from twilio.rest.assistants.v1.knowledge.chunk import ChunkList + + +class KnowledgeInstance(InstanceResource): + """ + :ivar description: The type of knowledge source. + :ivar id: The description of knowledge. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Knowledge resource. + :ivar knowledge_source_details: The details of the knowledge source based on the type. + :ivar name: The name of the knowledge source. + :ivar status: The status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED') + :ivar type: The type of knowledge source ('Web', 'Database', 'Text', 'File') + :ivar 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.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, + assistants_v1_service_update_knowledge_request: Union[ + AssistantsV1ServiceUpdateKnowledgeRequest, object + ] = values.unset, + ) -> "KnowledgeInstance": + """ + Update the KnowledgeInstance + + :param assistants_v1_service_update_knowledge_request: + + :returns: The updated KnowledgeInstance + """ + return self._proxy.update( + assistants_v1_service_update_knowledge_request=assistants_v1_service_update_knowledge_request, + ) + + async def update_async( + self, + assistants_v1_service_update_knowledge_request: Union[ + AssistantsV1ServiceUpdateKnowledgeRequest, object + ] = values.unset, + ) -> "KnowledgeInstance": + """ + Asynchronous coroutine to update the KnowledgeInstance + + :param assistants_v1_service_update_knowledge_request: + + :returns: The updated KnowledgeInstance + """ + return await self._proxy.update_async( + assistants_v1_service_update_knowledge_request=assistants_v1_service_update_knowledge_request, + ) + + @property + def chunks(self) -> ChunkList: + """ + Access the chunks + """ + return self._proxy.chunks + + 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): + + 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 + + def delete(self) -> bool: + """ + Deletes the KnowledgeInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._version.delete( + method="DELETE", + uri=self._uri, + ) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the KnowledgeInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._version.delete_async( + method="DELETE", + uri=self._uri, + ) + + def fetch(self) -> KnowledgeInstance: + """ + Fetch the KnowledgeInstance + + + :returns: The fetched KnowledgeInstance + """ + + payload = self._version.fetch( + method="GET", + uri=self._uri, + ) + + 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 + """ + + payload = await self._version.fetch_async( + method="GET", + uri=self._uri, + ) + + return KnowledgeInstance( + self._version, + payload, + id=self._solution["id"], + ) + + def update( + self, + assistants_v1_service_update_knowledge_request: Union[ + AssistantsV1ServiceUpdateKnowledgeRequest, object + ] = values.unset, + ) -> KnowledgeInstance: + """ + Update the KnowledgeInstance + + :param assistants_v1_service_update_knowledge_request: + + :returns: The updated KnowledgeInstance + """ + data = values.of({}) + headers = values.of( + { + "AssistantsV1ServiceUpdateKnowledgeRequest": assistants_v1_service_update_knowledge_request, + } + ) + + 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, + assistants_v1_service_update_knowledge_request: Union[ + AssistantsV1ServiceUpdateKnowledgeRequest, object + ] = values.unset, + ) -> KnowledgeInstance: + """ + Asynchronous coroutine to update the KnowledgeInstance + + :param assistants_v1_service_update_knowledge_request: + + :returns: The updated KnowledgeInstance + """ + data = values.of({}) + headers = values.of( + { + "AssistantsV1ServiceUpdateKnowledgeRequest": assistants_v1_service_update_knowledge_request, + } + ) + + 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 + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class KnowledgePage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> KnowledgeInstance: + """ + Build an instance of KnowledgeInstance + + :param payload: Payload response from the API + """ + return KnowledgeInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class KnowledgeList(ListResource): + + class AssistantsV1ServiceCreateKnowledgeRequest(object): + """ + :ivar assistant_id: The Assistant ID. + :ivar description: The description of the knowledge source. + :ivar knowledge_source_details: The details of the knowledge source based on the type. + :ivar name: The name of the tool. + :ivar policy: + :ivar type: The type of the knowledge source. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.assistant_id: Optional[str] = payload.get("assistant_id") + self.description: Optional[str] = payload.get("description") + self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( + "knowledge_source_details" + ) + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ + KnowledgeList.AssistantsV1ServiceCreatePolicyRequest + ] = payload.get("policy") + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "assistant_id": self.assistant_id, + "description": self.description, + "knowledge_source_details": self.knowledge_source_details, + "name": self.name, + "policy": self.policy.to_dict(), + "type": self.type, + } + + class AssistantsV1ServiceCreatePolicyRequest(object): + """ + :ivar description: The description of the policy. + :ivar id: The Policy ID. + :ivar name: The name of the policy. + :ivar policy_details: + :ivar type: The description of the policy. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.id: Optional[str] = payload.get("id") + self.name: Optional[str] = payload.get("name") + self.policy_details: Optional[Dict[str, object]] = payload.get( + "policy_details" + ) + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "description": self.description, + "id": self.id, + "name": self.name, + "policy_details": self.policy_details, + "type": self.type, + } + + class AssistantsV1ServiceUpdateKnowledgeRequest(object): + """ + :ivar description: The description of the knowledge source. + :ivar knowledge_source_details: The details of the knowledge source based on the type. + :ivar name: The name of the knowledge source. + :ivar policy: + :ivar type: The description of the knowledge source. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( + "knowledge_source_details" + ) + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ + KnowledgeList.AssistantsV1ServiceCreatePolicyRequest + ] = payload.get("policy") + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "description": self.description, + "knowledge_source_details": self.knowledge_source_details, + "name": self.name, + "policy": self.policy.to_dict(), + "type": self.type, + } + + def __init__(self, version: Version): + """ + Initialize the KnowledgeList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Knowledge" + + def create( + self, + assistants_v1_service_create_knowledge_request: AssistantsV1ServiceCreateKnowledgeRequest, + ) -> KnowledgeInstance: + """ + Create the KnowledgeInstance + + :param assistants_v1_service_create_knowledge_request: + + :returns: The created KnowledgeInstance + """ + data = assistants_v1_service_create_knowledge_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "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, + assistants_v1_service_create_knowledge_request: AssistantsV1ServiceCreateKnowledgeRequest, + ) -> KnowledgeInstance: + """ + Asynchronously create the KnowledgeInstance + + :param assistants_v1_service_create_knowledge_request: + + :returns: The created KnowledgeInstance + """ + data = assistants_v1_service_create_knowledge_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "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, + assistant_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[KnowledgeInstance]: + """ + Streams KnowledgeInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param str assistant_id: + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = self.page(assistant_id=assistant_id, page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + assistant_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[KnowledgeInstance]: + """ + Asynchronously streams KnowledgeInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param str assistant_id: + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = await self.page_async( + assistant_id=assistant_id, page_size=limits["page_size"] + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + assistant_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[KnowledgeInstance]: + """ + Lists KnowledgeInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str assistant_id: + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return list( + self.stream( + assistant_id=assistant_id, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + assistant_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[KnowledgeInstance]: + """ + Asynchronously lists KnowledgeInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str assistant_id: + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return [ + record + async for record in await self.stream_async( + assistant_id=assistant_id, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + assistant_id: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> KnowledgePage: + """ + Retrieve a single page of KnowledgeInstance records from the API. + Request is executed immediately + + :param assistant_id: + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of KnowledgeInstance + """ + data = values.of( + { + "AssistantId": assistant_id, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = self._version.page(method="GET", uri=self._uri, params=data) + return KnowledgePage(self._version, response) + + async def page_async( + self, + assistant_id: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> KnowledgePage: + """ + Asynchronously retrieve a single page of KnowledgeInstance records from the API. + Request is executed immediately + + :param assistant_id: + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of KnowledgeInstance + """ + data = values.of( + { + "AssistantId": assistant_id, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data + ) + 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/assistants/v1/knowledge/chunk.py b/twilio/rest/assistants/v1/knowledge/chunk.py new file mode 100644 index 000000000..29e1a3494 --- /dev/null +++ b/twilio/rest/assistants/v1/knowledge/chunk.py @@ -0,0 +1,287 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Assistants + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import deserialize, values + +from twilio.base.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, + } + ) + + response = self._version.page(method="GET", uri=self._uri, params=data) + 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, + } + ) + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data + ) + 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/assistants/v1/policy.py b/twilio/rest/assistants/v1/policy.py new file mode 100644 index 000000000..c63eee2e2 --- /dev/null +++ b/twilio/rest/assistants/v1/policy.py @@ -0,0 +1,322 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Assistants + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import deserialize, values + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version +from twilio.base.page import Page + + +class PolicyInstance(InstanceResource): + """ + :ivar id: The Policy ID. + :ivar name: The name of the policy. + :ivar description: The description of the policy. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Policy resource. + :ivar user_sid: The SID of the User that created the Policy resource. + :ivar type: The type of the policy. + :ivar policy_details: The details of the policy based on the type. + :ivar date_created: The date and time in GMT when the Policy was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar date_updated: The date and time in GMT when the Policy was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.id: Optional[str] = payload.get("id") + self.name: Optional[str] = payload.get("name") + self.description: Optional[str] = payload.get("description") + self.account_sid: Optional[str] = payload.get("account_sid") + self.user_sid: Optional[str] = payload.get("user_sid") + self.type: Optional[str] = payload.get("type") + self.policy_details: Optional[Dict[str, object]] = payload.get("policy_details") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class PolicyPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> PolicyInstance: + """ + Build an instance of PolicyInstance + + :param payload: Payload response from the API + """ + return PolicyInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class PolicyList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the PolicyList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Policies" + + def stream( + self, + tool_id: Union[str, object] = values.unset, + knowledge_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[PolicyInstance]: + """ + Streams PolicyInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param str tool_id: The tool ID. + :param str knowledge_id: The knowledge ID. + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = self.page( + tool_id=tool_id, knowledge_id=knowledge_id, page_size=limits["page_size"] + ) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + tool_id: Union[str, object] = values.unset, + knowledge_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[PolicyInstance]: + """ + Asynchronously streams PolicyInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param str tool_id: The tool ID. + :param str knowledge_id: The knowledge ID. + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = await self.page_async( + tool_id=tool_id, knowledge_id=knowledge_id, page_size=limits["page_size"] + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + tool_id: Union[str, object] = values.unset, + knowledge_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[PolicyInstance]: + """ + Lists PolicyInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str tool_id: The tool ID. + :param str knowledge_id: The knowledge ID. + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return list( + self.stream( + tool_id=tool_id, + knowledge_id=knowledge_id, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + tool_id: Union[str, object] = values.unset, + knowledge_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[PolicyInstance]: + """ + Asynchronously lists PolicyInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str tool_id: The tool ID. + :param str knowledge_id: The knowledge ID. + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return [ + record + async for record in await self.stream_async( + tool_id=tool_id, + knowledge_id=knowledge_id, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + tool_id: Union[str, object] = values.unset, + knowledge_id: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> PolicyPage: + """ + Retrieve a single page of PolicyInstance records from the API. + Request is executed immediately + + :param tool_id: The tool ID. + :param knowledge_id: The knowledge ID. + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of PolicyInstance + """ + data = values.of( + { + "ToolId": tool_id, + "KnowledgeId": knowledge_id, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = self._version.page(method="GET", uri=self._uri, params=data) + return PolicyPage(self._version, response) + + async def page_async( + self, + tool_id: Union[str, object] = values.unset, + knowledge_id: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> PolicyPage: + """ + Asynchronously retrieve a single page of PolicyInstance records from the API. + Request is executed immediately + + :param tool_id: The tool ID. + :param knowledge_id: The knowledge ID. + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of PolicyInstance + """ + data = values.of( + { + "ToolId": tool_id, + "KnowledgeId": knowledge_id, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data + ) + return PolicyPage(self._version, response) + + def get_page(self, target_url: str) -> PolicyPage: + """ + Retrieve a specific page of PolicyInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of PolicyInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return PolicyPage(self._version, response) + + async def get_page_async(self, target_url: str) -> PolicyPage: + """ + Asynchronously retrieve a specific page of PolicyInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of PolicyInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return PolicyPage(self._version, response) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/assistants/v1/session/__init__.py b/twilio/rest/assistants/v1/session/__init__.py new file mode 100644 index 000000000..1faf9c917 --- /dev/null +++ b/twilio/rest/assistants/v1/session/__init__.py @@ -0,0 +1,425 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Assistants + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import deserialize, values +from twilio.base.instance_context import InstanceContext +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version +from twilio.base.page import Page +from twilio.rest.assistants.v1.session.message import MessageList + + +class SessionInstance(InstanceResource): + """ + :ivar id: The Session ID. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Session resource. + :ivar assistant_id: The Assistant ID. + :ivar verified: True if the session is verified. + :ivar identity: The unique identity of user for the session. + :ivar date_created: The date and time in GMT when the Session was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar date_updated: The date and time in GMT when the Session was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], id: Optional[str] = None + ): + super().__init__(version) + + self.id: Optional[str] = payload.get("id") + self.account_sid: Optional[str] = payload.get("account_sid") + self.assistant_id: Optional[str] = payload.get("assistant_id") + self.verified: Optional[bool] = payload.get("verified") + self.identity: Optional[str] = payload.get("identity") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + + self._solution = { + "id": id or self.id, + } + self._context: Optional[SessionContext] = None + + @property + def _proxy(self) -> "SessionContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: SessionContext for this SessionInstance + """ + if self._context is None: + self._context = SessionContext( + self._version, + id=self._solution["id"], + ) + return self._context + + def fetch(self) -> "SessionInstance": + """ + Fetch the SessionInstance + + + :returns: The fetched SessionInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "SessionInstance": + """ + Asynchronous coroutine to fetch the SessionInstance + + + :returns: The fetched SessionInstance + """ + return await self._proxy.fetch_async() + + @property + def messages(self) -> MessageList: + """ + Access the messages + """ + return self._proxy.messages + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class SessionContext(InstanceContext): + + def __init__(self, version: Version, id: str): + """ + Initialize the SessionContext + + :param version: Version that contains the resource + :param id: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id": id, + } + self._uri = "/Sessions/{id}".format(**self._solution) + + self._messages: Optional[MessageList] = None + + def fetch(self) -> SessionInstance: + """ + Fetch the SessionInstance + + + :returns: The fetched SessionInstance + """ + + payload = self._version.fetch( + method="GET", + uri=self._uri, + ) + + return SessionInstance( + self._version, + payload, + id=self._solution["id"], + ) + + async def fetch_async(self) -> SessionInstance: + """ + Asynchronous coroutine to fetch the SessionInstance + + + :returns: The fetched SessionInstance + """ + + payload = await self._version.fetch_async( + method="GET", + uri=self._uri, + ) + + return SessionInstance( + self._version, + payload, + id=self._solution["id"], + ) + + @property + def messages(self) -> MessageList: + """ + Access the messages + """ + if self._messages is None: + self._messages = MessageList( + self._version, + self._solution["id"], + ) + return self._messages + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class SessionPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> SessionInstance: + """ + Build an instance of SessionInstance + + :param payload: Payload response from the API + """ + return SessionInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class SessionList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the SessionList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Sessions" + + def stream( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[SessionInstance]: + """ + Streams SessionInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = self.page(page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[SessionInstance]: + """ + Asynchronously streams SessionInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = await self.page_async(page_size=limits["page_size"]) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[SessionInstance]: + """ + Lists SessionInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return list( + self.stream( + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[SessionInstance]: + """ + Asynchronously lists SessionInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return [ + record + async for record in await self.stream_async( + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> SessionPage: + """ + Retrieve a single page of SessionInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of SessionInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = self._version.page(method="GET", uri=self._uri, params=data) + return SessionPage(self._version, response) + + async def page_async( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> SessionPage: + """ + Asynchronously retrieve a single page of SessionInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of SessionInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data + ) + return SessionPage(self._version, response) + + def get_page(self, target_url: str) -> SessionPage: + """ + Retrieve a specific page of SessionInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of SessionInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return SessionPage(self._version, response) + + async def get_page_async(self, target_url: str) -> SessionPage: + """ + Asynchronously retrieve a specific page of SessionInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of SessionInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return SessionPage(self._version, response) + + def get(self, id: str) -> SessionContext: + """ + Constructs a SessionContext + + :param id: + """ + return SessionContext(self._version, id=id) + + def __call__(self, id: str) -> SessionContext: + """ + Constructs a SessionContext + + :param id: + """ + return SessionContext(self._version, id=id) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/assistants/v1/session/message.py b/twilio/rest/assistants/v1/session/message.py new file mode 100644 index 000000000..b2d2921df --- /dev/null +++ b/twilio/rest/assistants/v1/session/message.py @@ -0,0 +1,299 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Assistants + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import deserialize, values + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version +from twilio.base.page import Page + + +class MessageInstance(InstanceResource): + """ + :ivar id: The message ID. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Message resource. + :ivar assistant_id: The Assistant ID. + :ivar session_id: The Session ID. + :ivar identity: The identity of the user. + :ivar role: The role of the user associated with the message. + :ivar content: The content of the message. + :ivar meta: The metadata of the message. + :ivar date_created: The date and time in GMT when the Message was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar date_updated: The date and time in GMT when the Message was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + """ + + def __init__(self, version: Version, payload: Dict[str, Any], session_id: str): + super().__init__(version) + + self.id: Optional[str] = payload.get("id") + self.account_sid: Optional[str] = payload.get("account_sid") + self.assistant_id: Optional[str] = payload.get("assistant_id") + self.session_id: Optional[str] = payload.get("session_id") + self.identity: Optional[str] = payload.get("identity") + self.role: Optional[str] = payload.get("role") + self.content: Optional[Dict[str, object]] = payload.get("content") + self.meta: Optional[Dict[str, object]] = payload.get("meta") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + + self._solution = { + "session_id": session_id, + } + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class MessagePage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> MessageInstance: + """ + Build an instance of MessageInstance + + :param payload: Payload response from the API + """ + return MessageInstance( + self._version, payload, session_id=self._solution["session_id"] + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class MessageList(ListResource): + + def __init__(self, version: Version, session_id: str): + """ + Initialize the MessageList + + :param version: Version that contains the resource + :param session_id: Session id or name + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "session_id": session_id, + } + self._uri = "/Sessions/{session_id}/Messages".format(**self._solution) + + def stream( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[MessageInstance]: + """ + Streams MessageInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = self.page(page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[MessageInstance]: + """ + Asynchronously streams MessageInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = await self.page_async(page_size=limits["page_size"]) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[MessageInstance]: + """ + Lists MessageInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return list( + self.stream( + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[MessageInstance]: + """ + Asynchronously lists MessageInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return [ + record + async for record in await self.stream_async( + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> MessagePage: + """ + Retrieve a single page of MessageInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of MessageInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = self._version.page(method="GET", uri=self._uri, params=data) + return MessagePage(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, + ) -> MessagePage: + """ + Asynchronously retrieve a single page of MessageInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of MessageInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data + ) + return MessagePage(self._version, response, self._solution) + + def get_page(self, target_url: str) -> MessagePage: + """ + Retrieve a specific page of MessageInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of MessageInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return MessagePage(self._version, response, self._solution) + + async def get_page_async(self, target_url: str) -> MessagePage: + """ + Asynchronously retrieve a specific page of MessageInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of MessageInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return MessagePage(self._version, response, self._solution) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/assistants/v1/tool.py b/twilio/rest/assistants/v1/tool.py new file mode 100644 index 000000000..a66a818b5 --- /dev/null +++ b/twilio/rest/assistants/v1/tool.py @@ -0,0 +1,639 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Assistants + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import deserialize, values +from twilio.base.instance_context import InstanceContext +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version +from twilio.base.page import Page + + +class ToolInstance(InstanceResource): + """ + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Tool resource. + :ivar description: The description of the tool. + :ivar enabled: True if the tool is enabled. + :ivar id: The tool ID. + :ivar meta: The metadata related to method, url, input_schema to used with the Tool. + :ivar name: The name of the tool. + :ivar requires_auth: The authentication requirement for the tool. + :ivar type: The type of the tool. ('WEBHOOK') + :ivar date_created: The date and time in GMT when the Tool was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar date_updated: The date and time in GMT when the Tool was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], id: Optional[str] = None + ): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.description: Optional[str] = payload.get("description") + self.enabled: Optional[bool] = payload.get("enabled") + self.id: Optional[str] = payload.get("id") + self.meta: Optional[Dict[str, object]] = payload.get("meta") + self.name: Optional[str] = payload.get("name") + self.requires_auth: Optional[bool] = payload.get("requires_auth") + self.type: Optional[str] = payload.get("type") + self.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[ToolContext] = None + + @property + def _proxy(self) -> "ToolContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: ToolContext for this ToolInstance + """ + if self._context is None: + self._context = ToolContext( + self._version, + id=self._solution["id"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the ToolInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the ToolInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def update( + self, + assistants_v1_service_update_tool_request: Union[ + AssistantsV1ServiceUpdateToolRequest, object + ] = values.unset, + ) -> "ToolInstance": + """ + Update the ToolInstance + + :param assistants_v1_service_update_tool_request: + + :returns: The updated ToolInstance + """ + return self._proxy.update( + assistants_v1_service_update_tool_request=assistants_v1_service_update_tool_request, + ) + + async def update_async( + self, + assistants_v1_service_update_tool_request: Union[ + AssistantsV1ServiceUpdateToolRequest, object + ] = values.unset, + ) -> "ToolInstance": + """ + Asynchronous coroutine to update the ToolInstance + + :param assistants_v1_service_update_tool_request: + + :returns: The updated ToolInstance + """ + return await self._proxy.update_async( + assistants_v1_service_update_tool_request=assistants_v1_service_update_tool_request, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class ToolContext(InstanceContext): + + def __init__(self, version: Version, id: str): + """ + Initialize the ToolContext + + :param version: Version that contains the resource + :param id: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id": id, + } + self._uri = "/Tools/{id}".format(**self._solution) + + def delete(self) -> bool: + """ + Deletes the ToolInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._version.delete( + method="DELETE", + uri=self._uri, + ) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the ToolInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._version.delete_async( + method="DELETE", + uri=self._uri, + ) + + def update( + self, + assistants_v1_service_update_tool_request: Union[ + AssistantsV1ServiceUpdateToolRequest, object + ] = values.unset, + ) -> ToolInstance: + """ + Update the ToolInstance + + :param assistants_v1_service_update_tool_request: + + :returns: The updated ToolInstance + """ + data = values.of({}) + headers = values.of( + { + "AssistantsV1ServiceUpdateToolRequest": assistants_v1_service_update_tool_request, + } + ) + + payload = self._version.update( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + return ToolInstance(self._version, payload, id=self._solution["id"]) + + async def update_async( + self, + assistants_v1_service_update_tool_request: Union[ + AssistantsV1ServiceUpdateToolRequest, object + ] = values.unset, + ) -> ToolInstance: + """ + Asynchronous coroutine to update the ToolInstance + + :param assistants_v1_service_update_tool_request: + + :returns: The updated ToolInstance + """ + data = values.of({}) + headers = values.of( + { + "AssistantsV1ServiceUpdateToolRequest": assistants_v1_service_update_tool_request, + } + ) + + payload = await self._version.update_async( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + return ToolInstance(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 ToolPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> ToolInstance: + """ + Build an instance of ToolInstance + + :param payload: Payload response from the API + """ + return ToolInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class ToolList(ListResource): + + class AssistantsV1ServiceCreatePolicyRequest(object): + """ + :ivar description: The description of the policy. + :ivar id: The Policy ID. + :ivar name: The name of the policy. + :ivar policy_details: + :ivar type: The description of the policy. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.id: Optional[str] = payload.get("id") + self.name: Optional[str] = payload.get("name") + self.policy_details: Optional[Dict[str, object]] = payload.get( + "policy_details" + ) + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "description": self.description, + "id": self.id, + "name": self.name, + "policy_details": self.policy_details, + "type": self.type, + } + + class AssistantsV1ServiceCreateToolRequest(object): + """ + :ivar assistant_id: The Assistant ID. + :ivar description: The description of the tool. + :ivar enabled: True if the tool is enabled. + :ivar meta: The metadata related to method, url, input_schema to used with the Tool. + :ivar name: The name of the tool. + :ivar policy: + :ivar type: The description of the tool. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.assistant_id: Optional[str] = payload.get("assistant_id") + self.description: Optional[str] = payload.get("description") + self.enabled: Optional[bool] = payload.get("enabled") + self.meta: Optional[Dict[str, object]] = payload.get("meta") + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ToolList.AssistantsV1ServiceCreatePolicyRequest] = ( + payload.get("policy") + ) + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "assistant_id": self.assistant_id, + "description": self.description, + "enabled": self.enabled, + "meta": self.meta, + "name": self.name, + "policy": self.policy.to_dict(), + "type": self.type, + } + + class AssistantsV1ServiceUpdateToolRequest(object): + """ + :ivar assistant_id: The Assistant ID. + :ivar description: The description of the tool. + :ivar enabled: True if the tool is enabled. + :ivar meta: The metadata related to method, url, input_schema to used with the Tool. + :ivar name: The name of the tool. + :ivar policy: + :ivar type: The type of the tool. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.assistant_id: Optional[str] = payload.get("assistant_id") + self.description: Optional[str] = payload.get("description") + self.enabled: Optional[bool] = payload.get("enabled") + self.meta: Optional[Dict[str, object]] = payload.get("meta") + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ToolList.AssistantsV1ServiceCreatePolicyRequest] = ( + payload.get("policy") + ) + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "assistant_id": self.assistant_id, + "description": self.description, + "enabled": self.enabled, + "meta": self.meta, + "name": self.name, + "policy": self.policy.to_dict(), + "type": self.type, + } + + def __init__(self, version: Version): + """ + Initialize the ToolList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Tools" + + def create( + self, + assistants_v1_service_create_tool_request: AssistantsV1ServiceCreateToolRequest, + ) -> ToolInstance: + """ + Create the ToolInstance + + :param assistants_v1_service_create_tool_request: + + :returns: The created ToolInstance + """ + data = assistants_v1_service_create_tool_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ToolInstance(self._version, payload) + + async def create_async( + self, + assistants_v1_service_create_tool_request: AssistantsV1ServiceCreateToolRequest, + ) -> ToolInstance: + """ + Asynchronously create the ToolInstance + + :param assistants_v1_service_create_tool_request: + + :returns: The created ToolInstance + """ + data = assistants_v1_service_create_tool_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ToolInstance(self._version, payload) + + def stream( + self, + assistant_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[ToolInstance]: + """ + Streams ToolInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param str assistant_id: + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = self.page(assistant_id=assistant_id, page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + assistant_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[ToolInstance]: + """ + Asynchronously streams ToolInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param str assistant_id: + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = await self.page_async( + assistant_id=assistant_id, page_size=limits["page_size"] + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + assistant_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ToolInstance]: + """ + Lists ToolInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str assistant_id: + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return list( + self.stream( + assistant_id=assistant_id, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + assistant_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ToolInstance]: + """ + Asynchronously lists ToolInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str assistant_id: + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return [ + record + async for record in await self.stream_async( + assistant_id=assistant_id, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + assistant_id: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> ToolPage: + """ + Retrieve a single page of ToolInstance records from the API. + Request is executed immediately + + :param assistant_id: + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of ToolInstance + """ + data = values.of( + { + "AssistantId": assistant_id, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = self._version.page(method="GET", uri=self._uri, params=data) + return ToolPage(self._version, response) + + async def page_async( + self, + assistant_id: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> ToolPage: + """ + Asynchronously retrieve a single page of ToolInstance records from the API. + Request is executed immediately + + :param assistant_id: + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of ToolInstance + """ + data = values.of( + { + "AssistantId": assistant_id, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data + ) + return ToolPage(self._version, response) + + def get_page(self, target_url: str) -> ToolPage: + """ + Retrieve a specific page of ToolInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of ToolInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return ToolPage(self._version, response) + + async def get_page_async(self, target_url: str) -> ToolPage: + """ + Asynchronously retrieve a specific page of ToolInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of ToolInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return ToolPage(self._version, response) + + def get(self, id: str) -> ToolContext: + """ + Constructs a ToolContext + + :param id: + """ + return ToolContext(self._version, id=id) + + def __call__(self, id: str) -> ToolContext: + """ + Constructs a ToolContext + + :param id: + """ + return ToolContext(self._version, id=id) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/content/v1/content/approval_fetch.py b/twilio/rest/content/v1/content/approval_fetch.py index f679a920a..f35ef6a48 100644 --- a/twilio/rest/content/v1/content/approval_fetch.py +++ b/twilio/rest/content/v1/content/approval_fetch.py @@ -27,7 +27,7 @@ class ApprovalFetchInstance(InstanceResource): :ivar url: The URL of the resource, relative to `https://content.twilio.com`. """ - def __init__(self, version: Version, payload: Dict[str, Any], content_sid: str): + def __init__(self, version: Version, payload: Dict[str, Any], sid: str): super().__init__(version) self.sid: Optional[str] = payload.get("sid") @@ -36,7 +36,7 @@ def __init__(self, version: Version, payload: Dict[str, Any], content_sid: str): self.url: Optional[str] = payload.get("url") self._solution = { - "content_sid": content_sid, + "sid": sid, } self._context: Optional[ApprovalFetchContext] = None @@ -51,7 +51,7 @@ def _proxy(self) -> "ApprovalFetchContext": if self._context is None: self._context = ApprovalFetchContext( self._version, - content_sid=self._solution["content_sid"], + sid=self._solution["sid"], ) return self._context @@ -85,20 +85,20 @@ def __repr__(self) -> str: class ApprovalFetchContext(InstanceContext): - def __init__(self, version: Version, content_sid: str): + def __init__(self, version: Version, sid: str): """ Initialize the ApprovalFetchContext :param version: Version that contains the resource - :param content_sid: The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. + :param sid: The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. """ super().__init__(version) # Path Solution self._solution = { - "content_sid": content_sid, + "sid": sid, } - self._uri = "/Content/{content_sid}/ApprovalRequests".format(**self._solution) + self._uri = "/Content/{sid}/ApprovalRequests".format(**self._solution) def fetch(self) -> ApprovalFetchInstance: """ @@ -116,7 +116,7 @@ def fetch(self) -> ApprovalFetchInstance: return ApprovalFetchInstance( self._version, payload, - content_sid=self._solution["content_sid"], + sid=self._solution["sid"], ) async def fetch_async(self) -> ApprovalFetchInstance: @@ -135,7 +135,7 @@ async def fetch_async(self) -> ApprovalFetchInstance: return ApprovalFetchInstance( self._version, payload, - content_sid=self._solution["content_sid"], + sid=self._solution["sid"], ) def __repr__(self) -> str: @@ -150,19 +150,19 @@ def __repr__(self) -> str: class ApprovalFetchList(ListResource): - def __init__(self, version: Version, content_sid: str): + def __init__(self, version: Version, sid: str): """ Initialize the ApprovalFetchList :param version: Version that contains the resource - :param content_sid: The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. + :param sid: The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. """ super().__init__(version) # Path Solution self._solution = { - "content_sid": content_sid, + "sid": sid, } def get(self) -> ApprovalFetchContext: @@ -170,18 +170,14 @@ def get(self) -> ApprovalFetchContext: Constructs a ApprovalFetchContext """ - return ApprovalFetchContext( - self._version, content_sid=self._solution["content_sid"] - ) + return ApprovalFetchContext(self._version, sid=self._solution["sid"]) def __call__(self) -> ApprovalFetchContext: """ Constructs a ApprovalFetchContext """ - return ApprovalFetchContext( - self._version, content_sid=self._solution["content_sid"] - ) + return ApprovalFetchContext(self._version, sid=self._solution["sid"]) def __repr__(self) -> str: """ diff --git a/twilio/rest/intelligence/v2/operator_type.py b/twilio/rest/intelligence/v2/operator_type.py index ff2403b1c..f1f839fe7 100644 --- a/twilio/rest/intelligence/v2/operator_type.py +++ b/twilio/rest/intelligence/v2/operator_type.py @@ -27,8 +27,9 @@ class OperatorTypeInstance(InstanceResource): class Availability(object): INTERNAL = "internal" BETA = "beta" - PUBLIC = "public" + GENERAL_AVAILABILITY = "general-availability" RETIRED = "retired" + DEPRECATED = "deprecated" class OutputType(object): TEXT_CLASSIFICATION = "text-classification" diff --git a/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_usage.py b/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_usage.py index 7e44ac4e0..47a9a7c13 100644 --- a/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_usage.py +++ b/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_usage.py @@ -22,8 +22,8 @@ class InstalledAddOnUsageInstance(InstanceResource): """ + :ivar total_submitted: Total amount in local currency that was billed in this request. Aggregates all billable_items that were successfully submitted. :ivar billable_items: - :ivar total_submitted: Represents the total quantity submitted. """ def __init__( @@ -31,10 +31,12 @@ def __init__( ): super().__init__(version) - self.billable_items: Optional[List[str]] = payload.get("billable_items") self.total_submitted: Optional[float] = deserialize.decimal( payload.get("total_submitted") ) + self.billable_items: Optional[List[InstalledAddOnUsageList.str]] = payload.get( + "billable_items" + ) self._solution = { "installed_add_on_sid": installed_add_on_sid, @@ -54,11 +56,15 @@ class InstalledAddOnUsageList(ListResource): class MarketplaceV1InstalledAddOnInstalledAddOnUsage(object): """ + :ivar total_submitted: Total amount in local currency that was billed in this request. Aggregates all billable_items that were successfully submitted. :ivar billable_items: """ def __init__(self, payload: Dict[str, Any]): + self.total_submitted: Optional[float] = deserialize.decimal( + payload.get("total_submitted") + ) self.billable_items: Optional[ List[ InstalledAddOnUsageList.MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems @@ -67,34 +73,18 @@ def __init__(self, payload: Dict[str, Any]): def to_dict(self): return { + "total_submitted": self.total_submitted, "billable_items": [ billable_items.to_dict() for billable_items in self.billable_items ], } - class MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems(object): - """ - :ivar quantity: Any floating number greater than 0. - :ivar sid: BillingSid to use for billing. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.quantity: Optional[float] = payload.get("quantity") - self.sid: Optional[str] = payload.get("sid") - - def to_dict(self): - return { - "quantity": self.quantity, - "sid": self.sid, - } - def __init__(self, version: Version, installed_add_on_sid: str): """ Initialize the InstalledAddOnUsageList :param version: Version that contains the resource - :param installed_add_on_sid: + :param installed_add_on_sid: Customer Installation SID to report usage on. """ super().__init__(version) diff --git a/twilio/rest/marketplace/v1/module_data_management.py b/twilio/rest/marketplace/v1/module_data_management.py index 837f5fc3f..8ef224cec 100644 --- a/twilio/rest/marketplace/v1/module_data_management.py +++ b/twilio/rest/marketplace/v1/module_data_management.py @@ -30,6 +30,7 @@ class ModuleDataManagementInstance(InstanceResource): :ivar module_info: A JSON object containing essential attributes that define a module. This information is presented on the Module detail page in the Twilio Marketplace Catalog. You can pass the following attributes in the JSON object :ivar documentation: A JSON object for providing comprehensive information, instructions, and resources related to the module :ivar configuration: A JSON object for providing listing specific configuration. Contains button setup, notification url, among others. + :ivar pricing: A JSON object for providing Listing specific pricing information. """ def __init__( @@ -45,6 +46,7 @@ def __init__( self.module_info: Optional[Dict[str, object]] = payload.get("module_info") self.documentation: Optional[Dict[str, object]] = payload.get("documentation") self.configuration: Optional[Dict[str, object]] = payload.get("configuration") + self.pricing: Optional[Dict[str, object]] = payload.get("pricing") self._solution = { "sid": sid or self.sid, @@ -92,16 +94,18 @@ def update( policies: Union[str, object] = values.unset, support: Union[str, object] = values.unset, configuration: Union[str, object] = values.unset, + pricing: Union[str, object] = values.unset, ) -> "ModuleDataManagementInstance": """ Update the ModuleDataManagementInstance - :param module_info: - :param description: - :param documentation: - :param policies: - :param support: - :param configuration: + :param module_info: A JSON object containing essential attributes that define a Listing. + :param description: A JSON object describing the Listing. You can define the main body of the description, highlight key features or aspects of the Listing, and provide code samples for developers if applicable. + :param documentation: A JSON object for providing comprehensive information, instructions, and resources related to the Listing. + :param policies: A JSON object describing the Listing's privacy and legal policies. The maximum file size for Policies is 5MB. + :param support: A JSON object containing information on how Marketplace users can obtain support for the Listing. Use this parameter to provide details such as contact information and support description. + :param configuration: A JSON object for providing Listing-specific configuration. Contains button setup, notification URL, and more. + :param pricing: A JSON object for providing Listing's purchase options. :returns: The updated ModuleDataManagementInstance """ @@ -112,6 +116,7 @@ def update( policies=policies, support=support, configuration=configuration, + pricing=pricing, ) async def update_async( @@ -122,16 +127,18 @@ async def update_async( policies: Union[str, object] = values.unset, support: Union[str, object] = values.unset, configuration: Union[str, object] = values.unset, + pricing: Union[str, object] = values.unset, ) -> "ModuleDataManagementInstance": """ Asynchronous coroutine to update the ModuleDataManagementInstance - :param module_info: - :param description: - :param documentation: - :param policies: - :param support: - :param configuration: + :param module_info: A JSON object containing essential attributes that define a Listing. + :param description: A JSON object describing the Listing. You can define the main body of the description, highlight key features or aspects of the Listing, and provide code samples for developers if applicable. + :param documentation: A JSON object for providing comprehensive information, instructions, and resources related to the Listing. + :param policies: A JSON object describing the Listing's privacy and legal policies. The maximum file size for Policies is 5MB. + :param support: A JSON object containing information on how Marketplace users can obtain support for the Listing. Use this parameter to provide details such as contact information and support description. + :param configuration: A JSON object for providing Listing-specific configuration. Contains button setup, notification URL, and more. + :param pricing: A JSON object for providing Listing's purchase options. :returns: The updated ModuleDataManagementInstance """ @@ -142,6 +149,7 @@ async def update_async( policies=policies, support=support, configuration=configuration, + pricing=pricing, ) def __repr__(self) -> str: @@ -161,7 +169,7 @@ def __init__(self, version: Version, sid: str): Initialize the ModuleDataManagementContext :param version: Version that contains the resource - :param sid: + :param sid: SID that uniquely identifies the Listing. """ super().__init__(version) @@ -217,16 +225,18 @@ def update( policies: Union[str, object] = values.unset, support: Union[str, object] = values.unset, configuration: Union[str, object] = values.unset, + pricing: Union[str, object] = values.unset, ) -> ModuleDataManagementInstance: """ Update the ModuleDataManagementInstance - :param module_info: - :param description: - :param documentation: - :param policies: - :param support: - :param configuration: + :param module_info: A JSON object containing essential attributes that define a Listing. + :param description: A JSON object describing the Listing. You can define the main body of the description, highlight key features or aspects of the Listing, and provide code samples for developers if applicable. + :param documentation: A JSON object for providing comprehensive information, instructions, and resources related to the Listing. + :param policies: A JSON object describing the Listing's privacy and legal policies. The maximum file size for Policies is 5MB. + :param support: A JSON object containing information on how Marketplace users can obtain support for the Listing. Use this parameter to provide details such as contact information and support description. + :param configuration: A JSON object for providing Listing-specific configuration. Contains button setup, notification URL, and more. + :param pricing: A JSON object for providing Listing's purchase options. :returns: The updated ModuleDataManagementInstance """ @@ -238,6 +248,7 @@ def update( "Policies": policies, "Support": support, "Configuration": configuration, + "Pricing": pricing, } ) @@ -259,16 +270,18 @@ async def update_async( policies: Union[str, object] = values.unset, support: Union[str, object] = values.unset, configuration: Union[str, object] = values.unset, + pricing: Union[str, object] = values.unset, ) -> ModuleDataManagementInstance: """ Asynchronous coroutine to update the ModuleDataManagementInstance - :param module_info: - :param description: - :param documentation: - :param policies: - :param support: - :param configuration: + :param module_info: A JSON object containing essential attributes that define a Listing. + :param description: A JSON object describing the Listing. You can define the main body of the description, highlight key features or aspects of the Listing, and provide code samples for developers if applicable. + :param documentation: A JSON object for providing comprehensive information, instructions, and resources related to the Listing. + :param policies: A JSON object describing the Listing's privacy and legal policies. The maximum file size for Policies is 5MB. + :param support: A JSON object containing information on how Marketplace users can obtain support for the Listing. Use this parameter to provide details such as contact information and support description. + :param configuration: A JSON object for providing Listing-specific configuration. Contains button setup, notification URL, and more. + :param pricing: A JSON object for providing Listing's purchase options. :returns: The updated ModuleDataManagementInstance """ @@ -280,6 +293,7 @@ async def update_async( "Policies": policies, "Support": support, "Configuration": configuration, + "Pricing": pricing, } ) @@ -318,7 +332,7 @@ def get(self, sid: str) -> ModuleDataManagementContext: """ Constructs a ModuleDataManagementContext - :param sid: + :param sid: SID that uniquely identifies the Listing. """ return ModuleDataManagementContext(self._version, sid=sid) @@ -326,7 +340,7 @@ def __call__(self, sid: str) -> ModuleDataManagementContext: """ Constructs a ModuleDataManagementContext - :param sid: + :param sid: SID that uniquely identifies the Listing. """ return ModuleDataManagementContext(self._version, sid=sid) diff --git a/twilio/rest/numbers/v2/bundle_clone.py b/twilio/rest/numbers/v2/bundle_clone.py index ff24e2906..820fbc9db 100644 --- a/twilio/rest/numbers/v2/bundle_clone.py +++ b/twilio/rest/numbers/v2/bundle_clone.py @@ -101,7 +101,7 @@ def create( Create the BundleCloneInstance :param target_account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) where the bundle needs to be cloned. - :param move_to_draft: This is to determine whether the cloned bundle needs to be in draft state or not. + :param move_to_draft: If set to true, the cloned bundle will be in the DRAFT state, else it will be twilio-approved :param friendly_name: The string that you assigned to describe the cloned bundle. :returns: The created BundleCloneInstance @@ -122,7 +122,7 @@ async def create_async( Asynchronous coroutine to create the BundleCloneInstance :param target_account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) where the bundle needs to be cloned. - :param move_to_draft: This is to determine whether the cloned bundle needs to be in draft state or not. + :param move_to_draft: If set to true, the cloned bundle will be in the DRAFT state, else it will be twilio-approved :param friendly_name: The string that you assigned to describe the cloned bundle. :returns: The created BundleCloneInstance @@ -172,7 +172,7 @@ def create( Create the BundleCloneInstance :param target_account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) where the bundle needs to be cloned. - :param move_to_draft: This is to determine whether the cloned bundle needs to be in draft state or not. + :param move_to_draft: If set to true, the cloned bundle will be in the DRAFT state, else it will be twilio-approved :param friendly_name: The string that you assigned to describe the cloned bundle. :returns: The created BundleCloneInstance @@ -201,7 +201,7 @@ async def create_async( Asynchronous coroutine to create the BundleCloneInstance :param target_account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) where the bundle needs to be cloned. - :param move_to_draft: This is to determine whether the cloned bundle needs to be in draft state or not. + :param move_to_draft: If set to true, the cloned bundle will be in the DRAFT state, else it will be twilio-approved :param friendly_name: The string that you assigned to describe the cloned bundle. :returns: The created BundleCloneInstance diff --git a/twilio/rest/numbers/v2/regulatory_compliance/bundle/__init__.py b/twilio/rest/numbers/v2/regulatory_compliance/bundle/__init__.py index 5c8b48f11..8ad16f21c 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/bundle/__init__.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/bundle/__init__.py @@ -499,7 +499,7 @@ def create( :param regulation_sid: The unique string of a regulation that is associated to the Bundle resource. :param iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Bundle's phone number country ownership request. :param end_user_type: - :param number_type: The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll free`. + :param number_type: The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll-free`. :param is_test: Indicates that Bundle is a Test Bundle and will be Auto-Rejected :returns: The created BundleInstance @@ -545,7 +545,7 @@ async def create_async( :param regulation_sid: The unique string of a regulation that is associated to the Bundle resource. :param iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Bundle's phone number country ownership request. :param end_user_type: - :param number_type: The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll free`. + :param number_type: The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll-free`. :param is_test: Indicates that Bundle is a Test Bundle and will be Auto-Rejected :returns: The created BundleInstance @@ -597,7 +597,7 @@ def stream( :param str friendly_name: The string that you assigned to describe the resource. The column can contain 255 variable characters. :param str regulation_sid: The unique string of a [Regulation resource](https://www.twilio.com/docs/phone-numbers/regulatory/api/regulations) that is associated to the Bundle resource. :param str iso_country: The 2-digit [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Bundle's phone number country ownership request. - :param str number_type: The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `tollfree`. + :param str number_type: The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll-free`. :param bool has_valid_until_date: Indicates that the Bundle is a valid Bundle until a specified expiration date. :param "BundleInstance.SortBy" sort_by: Can be `valid-until` or `date-updated`. Defaults to `date-created`. :param "BundleInstance.SortDirection" sort_direction: Default is `DESC`. Can be `ASC` or `DESC`. @@ -657,7 +657,7 @@ async def stream_async( :param str friendly_name: The string that you assigned to describe the resource. The column can contain 255 variable characters. :param str regulation_sid: The unique string of a [Regulation resource](https://www.twilio.com/docs/phone-numbers/regulatory/api/regulations) that is associated to the Bundle resource. :param str iso_country: The 2-digit [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Bundle's phone number country ownership request. - :param str number_type: The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `tollfree`. + :param str number_type: The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll-free`. :param bool has_valid_until_date: Indicates that the Bundle is a valid Bundle until a specified expiration date. :param "BundleInstance.SortBy" sort_by: Can be `valid-until` or `date-updated`. Defaults to `date-created`. :param "BundleInstance.SortDirection" sort_direction: Default is `DESC`. Can be `ASC` or `DESC`. @@ -716,7 +716,7 @@ def list( :param str friendly_name: The string that you assigned to describe the resource. The column can contain 255 variable characters. :param str regulation_sid: The unique string of a [Regulation resource](https://www.twilio.com/docs/phone-numbers/regulatory/api/regulations) that is associated to the Bundle resource. :param str iso_country: The 2-digit [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Bundle's phone number country ownership request. - :param str number_type: The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `tollfree`. + :param str number_type: The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll-free`. :param bool has_valid_until_date: Indicates that the Bundle is a valid Bundle until a specified expiration date. :param "BundleInstance.SortBy" sort_by: Can be `valid-until` or `date-updated`. Defaults to `date-created`. :param "BundleInstance.SortDirection" sort_direction: Default is `DESC`. Can be `ASC` or `DESC`. @@ -775,7 +775,7 @@ async def list_async( :param str friendly_name: The string that you assigned to describe the resource. The column can contain 255 variable characters. :param str regulation_sid: The unique string of a [Regulation resource](https://www.twilio.com/docs/phone-numbers/regulatory/api/regulations) that is associated to the Bundle resource. :param str iso_country: The 2-digit [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Bundle's phone number country ownership request. - :param str number_type: The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `tollfree`. + :param str number_type: The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll-free`. :param bool has_valid_until_date: Indicates that the Bundle is a valid Bundle until a specified expiration date. :param "BundleInstance.SortBy" sort_by: Can be `valid-until` or `date-updated`. Defaults to `date-created`. :param "BundleInstance.SortDirection" sort_direction: Default is `DESC`. Can be `ASC` or `DESC`. @@ -835,7 +835,7 @@ def page( :param friendly_name: The string that you assigned to describe the resource. The column can contain 255 variable characters. :param regulation_sid: The unique string of a [Regulation resource](https://www.twilio.com/docs/phone-numbers/regulatory/api/regulations) that is associated to the Bundle resource. :param iso_country: The 2-digit [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Bundle's phone number country ownership request. - :param number_type: The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `tollfree`. + :param number_type: The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll-free`. :param has_valid_until_date: Indicates that the Bundle is a valid Bundle until a specified expiration date. :param sort_by: Can be `valid-until` or `date-updated`. Defaults to `date-created`. :param sort_direction: Default is `DESC`. Can be `ASC` or `DESC`. @@ -895,7 +895,7 @@ async def page_async( :param friendly_name: The string that you assigned to describe the resource. The column can contain 255 variable characters. :param regulation_sid: The unique string of a [Regulation resource](https://www.twilio.com/docs/phone-numbers/regulatory/api/regulations) that is associated to the Bundle resource. :param iso_country: The 2-digit [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Bundle's phone number country ownership request. - :param number_type: The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `tollfree`. + :param number_type: The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll-free`. :param has_valid_until_date: Indicates that the Bundle is a valid Bundle until a specified expiration date. :param sort_by: Can be `valid-until` or `date-updated`. Defaults to `date-created`. :param sort_direction: Default is `DESC`. Can be `ASC` or `DESC`. From 4168b097641b9d0f4b0d60dc632650eb4babec92 Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 18 Sep 2024 13:23:24 +0000 Subject: [PATCH 17/37] Release 9.3.1 --- setup.py | 2 +- twilio/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 6366ea68e..c3b935f10 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setup( name="twilio", - version="9.3.0", + version="9.3.1", description="Twilio API client and TwiML generator", author="Twilio", help_center="https://www.twilio.com/help/contact", diff --git a/twilio/__init__.py b/twilio/__init__.py index 529960ecb..de97d5499 100644 --- a/twilio/__init__.py +++ b/twilio/__init__.py @@ -1,2 +1,2 @@ -__version_info__ = ("9", "3", "0") +__version_info__ = ("9", "3", "1") __version__ = ".".join(__version_info__) From 75e8b145c05da7e6cf9fc9a06812cbf102a65d90 Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 25 Sep 2024 11:48:41 +0000 Subject: [PATCH 18/37] [Librarian] Regenerated @ 08245333f4a8c9235d547b189cd9c422f73e0e7e 7bb98153c25ebfee95e6e85bd4c57969e6d02435 --- CHANGES.md | 11 + twilio/rest/accounts/v1/__init__.py | 16 + twilio/rest/accounts/v1/bulk_consents.py | 106 ++++ twilio/rest/accounts/v1/bulk_contacts.py | 106 ++++ .../rest/assistants/v1/assistant/__init__.py | 67 +++ .../v1/assistant/assistants_knowledge.py | 506 ++++++++++++++++++ .../v1/assistant/assistants_tool.py | 506 ++++++++++++++++++ .../rest/assistants/v1/assistant/message.py | 153 ++++++ .../rest/assistants/v1/knowledge/__init__.py | 23 + .../v1/knowledge/knowledge_status.py | 192 +++++++ twilio/rest/assistants/v1/tool.py | 60 +++ twilio/rest/numbers/v1/__init__.py | 24 +- ...hook_configuration_fetch.py => webhook.py} | 26 +- .../v1/service/environment/deployment.py | 14 +- 14 files changed, 1778 insertions(+), 32 deletions(-) create mode 100644 twilio/rest/accounts/v1/bulk_consents.py create mode 100644 twilio/rest/accounts/v1/bulk_contacts.py create mode 100644 twilio/rest/assistants/v1/assistant/assistants_knowledge.py create mode 100644 twilio/rest/assistants/v1/assistant/assistants_tool.py create mode 100644 twilio/rest/assistants/v1/assistant/message.py create mode 100644 twilio/rest/assistants/v1/knowledge/knowledge_status.py rename twilio/rest/numbers/v1/{porting_webhook_configuration_fetch.py => webhook.py} (77%) diff --git a/CHANGES.md b/CHANGES.md index e8d674865..307f94f7d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,17 @@ twilio-python Changelog Here you can see the full list of changes between each twilio-python release. +[2024-09-25] Version 9.3.2 +-------------------------- +**Accounts** +- Update docs and mounts. +- Change library visibility to public +- Enable consent and contact bulk upsert APIs in prod. + +**Serverless** +- Add is_plugin parameter in deployments api to check if it is plugins deployment + + [2024-09-18] Version 9.3.1 -------------------------- **Library - Chore** diff --git a/twilio/rest/accounts/v1/__init__.py b/twilio/rest/accounts/v1/__init__.py index 142d5c7a9..6f5012d0f 100644 --- a/twilio/rest/accounts/v1/__init__.py +++ b/twilio/rest/accounts/v1/__init__.py @@ -16,6 +16,8 @@ from twilio.base.version import Version from twilio.base.domain import Domain from twilio.rest.accounts.v1.auth_token_promotion import AuthTokenPromotionList +from twilio.rest.accounts.v1.bulk_consents import BulkConsentsList +from twilio.rest.accounts.v1.bulk_contacts import BulkContactsList from twilio.rest.accounts.v1.credential import CredentialList from twilio.rest.accounts.v1.safelist import SafelistList from twilio.rest.accounts.v1.secondary_auth_token import SecondaryAuthTokenList @@ -31,6 +33,8 @@ def __init__(self, domain: Domain): """ super().__init__(domain, "v1") self._auth_token_promotion: Optional[AuthTokenPromotionList] = None + self._bulk_consents: Optional[BulkConsentsList] = None + self._bulk_contacts: Optional[BulkContactsList] = None self._credentials: Optional[CredentialList] = None self._safelist: Optional[SafelistList] = None self._secondary_auth_token: Optional[SecondaryAuthTokenList] = None @@ -41,6 +45,18 @@ def auth_token_promotion(self) -> AuthTokenPromotionList: self._auth_token_promotion = AuthTokenPromotionList(self) return self._auth_token_promotion + @property + def bulk_consents(self) -> BulkConsentsList: + if self._bulk_consents is None: + self._bulk_consents = BulkConsentsList(self) + return self._bulk_consents + + @property + def bulk_contacts(self) -> BulkContactsList: + if self._bulk_contacts is None: + self._bulk_contacts = BulkContactsList(self) + return self._bulk_contacts + @property def credentials(self) -> CredentialList: if self._credentials is None: diff --git a/twilio/rest/accounts/v1/bulk_consents.py b/twilio/rest/accounts/v1/bulk_consents.py new file mode 100644 index 000000000..850d72162 --- /dev/null +++ b/twilio/rest/accounts/v1/bulk_consents.py @@ -0,0 +1,106 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Accounts + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, List, Optional +from twilio.base import serialize, values + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class BulkConsentsInstance(InstanceResource): + """ + :ivar items: A list of objects where each object represents the result of processing a `correlation_id`. Each object contains the following fields: `correlation_id`, a unique 32-character UUID that maps the response to the original request; `error_code`, an integer where 0 indicates success and any non-zero value represents an error; and `error_messages`, an array of strings describing specific validation errors encountered. If the request is successful, the error_messages array will be empty. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.items: Optional[Dict[str, object]] = payload.get("items") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class BulkConsentsList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the BulkConsentsList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Consents/Bulk" + + def create(self, items: List[object]) -> BulkConsentsInstance: + """ + Create the BulkConsentsInstance + + :param items: This is a list of objects that describes a contact's opt-in status. Each object contains the following fields: `contact_id`, which must be a string representing phone number in [E.164 format](https://www.twilio.com/docs/glossary/what-e164); `correlation_id`, a unique 32-character UUID used to uniquely map the request item with the response item; `sender_id`, which can be either a valid messaging service SID or a from phone number; `status`, a string representing the consent status. Can be one of [`opt-in`, `opt-out`]; and `source`, a string indicating the medium through which the consent was collected. Can be one of [`website`, `offline`, `opt-in-message`, `opt-out-message`, `others`]. + + :returns: The created BulkConsentsInstance + """ + + data = values.of( + { + "Items": serialize.map(items, lambda e: serialize.object(e)), + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return BulkConsentsInstance(self._version, payload) + + async def create_async(self, items: List[object]) -> BulkConsentsInstance: + """ + Asynchronously create the BulkConsentsInstance + + :param items: This is a list of objects that describes a contact's opt-in status. Each object contains the following fields: `contact_id`, which must be a string representing phone number in [E.164 format](https://www.twilio.com/docs/glossary/what-e164); `correlation_id`, a unique 32-character UUID used to uniquely map the request item with the response item; `sender_id`, which can be either a valid messaging service SID or a from phone number; `status`, a string representing the consent status. Can be one of [`opt-in`, `opt-out`]; and `source`, a string indicating the medium through which the consent was collected. Can be one of [`website`, `offline`, `opt-in-message`, `opt-out-message`, `others`]. + + :returns: The created BulkConsentsInstance + """ + + data = values.of( + { + "Items": serialize.map(items, lambda e: serialize.object(e)), + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return BulkConsentsInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/accounts/v1/bulk_contacts.py b/twilio/rest/accounts/v1/bulk_contacts.py new file mode 100644 index 000000000..0d68908e3 --- /dev/null +++ b/twilio/rest/accounts/v1/bulk_contacts.py @@ -0,0 +1,106 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Accounts + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, List, Optional +from twilio.base import serialize, values + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class BulkContactsInstance(InstanceResource): + """ + :ivar items: A list of objects where each object represents the result of processing a `correlation_id`. Each object contains the following fields: `correlation_id`, a unique 32-character UUID that maps the response to the original request; `error_code`, an integer where 0 indicates success and any non-zero value represents an error; and `error_messages`, an array of strings describing specific validation errors encountered. If the request is successful, the error_messages array will be empty. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.items: Optional[Dict[str, object]] = payload.get("items") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class BulkContactsList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the BulkContactsList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Contacts/Bulk" + + def create(self, items: List[object]) -> BulkContactsInstance: + """ + Create the BulkContactsInstance + + :param items: A list of objects where each object represents a contact's details. Each object includes the following fields: `contact_id`, which must be a string representing phone number in [E.164 format](https://www.twilio.com/docs/glossary/what-e164); `correlation_id`, a unique 32-character UUID that maps the response to the original request; `country_iso_code`, a string representing the country using the ISO format (e.g., US for the United States); and `zip_code`, a string representing the postal code. + + :returns: The created BulkContactsInstance + """ + + data = values.of( + { + "Items": serialize.map(items, lambda e: serialize.object(e)), + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return BulkContactsInstance(self._version, payload) + + async def create_async(self, items: List[object]) -> BulkContactsInstance: + """ + Asynchronously create the BulkContactsInstance + + :param items: A list of objects where each object represents a contact's details. Each object includes the following fields: `contact_id`, which must be a string representing phone number in [E.164 format](https://www.twilio.com/docs/glossary/what-e164); `correlation_id`, a unique 32-character UUID that maps the response to the original request; `country_iso_code`, a string representing the country using the ISO format (e.g., US for the United States); and `zip_code`, a string representing the postal code. + + :returns: The created BulkContactsInstance + """ + + data = values.of( + { + "Items": serialize.map(items, lambda e: serialize.object(e)), + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return BulkContactsInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/assistants/v1/assistant/__init__.py b/twilio/rest/assistants/v1/assistant/__init__.py index 10e90c474..a865a040e 100644 --- a/twilio/rest/assistants/v1/assistant/__init__.py +++ b/twilio/rest/assistants/v1/assistant/__init__.py @@ -20,7 +20,12 @@ from twilio.base.list_resource import ListResource from twilio.base.version import Version from twilio.base.page import Page +from twilio.rest.assistants.v1.assistant.assistants_knowledge import ( + AssistantsKnowledgeList, +) +from twilio.rest.assistants.v1.assistant.assistants_tool import AssistantsToolList from twilio.rest.assistants.v1.assistant.feedback import FeedbackList +from twilio.rest.assistants.v1.assistant.message import MessageList class AssistantInstance(InstanceResource): @@ -31,6 +36,7 @@ class AssistantInstance(InstanceResource): :ivar model: The default model used by the assistant. :ivar name: The name of the assistant. :ivar owner: The owner/company of the assistant. + :ivar url: The url of the assistant resource. :ivar personality_prompt: The personality prompt to be used for assistant. :ivar date_created: The date and time in GMT when the Assistant was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. :ivar date_updated: The date and time in GMT when the Assistant was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. @@ -49,6 +55,7 @@ def __init__( self.model: Optional[str] = payload.get("model") self.name: Optional[str] = payload.get("name") self.owner: Optional[str] = payload.get("owner") + self.url: Optional[str] = payload.get("url") self.personality_prompt: Optional[str] = payload.get("personality_prompt") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") @@ -149,6 +156,20 @@ async def update_async( assistants_v1_service_update_assistant_request=assistants_v1_service_update_assistant_request, ) + @property + def assistants_knowledge(self) -> AssistantsKnowledgeList: + """ + Access the assistants_knowledge + """ + return self._proxy.assistants_knowledge + + @property + def assistants_tools(self) -> AssistantsToolList: + """ + Access the assistants_tools + """ + return self._proxy.assistants_tools + @property def feedbacks(self) -> FeedbackList: """ @@ -156,6 +177,13 @@ def feedbacks(self) -> FeedbackList: """ return self._proxy.feedbacks + @property + def messages(self) -> MessageList: + """ + Access the messages + """ + return self._proxy.messages + def __repr__(self) -> str: """ Provide a friendly representation @@ -183,7 +211,10 @@ def __init__(self, version: Version, id: str): } self._uri = "/Assistants/{id}".format(**self._solution) + self._assistants_knowledge: Optional[AssistantsKnowledgeList] = None + self._assistants_tools: Optional[AssistantsToolList] = None self._feedbacks: Optional[FeedbackList] = None + self._messages: Optional[MessageList] = None def delete(self) -> bool: """ @@ -299,6 +330,30 @@ async def update_async( return AssistantInstance(self._version, payload, id=self._solution["id"]) + @property + def assistants_knowledge(self) -> AssistantsKnowledgeList: + """ + Access the assistants_knowledge + """ + if self._assistants_knowledge is None: + self._assistants_knowledge = AssistantsKnowledgeList( + self._version, + self._solution["id"], + ) + return self._assistants_knowledge + + @property + def assistants_tools(self) -> AssistantsToolList: + """ + Access the assistants_tools + """ + if self._assistants_tools is None: + self._assistants_tools = AssistantsToolList( + self._version, + self._solution["id"], + ) + return self._assistants_tools + @property def feedbacks(self) -> FeedbackList: """ @@ -311,6 +366,18 @@ def feedbacks(self) -> FeedbackList: ) return self._feedbacks + @property + def messages(self) -> MessageList: + """ + Access the messages + """ + if self._messages is None: + self._messages = MessageList( + self._version, + self._solution["id"], + ) + return self._messages + def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/assistants/v1/assistant/assistants_knowledge.py b/twilio/rest/assistants/v1/assistant/assistants_knowledge.py new file mode 100644 index 000000000..b3c7e9ae0 --- /dev/null +++ b/twilio/rest/assistants/v1/assistant/assistants_knowledge.py @@ -0,0 +1,506 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Assistants + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import deserialize, values +from twilio.base.instance_context import InstanceContext +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version +from twilio.base.page import Page + + +class AssistantsKnowledgeInstance(InstanceResource): + """ + :ivar description: The type of knowledge source. + :ivar id: The description of knowledge. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Knowledge resource. + :ivar knowledge_source_details: The details of the knowledge source based on the type. + :ivar name: The name of the knowledge source. + :ivar status: The status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED') + :ivar type: The type of knowledge source ('Web', 'Database', 'Text', 'File') + :ivar url: The url of the knowledge resource. + :ivar date_created: The date and time in GMT when the Knowledge was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar date_updated: The date and time in GMT when the Knowledge was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + assistant_id: str, + id: Optional[str] = None, + ): + super().__init__(version) + + self.description: Optional[str] = payload.get("description") + self.id: Optional[str] = payload.get("id") + self.account_sid: Optional[str] = payload.get("account_sid") + self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( + "knowledge_source_details" + ) + self.name: Optional[str] = payload.get("name") + self.status: Optional[str] = payload.get("status") + self.type: Optional[str] = payload.get("type") + self.url: Optional[str] = payload.get("url") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + + self._solution = { + "assistant_id": assistant_id, + "id": id or self.id, + } + self._context: Optional[AssistantsKnowledgeContext] = None + + @property + def _proxy(self) -> "AssistantsKnowledgeContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: AssistantsKnowledgeContext for this AssistantsKnowledgeInstance + """ + if self._context is None: + self._context = AssistantsKnowledgeContext( + self._version, + assistant_id=self._solution["assistant_id"], + id=self._solution["id"], + ) + return self._context + + def create(self) -> "AssistantsKnowledgeInstance": + """ + Create the AssistantsKnowledgeInstance + + + :returns: The created AssistantsKnowledgeInstance + """ + return self._proxy.create() + + async def create_async(self) -> "AssistantsKnowledgeInstance": + """ + Asynchronous coroutine to create the AssistantsKnowledgeInstance + + + :returns: The created AssistantsKnowledgeInstance + """ + return await self._proxy.create_async() + + def delete(self) -> bool: + """ + Deletes the AssistantsKnowledgeInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the AssistantsKnowledgeInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class AssistantsKnowledgeContext(InstanceContext): + + def __init__(self, version: Version, assistant_id: str, id: str): + """ + Initialize the AssistantsKnowledgeContext + + :param version: Version that contains the resource + :param assistant_id: The assistant ID. + :param id: The knowledge ID. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "assistant_id": assistant_id, + "id": id, + } + self._uri = "/Assistants/{assistant_id}/Knowledge/{id}".format(**self._solution) + + def create(self) -> AssistantsKnowledgeInstance: + """ + Create the AssistantsKnowledgeInstance + + + :returns: The created AssistantsKnowledgeInstance + """ + data = values.of({}) + + payload = self._version.create(method="POST", uri=self._uri, data=data) + + return AssistantsKnowledgeInstance( + self._version, + payload, + assistant_id=self._solution["assistant_id"], + id=self._solution["id"], + ) + + async def create_async(self) -> AssistantsKnowledgeInstance: + """ + Asynchronous coroutine to create the AssistantsKnowledgeInstance + + + :returns: The created AssistantsKnowledgeInstance + """ + data = values.of({}) + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data + ) + + return AssistantsKnowledgeInstance( + self._version, + payload, + assistant_id=self._solution["assistant_id"], + id=self._solution["id"], + ) + + def delete(self) -> bool: + """ + Deletes the AssistantsKnowledgeInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._version.delete( + method="DELETE", + uri=self._uri, + ) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the AssistantsKnowledgeInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._version.delete_async( + method="DELETE", + uri=self._uri, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class AssistantsKnowledgePage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> AssistantsKnowledgeInstance: + """ + Build an instance of AssistantsKnowledgeInstance + + :param payload: Payload response from the API + """ + return AssistantsKnowledgeInstance( + self._version, payload, assistant_id=self._solution["assistant_id"] + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class AssistantsKnowledgeList(ListResource): + + def __init__(self, version: Version, assistant_id: str): + """ + Initialize the AssistantsKnowledgeList + + :param version: Version that contains the resource + :param assistant_id: The assistant ID. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "assistant_id": assistant_id, + } + self._uri = "/Assistants/{assistant_id}/Knowledge".format(**self._solution) + + def create(self) -> AssistantsKnowledgeInstance: + """ + Create the AssistantsKnowledgeInstance + + + :returns: The created AssistantsKnowledgeInstance + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + payload = self._version.create(method="POST", uri=self._uri, headers=headers) + + return AssistantsKnowledgeInstance( + self._version, payload, assistant_id=self._solution["assistant_id"] + ) + + async def create_async(self) -> AssistantsKnowledgeInstance: + """ + Asynchronously create the AssistantsKnowledgeInstance + + + :returns: The created AssistantsKnowledgeInstance + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + payload = await self._version.create_async( + method="POST", uri=self._uri, headers=headers + ) + + return AssistantsKnowledgeInstance( + self._version, payload, assistant_id=self._solution["assistant_id"] + ) + + def stream( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[AssistantsKnowledgeInstance]: + """ + Streams AssistantsKnowledgeInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = self.page(page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[AssistantsKnowledgeInstance]: + """ + Asynchronously streams AssistantsKnowledgeInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = await self.page_async(page_size=limits["page_size"]) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[AssistantsKnowledgeInstance]: + """ + Lists AssistantsKnowledgeInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return list( + self.stream( + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[AssistantsKnowledgeInstance]: + """ + Asynchronously lists AssistantsKnowledgeInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return [ + record + async for record in await self.stream_async( + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> AssistantsKnowledgePage: + """ + Retrieve a single page of AssistantsKnowledgeInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of AssistantsKnowledgeInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = self._version.page(method="GET", uri=self._uri, params=data) + return AssistantsKnowledgePage(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, + ) -> AssistantsKnowledgePage: + """ + Asynchronously retrieve a single page of AssistantsKnowledgeInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of AssistantsKnowledgeInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data + ) + return AssistantsKnowledgePage(self._version, response, self._solution) + + def get_page(self, target_url: str) -> AssistantsKnowledgePage: + """ + Retrieve a specific page of AssistantsKnowledgeInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of AssistantsKnowledgeInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return AssistantsKnowledgePage(self._version, response, self._solution) + + async def get_page_async(self, target_url: str) -> AssistantsKnowledgePage: + """ + Asynchronously retrieve a specific page of AssistantsKnowledgeInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of AssistantsKnowledgeInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return AssistantsKnowledgePage(self._version, response, self._solution) + + def get(self, id: str) -> AssistantsKnowledgeContext: + """ + Constructs a AssistantsKnowledgeContext + + :param id: The knowledge ID. + """ + return AssistantsKnowledgeContext( + self._version, assistant_id=self._solution["assistant_id"], id=id + ) + + def __call__(self, id: str) -> AssistantsKnowledgeContext: + """ + Constructs a AssistantsKnowledgeContext + + :param id: The knowledge ID. + """ + return AssistantsKnowledgeContext( + self._version, assistant_id=self._solution["assistant_id"], id=id + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/assistants/v1/assistant/assistants_tool.py b/twilio/rest/assistants/v1/assistant/assistants_tool.py new file mode 100644 index 000000000..0bed2b76a --- /dev/null +++ b/twilio/rest/assistants/v1/assistant/assistants_tool.py @@ -0,0 +1,506 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Assistants + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import deserialize, values +from twilio.base.instance_context import InstanceContext +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version +from twilio.base.page import Page + + +class AssistantsToolInstance(InstanceResource): + """ + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Tool resource. + :ivar description: The description of the tool. + :ivar enabled: True if the tool is enabled. + :ivar id: The tool ID. + :ivar meta: The metadata related to method, url, input_schema to used with the Tool. + :ivar name: The name of the tool. + :ivar requires_auth: The authentication requirement for the tool. + :ivar type: The type of the tool. ('WEBHOOK') + :ivar url: The url of the tool resource. + :ivar date_created: The date and time in GMT when the Tool was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar date_updated: The date and time in GMT when the Tool was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + assistant_id: str, + id: Optional[str] = None, + ): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.description: Optional[str] = payload.get("description") + self.enabled: Optional[bool] = payload.get("enabled") + self.id: Optional[str] = payload.get("id") + self.meta: Optional[Dict[str, object]] = payload.get("meta") + self.name: Optional[str] = payload.get("name") + self.requires_auth: Optional[bool] = payload.get("requires_auth") + self.type: Optional[str] = payload.get("type") + self.url: Optional[str] = payload.get("url") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + + self._solution = { + "assistant_id": assistant_id, + "id": id or self.id, + } + self._context: Optional[AssistantsToolContext] = None + + @property + def _proxy(self) -> "AssistantsToolContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: AssistantsToolContext for this AssistantsToolInstance + """ + if self._context is None: + self._context = AssistantsToolContext( + self._version, + assistant_id=self._solution["assistant_id"], + id=self._solution["id"], + ) + return self._context + + def create(self) -> "AssistantsToolInstance": + """ + Create the AssistantsToolInstance + + + :returns: The created AssistantsToolInstance + """ + return self._proxy.create() + + async def create_async(self) -> "AssistantsToolInstance": + """ + Asynchronous coroutine to create the AssistantsToolInstance + + + :returns: The created AssistantsToolInstance + """ + return await self._proxy.create_async() + + def delete(self) -> bool: + """ + Deletes the AssistantsToolInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the AssistantsToolInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class AssistantsToolContext(InstanceContext): + + def __init__(self, version: Version, assistant_id: str, id: str): + """ + Initialize the AssistantsToolContext + + :param version: Version that contains the resource + :param assistant_id: The assistant ID. + :param id: The tool ID. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "assistant_id": assistant_id, + "id": id, + } + self._uri = "/Assistants/{assistant_id}/Tools/{id}".format(**self._solution) + + def create(self) -> AssistantsToolInstance: + """ + Create the AssistantsToolInstance + + + :returns: The created AssistantsToolInstance + """ + data = values.of({}) + + payload = self._version.create(method="POST", uri=self._uri, data=data) + + return AssistantsToolInstance( + self._version, + payload, + assistant_id=self._solution["assistant_id"], + id=self._solution["id"], + ) + + async def create_async(self) -> AssistantsToolInstance: + """ + Asynchronous coroutine to create the AssistantsToolInstance + + + :returns: The created AssistantsToolInstance + """ + data = values.of({}) + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data + ) + + return AssistantsToolInstance( + self._version, + payload, + assistant_id=self._solution["assistant_id"], + id=self._solution["id"], + ) + + def delete(self) -> bool: + """ + Deletes the AssistantsToolInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._version.delete( + method="DELETE", + uri=self._uri, + ) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the AssistantsToolInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._version.delete_async( + method="DELETE", + uri=self._uri, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class AssistantsToolPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> AssistantsToolInstance: + """ + Build an instance of AssistantsToolInstance + + :param payload: Payload response from the API + """ + return AssistantsToolInstance( + self._version, payload, assistant_id=self._solution["assistant_id"] + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class AssistantsToolList(ListResource): + + def __init__(self, version: Version, assistant_id: str): + """ + Initialize the AssistantsToolList + + :param version: Version that contains the resource + :param assistant_id: The assistant ID. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "assistant_id": assistant_id, + } + self._uri = "/Assistants/{assistant_id}/Tools".format(**self._solution) + + def create(self) -> AssistantsToolInstance: + """ + Create the AssistantsToolInstance + + + :returns: The created AssistantsToolInstance + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + payload = self._version.create(method="POST", uri=self._uri, headers=headers) + + return AssistantsToolInstance( + self._version, payload, assistant_id=self._solution["assistant_id"] + ) + + async def create_async(self) -> AssistantsToolInstance: + """ + Asynchronously create the AssistantsToolInstance + + + :returns: The created AssistantsToolInstance + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + payload = await self._version.create_async( + method="POST", uri=self._uri, headers=headers + ) + + return AssistantsToolInstance( + self._version, payload, assistant_id=self._solution["assistant_id"] + ) + + def stream( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[AssistantsToolInstance]: + """ + Streams AssistantsToolInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = self.page(page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[AssistantsToolInstance]: + """ + Asynchronously streams AssistantsToolInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = await self.page_async(page_size=limits["page_size"]) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[AssistantsToolInstance]: + """ + Lists AssistantsToolInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return list( + self.stream( + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[AssistantsToolInstance]: + """ + Asynchronously lists AssistantsToolInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return [ + record + async for record in await self.stream_async( + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> AssistantsToolPage: + """ + Retrieve a single page of AssistantsToolInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of AssistantsToolInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = self._version.page(method="GET", uri=self._uri, params=data) + return AssistantsToolPage(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, + ) -> AssistantsToolPage: + """ + Asynchronously retrieve a single page of AssistantsToolInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of AssistantsToolInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data + ) + return AssistantsToolPage(self._version, response, self._solution) + + def get_page(self, target_url: str) -> AssistantsToolPage: + """ + Retrieve a specific page of AssistantsToolInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of AssistantsToolInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return AssistantsToolPage(self._version, response, self._solution) + + async def get_page_async(self, target_url: str) -> AssistantsToolPage: + """ + Asynchronously retrieve a specific page of AssistantsToolInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of AssistantsToolInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return AssistantsToolPage(self._version, response, self._solution) + + def get(self, id: str) -> AssistantsToolContext: + """ + Constructs a AssistantsToolContext + + :param id: The tool ID. + """ + return AssistantsToolContext( + self._version, assistant_id=self._solution["assistant_id"], id=id + ) + + def __call__(self, id: str) -> AssistantsToolContext: + """ + Constructs a AssistantsToolContext + + :param id: The tool ID. + """ + return AssistantsToolContext( + self._version, assistant_id=self._solution["assistant_id"], id=id + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/assistants/v1/assistant/message.py b/twilio/rest/assistants/v1/assistant/message.py new file mode 100644 index 000000000..b42514cb3 --- /dev/null +++ b/twilio/rest/assistants/v1/assistant/message.py @@ -0,0 +1,153 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Assistants + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, Optional +from twilio.base import values + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class MessageInstance(InstanceResource): + """ + :ivar status: success or failure based on whether the request successfully generated a response. + :ivar flagged: If successful, this property will denote whether the response was flagged or not. + :ivar aborted: This property will denote whether the request was aborted or not. + :ivar session_id: The unique name for the session. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that sent the Message. + :ivar body: If successful, the body of the generated response + :ivar error: The error message if generation was not successful + """ + + def __init__(self, version: Version, payload: Dict[str, Any], id: str): + super().__init__(version) + + self.status: Optional[str] = payload.get("status") + self.flagged: Optional[bool] = payload.get("flagged") + self.aborted: Optional[bool] = payload.get("aborted") + self.session_id: Optional[str] = payload.get("session_id") + self.account_sid: Optional[str] = payload.get("account_sid") + self.body: Optional[str] = payload.get("body") + self.error: Optional[str] = payload.get("error") + + self._solution = { + "id": id, + } + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class MessageList(ListResource): + + class AssistantsV1ServiceAssistantSendMessageRequest(object): + """ + :ivar identity: The unique identity of user for the session. + :ivar session_id: The unique name for the session. + :ivar body: The query to ask the assistant. + :ivar webhook: The webhook url to call after the assistant has generated a response or report an error. + :ivar mode: one of the modes 'chat', 'email' or 'voice' + """ + + def __init__(self, payload: Dict[str, Any]): + + self.identity: Optional[str] = payload.get("identity") + self.session_id: Optional[str] = payload.get("session_id") + self.body: Optional[str] = payload.get("body") + self.webhook: Optional[str] = payload.get("webhook") + self.mode: Optional[str] = payload.get("mode") + + def to_dict(self): + return { + "identity": self.identity, + "session_id": self.session_id, + "body": self.body, + "webhook": self.webhook, + "mode": self.mode, + } + + def __init__(self, version: Version, id: str): + """ + Initialize the MessageList + + :param version: Version that contains the resource + :param id: the Assistant ID. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id": id, + } + self._uri = "/Assistants/{id}/Messages".format(**self._solution) + + def create( + self, + assistants_v1_service_assistant_send_message_request: AssistantsV1ServiceAssistantSendMessageRequest, + ) -> MessageInstance: + """ + Create the MessageInstance + + :param assistants_v1_service_assistant_send_message_request: + + :returns: The created MessageInstance + """ + data = assistants_v1_service_assistant_send_message_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return MessageInstance(self._version, payload, id=self._solution["id"]) + + async def create_async( + self, + assistants_v1_service_assistant_send_message_request: AssistantsV1ServiceAssistantSendMessageRequest, + ) -> MessageInstance: + """ + Asynchronously create the MessageInstance + + :param assistants_v1_service_assistant_send_message_request: + + :returns: The created MessageInstance + """ + data = assistants_v1_service_assistant_send_message_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return MessageInstance(self._version, payload, id=self._solution["id"]) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/assistants/v1/knowledge/__init__.py b/twilio/rest/assistants/v1/knowledge/__init__.py index 32b17e235..498bc80f9 100644 --- a/twilio/rest/assistants/v1/knowledge/__init__.py +++ b/twilio/rest/assistants/v1/knowledge/__init__.py @@ -21,6 +21,7 @@ from twilio.base.version import Version from twilio.base.page import Page from twilio.rest.assistants.v1.knowledge.chunk import ChunkList +from twilio.rest.assistants.v1.knowledge.knowledge_status import KnowledgeStatusList class KnowledgeInstance(InstanceResource): @@ -32,6 +33,7 @@ class KnowledgeInstance(InstanceResource): :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 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. """ @@ -50,6 +52,7 @@ def __init__( 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.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) @@ -154,6 +157,13 @@ def chunks(self) -> ChunkList: """ 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 @@ -182,6 +192,7 @@ def __init__(self, version: Version, id: str): self._uri = "/Knowledge/{id}".format(**self._solution) self._chunks: Optional[ChunkList] = None + self._knowledge_status: Optional[KnowledgeStatusList] = None def delete(self) -> bool: """ @@ -309,6 +320,18 @@ def chunks(self) -> ChunkList: ) 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 diff --git a/twilio/rest/assistants/v1/knowledge/knowledge_status.py b/twilio/rest/assistants/v1/knowledge/knowledge_status.py new file mode 100644 index 000000000..14a56b0cc --- /dev/null +++ b/twilio/rest/assistants/v1/knowledge/knowledge_status.py @@ -0,0 +1,192 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Assistants + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, Optional +from twilio.base import deserialize +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 + """ + + payload = self._version.fetch( + method="GET", + uri=self._uri, + ) + + 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 + """ + + payload = await self._version.fetch_async( + method="GET", + uri=self._uri, + ) + + 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/assistants/v1/tool.py b/twilio/rest/assistants/v1/tool.py index a66a818b5..a8b1ac647 100644 --- a/twilio/rest/assistants/v1/tool.py +++ b/twilio/rest/assistants/v1/tool.py @@ -32,8 +32,10 @@ class ToolInstance(InstanceResource): :ivar name: The name of the tool. :ivar requires_auth: The authentication requirement for the tool. :ivar type: The type of the tool. ('WEBHOOK') + :ivar url: The url of the tool resource. :ivar date_created: The date and time in GMT when the Tool was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. :ivar date_updated: The date and time in GMT when the Tool was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar policies: The Policies associated with the tool. """ def __init__( @@ -49,12 +51,14 @@ def __init__( self.name: Optional[str] = payload.get("name") self.requires_auth: Optional[bool] = payload.get("requires_auth") self.type: Optional[str] = payload.get("type") + self.url: Optional[str] = payload.get("url") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_updated") ) + self.policies: Optional[List[str]] = payload.get("policies") self._solution = { "id": id or self.id, @@ -94,6 +98,24 @@ async def delete_async(self) -> bool: """ return await self._proxy.delete_async() + def fetch(self) -> "ToolInstance": + """ + Fetch the ToolInstance + + + :returns: The fetched ToolInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "ToolInstance": + """ + Asynchronous coroutine to fetch the ToolInstance + + + :returns: The fetched ToolInstance + """ + return await self._proxy.fetch_async() + def update( self, assistants_v1_service_update_tool_request: Union[ @@ -179,6 +201,44 @@ async def delete_async(self) -> bool: uri=self._uri, ) + def fetch(self) -> ToolInstance: + """ + Fetch the ToolInstance + + + :returns: The fetched ToolInstance + """ + + payload = self._version.fetch( + method="GET", + uri=self._uri, + ) + + return ToolInstance( + self._version, + payload, + id=self._solution["id"], + ) + + async def fetch_async(self) -> ToolInstance: + """ + Asynchronous coroutine to fetch the ToolInstance + + + :returns: The fetched ToolInstance + """ + + payload = await self._version.fetch_async( + method="GET", + uri=self._uri, + ) + + return ToolInstance( + self._version, + payload, + id=self._solution["id"], + ) + def update( self, assistants_v1_service_update_tool_request: Union[ diff --git a/twilio/rest/numbers/v1/__init__.py b/twilio/rest/numbers/v1/__init__.py index 043364c3d..68f078a88 100644 --- a/twilio/rest/numbers/v1/__init__.py +++ b/twilio/rest/numbers/v1/__init__.py @@ -28,12 +28,10 @@ from twilio.rest.numbers.v1.porting_webhook_configuration_delete import ( PortingWebhookConfigurationDeleteList, ) -from twilio.rest.numbers.v1.porting_webhook_configuration_fetch import ( - PortingWebhookConfigurationFetchList, -) from twilio.rest.numbers.v1.signing_request_configuration import ( SigningRequestConfigurationList, ) +from twilio.rest.numbers.v1.webhook import WebhookList class V1(Version): @@ -58,12 +56,10 @@ def __init__(self, domain: Domain): self._porting_webhook_configurations_delete: Optional[ PortingWebhookConfigurationDeleteList ] = None - self._porting_webhook_configuration_fetch: Optional[ - PortingWebhookConfigurationFetchList - ] = None self._signing_request_configurations: Optional[ SigningRequestConfigurationList ] = None + self._webhook: Optional[WebhookList] = None @property def bulk_eligibilities(self) -> BulkEligibilityList: @@ -111,22 +107,18 @@ def porting_webhook_configurations_delete( ) return self._porting_webhook_configurations_delete - @property - def porting_webhook_configuration_fetch( - self, - ) -> PortingWebhookConfigurationFetchList: - if self._porting_webhook_configuration_fetch is None: - self._porting_webhook_configuration_fetch = ( - PortingWebhookConfigurationFetchList(self) - ) - return self._porting_webhook_configuration_fetch - @property def signing_request_configurations(self) -> SigningRequestConfigurationList: if self._signing_request_configurations is None: self._signing_request_configurations = SigningRequestConfigurationList(self) return self._signing_request_configurations + @property + def webhook(self) -> WebhookList: + if self._webhook is None: + self._webhook = WebhookList(self) + return self._webhook + def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/numbers/v1/porting_webhook_configuration_fetch.py b/twilio/rest/numbers/v1/webhook.py similarity index 77% rename from twilio/rest/numbers/v1/porting_webhook_configuration_fetch.py rename to twilio/rest/numbers/v1/webhook.py index 89b8064bd..88ca64e9e 100644 --- a/twilio/rest/numbers/v1/porting_webhook_configuration_fetch.py +++ b/twilio/rest/numbers/v1/webhook.py @@ -21,7 +21,7 @@ from twilio.base.version import Version -class PortingWebhookConfigurationFetchInstance(InstanceResource): +class WebhookInstance(InstanceResource): """ :ivar url: The URL of the webhook configuration request :ivar port_in_target_url: The complete webhook url that will be called when a notification event for port in request or port in phone number happens @@ -52,14 +52,14 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" -class PortingWebhookConfigurationFetchList(ListResource): +class WebhookList(ListResource): def __init__(self, version: Version): """ - Initialize the PortingWebhookConfigurationFetchList + Initialize the WebhookList :param version: Version that contains the resource @@ -68,25 +68,25 @@ def __init__(self, version: Version): self._uri = "/Porting/Configuration/Webhook" - def fetch(self) -> PortingWebhookConfigurationFetchInstance: + def fetch(self) -> WebhookInstance: """ - Asynchronously fetch the PortingWebhookConfigurationFetchInstance + Asynchronously fetch the WebhookInstance - :returns: The fetched PortingWebhookConfigurationFetchInstance + :returns: The fetched WebhookInstance """ headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) - return PortingWebhookConfigurationFetchInstance(self._version, payload) + return WebhookInstance(self._version, payload) - async def fetch_async(self) -> PortingWebhookConfigurationFetchInstance: + async def fetch_async(self) -> WebhookInstance: """ - Asynchronously fetch the PortingWebhookConfigurationFetchInstance + Asynchronously fetch the WebhookInstance - :returns: The fetched PortingWebhookConfigurationFetchInstance + :returns: The fetched WebhookInstance """ headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) @@ -94,7 +94,7 @@ async def fetch_async(self) -> PortingWebhookConfigurationFetchInstance: method="GET", uri=self._uri, headers=headers ) - return PortingWebhookConfigurationFetchInstance(self._version, payload) + return WebhookInstance(self._version, payload) def __repr__(self) -> str: """ @@ -102,4 +102,4 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" diff --git a/twilio/rest/serverless/v1/service/environment/deployment.py b/twilio/rest/serverless/v1/service/environment/deployment.py index 63ef1b461..e9d86d0c3 100644 --- a/twilio/rest/serverless/v1/service/environment/deployment.py +++ b/twilio/rest/serverless/v1/service/environment/deployment.py @@ -14,7 +14,7 @@ from datetime import datetime from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator -from twilio.base import deserialize, values +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 @@ -235,12 +235,15 @@ def __init__(self, version: Version, service_sid: str, environment_sid: str): ) def create( - self, build_sid: Union[str, object] = values.unset + self, + build_sid: Union[str, object] = values.unset, + is_plugin: Union[bool, object] = values.unset, ) -> DeploymentInstance: """ Create the DeploymentInstance :param build_sid: The SID of the Build for the Deployment. + :param is_plugin: Whether the Deployment is a plugin. :returns: The created DeploymentInstance """ @@ -248,6 +251,7 @@ def create( data = values.of( { "BuildSid": build_sid, + "IsPlugin": serialize.boolean_to_string(is_plugin), } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) @@ -264,12 +268,15 @@ def create( ) async def create_async( - self, build_sid: Union[str, object] = values.unset + self, + build_sid: Union[str, object] = values.unset, + is_plugin: Union[bool, object] = values.unset, ) -> DeploymentInstance: """ Asynchronously create the DeploymentInstance :param build_sid: The SID of the Build for the Deployment. + :param is_plugin: Whether the Deployment is a plugin. :returns: The created DeploymentInstance """ @@ -277,6 +284,7 @@ async def create_async( data = values.of( { "BuildSid": build_sid, + "IsPlugin": serialize.boolean_to_string(is_plugin), } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) From 0f81bbb865e29b67ab7bcc0cfe084894023faca5 Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 25 Sep 2024 11:53:24 +0000 Subject: [PATCH 19/37] Release 9.3.2 --- setup.py | 2 +- twilio/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index c3b935f10..be0c82e70 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setup( name="twilio", - version="9.3.1", + version="9.3.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 de97d5499..9c85cf3a4 100644 --- a/twilio/__init__.py +++ b/twilio/__init__.py @@ -1,2 +1,2 @@ -__version_info__ = ("9", "3", "1") +__version_info__ = ("9", "3", "2") __version__ = ".".join(__version_info__) From 15e15c0169725a4f254f54142d967c5494a756f4 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Thu, 26 Sep 2024 17:56:00 +0530 Subject: [PATCH 20/37] twilio python changes for orgs api uptake --- twilio/authStrategy/authStrategy.py | 21 ++++++ twilio/authStrategy/authType.py | 11 +++ twilio/authStrategy/basicAuthStrategy.py | 17 +++++ twilio/authStrategy/noAuthStrategy.py | 11 +++ twilio/authStrategy/tokenAuthStrategy.py | 35 +++++++++ twilio/base/client_base.py | 74 +++++++++++-------- twilio/base/domain.py | 5 -- twilio/base/exceptions.py | 1 - twilio/base/version.py | 16 ---- twilio/credential/credentialProvider.py | 12 +++ twilio/credential/orgsCredentialProvider.py | 26 +++++++ twilio/http/http_client.py | 11 ++- twilio/http/orgs_token_manager.py | 8 +- twilio/rest/__init__.py | 3 + .../preview_iam/organizations/__init__.py | 12 ++- twilio/rest/preview_iam/v1/token.py | 2 +- 16 files changed, 202 insertions(+), 63 deletions(-) create mode 100644 twilio/authStrategy/authStrategy.py create mode 100644 twilio/authStrategy/authType.py create mode 100644 twilio/authStrategy/basicAuthStrategy.py create mode 100644 twilio/authStrategy/noAuthStrategy.py create mode 100644 twilio/authStrategy/tokenAuthStrategy.py create mode 100644 twilio/credential/credentialProvider.py create mode 100644 twilio/credential/orgsCredentialProvider.py diff --git a/twilio/authStrategy/authStrategy.py b/twilio/authStrategy/authStrategy.py new file mode 100644 index 000000000..55b901848 --- /dev/null +++ b/twilio/authStrategy/authStrategy.py @@ -0,0 +1,21 @@ +from twilio.authStrategy.authType import AuthType +from enum import Enum +from abc import abstractmethod + + +class AuthStrategy(object): + def __init__(self, auth_type: AuthType): + self._auth_type = auth_type + + @property + def auth_type(self) -> AuthType: + return self._auth_type + + def get_auth_string(self) -> str: + """Return the authentication string.""" + pass + + @abstractmethod + def requires_authentication(self) -> bool: + """Return True if authentication is required, else False.""" + pass \ No newline at end of file diff --git a/twilio/authStrategy/authType.py b/twilio/authStrategy/authType.py new file mode 100644 index 000000000..fe9f00203 --- /dev/null +++ b/twilio/authStrategy/authType.py @@ -0,0 +1,11 @@ +from enum import Enum + +class AuthType(Enum): + TOKEN = 'token' + NO_AUTH = 'noauth' + BASIC = 'basic' + API_KEY = 'api_key' + CLIENT_CREDENTIALS = 'client_credentials' + + def __str__(self): + return self.value \ No newline at end of file diff --git a/twilio/authStrategy/basicAuthStrategy.py b/twilio/authStrategy/basicAuthStrategy.py new file mode 100644 index 000000000..18784a316 --- /dev/null +++ b/twilio/authStrategy/basicAuthStrategy.py @@ -0,0 +1,17 @@ +import base64 +from enum import Enum + + +class BasicAuthStrategy(AuthStrategy): + def __init__(self, username: str, password: str): + super().__init__(AuthType.BASIC) + self.username = username + self.password = password + + def get_auth_string(self) -> str: + credentials = f"{self.username}:{self.password}" + encoded = base64.b64encode(credentials.encode('ascii')).decode('ascii') + return f"Basic {encoded}" + + def requires_authentication(self) -> bool: + return True \ No newline at end of file diff --git a/twilio/authStrategy/noAuthStrategy.py b/twilio/authStrategy/noAuthStrategy.py new file mode 100644 index 000000000..138195106 --- /dev/null +++ b/twilio/authStrategy/noAuthStrategy.py @@ -0,0 +1,11 @@ +from auth_type import AuthType + +class NoAuthStrategy(AuthStrategy): + def __init__(self): + super().__init__(AuthType.NO_AUTH) + + def get_auth_string(self) -> str: + return "" + + def requires_authentication(self) -> bool: + return False \ No newline at end of file diff --git a/twilio/authStrategy/tokenAuthStrategy.py b/twilio/authStrategy/tokenAuthStrategy.py new file mode 100644 index 000000000..ad6a0bb3c --- /dev/null +++ b/twilio/authStrategy/tokenAuthStrategy.py @@ -0,0 +1,35 @@ +import jwt +import threading +from datetime import datetime, timedelta + +from twilio.authStrategy.authType import AuthType +from twilio.authStrategy.authStrategy import AuthStrategy +from twilio.http.token_manager import TokenManager + + +class TokenAuthStrategy(AuthStrategy): + def __init__(self, token_manager: TokenManager): + super().__init__(AuthType.TOKEN) + self.token_manager = token_manager + self.token = None + self.lock = threading.Lock() + + def get_auth_string(self) -> str: + return f"Bearer {self.token}" + + def requires_authentication(self) -> bool: + return True + + def fetch_token(self): + if self.token is None or self.token == "" or self.is_token_expired(self.token): + with self.lock: + if self.token is None or self.token == "" or self.is_token_expired(self.token): + self.token = self.token_manager.fetch_access_token() + + def is_token_expired(self, token): + decoded_jwt = jwt.decode(token, options={"verify_signature": True}) + expires_at = decoded_jwt.get("exp") + # Add a buffer of 30 seconds + buffer_seconds = 30 + buffer_expires_at = expires_at - buffer_seconds + return buffer_expires_at < datetime.datetime.now().timestamp() \ No newline at end of file diff --git a/twilio/base/client_base.py b/twilio/base/client_base.py index 1bee0f613..0f2a000d8 100644 --- a/twilio/base/client_base.py +++ b/twilio/base/client_base.py @@ -4,10 +4,11 @@ from urllib.parse import urlparse, urlunparse from twilio import __version__ -from twilio.base.exceptions import TwilioException from twilio.http import HttpClient from twilio.http.http_client import TwilioHttpClient from twilio.http.response import Response +from twilio.authStrategy.authType import AuthType +from twilio.credential.credentialProvider import CredentialProvider class ClientBase(object): @@ -23,6 +24,7 @@ def __init__( environment: Optional[MutableMapping[str, str]] = None, edge: Optional[str] = None, user_agent_extensions: Optional[List[str]] = None, + credential_provider: Optional[CredentialProvider] = None, ): """ Initializes the Twilio Client @@ -35,7 +37,9 @@ def __init__( :param environment: Environment to look for auth details, defaults to os.environ :param edge: Twilio Edge to make requests to, defaults to None :param user_agent_extensions: Additions to the user agent string + :param credential_provider: credential provider for authentication method that needs to be used """ + environment = environment or os.environ self.username = username or environment.get("TWILIO_ACCOUNT_SID") @@ -48,9 +52,8 @@ def __init__( """ :type : str """ self.user_agent_extensions = user_agent_extensions or [] """ :type : list[str] """ - - if not self.username or not self.password: - raise TwilioException("Credentials are required to create a TwilioClient") + self.credential_provider = credential_provider or None + """ :type : CredentialProvider """ self.account_sid = account_sid or self.username """ :type : str """ @@ -69,8 +72,6 @@ def request( auth: Optional[Tuple[str, str]] = None, timeout: Optional[float] = None, allow_redirects: bool = False, - is_oauth: bool = False, - domain: Optional[str] = None, ) -> Response: """ Makes a request to the Twilio API using the configured http client @@ -88,20 +89,26 @@ def request( :returns: Response from the Twilio API """ - print('*****') - if not is_oauth: - auth = self.get_auth(auth) headers = self.get_headers(method, headers) + + ##If credential provider is provided by user, get the associated auth strategy + ##Using the auth strategy, fetch the auth string and set it to authorization header + auth_strategy = None ##Initialization + if self.credential_provider: + print(f'Reached here 2 {self.credential_provider}') + auth_strategy = self.credential_provider.to_auth_strategy() + if auth_strategy.auth_type == AuthType.TOKEN: + auth_strategy.fetch_token() + headers["Authorization"] = auth_strategy.get_auth_string() + if auth_strategy.auth_type == AuthType.BASIC: + headers["Authorization"] = auth_strategy.get_auth_string() + else: + auth = self.get_auth(auth) + + print(f'auth2 *** {auth}') + + uri = self.get_hostname(uri) - if is_oauth: - OauthTokenBase = dynamic_import( - "twilio.base.oauth_token_base", "OauthTokenBase" - ) - token = OauthTokenBase().get_oauth_token( - domain, "v1", self.username, self.password - ) - headers["Authorization"] = f"Bearer {token}" - headers.get("Authorization") return self.http_client.request( method, @@ -124,7 +131,6 @@ async def request_async( auth: Optional[Tuple[str, str]] = None, timeout: Optional[float] = None, allow_redirects: bool = False, - is_oauth: bool = False, ) -> Response: """ Asynchronously makes a request to the Twilio API using the configured http client @@ -146,19 +152,25 @@ async def request_async( raise RuntimeError( "http_client must be asynchronous to support async API requests" ) - if not is_oauth: - auth = self.get_auth(auth) + + headers = self.get_headers(method, headers) - uri = self.get_hostname(uri) - if is_oauth: - OauthTokenBase = dynamic_import( - "twilio.base.oauth_token_base", "OauthTokenBase" - ) - token = OauthTokenBase().get_oauth_token( - domain, "v1", self.username, self.password - ) - headers["Authorization"] = f"Bearer {token}" - headers.get("Authorization") + + ##If credential provider is provided by user, get the associated auth strategy + ##Using the auth strategy, fetch the auth string and set it to authorization header + auth_strategy = None ##Initialization + if self.credential_provider: + print(f'Reached here 1') + auth_strategy = self.credential_provider.to_auth_strategy() + if auth_strategy.auth_type == AuthType.TOKEN: + auth_strategy.fetch_token() + headers["Authorization"] = auth_strategy.get_auth_string() + if auth_strategy.auth_type == AuthType.BASIC: + headers["Authorization"] = auth_strategy.get_auth_string() + else: + auth = self.get_auth(auth) + + print(f'auth2 *** {auth}') return await self.http_client.request( method, diff --git a/twilio/base/domain.py b/twilio/base/domain.py index 72724aa9d..4f8395ddf 100644 --- a/twilio/base/domain.py +++ b/twilio/base/domain.py @@ -32,7 +32,6 @@ def request( auth: Optional[Tuple[str, str]] = None, timeout: Optional[float] = None, allow_redirects: bool = False, - is_oauth: bool = False, ) -> Response: """ Makes an HTTP request to this domain. @@ -56,8 +55,6 @@ def request( auth=auth, timeout=timeout, allow_redirects=allow_redirects, - is_oauth=is_oauth, - domain=self.base_url, ) async def request_async( @@ -70,7 +67,6 @@ async def request_async( auth: Optional[Tuple[str, str]] = None, timeout: Optional[float] = None, allow_redirects: bool = False, - is_oauth: bool = False, ) -> Response: """ Makes an asynchronous HTTP request to this domain. @@ -94,5 +90,4 @@ async def request_async( auth=auth, timeout=timeout, allow_redirects=allow_redirects, - is_oauth=is_oauth, ) diff --git a/twilio/base/exceptions.py b/twilio/base/exceptions.py index 05a7c96e8..9adb4a0d8 100644 --- a/twilio/base/exceptions.py +++ b/twilio/base/exceptions.py @@ -63,7 +63,6 @@ def get_uri(code: int) -> str: red_error=red("HTTP Error"), request_was=white("Your request was:"), http_line=teal("%s %s" % (self.method, self.uri, self.data, self.uri)), - http_line=teal("%s %s" % (self.data, self.headers)), twilio_returned=white("Twilio returned the following information:"), message=blue(str(self.msg)), ) diff --git a/twilio/base/version.py b/twilio/base/version.py index 68cf5ca30..c026f5dbf 100644 --- a/twilio/base/version.py +++ b/twilio/base/version.py @@ -39,7 +39,6 @@ def request( auth: Optional[Tuple[str, str]] = None, timeout: Optional[float] = None, allow_redirects: bool = False, - is_oauth: bool = False, ) -> Response: """ Make an HTTP request. @@ -54,7 +53,6 @@ def request( auth=auth, timeout=timeout, allow_redirects=allow_redirects, - is_oauth=is_oauth, ) async def request_async( @@ -67,7 +65,6 @@ async def request_async( auth: Optional[Tuple[str, str]] = None, timeout: Optional[float] = None, allow_redirects: bool = False, - is_oauth: bool = False, ) -> Response: """ Make an asynchronous HTTP request @@ -82,7 +79,6 @@ async def request_async( auth=auth, timeout=timeout, allow_redirects=allow_redirects, - is_oauth=is_oauth, ) @classmethod @@ -127,7 +123,6 @@ def fetch( auth: Optional[Tuple[str, str]] = None, timeout: Optional[float] = None, allow_redirects: bool = False, - is_oauth: bool = False, ) -> Any: """ Fetch a resource instance. @@ -141,7 +136,6 @@ def fetch( auth=auth, timeout=timeout, allow_redirects=allow_redirects, - is_oauth=is_oauth, ) return self._parse_fetch(method, uri, response) @@ -156,7 +150,6 @@ async def fetch_async( auth: Optional[Tuple[str, str]] = None, timeout: Optional[float] = None, allow_redirects: bool = False, - is_oauth: bool = False, ) -> Any: """ Asynchronously fetch a resource instance. @@ -170,7 +163,6 @@ async def fetch_async( auth=auth, timeout=timeout, allow_redirects=allow_redirects, - is_oauth=is_oauth, ) return self._parse_fetch(method, uri, response) @@ -194,7 +186,6 @@ def update( auth: Optional[Tuple[str, str]] = None, timeout: Optional[float] = None, allow_redirects: bool = False, - is_oauth: bool = False, ) -> Any: """ Update a resource instance. @@ -222,7 +213,6 @@ async def update_async( auth: Optional[Tuple[str, str]] = None, timeout: Optional[float] = None, allow_redirects: bool = False, - is_oauth: bool = False, ) -> Any: """ Asynchronously update a resource instance. @@ -236,7 +226,6 @@ async def update_async( auth=auth, timeout=timeout, allow_redirects=allow_redirects, - is_oauth=is_oauth, ) return self._parse_update(method, uri, response) @@ -260,7 +249,6 @@ def delete( auth: Optional[Tuple[str, str]] = None, timeout: Optional[float] = None, allow_redirects: bool = False, - is_oauth: bool = False, ) -> bool: """ Delete a resource. @@ -288,7 +276,6 @@ async def delete_async( auth: Optional[Tuple[str, str]] = None, timeout: Optional[float] = None, allow_redirects: bool = False, - is_oauth: bool = False, ) -> bool: """ Asynchronously delete a resource. @@ -302,7 +289,6 @@ async def delete_async( auth=auth, timeout=timeout, allow_redirects=allow_redirects, - is_oauth=is_oauth, ) return self._parse_delete(method, uri, response) @@ -361,7 +347,6 @@ async def page_async( auth: Optional[Tuple[str, str]] = None, timeout: Optional[float] = None, allow_redirects: bool = False, - is_oauth: bool = False, ) -> Response: """ Makes an asynchronous HTTP request. @@ -375,7 +360,6 @@ async def page_async( auth=auth, timeout=timeout, allow_redirects=allow_redirects, - is_oauth=is_oauth, ) def stream( diff --git a/twilio/credential/credentialProvider.py b/twilio/credential/credentialProvider.py new file mode 100644 index 000000000..2fc103f02 --- /dev/null +++ b/twilio/credential/credentialProvider.py @@ -0,0 +1,12 @@ +from twilio.authStrategy.authType import AuthType + +class CredentialProvider: + def __init__(self, auth_type: AuthType): + self._auth_type = auth_type + + @property + def auth_type(self) -> AuthType: + return self._auth_type + + def to_auth_strategy(self): + raise NotImplementedError("Subclasses must implement this method") diff --git a/twilio/credential/orgsCredentialProvider.py b/twilio/credential/orgsCredentialProvider.py new file mode 100644 index 000000000..6668a18d4 --- /dev/null +++ b/twilio/credential/orgsCredentialProvider.py @@ -0,0 +1,26 @@ + + +from twilio.http.orgs_token_manager import OrgTokenManager +from twilio.base.exceptions import TwilioException +from twilio.credential.credentialProvider import CredentialProvider +from twilio.authStrategy.authType import AuthType +from twilio.authStrategy.tokenAuthStrategy import TokenAuthStrategy + + +class OrgsCredentialProvider(CredentialProvider): + def __init__(self, client_id: str, client_secret: str, token_manager=None): + super().__init__(AuthType.CLIENT_CREDENTIALS) + + if client_id is None or client_secret is None: + raise TwilioException("Invalid credentials passed") + + self.grant_type = "client_credentials" + self.client_id = client_id + self.client_secret = client_secret + self.token_manager = token_manager + + def to_auth_strategy(self): + if self.token_manager is None: + self.token_manager = OrgTokenManager(self.grant_type, self.client_id, self.client_secret) + + return TokenAuthStrategy(self.token_manager) diff --git a/twilio/http/http_client.py b/twilio/http/http_client.py index c97c6e830..3e3560084 100644 --- a/twilio/http/http_client.py +++ b/twilio/http/http_client.py @@ -8,6 +8,7 @@ from twilio.http import HttpClient from twilio.http.request import Request as TwilioRequest from twilio.http.response import Response +from twilio.authStrategy.authStrategy import AuthStrategy _logger = logging.getLogger("twilio.http_client") @@ -57,7 +58,6 @@ def request( auth: Optional[Tuple[str, str]] = None, timeout: Optional[float] = None, allow_redirects: bool = False, - is_oauth: bool = False, ) -> Response: """ Make an HTTP Request with parameters provided. @@ -79,6 +79,12 @@ def request( elif timeout <= 0: raise ValueError(timeout) + print(f'auth *** {auth}') + + if "Requires-Authentication" in headers: + headers.pop("Requires-Authentication", None) + auth = None + kwargs = { "method": method.upper(), "url": url, @@ -92,7 +98,7 @@ def request( else: kwargs["data"] = data self.log_request(kwargs) - + print(f'kwargs {kwargs}') self._test_only_last_response = None session = self.session or Session() request = Request(**kwargs) @@ -103,7 +109,6 @@ def request( settings = session.merge_environment_settings( prepped_request.url, self.proxy, None, None, None ) - response = session.send( prepped_request, allow_redirects=allow_redirects, diff --git a/twilio/http/orgs_token_manager.py b/twilio/http/orgs_token_manager.py index 1929f21a5..396231b83 100644 --- a/twilio/http/orgs_token_manager.py +++ b/twilio/http/orgs_token_manager.py @@ -1,6 +1,7 @@ from twilio.base.version import Version from twilio.http.token_manager import TokenManager from twilio.rest.preview_iam.v1.token import TokenList +from twilio.rest import Client class OrgTokenManager(TokenManager): @@ -27,10 +28,11 @@ def __init__( self.audience = audience self.refreshToken = refreshToken self.scope = scope + self.client = Client() - def fetch_access_token(self, version: Version): - token_list = TokenList(version) - token_instance = token_list.create( + def fetch_access_token(self): + # token_list = TokenList(version) + token_instance = self.client.preview_iam.v1.token.create( grant_type=self.grant_type, client_id=self.client_id, client_secret=self.client_secret, diff --git a/twilio/rest/__init__.py b/twilio/rest/__init__.py index 9c71ce2bb..06c5ef9f3 100644 --- a/twilio/rest/__init__.py +++ b/twilio/rest/__init__.py @@ -95,6 +95,7 @@ def __init__( environment=None, edge=None, user_agent_extensions=None, + credential_provider=None, ): """ Initializes the Twilio Client @@ -111,6 +112,7 @@ def __init__( :returns: Twilio Client :rtype: twilio.rest.Client """ + super().__init__( username, password, @@ -120,6 +122,7 @@ def __init__( environment, edge, user_agent_extensions, + credential_provider, ) # Domains diff --git a/twilio/rest/preview_iam/organizations/__init__.py b/twilio/rest/preview_iam/organizations/__init__.py index 9cd6cd7a6..6a57e0b45 100644 --- a/twilio/rest/preview_iam/organizations/__init__.py +++ b/twilio/rest/preview_iam/organizations/__init__.py @@ -27,17 +27,23 @@ def __init__(self, domain: Domain): :param domain: The Twilio.preview_iam domain """ - super().__init__(domain, "organizations") + super().__init__(domain, "Organizations") self._accounts: Optional[AccountList] = None self._role_assignments: Optional[RoleAssignmentList] = None - self._users: Optional[UserList] = None + # self._users: Optional[UserList] = None @property def accounts(self) -> AccountList: if self._accounts is None: - self._accounts = AccountList(self) + self._accounts = AccountList(self, organization_sid="OR64adedc0f4dc99b9113305f725677b47") return self._accounts + # @property + # def accounts(self, organization_sid) -> AccountList: + # if self._accounts is None: + # self._accounts = AccountList(self, "OR64adedc0f4dc99b9113305f725677b47") + # return self._accounts + @property def role_assignments(self) -> RoleAssignmentList: if self._role_assignments is None: diff --git a/twilio/rest/preview_iam/v1/token.py b/twilio/rest/preview_iam/v1/token.py index 50e37b9ea..461ee40fe 100644 --- a/twilio/rest/preview_iam/v1/token.py +++ b/twilio/rest/preview_iam/v1/token.py @@ -99,7 +99,7 @@ def create( "scope": scope, } ) - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded", "Requires-Authentication": "none"}) payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) From 7b07ba7952807b8d80087cb27bf2f4bbaf53ffbb Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Thu, 26 Sep 2024 17:58:45 +0530 Subject: [PATCH 21/37] twilio python changes for orgs api uptake --- twilio/authStrategy/basicAuthStrategy.py | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 twilio/authStrategy/basicAuthStrategy.py diff --git a/twilio/authStrategy/basicAuthStrategy.py b/twilio/authStrategy/basicAuthStrategy.py deleted file mode 100644 index 18784a316..000000000 --- a/twilio/authStrategy/basicAuthStrategy.py +++ /dev/null @@ -1,17 +0,0 @@ -import base64 -from enum import Enum - - -class BasicAuthStrategy(AuthStrategy): - def __init__(self, username: str, password: str): - super().__init__(AuthType.BASIC) - self.username = username - self.password = password - - def get_auth_string(self) -> str: - credentials = f"{self.username}:{self.password}" - encoded = base64.b64encode(credentials.encode('ascii')).decode('ascii') - return f"Basic {encoded}" - - def requires_authentication(self) -> bool: - return True \ No newline at end of file From af11fd29876c70936314917f526203babe8186d6 Mon Sep 17 00:00:00 2001 From: Athira Sabu <102021496+AsabuHere@users.noreply.github.com> Date: Thu, 26 Sep 2024 17:59:13 +0530 Subject: [PATCH 22/37] Update test_cluster.py --- tests/cluster/test_cluster.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/cluster/test_cluster.py b/tests/cluster/test_cluster.py index 76a6f85d0..3b96d1813 100644 --- a/tests/cluster/test_cluster.py +++ b/tests/cluster/test_cluster.py @@ -20,14 +20,6 @@ def setUp(self): self.voice_twiml = VoiceResponse() - def test_token_fetch(self): - token = self.client.preview_iam.token.create( - grant_type = GRANT_TYPE, - client_id = CLIENT_ID, - client_secret = CLIENT_SECRET) - print(f'{token}') - - def test_send_text_message(self): msg = self.client.messages.create( to=self.to_number, from_=self.from_number, body="hello world" From 661785db3b09499392e985bfe15b7249b0485c40 Mon Sep 17 00:00:00 2001 From: Athira Sabu <102021496+AsabuHere@users.noreply.github.com> Date: Thu, 26 Sep 2024 17:59:27 +0530 Subject: [PATCH 23/37] Update test_cluster.py --- tests/cluster/test_cluster.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/cluster/test_cluster.py b/tests/cluster/test_cluster.py index 3b96d1813..556fa8da7 100644 --- a/tests/cluster/test_cluster.py +++ b/tests/cluster/test_cluster.py @@ -19,7 +19,6 @@ def setUp(self): ) self.voice_twiml = VoiceResponse() - def test_send_text_message(self): msg = self.client.messages.create( to=self.to_number, from_=self.from_number, body="hello world" From 6a8c2d8b4212cff07c0d12ba2aceb724d043a2b3 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Thu, 26 Sep 2024 18:01:16 +0530 Subject: [PATCH 24/37] twilio python changes for orgs api uptake --- twilio/base/client_base.py | 6 ------ twilio/http/http_client.py | 3 --- 2 files changed, 9 deletions(-) diff --git a/twilio/base/client_base.py b/twilio/base/client_base.py index 0f2a000d8..4a109e2f8 100644 --- a/twilio/base/client_base.py +++ b/twilio/base/client_base.py @@ -95,7 +95,6 @@ def request( ##Using the auth strategy, fetch the auth string and set it to authorization header auth_strategy = None ##Initialization if self.credential_provider: - print(f'Reached here 2 {self.credential_provider}') auth_strategy = self.credential_provider.to_auth_strategy() if auth_strategy.auth_type == AuthType.TOKEN: auth_strategy.fetch_token() @@ -105,8 +104,6 @@ def request( else: auth = self.get_auth(auth) - print(f'auth2 *** {auth}') - uri = self.get_hostname(uri) @@ -160,7 +157,6 @@ async def request_async( ##Using the auth strategy, fetch the auth string and set it to authorization header auth_strategy = None ##Initialization if self.credential_provider: - print(f'Reached here 1') auth_strategy = self.credential_provider.to_auth_strategy() if auth_strategy.auth_type == AuthType.TOKEN: auth_strategy.fetch_token() @@ -170,8 +166,6 @@ async def request_async( else: auth = self.get_auth(auth) - print(f'auth2 *** {auth}') - return await self.http_client.request( method, uri, diff --git a/twilio/http/http_client.py b/twilio/http/http_client.py index 3e3560084..de5bdef53 100644 --- a/twilio/http/http_client.py +++ b/twilio/http/http_client.py @@ -79,8 +79,6 @@ def request( elif timeout <= 0: raise ValueError(timeout) - print(f'auth *** {auth}') - if "Requires-Authentication" in headers: headers.pop("Requires-Authentication", None) auth = None @@ -98,7 +96,6 @@ def request( else: kwargs["data"] = data self.log_request(kwargs) - print(f'kwargs {kwargs}') self._test_only_last_response = None session = self.session or Session() request = Request(**kwargs) From 1ba2f9b2b8004559c80b2ebed1b54b31223bf0ed Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Thu, 26 Sep 2024 18:13:43 +0530 Subject: [PATCH 25/37] twilio python changes for orgs api uptake --- twilio/base/client_base.py | 11 ------ twilio/base/exceptions.py | 2 +- twilio/base/oauth_token_base.py | 37 ------------------- twilio/base/version.py | 3 -- twilio/http/no_auth_http_client.py | 4 -- twilio/http/orgs_token_manager.py | 1 - twilio/rest/__init__.py | 1 - .../preview_iam/organizations/__init__.py | 7 +--- twilio/twilio_bearer_token_auth.py | 33 ----------------- 9 files changed, 2 insertions(+), 97 deletions(-) delete mode 100644 twilio/base/oauth_token_base.py delete mode 100644 twilio/http/no_auth_http_client.py delete mode 100644 twilio/twilio_bearer_token_auth.py diff --git a/twilio/base/client_base.py b/twilio/base/client_base.py index 4a109e2f8..5eb4af623 100644 --- a/twilio/base/client_base.py +++ b/twilio/base/client_base.py @@ -99,8 +99,6 @@ def request( if auth_strategy.auth_type == AuthType.TOKEN: auth_strategy.fetch_token() headers["Authorization"] = auth_strategy.get_auth_string() - if auth_strategy.auth_type == AuthType.BASIC: - headers["Authorization"] = auth_strategy.get_auth_string() else: auth = self.get_auth(auth) @@ -161,8 +159,6 @@ async def request_async( if auth_strategy.auth_type == AuthType.TOKEN: auth_strategy.fetch_token() headers["Authorization"] = auth_strategy.get_auth_string() - if auth_strategy.auth_type == AuthType.BASIC: - headers["Authorization"] = auth_strategy.get_auth_string() else: auth = self.get_auth(auth) @@ -262,10 +258,3 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ return "".format(self.account_sid) - - -def dynamic_import(module_name, class_name): - from importlib import import_module - - module = import_module(module_name) - return getattr(module, class_name) diff --git a/twilio/base/exceptions.py b/twilio/base/exceptions.py index 9adb4a0d8..8f3b7cc7a 100644 --- a/twilio/base/exceptions.py +++ b/twilio/base/exceptions.py @@ -62,7 +62,7 @@ def get_uri(code: int) -> str: "\n\n{twilio_returned}\n\n{message}\n".format( red_error=red("HTTP Error"), request_was=white("Your request was:"), - http_line=teal("%s %s" % (self.method, self.uri, self.data, self.uri)), + http_line=teal("%s %s" % (self.method, self.uri)), twilio_returned=white("Twilio returned the following information:"), message=blue(str(self.msg)), ) diff --git a/twilio/base/oauth_token_base.py b/twilio/base/oauth_token_base.py deleted file mode 100644 index f58a143c8..000000000 --- a/twilio/base/oauth_token_base.py +++ /dev/null @@ -1,37 +0,0 @@ -from twilio.http.token_manager_initializer import TokenManagerInitializer - - -# Dynamic import utility function -def dynamic_import(module_name, class_name): - from importlib import import_module - - module = import_module(module_name) - return getattr(module, class_name) - - -class OauthTokenBase: - def get_oauth_token(self, domain: str, version: str, username: str, password: str): - Domain = dynamic_import("twilio.base.domain", "Domain") - Version = dynamic_import("twilio.base.version", "Version") - BearerTokenHTTPClient = dynamic_import( - "twilio.http.bearer_token_http_client", "BearerTokenHTTPClient" - ) - OrgTokenManager = dynamic_import( - "twilio.http.orgs_token_manager", "OrgTokenManager" - ) - Client = dynamic_import("twilio.rest", "Client") - try: - orgs_token_manager = TokenManagerInitializer.get_token_manager() - return BearerTokenHTTPClient(orgs_token_manager).get_access_token( - Version(Domain(Client(username, password), domain), version) - ) - except Exception: - orgs_token_manager = OrgTokenManager( - grant_type="client_credentials", - client_id=username, - client_secret=password, - ) - TokenManagerInitializer().set_token_manager(orgs_token_manager) - return BearerTokenHTTPClient(orgs_token_manager).get_access_token( - Version(Domain(Client(username, password), domain), version) - ) diff --git a/twilio/base/version.py b/twilio/base/version.py index c026f5dbf..4d7ab803c 100644 --- a/twilio/base/version.py +++ b/twilio/base/version.py @@ -447,7 +447,6 @@ def create( auth: Optional[Tuple[str, str]] = None, timeout: Optional[float] = None, allow_redirects: bool = False, - is_oauth: bool = False, ) -> Any: """ Create a resource instance. @@ -474,7 +473,6 @@ async def create_async( auth: Optional[Tuple[str, str]] = None, timeout: Optional[float] = None, allow_redirects: bool = False, - is_oauth: bool = False, ) -> Any: """ Asynchronously create a resource instance. @@ -488,6 +486,5 @@ async def create_async( auth=auth, timeout=timeout, allow_redirects=allow_redirects, - is_oauth=is_oauth, ) return self._parse_create(method, uri, response) diff --git a/twilio/http/no_auth_http_client.py b/twilio/http/no_auth_http_client.py deleted file mode 100644 index daa5e5cdc..000000000 --- a/twilio/http/no_auth_http_client.py +++ /dev/null @@ -1,4 +0,0 @@ -class NoAuthHTTPClient: - def get_headers(self): - headers = {} - return headers diff --git a/twilio/http/orgs_token_manager.py b/twilio/http/orgs_token_manager.py index 396231b83..a232d4f51 100644 --- a/twilio/http/orgs_token_manager.py +++ b/twilio/http/orgs_token_manager.py @@ -31,7 +31,6 @@ def __init__( self.client = Client() def fetch_access_token(self): - # token_list = TokenList(version) token_instance = self.client.preview_iam.v1.token.create( grant_type=self.grant_type, client_id=self.client_id, diff --git a/twilio/rest/__init__.py b/twilio/rest/__init__.py index 06c5ef9f3..92d729d20 100644 --- a/twilio/rest/__init__.py +++ b/twilio/rest/__init__.py @@ -112,7 +112,6 @@ def __init__( :returns: Twilio Client :rtype: twilio.rest.Client """ - super().__init__( username, password, diff --git a/twilio/rest/preview_iam/organizations/__init__.py b/twilio/rest/preview_iam/organizations/__init__.py index 6a57e0b45..70e1772ef 100644 --- a/twilio/rest/preview_iam/organizations/__init__.py +++ b/twilio/rest/preview_iam/organizations/__init__.py @@ -35,14 +35,9 @@ def __init__(self, domain: Domain): @property def accounts(self) -> AccountList: if self._accounts is None: - self._accounts = AccountList(self, organization_sid="OR64adedc0f4dc99b9113305f725677b47") + self._accounts = AccountList(self) return self._accounts - # @property - # def accounts(self, organization_sid) -> AccountList: - # if self._accounts is None: - # self._accounts = AccountList(self, "OR64adedc0f4dc99b9113305f725677b47") - # return self._accounts @property def role_assignments(self) -> RoleAssignmentList: diff --git a/twilio/twilio_bearer_token_auth.py b/twilio/twilio_bearer_token_auth.py deleted file mode 100644 index ffc8814cd..000000000 --- a/twilio/twilio_bearer_token_auth.py +++ /dev/null @@ -1,33 +0,0 @@ -from threading import Lock - - -class BearerTokenTwilioRestClient: - pass - - -class TwilioBearerTokenAuth: - _lock = Lock() - access_token = None - rest_client = None - user_agent_extensions = None - region = None - edge = None - - @classmethod - def init(cls, access_token): - with cls._lock: - if not access_token: - raise ValueError("Access Token cannot be null or Empty") - if access_token != cls.access_token: - cls.access_token = None - cls.access_token = access_token - - @classmethod - def get_access_token(cls): - with cls._lock: - return cls.access_token - - @classmethod - def get_header_param(cls): - with cls._lock: - return {"Authorization": "Bearer {token}".format(token=cls.access_token)} From 98708f08a9389bea72cb199f150b5b9daf94ae17 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Thu, 26 Sep 2024 18:47:49 +0530 Subject: [PATCH 26/37] twilio python changes for orgs api uptake --- twilio/http/bearer_token_http_client.py | 30 ------------------------- twilio/http/http_client.py | 7 +++--- 2 files changed, 4 insertions(+), 33 deletions(-) delete mode 100644 twilio/http/bearer_token_http_client.py diff --git a/twilio/http/bearer_token_http_client.py b/twilio/http/bearer_token_http_client.py deleted file mode 100644 index eb5758db9..000000000 --- a/twilio/http/bearer_token_http_client.py +++ /dev/null @@ -1,30 +0,0 @@ -import datetime -import jwt - -from twilio.base.version import Version -from twilio.http.token_manager import TokenManager -from twilio.twilio_bearer_token_auth import TwilioBearerTokenAuth - - -class BearerTokenHTTPClient: - def __init__(self, orgs_token_manager: TokenManager): - self.orgs_token_manager = orgs_token_manager - - def get_access_token(self, version: Version): - if TwilioBearerTokenAuth.get_access_token() is None or self.is_token_expired( - TwilioBearerTokenAuth.get_access_token() - ): - access_token = self.orgs_token_manager.fetch_access_token(version) - TwilioBearerTokenAuth.init(access_token) - else: - access_token = TwilioBearerTokenAuth.get_access_token() - - return access_token - - def is_token_expired(self, token): - decoded_jwt = jwt.decode(token, options={"verify_signature": True}) - expires_at = decoded_jwt.get("exp") - # Add a buffer of 30 seconds - buffer_seconds = 30 - buffer_expires_at = expires_at - buffer_seconds - return buffer_expires_at < datetime.datetime.now().timestamp() diff --git a/twilio/http/http_client.py b/twilio/http/http_client.py index de5bdef53..83c0fd13d 100644 --- a/twilio/http/http_client.py +++ b/twilio/http/http_client.py @@ -79,9 +79,10 @@ def request( elif timeout <= 0: raise ValueError(timeout) - if "Requires-Authentication" in headers: - headers.pop("Requires-Authentication", None) - auth = None + if headers: + if "Requires-Authentication" in headers: + headers.pop("Requires-Authentication", None) + auth = None kwargs = { "method": method.upper(), From d78d5d59effe1f043bfeec2562936678780bf532 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Thu, 26 Sep 2024 18:51:25 +0530 Subject: [PATCH 27/37] twilio python changes for orgs api uptake --- twilio/http/http_client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/twilio/http/http_client.py b/twilio/http/http_client.py index 83c0fd13d..0e3e7638f 100644 --- a/twilio/http/http_client.py +++ b/twilio/http/http_client.py @@ -8,7 +8,6 @@ from twilio.http import HttpClient from twilio.http.request import Request as TwilioRequest from twilio.http.response import Response -from twilio.authStrategy.authStrategy import AuthStrategy _logger = logging.getLogger("twilio.http_client") From bc777701090ff4f4a0d8f80c77fbd832ad3e4ab4 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Fri, 27 Sep 2024 13:16:53 +0530 Subject: [PATCH 28/37] twilio python changes for orgs api uptake --- twilio/authStrategy/__init__.py | 0 twilio/authStrategy/authStrategy.py | 1 + 2 files changed, 1 insertion(+) create mode 100644 twilio/authStrategy/__init__.py diff --git a/twilio/authStrategy/__init__.py b/twilio/authStrategy/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/twilio/authStrategy/authStrategy.py b/twilio/authStrategy/authStrategy.py index 55b901848..901a6b4b7 100644 --- a/twilio/authStrategy/authStrategy.py +++ b/twilio/authStrategy/authStrategy.py @@ -11,6 +11,7 @@ def __init__(self, auth_type: AuthType): def auth_type(self) -> AuthType: return self._auth_type + @abstractmethod def get_auth_string(self) -> str: """Return the authentication string.""" pass From 0211f23f37c55e050960e607eb6e503ca9ee5607 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Fri, 27 Sep 2024 13:20:20 +0530 Subject: [PATCH 29/37] twilio python changes for orgs api uptake --- twilio/credential/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 twilio/credential/__init__.py diff --git a/twilio/credential/__init__.py b/twilio/credential/__init__.py new file mode 100644 index 000000000..e69de29bb From 27dec325b9a71e8d341652faa9396dbaa56b95d9 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Fri, 27 Sep 2024 13:52:10 +0530 Subject: [PATCH 30/37] twilio python changes for orgs api uptake --- twilio/authStrategy/tokenAuthStrategy.py | 6 +++++- twilio/base/client_base.py | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/twilio/authStrategy/tokenAuthStrategy.py b/twilio/authStrategy/tokenAuthStrategy.py index ad6a0bb3c..ac8acafcb 100644 --- a/twilio/authStrategy/tokenAuthStrategy.py +++ b/twilio/authStrategy/tokenAuthStrategy.py @@ -15,19 +15,23 @@ def __init__(self, token_manager: TokenManager): self.lock = threading.Lock() def get_auth_string(self) -> str: + if self.token is None: + self.fetch_token() return f"Bearer {self.token}" def requires_authentication(self) -> bool: return True def fetch_token(self): + print(f'token is fetch_token {self.token}') if self.token is None or self.token == "" or self.is_token_expired(self.token): with self.lock: if self.token is None or self.token == "" or self.is_token_expired(self.token): self.token = self.token_manager.fetch_access_token() def is_token_expired(self, token): - decoded_jwt = jwt.decode(token, options={"verify_signature": True}) + print(f'token is {token}') + decoded_jwt = jwt.decode(token, options={"verify_signature": True}, algorithms=["RS256"]) expires_at = decoded_jwt.get("exp") # Add a buffer of 30 seconds buffer_seconds = 30 diff --git a/twilio/base/client_base.py b/twilio/base/client_base.py index 5eb4af623..2d18e8899 100644 --- a/twilio/base/client_base.py +++ b/twilio/base/client_base.py @@ -96,9 +96,7 @@ def request( auth_strategy = None ##Initialization if self.credential_provider: auth_strategy = self.credential_provider.to_auth_strategy() - if auth_strategy.auth_type == AuthType.TOKEN: - auth_strategy.fetch_token() - headers["Authorization"] = auth_strategy.get_auth_string() + headers["Authorization"] = auth_strategy.get_auth_string() else: auth = self.get_auth(auth) From 29596894ac20277f42afa30247a7cbe3f27c5eca Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Fri, 27 Sep 2024 13:58:34 +0530 Subject: [PATCH 31/37] twilio python changes for orgs api uptake --- twilio/rest/__init__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/twilio/rest/__init__.py b/twilio/rest/__init__.py index e2b644489..458168fa2 100644 --- a/twilio/rest/__init__.py +++ b/twilio/rest/__init__.py @@ -136,6 +136,7 @@ def __init__( self._events: Optional["Events"] = None self._flex_api: Optional["FlexApi"] = None self._frontline_api: Optional["FrontlineApi"] = None + self._preview_iam: Optional["PreviewIam"] = None self._insights: Optional["Insights"] = None self._intelligence: Optional["Intelligence"] = None self._ip_messaging: Optional["IpMessaging"] = None @@ -398,6 +399,19 @@ def microvisor(self) -> "Microvisor": self._microvisor = Microvisor(self) return self._microvisor + @property + def preview_iam(self) -> "PreviewIam": + """ + Access the PreviewIam Twilio Domain + + :returns: PreviewIam Twilio Domain + """ + if self._preview_iam is None: + from twilio.rest.preview_iam import PreviewIam + + self._preview_iam = PreviewIam(self) + return self._preview_iam + @property def monitor(self) -> "Monitor": """ From b973065d28328adebdccb71c63a91dd435b08deb Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 1 Oct 2024 22:36:51 +0530 Subject: [PATCH 32/37] Uptake of review comments --- .../{authStrategy => auth_strategy}/__init__.py | 0 .../auth_strategy.py} | 2 +- .../authType.py => auth_strategy/auth_type.py} | 2 +- .../no_auth_strategy.py} | 0 .../token_auth_strategy.py} | 11 +++++++---- twilio/base/client_base.py | 12 +++++------- ...dentialProvider.py => credential_provider.py} | 2 +- ...alProvider.py => orgs_credential_provider.py} | 6 +++--- twilio/http/token_manager_initializer.py | 16 ---------------- .../rest/preview_iam/organizations/__init__.py | 2 +- 10 files changed, 19 insertions(+), 34 deletions(-) rename twilio/{authStrategy => auth_strategy}/__init__.py (100%) rename twilio/{authStrategy/authStrategy.py => auth_strategy/auth_strategy.py} (90%) rename twilio/{authStrategy/authType.py => auth_strategy/auth_type.py} (86%) rename twilio/{authStrategy/noAuthStrategy.py => auth_strategy/no_auth_strategy.py} (100%) rename twilio/{authStrategy/tokenAuthStrategy.py => auth_strategy/token_auth_strategy.py} (78%) rename twilio/credential/{credentialProvider.py => credential_provider.py} (85%) rename twilio/credential/{orgsCredentialProvider.py => orgs_credential_provider.py} (80%) delete mode 100644 twilio/http/token_manager_initializer.py diff --git a/twilio/authStrategy/__init__.py b/twilio/auth_strategy/__init__.py similarity index 100% rename from twilio/authStrategy/__init__.py rename to twilio/auth_strategy/__init__.py diff --git a/twilio/authStrategy/authStrategy.py b/twilio/auth_strategy/auth_strategy.py similarity index 90% rename from twilio/authStrategy/authStrategy.py rename to twilio/auth_strategy/auth_strategy.py index 901a6b4b7..63107ef97 100644 --- a/twilio/authStrategy/authStrategy.py +++ b/twilio/auth_strategy/auth_strategy.py @@ -1,4 +1,4 @@ -from twilio.authStrategy.authType import AuthType +from twilio.auth_strategy.auth_type import AuthType from enum import Enum from abc import abstractmethod diff --git a/twilio/authStrategy/authType.py b/twilio/auth_strategy/auth_type.py similarity index 86% rename from twilio/authStrategy/authType.py rename to twilio/auth_strategy/auth_type.py index fe9f00203..83653b756 100644 --- a/twilio/authStrategy/authType.py +++ b/twilio/auth_strategy/auth_type.py @@ -1,7 +1,7 @@ from enum import Enum class AuthType(Enum): - TOKEN = 'token' + ORGS_TOKEN = 'orgs_stoken' NO_AUTH = 'noauth' BASIC = 'basic' API_KEY = 'api_key' diff --git a/twilio/authStrategy/noAuthStrategy.py b/twilio/auth_strategy/no_auth_strategy.py similarity index 100% rename from twilio/authStrategy/noAuthStrategy.py rename to twilio/auth_strategy/no_auth_strategy.py diff --git a/twilio/authStrategy/tokenAuthStrategy.py b/twilio/auth_strategy/token_auth_strategy.py similarity index 78% rename from twilio/authStrategy/tokenAuthStrategy.py rename to twilio/auth_strategy/token_auth_strategy.py index ac8acafcb..88b0d787f 100644 --- a/twilio/authStrategy/tokenAuthStrategy.py +++ b/twilio/auth_strategy/token_auth_strategy.py @@ -1,18 +1,21 @@ import jwt import threading +import logging from datetime import datetime, timedelta -from twilio.authStrategy.authType import AuthType -from twilio.authStrategy.authStrategy import AuthStrategy +from twilio.auth_strategy.auth_type import AuthType +from twilio.auth_strategy.auth_strategy import AuthStrategy from twilio.http.token_manager import TokenManager class TokenAuthStrategy(AuthStrategy): def __init__(self, token_manager: TokenManager): - super().__init__(AuthType.TOKEN) + super().__init__(AuthType.ORGS_TOKEN) self.token_manager = token_manager self.token = None self.lock = threading.Lock() + logging.basicConfig(level=logging.INFO) + self.logger = logging.getLogger(__name__) def get_auth_string(self) -> str: if self.token is None: @@ -23,7 +26,7 @@ def requires_authentication(self) -> bool: return True def fetch_token(self): - print(f'token is fetch_token {self.token}') + self.logger.info("New token fetched for accessing organization API") if self.token is None or self.token == "" or self.is_token_expired(self.token): with self.lock: if self.token is None or self.token == "" or self.is_token_expired(self.token): diff --git a/twilio/base/client_base.py b/twilio/base/client_base.py index 2d18e8899..1fdc689ea 100644 --- a/twilio/base/client_base.py +++ b/twilio/base/client_base.py @@ -7,8 +7,8 @@ from twilio.http import HttpClient from twilio.http.http_client import TwilioHttpClient from twilio.http.response import Response -from twilio.authStrategy.authType import AuthType -from twilio.credential.credentialProvider import CredentialProvider +from twilio.auth_strategy.auth_type import AuthType +from twilio.credential.credential_provider import CredentialProvider class ClientBase(object): @@ -93,7 +93,6 @@ def request( ##If credential provider is provided by user, get the associated auth strategy ##Using the auth strategy, fetch the auth string and set it to authorization header - auth_strategy = None ##Initialization if self.credential_provider: auth_strategy = self.credential_provider.to_auth_strategy() headers["Authorization"] = auth_strategy.get_auth_string() @@ -151,15 +150,14 @@ async def request_async( ##If credential provider is provided by user, get the associated auth strategy ##Using the auth strategy, fetch the auth string and set it to authorization header - auth_strategy = None ##Initialization if self.credential_provider: auth_strategy = self.credential_provider.to_auth_strategy() - if auth_strategy.auth_type == AuthType.TOKEN: - auth_strategy.fetch_token() - headers["Authorization"] = auth_strategy.get_auth_string() + headers["Authorization"] = auth_strategy.get_auth_string() else: auth = self.get_auth(auth) + uri = self.get_hostname(uri) + return await self.http_client.request( method, uri, diff --git a/twilio/credential/credentialProvider.py b/twilio/credential/credential_provider.py similarity index 85% rename from twilio/credential/credentialProvider.py rename to twilio/credential/credential_provider.py index 2fc103f02..27e6a7eb4 100644 --- a/twilio/credential/credentialProvider.py +++ b/twilio/credential/credential_provider.py @@ -1,4 +1,4 @@ -from twilio.authStrategy.authType import AuthType +from twilio.auth_strategy.auth_type import AuthType class CredentialProvider: def __init__(self, auth_type: AuthType): diff --git a/twilio/credential/orgsCredentialProvider.py b/twilio/credential/orgs_credential_provider.py similarity index 80% rename from twilio/credential/orgsCredentialProvider.py rename to twilio/credential/orgs_credential_provider.py index 6668a18d4..10d83d32c 100644 --- a/twilio/credential/orgsCredentialProvider.py +++ b/twilio/credential/orgs_credential_provider.py @@ -2,9 +2,9 @@ from twilio.http.orgs_token_manager import OrgTokenManager from twilio.base.exceptions import TwilioException -from twilio.credential.credentialProvider import CredentialProvider -from twilio.authStrategy.authType import AuthType -from twilio.authStrategy.tokenAuthStrategy import TokenAuthStrategy +from twilio.credential.credential_provider import CredentialProvider +from twilio.auth_strategy.auth_type import AuthType +from twilio.auth_strategy.token_auth_strategy import TokenAuthStrategy class OrgsCredentialProvider(CredentialProvider): diff --git a/twilio/http/token_manager_initializer.py b/twilio/http/token_manager_initializer.py deleted file mode 100644 index 36ee83f1a..000000000 --- a/twilio/http/token_manager_initializer.py +++ /dev/null @@ -1,16 +0,0 @@ -from twilio.http.token_manager import TokenManager - - -class TokenManagerInitializer: - - org_token_manager = None - - @classmethod - def set_token_manager(cls, token_manager: TokenManager): - cls.org_token_manager = token_manager - - @classmethod - def get_token_manager(cls): - if cls.org_token_manager is None: - raise Exception("Token Manager not initialized") - return cls.org_token_manager diff --git a/twilio/rest/preview_iam/organizations/__init__.py b/twilio/rest/preview_iam/organizations/__init__.py index 70e1772ef..0dcd28734 100644 --- a/twilio/rest/preview_iam/organizations/__init__.py +++ b/twilio/rest/preview_iam/organizations/__init__.py @@ -35,7 +35,7 @@ def __init__(self, domain: Domain): @property def accounts(self) -> AccountList: if self._accounts is None: - self._accounts = AccountList(self) + self._accounts = AccountList(self, "OR64adedc0f4dc99b9113305f725677b47") return self._accounts From ceebd46e29f3b4fde594630f294a46c4d9bcec0d Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 1 Oct 2024 22:38:41 +0530 Subject: [PATCH 33/37] modified error messages --- twilio/credential/orgs_credential_provider.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/twilio/credential/orgs_credential_provider.py b/twilio/credential/orgs_credential_provider.py index 10d83d32c..4e58271a9 100644 --- a/twilio/credential/orgs_credential_provider.py +++ b/twilio/credential/orgs_credential_provider.py @@ -12,7 +12,7 @@ def __init__(self, client_id: str, client_secret: str, token_manager=None): super().__init__(AuthType.CLIENT_CREDENTIALS) if client_id is None or client_secret is None: - raise TwilioException("Invalid credentials passed") + raise TwilioException("Client id and Client secret are mandatory") self.grant_type = "client_credentials" self.client_id = client_id From 7fc68cb385b22a783ed63fb503fca21828fe4d68 Mon Sep 17 00:00:00 2001 From: Shubham Date: Thu, 3 Oct 2024 15:08:15 +0530 Subject: [PATCH 34/37] chore: add assistants init files (#816) --- twilio/rest/assistants/__init__.py | 56 ++++++++++++++++++++++++++++++ twilio/rest/iam/__init__.py | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 twilio/rest/assistants/__init__.py diff --git a/twilio/rest/assistants/__init__.py b/twilio/rest/assistants/__init__.py new file mode 100644 index 000000000..60c812014 --- /dev/null +++ b/twilio/rest/assistants/__init__.py @@ -0,0 +1,56 @@ +from warnings import warn + +from twilio.rest.assistants import AssistantsBase +from twilio.rest.assistants.v1.assistant import AssistantList +from twilio.rest.assistants.v1.knowledge import KnowledgeList +from twilio.rest.assistants.v1.policy import PolicyList +from twilio.rest.assistants.v1.session import SessionList +from twilio.rest.assistants.v1.tool import ToolList + + +class Assistants(AssistantsBase): + + @property + def assistants(self) -> AssistantList: + warn( + "assistants is deprecated. Use v1.assistants instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.v1.assistants + + @property + def knowledge(self) -> KnowledgeList: + warn( + "knowledge is deprecated. Use v1.knowledge instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.v1.knowledge + + @property + def policies(self) -> PolicyList: + warn( + "policies is deprecated. Use v1.policies instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.v1.policies + + @property + def sessions(self) -> SessionList: + warn( + "sessions is deprecated. Use v1.sessions instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.v1.sessions + + @property + def tools(self) -> ToolList: + warn( + "tools is deprecated. Use v1.tools instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.v1.tools diff --git a/twilio/rest/iam/__init__.py b/twilio/rest/iam/__init__.py index 7a7819bcc..f992caa57 100644 --- a/twilio/rest/iam/__init__.py +++ b/twilio/rest/iam/__init__.py @@ -6,7 +6,7 @@ from twilio.rest.iam.v1.new_api_key import NewApiKeyList -class Accounts(IamBase): +class Iam(IamBase): @property def api_key(self) -> ApiKeyList: warn( From 726c36a09758eeddb7f07fcd9859ac365c3c805a Mon Sep 17 00:00:00 2001 From: Twilio Date: Thu, 3 Oct 2024 15:38:15 +0000 Subject: [PATCH 35/37] [Librarian] Regenerated @ 021bab52f93b55d7a5786bd27716bf3a0be2d7b9 aa81ca7c51512c448626fafb32aeb46838510334 --- CHANGES.md | 16 + twilio/rest/iam/v1/__init__.py | 12 +- twilio/rest/iam/v1/{new_api_key.py => key.py} | 30 +- twilio/rest/numbers/v1/porting_portability.py | 24 +- twilio/rest/preview/PreviewBase.py | 11 - .../rest/preview/deployed_devices/__init__.py | 43 -- .../deployed_devices/fleet/__init__.py | 674 ----------------- .../deployed_devices/fleet/certificate.py | 656 ---------------- .../deployed_devices/fleet/deployment.py | 630 ---------------- .../preview/deployed_devices/fleet/device.py | 700 ------------------ .../preview/deployed_devices/fleet/key.py | 646 ---------------- .../taskrouter/v1/workspace/task/__init__.py | 12 +- twilio/rest/verify/v2/service/verification.py | 10 + .../verify/v2/service/verification_check.py | 6 + 14 files changed, 79 insertions(+), 3391 deletions(-) rename twilio/rest/iam/v1/{new_api_key.py => key.py} (88%) delete mode 100644 twilio/rest/preview/deployed_devices/__init__.py delete mode 100644 twilio/rest/preview/deployed_devices/fleet/__init__.py delete mode 100644 twilio/rest/preview/deployed_devices/fleet/certificate.py delete mode 100644 twilio/rest/preview/deployed_devices/fleet/deployment.py delete mode 100644 twilio/rest/preview/deployed_devices/fleet/device.py delete mode 100644 twilio/rest/preview/deployed_devices/fleet/key.py diff --git a/CHANGES.md b/CHANGES.md index 307f94f7d..5808d307b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,22 @@ twilio-python Changelog Here you can see the full list of changes between each twilio-python release. +[2024-10-03] Version 9.3.3 +-------------------------- +**Library - Chore** +- [PR #816](https://github.com/twilio/twilio-python/pull/816): add assistants init files. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! + +**Messaging** +- Add A2P external campaign CnpMigration flag + +**Numbers** +- Add address sid to portability API + +**Verify** +- Add `SnaClientToken` optional parameter on Verification check. +- Add `EnableSnaClientToken` optional parameter for Verification creation. + + [2024-09-25] Version 9.3.2 -------------------------- **Accounts** diff --git a/twilio/rest/iam/v1/__init__.py b/twilio/rest/iam/v1/__init__.py index 0c4694734..408de11ac 100644 --- a/twilio/rest/iam/v1/__init__.py +++ b/twilio/rest/iam/v1/__init__.py @@ -17,7 +17,7 @@ from twilio.base.domain import Domain from twilio.rest.iam.v1.api_key import ApiKeyList from twilio.rest.iam.v1.get_api_keys import GetApiKeysList -from twilio.rest.iam.v1.new_api_key import NewApiKeyList +from twilio.rest.iam.v1.key import KeyList class V1(Version): @@ -31,7 +31,7 @@ def __init__(self, domain: Domain): super().__init__(domain, "v1") self._api_key: Optional[ApiKeyList] = None self._get_api_keys: Optional[GetApiKeysList] = None - self._new_api_key: Optional[NewApiKeyList] = None + self._keys: Optional[KeyList] = None @property def api_key(self) -> ApiKeyList: @@ -46,10 +46,10 @@ def get_api_keys(self) -> GetApiKeysList: return self._get_api_keys @property - def new_api_key(self) -> NewApiKeyList: - if self._new_api_key is None: - self._new_api_key = NewApiKeyList(self) - return self._new_api_key + def keys(self) -> KeyList: + if self._keys is None: + self._keys = KeyList(self) + return self._keys def __repr__(self) -> str: """ diff --git a/twilio/rest/iam/v1/new_api_key.py b/twilio/rest/iam/v1/key.py similarity index 88% rename from twilio/rest/iam/v1/new_api_key.py rename to twilio/rest/iam/v1/key.py index e3f9fa05a..5adcbc693 100644 --- a/twilio/rest/iam/v1/new_api_key.py +++ b/twilio/rest/iam/v1/key.py @@ -21,7 +21,7 @@ from twilio.base.version import Version -class NewApiKeyInstance(InstanceResource): +class KeyInstance(InstanceResource): class Keytype(object): RESTRICTED = "restricted" @@ -56,14 +56,14 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" -class NewApiKeyList(ListResource): +class KeyList(ListResource): def __init__(self, version: Version): """ - Initialize the NewApiKeyList + Initialize the KeyList :param version: Version that contains the resource @@ -76,18 +76,18 @@ def create( self, account_sid: str, friendly_name: Union[str, object] = values.unset, - key_type: Union["NewApiKeyInstance.Keytype", object] = values.unset, + key_type: Union["KeyInstance.Keytype", object] = values.unset, policy: Union[object, object] = values.unset, - ) -> NewApiKeyInstance: + ) -> KeyInstance: """ - Create the NewApiKeyInstance + Create the KeyInstance :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource. :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long. :param key_type: :param policy: The \\\\`Policy\\\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys). - :returns: The created NewApiKeyInstance + :returns: The created KeyInstance """ data = values.of( @@ -104,24 +104,24 @@ def create( method="POST", uri=self._uri, data=data, headers=headers ) - return NewApiKeyInstance(self._version, payload) + return KeyInstance(self._version, payload) async def create_async( self, account_sid: str, friendly_name: Union[str, object] = values.unset, - key_type: Union["NewApiKeyInstance.Keytype", object] = values.unset, + key_type: Union["KeyInstance.Keytype", object] = values.unset, policy: Union[object, object] = values.unset, - ) -> NewApiKeyInstance: + ) -> KeyInstance: """ - Asynchronously create the NewApiKeyInstance + Asynchronously create the KeyInstance :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource. :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long. :param key_type: :param policy: The \\\\`Policy\\\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys). - :returns: The created NewApiKeyInstance + :returns: The created KeyInstance """ data = values.of( @@ -138,7 +138,7 @@ async def create_async( method="POST", uri=self._uri, data=data, headers=headers ) - return NewApiKeyInstance(self._version, payload) + return KeyInstance(self._version, payload) def __repr__(self) -> str: """ @@ -146,4 +146,4 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" diff --git a/twilio/rest/numbers/v1/porting_portability.py b/twilio/rest/numbers/v1/porting_portability.py index 1f0fc210a..826a69a24 100644 --- a/twilio/rest/numbers/v1/porting_portability.py +++ b/twilio/rest/numbers/v1/porting_portability.py @@ -85,31 +85,39 @@ def _proxy(self) -> "PortingPortabilityContext": return self._context def fetch( - self, target_account_sid: Union[str, object] = values.unset + self, + target_account_sid: Union[str, object] = values.unset, + address_sid: Union[str, object] = values.unset, ) -> "PortingPortabilityInstance": """ Fetch the PortingPortabilityInstance :param target_account_sid: Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account. + :param address_sid: Address Sid of customer to which the number will be ported. :returns: The fetched PortingPortabilityInstance """ return self._proxy.fetch( target_account_sid=target_account_sid, + address_sid=address_sid, ) async def fetch_async( - self, target_account_sid: Union[str, object] = values.unset + self, + target_account_sid: Union[str, object] = values.unset, + address_sid: Union[str, object] = values.unset, ) -> "PortingPortabilityInstance": """ Asynchronous coroutine to fetch the PortingPortabilityInstance :param target_account_sid: Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account. + :param address_sid: Address Sid of customer to which the number will be ported. :returns: The fetched PortingPortabilityInstance """ return await self._proxy.fetch_async( target_account_sid=target_account_sid, + address_sid=address_sid, ) def __repr__(self) -> str: @@ -142,12 +150,15 @@ def __init__(self, version: Version, phone_number: str): ) def fetch( - self, target_account_sid: Union[str, object] = values.unset + self, + target_account_sid: Union[str, object] = values.unset, + address_sid: Union[str, object] = values.unset, ) -> PortingPortabilityInstance: """ Fetch the PortingPortabilityInstance :param target_account_sid: Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account. + :param address_sid: Address Sid of customer to which the number will be ported. :returns: The fetched PortingPortabilityInstance """ @@ -155,6 +166,7 @@ def fetch( data = values.of( { "TargetAccountSid": target_account_sid, + "AddressSid": address_sid, } ) @@ -167,12 +179,15 @@ def fetch( ) async def fetch_async( - self, target_account_sid: Union[str, object] = values.unset + self, + target_account_sid: Union[str, object] = values.unset, + address_sid: Union[str, object] = values.unset, ) -> PortingPortabilityInstance: """ Asynchronous coroutine to fetch the PortingPortabilityInstance :param target_account_sid: Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account. + :param address_sid: Address Sid of customer to which the number will be ported. :returns: The fetched PortingPortabilityInstance """ @@ -180,6 +195,7 @@ async def fetch_async( data = values.of( { "TargetAccountSid": target_account_sid, + "AddressSid": address_sid, } ) diff --git a/twilio/rest/preview/PreviewBase.py b/twilio/rest/preview/PreviewBase.py index 6608a69a2..2b44efaf6 100644 --- a/twilio/rest/preview/PreviewBase.py +++ b/twilio/rest/preview/PreviewBase.py @@ -13,7 +13,6 @@ from twilio.base.domain import Domain from twilio.rest import Client -from twilio.rest.preview.deployed_devices import DeployedDevices from twilio.rest.preview.hosted_numbers import HostedNumbers from twilio.rest.preview.sync import Sync from twilio.rest.preview.marketplace import Marketplace @@ -29,21 +28,11 @@ def __init__(self, twilio: Client): :returns: Domain for Preview """ super().__init__(twilio, "https://preview.twilio.com") - self._deployed_devices: Optional[DeployedDevices] = None self._hosted_numbers: Optional[HostedNumbers] = None self._sync: Optional[Sync] = None self._marketplace: Optional[Marketplace] = None self._wireless: Optional[Wireless] = None - @property - def deployed_devices(self) -> DeployedDevices: - """ - :returns: Versions deployed_devices of Preview - """ - if self._deployed_devices is None: - self._deployed_devices = DeployedDevices(self) - return self._deployed_devices - @property def hosted_numbers(self) -> HostedNumbers: """ diff --git a/twilio/rest/preview/deployed_devices/__init__.py b/twilio/rest/preview/deployed_devices/__init__.py deleted file mode 100644 index 795ee9656..000000000 --- a/twilio/rest/preview/deployed_devices/__init__.py +++ /dev/null @@ -1,43 +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 Optional -from twilio.base.version import Version -from twilio.base.domain import Domain -from twilio.rest.preview.deployed_devices.fleet import FleetList - - -class DeployedDevices(Version): - - def __init__(self, domain: Domain): - """ - Initialize the DeployedDevices version of Preview - - :param domain: The Twilio.preview domain - """ - super().__init__(domain, "DeployedDevices") - self._fleets: Optional[FleetList] = None - - @property - def fleets(self) -> FleetList: - if self._fleets is None: - self._fleets = FleetList(self) - return self._fleets - - def __repr__(self) -> str: - """ - Provide a friendly representation - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/deployed_devices/fleet/__init__.py b/twilio/rest/preview/deployed_devices/fleet/__init__.py deleted file mode 100644 index f7321fdb2..000000000 --- a/twilio/rest/preview/deployed_devices/fleet/__init__.py +++ /dev/null @@ -1,674 +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.deployed_devices.fleet.certificate import CertificateList -from twilio.rest.preview.deployed_devices.fleet.deployment import DeploymentList -from twilio.rest.preview.deployed_devices.fleet.device import DeviceList -from twilio.rest.preview.deployed_devices.fleet.key import KeyList - - -class FleetInstance(InstanceResource): - """ - :ivar sid: Contains a 34 character string that uniquely identifies this Fleet resource. - :ivar url: Contains an absolute URL for this Fleet resource. - :ivar unique_name: Contains a unique and addressable name of this Fleet, e.g. 'default', up to 128 characters long. - :ivar friendly_name: Contains a human readable descriptive text for this Fleet, up to 256 characters long. - :ivar account_sid: Speicifies the unique string identifier of the Account responsible for this Fleet. - :ivar default_deployment_sid: Contains the string identifier of the automatically provisioned default Deployment of this Fleet. - :ivar date_created: Specifies the date this Fleet was created, given in UTC ISO 8601 format. - :ivar date_updated: Specifies the date this Fleet was last updated, given in UTC ISO 8601 format. - :ivar links: Contains a dictionary of URL links to nested resources of this Fleet. - """ - - def __init__( - self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None - ): - super().__init__(version) - - self.sid: Optional[str] = payload.get("sid") - self.url: Optional[str] = payload.get("url") - self.unique_name: Optional[str] = payload.get("unique_name") - self.friendly_name: Optional[str] = payload.get("friendly_name") - self.account_sid: Optional[str] = payload.get("account_sid") - self.default_deployment_sid: Optional[str] = payload.get( - "default_deployment_sid" - ) - 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.links: Optional[Dict[str, object]] = payload.get("links") - - self._solution = { - "sid": sid or self.sid, - } - self._context: Optional[FleetContext] = None - - @property - def _proxy(self) -> "FleetContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: FleetContext for this FleetInstance - """ - if self._context is None: - self._context = FleetContext( - self._version, - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the FleetInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the FleetInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "FleetInstance": - """ - Fetch the FleetInstance - - - :returns: The fetched FleetInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "FleetInstance": - """ - Asynchronous coroutine to fetch the FleetInstance - - - :returns: The fetched FleetInstance - """ - return await self._proxy.fetch_async() - - def update( - self, - friendly_name: Union[str, object] = values.unset, - default_deployment_sid: Union[str, object] = values.unset, - ) -> "FleetInstance": - """ - Update the FleetInstance - - :param friendly_name: Provides a human readable descriptive text for this Fleet, up to 256 characters long. - :param default_deployment_sid: Provides a string identifier of a Deployment that is going to be used as a default one for this Fleet. - - :returns: The updated FleetInstance - """ - return self._proxy.update( - friendly_name=friendly_name, - default_deployment_sid=default_deployment_sid, - ) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - default_deployment_sid: Union[str, object] = values.unset, - ) -> "FleetInstance": - """ - Asynchronous coroutine to update the FleetInstance - - :param friendly_name: Provides a human readable descriptive text for this Fleet, up to 256 characters long. - :param default_deployment_sid: Provides a string identifier of a Deployment that is going to be used as a default one for this Fleet. - - :returns: The updated FleetInstance - """ - return await self._proxy.update_async( - friendly_name=friendly_name, - default_deployment_sid=default_deployment_sid, - ) - - @property - def certificates(self) -> CertificateList: - """ - Access the certificates - """ - return self._proxy.certificates - - @property - def deployments(self) -> DeploymentList: - """ - Access the deployments - """ - return self._proxy.deployments - - @property - def devices(self) -> DeviceList: - """ - Access the devices - """ - return self._proxy.devices - - @property - def keys(self) -> KeyList: - """ - Access the keys - """ - return self._proxy.keys - - 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 FleetContext(InstanceContext): - - def __init__(self, version: Version, sid: str): - """ - Initialize the FleetContext - - :param version: Version that contains the resource - :param sid: Provides a 34 character string that uniquely identifies the requested Fleet resource. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "sid": sid, - } - self._uri = "/Fleets/{sid}".format(**self._solution) - - self._certificates: Optional[CertificateList] = None - self._deployments: Optional[DeploymentList] = None - self._devices: Optional[DeviceList] = None - self._keys: Optional[KeyList] = None - - def delete(self) -> bool: - """ - Deletes the FleetInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the FleetInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> FleetInstance: - """ - Fetch the FleetInstance - - - :returns: The fetched FleetInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return FleetInstance( - self._version, - payload, - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> FleetInstance: - """ - Asynchronous coroutine to fetch the FleetInstance - - - :returns: The fetched FleetInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return FleetInstance( - self._version, - payload, - sid=self._solution["sid"], - ) - - def update( - self, - friendly_name: Union[str, object] = values.unset, - default_deployment_sid: Union[str, object] = values.unset, - ) -> FleetInstance: - """ - Update the FleetInstance - - :param friendly_name: Provides a human readable descriptive text for this Fleet, up to 256 characters long. - :param default_deployment_sid: Provides a string identifier of a Deployment that is going to be used as a default one for this Fleet. - - :returns: The updated FleetInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "DefaultDeploymentSid": default_deployment_sid, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return FleetInstance(self._version, payload, sid=self._solution["sid"]) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - default_deployment_sid: Union[str, object] = values.unset, - ) -> FleetInstance: - """ - Asynchronous coroutine to update the FleetInstance - - :param friendly_name: Provides a human readable descriptive text for this Fleet, up to 256 characters long. - :param default_deployment_sid: Provides a string identifier of a Deployment that is going to be used as a default one for this Fleet. - - :returns: The updated FleetInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "DefaultDeploymentSid": default_deployment_sid, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return FleetInstance(self._version, payload, sid=self._solution["sid"]) - - @property - def certificates(self) -> CertificateList: - """ - Access the certificates - """ - if self._certificates is None: - self._certificates = CertificateList( - self._version, - self._solution["sid"], - ) - return self._certificates - - @property - def deployments(self) -> DeploymentList: - """ - Access the deployments - """ - if self._deployments is None: - self._deployments = DeploymentList( - self._version, - self._solution["sid"], - ) - return self._deployments - - @property - def devices(self) -> DeviceList: - """ - Access the devices - """ - if self._devices is None: - self._devices = DeviceList( - self._version, - self._solution["sid"], - ) - return self._devices - - @property - def keys(self) -> KeyList: - """ - Access the keys - """ - if self._keys is None: - self._keys = KeyList( - self._version, - self._solution["sid"], - ) - return self._keys - - 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 FleetPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> FleetInstance: - """ - Build an instance of FleetInstance - - :param payload: Payload response from the API - """ - return FleetInstance(self._version, payload) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class FleetList(ListResource): - - def __init__(self, version: Version): - """ - Initialize the FleetList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/Fleets" - - def create(self, friendly_name: Union[str, object] = values.unset) -> FleetInstance: - """ - Create the FleetInstance - - :param friendly_name: Provides a human readable descriptive text for this Fleet, up to 256 characters long. - - :returns: The created FleetInstance - """ - - data = values.of( - { - "FriendlyName": friendly_name, - } - ) - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - payload = self._version.create( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return FleetInstance(self._version, payload) - - async def create_async( - self, friendly_name: Union[str, object] = values.unset - ) -> FleetInstance: - """ - Asynchronously create the FleetInstance - - :param friendly_name: Provides a human readable descriptive text for this Fleet, up to 256 characters long. - - :returns: The created FleetInstance - """ - - data = values.of( - { - "FriendlyName": friendly_name, - } - ) - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - payload = await self._version.create_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return FleetInstance(self._version, payload) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[FleetInstance]: - """ - Streams FleetInstance 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[FleetInstance]: - """ - Asynchronously streams FleetInstance 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[FleetInstance]: - """ - Lists FleetInstance 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[FleetInstance]: - """ - Asynchronously lists FleetInstance 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, - ) -> FleetPage: - """ - Retrieve a single page of FleetInstance 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 FleetInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return FleetPage(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, - ) -> FleetPage: - """ - Asynchronously retrieve a single page of FleetInstance 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 FleetInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return FleetPage(self._version, response) - - def get_page(self, target_url: str) -> FleetPage: - """ - Retrieve a specific page of FleetInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of FleetInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return FleetPage(self._version, response) - - async def get_page_async(self, target_url: str) -> FleetPage: - """ - Asynchronously retrieve a specific page of FleetInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of FleetInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return FleetPage(self._version, response) - - def get(self, sid: str) -> FleetContext: - """ - Constructs a FleetContext - - :param sid: Provides a 34 character string that uniquely identifies the requested Fleet resource. - """ - return FleetContext(self._version, sid=sid) - - def __call__(self, sid: str) -> FleetContext: - """ - Constructs a FleetContext - - :param sid: Provides a 34 character string that uniquely identifies the requested Fleet resource. - """ - return FleetContext(self._version, sid=sid) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/deployed_devices/fleet/certificate.py b/twilio/rest/preview/deployed_devices/fleet/certificate.py deleted file mode 100644 index 895bdc568..000000000 --- a/twilio/rest/preview/deployed_devices/fleet/certificate.py +++ /dev/null @@ -1,656 +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 - - -class CertificateInstance(InstanceResource): - """ - :ivar sid: Contains a 34 character string that uniquely identifies this Certificate credential resource. - :ivar url: Contains an absolute URL for this Certificate credential resource. - :ivar friendly_name: Contains a human readable descriptive text for this Certificate credential, up to 256 characters long. - :ivar fleet_sid: Specifies the unique string identifier of the Fleet that the given Certificate credential belongs to. - :ivar account_sid: Specifies the unique string identifier of the Account responsible for this Certificate credential. - :ivar device_sid: Specifies the unique string identifier of a Device authenticated with this Certificate credential. - :ivar thumbprint: Contains a unique hash of the payload of this Certificate credential, used to authenticate the Device. - :ivar date_created: Specifies the date this Certificate credential was created, given in UTC ISO 8601 format. - :ivar date_updated: Specifies the date this Certificate credential was last updated, given in UTC ISO 8601 format. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - fleet_sid: str, - sid: Optional[str] = None, - ): - super().__init__(version) - - self.sid: Optional[str] = payload.get("sid") - self.url: Optional[str] = payload.get("url") - self.friendly_name: Optional[str] = payload.get("friendly_name") - self.fleet_sid: Optional[str] = payload.get("fleet_sid") - self.account_sid: Optional[str] = payload.get("account_sid") - self.device_sid: Optional[str] = payload.get("device_sid") - self.thumbprint: Optional[str] = payload.get("thumbprint") - 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 = { - "fleet_sid": fleet_sid, - "sid": sid or self.sid, - } - self._context: Optional[CertificateContext] = None - - @property - def _proxy(self) -> "CertificateContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: CertificateContext for this CertificateInstance - """ - if self._context is None: - self._context = CertificateContext( - self._version, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the CertificateInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the CertificateInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "CertificateInstance": - """ - Fetch the CertificateInstance - - - :returns: The fetched CertificateInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "CertificateInstance": - """ - Asynchronous coroutine to fetch the CertificateInstance - - - :returns: The fetched CertificateInstance - """ - return await self._proxy.fetch_async() - - def update( - self, - friendly_name: Union[str, object] = values.unset, - device_sid: Union[str, object] = values.unset, - ) -> "CertificateInstance": - """ - Update the CertificateInstance - - :param friendly_name: Provides a human readable descriptive text for this Certificate credential, up to 256 characters long. - :param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Certificate credential. - - :returns: The updated CertificateInstance - """ - return self._proxy.update( - friendly_name=friendly_name, - device_sid=device_sid, - ) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - device_sid: Union[str, object] = values.unset, - ) -> "CertificateInstance": - """ - Asynchronous coroutine to update the CertificateInstance - - :param friendly_name: Provides a human readable descriptive text for this Certificate credential, up to 256 characters long. - :param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Certificate credential. - - :returns: The updated CertificateInstance - """ - return await self._proxy.update_async( - friendly_name=friendly_name, - device_sid=device_sid, - ) - - 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 CertificateContext(InstanceContext): - - def __init__(self, version: Version, fleet_sid: str, sid: str): - """ - Initialize the CertificateContext - - :param version: Version that contains the resource - :param fleet_sid: - :param sid: Provides a 34 character string that uniquely identifies the requested Certificate credential resource. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "fleet_sid": fleet_sid, - "sid": sid, - } - self._uri = "/Fleets/{fleet_sid}/Certificates/{sid}".format(**self._solution) - - def delete(self) -> bool: - """ - Deletes the CertificateInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the CertificateInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> CertificateInstance: - """ - Fetch the CertificateInstance - - - :returns: The fetched CertificateInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return CertificateInstance( - self._version, - payload, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> CertificateInstance: - """ - Asynchronous coroutine to fetch the CertificateInstance - - - :returns: The fetched CertificateInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return CertificateInstance( - self._version, - payload, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - - def update( - self, - friendly_name: Union[str, object] = values.unset, - device_sid: Union[str, object] = values.unset, - ) -> CertificateInstance: - """ - Update the CertificateInstance - - :param friendly_name: Provides a human readable descriptive text for this Certificate credential, up to 256 characters long. - :param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Certificate credential. - - :returns: The updated CertificateInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "DeviceSid": device_sid, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return CertificateInstance( - self._version, - payload, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - device_sid: Union[str, object] = values.unset, - ) -> CertificateInstance: - """ - Asynchronous coroutine to update the CertificateInstance - - :param friendly_name: Provides a human readable descriptive text for this Certificate credential, up to 256 characters long. - :param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Certificate credential. - - :returns: The updated CertificateInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "DeviceSid": device_sid, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return CertificateInstance( - self._version, - payload, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - - 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 CertificatePage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> CertificateInstance: - """ - Build an instance of CertificateInstance - - :param payload: Payload response from the API - """ - return CertificateInstance( - self._version, payload, fleet_sid=self._solution["fleet_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class CertificateList(ListResource): - - def __init__(self, version: Version, fleet_sid: str): - """ - Initialize the CertificateList - - :param version: Version that contains the resource - :param fleet_sid: - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "fleet_sid": fleet_sid, - } - self._uri = "/Fleets/{fleet_sid}/Certificates".format(**self._solution) - - def create( - self, - certificate_data: str, - friendly_name: Union[str, object] = values.unset, - device_sid: Union[str, object] = values.unset, - ) -> CertificateInstance: - """ - Create the CertificateInstance - - :param certificate_data: Provides a URL encoded representation of the public certificate in PEM format. - :param friendly_name: Provides a human readable descriptive text for this Certificate credential, up to 256 characters long. - :param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Certificate credential. - - :returns: The created CertificateInstance - """ - - data = values.of( - { - "CertificateData": certificate_data, - "FriendlyName": friendly_name, - "DeviceSid": device_sid, - } - ) - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - payload = self._version.create( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return CertificateInstance( - self._version, payload, fleet_sid=self._solution["fleet_sid"] - ) - - async def create_async( - self, - certificate_data: str, - friendly_name: Union[str, object] = values.unset, - device_sid: Union[str, object] = values.unset, - ) -> CertificateInstance: - """ - Asynchronously create the CertificateInstance - - :param certificate_data: Provides a URL encoded representation of the public certificate in PEM format. - :param friendly_name: Provides a human readable descriptive text for this Certificate credential, up to 256 characters long. - :param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Certificate credential. - - :returns: The created CertificateInstance - """ - - data = values.of( - { - "CertificateData": certificate_data, - "FriendlyName": friendly_name, - "DeviceSid": device_sid, - } - ) - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - payload = await self._version.create_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return CertificateInstance( - self._version, payload, fleet_sid=self._solution["fleet_sid"] - ) - - def stream( - self, - device_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[CertificateInstance]: - """ - Streams CertificateInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param str device_sid: Filters the resulting list of Certificates by a unique string identifier of an authenticated Device. - :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(device_sid=device_sid, page_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - device_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[CertificateInstance]: - """ - Asynchronously streams CertificateInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param str device_sid: Filters the resulting list of Certificates by a unique string identifier of an authenticated Device. - :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( - device_sid=device_sid, page_size=limits["page_size"] - ) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - device_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[CertificateInstance]: - """ - Lists CertificateInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str device_sid: Filters the resulting list of Certificates by a unique string identifier of an authenticated Device. - :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( - device_sid=device_sid, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - device_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[CertificateInstance]: - """ - Asynchronously lists CertificateInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str device_sid: Filters the resulting list of Certificates by a unique string identifier of an authenticated Device. - :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( - device_sid=device_sid, - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - device_sid: Union[str, object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> CertificatePage: - """ - Retrieve a single page of CertificateInstance records from the API. - Request is executed immediately - - :param device_sid: Filters the resulting list of Certificates by a unique string identifier of an authenticated Device. - :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 CertificateInstance - """ - data = values.of( - { - "DeviceSid": device_sid, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return CertificatePage(self._version, response, self._solution) - - async def page_async( - self, - device_sid: Union[str, object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> CertificatePage: - """ - Asynchronously retrieve a single page of CertificateInstance records from the API. - Request is executed immediately - - :param device_sid: Filters the resulting list of Certificates by a unique string identifier of an authenticated Device. - :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 CertificateInstance - """ - data = values.of( - { - "DeviceSid": device_sid, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return CertificatePage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> CertificatePage: - """ - Retrieve a specific page of CertificateInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of CertificateInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return CertificatePage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> CertificatePage: - """ - Asynchronously retrieve a specific page of CertificateInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of CertificateInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return CertificatePage(self._version, response, self._solution) - - def get(self, sid: str) -> CertificateContext: - """ - Constructs a CertificateContext - - :param sid: Provides a 34 character string that uniquely identifies the requested Certificate credential resource. - """ - return CertificateContext( - self._version, fleet_sid=self._solution["fleet_sid"], sid=sid - ) - - def __call__(self, sid: str) -> CertificateContext: - """ - Constructs a CertificateContext - - :param sid: Provides a 34 character string that uniquely identifies the requested Certificate credential resource. - """ - return CertificateContext( - self._version, fleet_sid=self._solution["fleet_sid"], sid=sid - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/deployed_devices/fleet/deployment.py b/twilio/rest/preview/deployed_devices/fleet/deployment.py deleted file mode 100644 index 80f9f2372..000000000 --- a/twilio/rest/preview/deployed_devices/fleet/deployment.py +++ /dev/null @@ -1,630 +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 - - -class DeploymentInstance(InstanceResource): - """ - :ivar sid: Contains a 34 character string that uniquely identifies this Deployment resource. - :ivar url: Contains an absolute URL for this Deployment resource. - :ivar friendly_name: Contains a human readable descriptive text for this Deployment, up to 64 characters long - :ivar fleet_sid: Specifies the unique string identifier of the Fleet that the given Deployment belongs to. - :ivar account_sid: Specifies the unique string identifier of the Account responsible for this Deployment. - :ivar sync_service_sid: Specifies the unique string identifier of the Twilio Sync service instance linked to and accessible by this Deployment. - :ivar date_created: Specifies the date this Deployment was created, given in UTC ISO 8601 format. - :ivar date_updated: Specifies the date this Deployment was last updated, given in UTC ISO 8601 format. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - fleet_sid: str, - sid: Optional[str] = None, - ): - super().__init__(version) - - self.sid: Optional[str] = payload.get("sid") - self.url: Optional[str] = payload.get("url") - self.friendly_name: Optional[str] = payload.get("friendly_name") - self.fleet_sid: Optional[str] = payload.get("fleet_sid") - self.account_sid: Optional[str] = payload.get("account_sid") - self.sync_service_sid: Optional[str] = payload.get("sync_service_sid") - 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 = { - "fleet_sid": fleet_sid, - "sid": sid or self.sid, - } - self._context: Optional[DeploymentContext] = None - - @property - def _proxy(self) -> "DeploymentContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: DeploymentContext for this DeploymentInstance - """ - if self._context is None: - self._context = DeploymentContext( - self._version, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the DeploymentInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the DeploymentInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "DeploymentInstance": - """ - Fetch the DeploymentInstance - - - :returns: The fetched DeploymentInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "DeploymentInstance": - """ - Asynchronous coroutine to fetch the DeploymentInstance - - - :returns: The fetched DeploymentInstance - """ - return await self._proxy.fetch_async() - - def update( - self, - friendly_name: Union[str, object] = values.unset, - sync_service_sid: Union[str, object] = values.unset, - ) -> "DeploymentInstance": - """ - Update the DeploymentInstance - - :param friendly_name: Provides a human readable descriptive text for this Deployment, up to 64 characters long - :param sync_service_sid: Provides the unique string identifier of the Twilio Sync service instance that will be linked to and accessible by this Deployment. - - :returns: The updated DeploymentInstance - """ - return self._proxy.update( - friendly_name=friendly_name, - sync_service_sid=sync_service_sid, - ) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - sync_service_sid: Union[str, object] = values.unset, - ) -> "DeploymentInstance": - """ - Asynchronous coroutine to update the DeploymentInstance - - :param friendly_name: Provides a human readable descriptive text for this Deployment, up to 64 characters long - :param sync_service_sid: Provides the unique string identifier of the Twilio Sync service instance that will be linked to and accessible by this Deployment. - - :returns: The updated DeploymentInstance - """ - return await self._proxy.update_async( - friendly_name=friendly_name, - sync_service_sid=sync_service_sid, - ) - - 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 DeploymentContext(InstanceContext): - - def __init__(self, version: Version, fleet_sid: str, sid: str): - """ - Initialize the DeploymentContext - - :param version: Version that contains the resource - :param fleet_sid: - :param sid: Provides a 34 character string that uniquely identifies the requested Deployment resource. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "fleet_sid": fleet_sid, - "sid": sid, - } - self._uri = "/Fleets/{fleet_sid}/Deployments/{sid}".format(**self._solution) - - def delete(self) -> bool: - """ - Deletes the DeploymentInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the DeploymentInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> DeploymentInstance: - """ - Fetch the DeploymentInstance - - - :returns: The fetched DeploymentInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return DeploymentInstance( - self._version, - payload, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> DeploymentInstance: - """ - Asynchronous coroutine to fetch the DeploymentInstance - - - :returns: The fetched DeploymentInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return DeploymentInstance( - self._version, - payload, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - - def update( - self, - friendly_name: Union[str, object] = values.unset, - sync_service_sid: Union[str, object] = values.unset, - ) -> DeploymentInstance: - """ - Update the DeploymentInstance - - :param friendly_name: Provides a human readable descriptive text for this Deployment, up to 64 characters long - :param sync_service_sid: Provides the unique string identifier of the Twilio Sync service instance that will be linked to and accessible by this Deployment. - - :returns: The updated DeploymentInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "SyncServiceSid": sync_service_sid, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return DeploymentInstance( - self._version, - payload, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - sync_service_sid: Union[str, object] = values.unset, - ) -> DeploymentInstance: - """ - Asynchronous coroutine to update the DeploymentInstance - - :param friendly_name: Provides a human readable descriptive text for this Deployment, up to 64 characters long - :param sync_service_sid: Provides the unique string identifier of the Twilio Sync service instance that will be linked to and accessible by this Deployment. - - :returns: The updated DeploymentInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "SyncServiceSid": sync_service_sid, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return DeploymentInstance( - self._version, - payload, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - - 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 DeploymentPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> DeploymentInstance: - """ - Build an instance of DeploymentInstance - - :param payload: Payload response from the API - """ - return DeploymentInstance( - self._version, payload, fleet_sid=self._solution["fleet_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class DeploymentList(ListResource): - - def __init__(self, version: Version, fleet_sid: str): - """ - Initialize the DeploymentList - - :param version: Version that contains the resource - :param fleet_sid: - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "fleet_sid": fleet_sid, - } - self._uri = "/Fleets/{fleet_sid}/Deployments".format(**self._solution) - - def create( - self, - friendly_name: Union[str, object] = values.unset, - sync_service_sid: Union[str, object] = values.unset, - ) -> DeploymentInstance: - """ - Create the DeploymentInstance - - :param friendly_name: Provides a human readable descriptive text for this Deployment, up to 256 characters long. - :param sync_service_sid: Provides the unique string identifier of the Twilio Sync service instance that will be linked to and accessible by this Deployment. - - :returns: The created DeploymentInstance - """ - - data = values.of( - { - "FriendlyName": friendly_name, - "SyncServiceSid": sync_service_sid, - } - ) - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - payload = self._version.create( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return DeploymentInstance( - self._version, payload, fleet_sid=self._solution["fleet_sid"] - ) - - async def create_async( - self, - friendly_name: Union[str, object] = values.unset, - sync_service_sid: Union[str, object] = values.unset, - ) -> DeploymentInstance: - """ - Asynchronously create the DeploymentInstance - - :param friendly_name: Provides a human readable descriptive text for this Deployment, up to 256 characters long. - :param sync_service_sid: Provides the unique string identifier of the Twilio Sync service instance that will be linked to and accessible by this Deployment. - - :returns: The created DeploymentInstance - """ - - data = values.of( - { - "FriendlyName": friendly_name, - "SyncServiceSid": sync_service_sid, - } - ) - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - payload = await self._version.create_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return DeploymentInstance( - self._version, payload, fleet_sid=self._solution["fleet_sid"] - ) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[DeploymentInstance]: - """ - Streams DeploymentInstance 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[DeploymentInstance]: - """ - Asynchronously streams DeploymentInstance 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[DeploymentInstance]: - """ - Lists DeploymentInstance 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[DeploymentInstance]: - """ - Asynchronously lists DeploymentInstance 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, - ) -> DeploymentPage: - """ - Retrieve a single page of DeploymentInstance 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 DeploymentInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return DeploymentPage(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, - ) -> DeploymentPage: - """ - Asynchronously retrieve a single page of DeploymentInstance 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 DeploymentInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return DeploymentPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> DeploymentPage: - """ - Retrieve a specific page of DeploymentInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of DeploymentInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return DeploymentPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> DeploymentPage: - """ - Asynchronously retrieve a specific page of DeploymentInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of DeploymentInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return DeploymentPage(self._version, response, self._solution) - - def get(self, sid: str) -> DeploymentContext: - """ - Constructs a DeploymentContext - - :param sid: Provides a 34 character string that uniquely identifies the requested Deployment resource. - """ - return DeploymentContext( - self._version, fleet_sid=self._solution["fleet_sid"], sid=sid - ) - - def __call__(self, sid: str) -> DeploymentContext: - """ - Constructs a DeploymentContext - - :param sid: Provides a 34 character string that uniquely identifies the requested Deployment resource. - """ - return DeploymentContext( - self._version, fleet_sid=self._solution["fleet_sid"], sid=sid - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/deployed_devices/fleet/device.py b/twilio/rest/preview/deployed_devices/fleet/device.py deleted file mode 100644 index 3cacc88f2..000000000 --- a/twilio/rest/preview/deployed_devices/fleet/device.py +++ /dev/null @@ -1,700 +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 DeviceInstance(InstanceResource): - """ - :ivar sid: Contains a 34 character string that uniquely identifies this Device resource. - :ivar url: Contains an absolute URL for this Device resource. - :ivar unique_name: Contains a unique and addressable name of this Device, assigned by the developer, up to 128 characters long. - :ivar friendly_name: Contains a human readable descriptive text for this Device, up to 256 characters long - :ivar fleet_sid: Specifies the unique string identifier of the Fleet that the given Device belongs to. - :ivar enabled: Contains a boolean flag indicating whether the device is enabled or not, blocks device connectivity if set to false. - :ivar account_sid: Specifies the unique string identifier of the Account responsible for this Device. - :ivar identity: Contains an arbitrary string identifier representing a human user associated with this Device, assigned by the developer, up to 256 characters long. - :ivar deployment_sid: Specifies the unique string identifier of the Deployment group that this Device is associated with. - :ivar date_created: Specifies the date this Device was created, given in UTC ISO 8601 format. - :ivar date_updated: Specifies the date this Device was last updated, given in UTC ISO 8601 format. - :ivar date_authenticated: Specifies the date this Device was last authenticated, given in UTC ISO 8601 format. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - fleet_sid: str, - sid: Optional[str] = None, - ): - super().__init__(version) - - self.sid: Optional[str] = payload.get("sid") - self.url: Optional[str] = payload.get("url") - self.unique_name: Optional[str] = payload.get("unique_name") - self.friendly_name: Optional[str] = payload.get("friendly_name") - self.fleet_sid: Optional[str] = payload.get("fleet_sid") - self.enabled: Optional[bool] = payload.get("enabled") - self.account_sid: Optional[str] = payload.get("account_sid") - self.identity: Optional[str] = payload.get("identity") - self.deployment_sid: Optional[str] = payload.get("deployment_sid") - 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.date_authenticated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_authenticated") - ) - - self._solution = { - "fleet_sid": fleet_sid, - "sid": sid or self.sid, - } - self._context: Optional[DeviceContext] = None - - @property - def _proxy(self) -> "DeviceContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: DeviceContext for this DeviceInstance - """ - if self._context is None: - self._context = DeviceContext( - self._version, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the DeviceInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the DeviceInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "DeviceInstance": - """ - Fetch the DeviceInstance - - - :returns: The fetched DeviceInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "DeviceInstance": - """ - Asynchronous coroutine to fetch the DeviceInstance - - - :returns: The fetched DeviceInstance - """ - return await self._proxy.fetch_async() - - def update( - self, - friendly_name: Union[str, object] = values.unset, - identity: Union[str, object] = values.unset, - deployment_sid: Union[str, object] = values.unset, - enabled: Union[bool, object] = values.unset, - ) -> "DeviceInstance": - """ - Update the DeviceInstance - - :param friendly_name: Provides a human readable descriptive text to be assigned to this Device, up to 256 characters long. - :param identity: Provides an arbitrary string identifier representing a human user to be associated with this Device, up to 256 characters long. - :param deployment_sid: Specifies the unique string identifier of the Deployment group that this Device is going to be associated with. - :param enabled: - - :returns: The updated DeviceInstance - """ - return self._proxy.update( - friendly_name=friendly_name, - identity=identity, - deployment_sid=deployment_sid, - enabled=enabled, - ) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - identity: Union[str, object] = values.unset, - deployment_sid: Union[str, object] = values.unset, - enabled: Union[bool, object] = values.unset, - ) -> "DeviceInstance": - """ - Asynchronous coroutine to update the DeviceInstance - - :param friendly_name: Provides a human readable descriptive text to be assigned to this Device, up to 256 characters long. - :param identity: Provides an arbitrary string identifier representing a human user to be associated with this Device, up to 256 characters long. - :param deployment_sid: Specifies the unique string identifier of the Deployment group that this Device is going to be associated with. - :param enabled: - - :returns: The updated DeviceInstance - """ - return await self._proxy.update_async( - friendly_name=friendly_name, - identity=identity, - deployment_sid=deployment_sid, - enabled=enabled, - ) - - 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 DeviceContext(InstanceContext): - - def __init__(self, version: Version, fleet_sid: str, sid: str): - """ - Initialize the DeviceContext - - :param version: Version that contains the resource - :param fleet_sid: - :param sid: Provides a 34 character string that uniquely identifies the requested Device resource. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "fleet_sid": fleet_sid, - "sid": sid, - } - self._uri = "/Fleets/{fleet_sid}/Devices/{sid}".format(**self._solution) - - def delete(self) -> bool: - """ - Deletes the DeviceInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the DeviceInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> DeviceInstance: - """ - Fetch the DeviceInstance - - - :returns: The fetched DeviceInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return DeviceInstance( - self._version, - payload, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> DeviceInstance: - """ - Asynchronous coroutine to fetch the DeviceInstance - - - :returns: The fetched DeviceInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return DeviceInstance( - self._version, - payload, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - - def update( - self, - friendly_name: Union[str, object] = values.unset, - identity: Union[str, object] = values.unset, - deployment_sid: Union[str, object] = values.unset, - enabled: Union[bool, object] = values.unset, - ) -> DeviceInstance: - """ - Update the DeviceInstance - - :param friendly_name: Provides a human readable descriptive text to be assigned to this Device, up to 256 characters long. - :param identity: Provides an arbitrary string identifier representing a human user to be associated with this Device, up to 256 characters long. - :param deployment_sid: Specifies the unique string identifier of the Deployment group that this Device is going to be associated with. - :param enabled: - - :returns: The updated DeviceInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "Identity": identity, - "DeploymentSid": deployment_sid, - "Enabled": serialize.boolean_to_string(enabled), - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return DeviceInstance( - self._version, - payload, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - identity: Union[str, object] = values.unset, - deployment_sid: Union[str, object] = values.unset, - enabled: Union[bool, object] = values.unset, - ) -> DeviceInstance: - """ - Asynchronous coroutine to update the DeviceInstance - - :param friendly_name: Provides a human readable descriptive text to be assigned to this Device, up to 256 characters long. - :param identity: Provides an arbitrary string identifier representing a human user to be associated with this Device, up to 256 characters long. - :param deployment_sid: Specifies the unique string identifier of the Deployment group that this Device is going to be associated with. - :param enabled: - - :returns: The updated DeviceInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "Identity": identity, - "DeploymentSid": deployment_sid, - "Enabled": serialize.boolean_to_string(enabled), - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return DeviceInstance( - self._version, - payload, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - - 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 DevicePage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> DeviceInstance: - """ - Build an instance of DeviceInstance - - :param payload: Payload response from the API - """ - return DeviceInstance( - self._version, payload, fleet_sid=self._solution["fleet_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class DeviceList(ListResource): - - def __init__(self, version: Version, fleet_sid: str): - """ - Initialize the DeviceList - - :param version: Version that contains the resource - :param fleet_sid: - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "fleet_sid": fleet_sid, - } - self._uri = "/Fleets/{fleet_sid}/Devices".format(**self._solution) - - def create( - self, - unique_name: Union[str, object] = values.unset, - friendly_name: Union[str, object] = values.unset, - identity: Union[str, object] = values.unset, - deployment_sid: Union[str, object] = values.unset, - enabled: Union[bool, object] = values.unset, - ) -> DeviceInstance: - """ - Create the DeviceInstance - - :param unique_name: Provides a unique and addressable name to be assigned to this Device, to be used in addition to SID, up to 128 characters long. - :param friendly_name: Provides a human readable descriptive text to be assigned to this Device, up to 256 characters long. - :param identity: Provides an arbitrary string identifier representing a human user to be associated with this Device, up to 256 characters long. - :param deployment_sid: Specifies the unique string identifier of the Deployment group that this Device is going to be associated with. - :param enabled: - - :returns: The created DeviceInstance - """ - - data = values.of( - { - "UniqueName": unique_name, - "FriendlyName": friendly_name, - "Identity": identity, - "DeploymentSid": deployment_sid, - "Enabled": serialize.boolean_to_string(enabled), - } - ) - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - payload = self._version.create( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return DeviceInstance( - self._version, payload, fleet_sid=self._solution["fleet_sid"] - ) - - async def create_async( - self, - unique_name: Union[str, object] = values.unset, - friendly_name: Union[str, object] = values.unset, - identity: Union[str, object] = values.unset, - deployment_sid: Union[str, object] = values.unset, - enabled: Union[bool, object] = values.unset, - ) -> DeviceInstance: - """ - Asynchronously create the DeviceInstance - - :param unique_name: Provides a unique and addressable name to be assigned to this Device, to be used in addition to SID, up to 128 characters long. - :param friendly_name: Provides a human readable descriptive text to be assigned to this Device, up to 256 characters long. - :param identity: Provides an arbitrary string identifier representing a human user to be associated with this Device, up to 256 characters long. - :param deployment_sid: Specifies the unique string identifier of the Deployment group that this Device is going to be associated with. - :param enabled: - - :returns: The created DeviceInstance - """ - - data = values.of( - { - "UniqueName": unique_name, - "FriendlyName": friendly_name, - "Identity": identity, - "DeploymentSid": deployment_sid, - "Enabled": serialize.boolean_to_string(enabled), - } - ) - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - payload = await self._version.create_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return DeviceInstance( - self._version, payload, fleet_sid=self._solution["fleet_sid"] - ) - - def stream( - self, - deployment_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[DeviceInstance]: - """ - Streams DeviceInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param str deployment_sid: Filters the resulting list of Devices by a unique string identifier of the Deployment they are associated with. - :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(deployment_sid=deployment_sid, page_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - deployment_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[DeviceInstance]: - """ - Asynchronously streams DeviceInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param str deployment_sid: Filters the resulting list of Devices by a unique string identifier of the Deployment they are associated with. - :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( - deployment_sid=deployment_sid, page_size=limits["page_size"] - ) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - deployment_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[DeviceInstance]: - """ - Lists DeviceInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str deployment_sid: Filters the resulting list of Devices by a unique string identifier of the Deployment they are associated with. - :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( - deployment_sid=deployment_sid, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - deployment_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[DeviceInstance]: - """ - Asynchronously lists DeviceInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str deployment_sid: Filters the resulting list of Devices by a unique string identifier of the Deployment they are associated with. - :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( - deployment_sid=deployment_sid, - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - deployment_sid: Union[str, object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> DevicePage: - """ - Retrieve a single page of DeviceInstance records from the API. - Request is executed immediately - - :param deployment_sid: Filters the resulting list of Devices by a unique string identifier of the Deployment they are associated with. - :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 DeviceInstance - """ - data = values.of( - { - "DeploymentSid": deployment_sid, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return DevicePage(self._version, response, self._solution) - - async def page_async( - self, - deployment_sid: Union[str, object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> DevicePage: - """ - Asynchronously retrieve a single page of DeviceInstance records from the API. - Request is executed immediately - - :param deployment_sid: Filters the resulting list of Devices by a unique string identifier of the Deployment they are associated with. - :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 DeviceInstance - """ - data = values.of( - { - "DeploymentSid": deployment_sid, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return DevicePage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> DevicePage: - """ - Retrieve a specific page of DeviceInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of DeviceInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return DevicePage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> DevicePage: - """ - Asynchronously retrieve a specific page of DeviceInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of DeviceInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return DevicePage(self._version, response, self._solution) - - def get(self, sid: str) -> DeviceContext: - """ - Constructs a DeviceContext - - :param sid: Provides a 34 character string that uniquely identifies the requested Device resource. - """ - return DeviceContext( - self._version, fleet_sid=self._solution["fleet_sid"], sid=sid - ) - - def __call__(self, sid: str) -> DeviceContext: - """ - Constructs a DeviceContext - - :param sid: Provides a 34 character string that uniquely identifies the requested Device resource. - """ - return DeviceContext( - self._version, fleet_sid=self._solution["fleet_sid"], sid=sid - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/deployed_devices/fleet/key.py b/twilio/rest/preview/deployed_devices/fleet/key.py deleted file mode 100644 index 1b7c06e1f..000000000 --- a/twilio/rest/preview/deployed_devices/fleet/key.py +++ /dev/null @@ -1,646 +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 - - -class KeyInstance(InstanceResource): - """ - :ivar sid: Contains a 34 character string that uniquely identifies this Key credential resource. - :ivar url: Contains an absolute URL for this Key credential resource. - :ivar friendly_name: Contains a human readable descriptive text for this Key credential, up to 256 characters long. - :ivar fleet_sid: Specifies the unique string identifier of the Fleet that the given Key credential belongs to. - :ivar account_sid: Specifies the unique string identifier of the Account responsible for this Key credential. - :ivar device_sid: Specifies the unique string identifier of a Device authenticated with this Key credential. - :ivar secret: Contains the automatically generated secret belonging to this Key credential, used to authenticate the Device. - :ivar date_created: Specifies the date this Key credential was created, given in UTC ISO 8601 format. - :ivar date_updated: Specifies the date this Key credential was last updated, given in UTC ISO 8601 format. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - fleet_sid: str, - sid: Optional[str] = None, - ): - super().__init__(version) - - self.sid: Optional[str] = payload.get("sid") - self.url: Optional[str] = payload.get("url") - self.friendly_name: Optional[str] = payload.get("friendly_name") - self.fleet_sid: Optional[str] = payload.get("fleet_sid") - self.account_sid: Optional[str] = payload.get("account_sid") - self.device_sid: Optional[str] = payload.get("device_sid") - self.secret: Optional[str] = payload.get("secret") - 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 = { - "fleet_sid": fleet_sid, - "sid": sid or self.sid, - } - self._context: Optional[KeyContext] = None - - @property - def _proxy(self) -> "KeyContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: KeyContext for this KeyInstance - """ - if self._context is None: - self._context = KeyContext( - self._version, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the KeyInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the KeyInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "KeyInstance": - """ - Fetch the KeyInstance - - - :returns: The fetched KeyInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "KeyInstance": - """ - Asynchronous coroutine to fetch the KeyInstance - - - :returns: The fetched KeyInstance - """ - return await self._proxy.fetch_async() - - def update( - self, - friendly_name: Union[str, object] = values.unset, - device_sid: Union[str, object] = values.unset, - ) -> "KeyInstance": - """ - Update the KeyInstance - - :param friendly_name: Provides a human readable descriptive text for this Key credential, up to 256 characters long. - :param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Key credential. - - :returns: The updated KeyInstance - """ - return self._proxy.update( - friendly_name=friendly_name, - device_sid=device_sid, - ) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - device_sid: Union[str, object] = values.unset, - ) -> "KeyInstance": - """ - Asynchronous coroutine to update the KeyInstance - - :param friendly_name: Provides a human readable descriptive text for this Key credential, up to 256 characters long. - :param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Key credential. - - :returns: The updated KeyInstance - """ - return await self._proxy.update_async( - friendly_name=friendly_name, - device_sid=device_sid, - ) - - 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 KeyContext(InstanceContext): - - def __init__(self, version: Version, fleet_sid: str, sid: str): - """ - Initialize the KeyContext - - :param version: Version that contains the resource - :param fleet_sid: - :param sid: Provides a 34 character string that uniquely identifies the requested Key credential resource. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "fleet_sid": fleet_sid, - "sid": sid, - } - self._uri = "/Fleets/{fleet_sid}/Keys/{sid}".format(**self._solution) - - def delete(self) -> bool: - """ - Deletes the KeyInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the KeyInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> KeyInstance: - """ - Fetch the KeyInstance - - - :returns: The fetched KeyInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return KeyInstance( - self._version, - payload, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> KeyInstance: - """ - Asynchronous coroutine to fetch the KeyInstance - - - :returns: The fetched KeyInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return KeyInstance( - self._version, - payload, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - - def update( - self, - friendly_name: Union[str, object] = values.unset, - device_sid: Union[str, object] = values.unset, - ) -> KeyInstance: - """ - Update the KeyInstance - - :param friendly_name: Provides a human readable descriptive text for this Key credential, up to 256 characters long. - :param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Key credential. - - :returns: The updated KeyInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "DeviceSid": device_sid, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return KeyInstance( - self._version, - payload, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - device_sid: Union[str, object] = values.unset, - ) -> KeyInstance: - """ - Asynchronous coroutine to update the KeyInstance - - :param friendly_name: Provides a human readable descriptive text for this Key credential, up to 256 characters long. - :param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Key credential. - - :returns: The updated KeyInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "DeviceSid": device_sid, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return KeyInstance( - self._version, - payload, - fleet_sid=self._solution["fleet_sid"], - sid=self._solution["sid"], - ) - - 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 KeyPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> KeyInstance: - """ - Build an instance of KeyInstance - - :param payload: Payload response from the API - """ - return KeyInstance( - self._version, payload, fleet_sid=self._solution["fleet_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class KeyList(ListResource): - - def __init__(self, version: Version, fleet_sid: str): - """ - Initialize the KeyList - - :param version: Version that contains the resource - :param fleet_sid: - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "fleet_sid": fleet_sid, - } - self._uri = "/Fleets/{fleet_sid}/Keys".format(**self._solution) - - def create( - self, - friendly_name: Union[str, object] = values.unset, - device_sid: Union[str, object] = values.unset, - ) -> KeyInstance: - """ - Create the KeyInstance - - :param friendly_name: Provides a human readable descriptive text for this Key credential, up to 256 characters long. - :param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Key credential. - - :returns: The created KeyInstance - """ - - data = values.of( - { - "FriendlyName": friendly_name, - "DeviceSid": device_sid, - } - ) - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - payload = self._version.create( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return KeyInstance( - self._version, payload, fleet_sid=self._solution["fleet_sid"] - ) - - async def create_async( - self, - friendly_name: Union[str, object] = values.unset, - device_sid: Union[str, object] = values.unset, - ) -> KeyInstance: - """ - Asynchronously create the KeyInstance - - :param friendly_name: Provides a human readable descriptive text for this Key credential, up to 256 characters long. - :param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Key credential. - - :returns: The created KeyInstance - """ - - data = values.of( - { - "FriendlyName": friendly_name, - "DeviceSid": device_sid, - } - ) - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - payload = await self._version.create_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return KeyInstance( - self._version, payload, fleet_sid=self._solution["fleet_sid"] - ) - - def stream( - self, - device_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[KeyInstance]: - """ - Streams KeyInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param str device_sid: Filters the resulting list of Keys by a unique string identifier of an authenticated Device. - :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(device_sid=device_sid, page_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - device_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[KeyInstance]: - """ - Asynchronously streams KeyInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param str device_sid: Filters the resulting list of Keys by a unique string identifier of an authenticated Device. - :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( - device_sid=device_sid, page_size=limits["page_size"] - ) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - device_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[KeyInstance]: - """ - Lists KeyInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str device_sid: Filters the resulting list of Keys by a unique string identifier of an authenticated Device. - :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( - device_sid=device_sid, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - device_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[KeyInstance]: - """ - Asynchronously lists KeyInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str device_sid: Filters the resulting list of Keys by a unique string identifier of an authenticated Device. - :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( - device_sid=device_sid, - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - device_sid: Union[str, object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> KeyPage: - """ - Retrieve a single page of KeyInstance records from the API. - Request is executed immediately - - :param device_sid: Filters the resulting list of Keys by a unique string identifier of an authenticated Device. - :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 KeyInstance - """ - data = values.of( - { - "DeviceSid": device_sid, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return KeyPage(self._version, response, self._solution) - - async def page_async( - self, - device_sid: Union[str, object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> KeyPage: - """ - Asynchronously retrieve a single page of KeyInstance records from the API. - Request is executed immediately - - :param device_sid: Filters the resulting list of Keys by a unique string identifier of an authenticated Device. - :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 KeyInstance - """ - data = values.of( - { - "DeviceSid": device_sid, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return KeyPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> KeyPage: - """ - Retrieve a specific page of KeyInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of KeyInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return KeyPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> KeyPage: - """ - Asynchronously retrieve a specific page of KeyInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of KeyInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return KeyPage(self._version, response, self._solution) - - def get(self, sid: str) -> KeyContext: - """ - Constructs a KeyContext - - :param sid: Provides a 34 character string that uniquely identifies the requested Key credential resource. - """ - return KeyContext(self._version, fleet_sid=self._solution["fleet_sid"], sid=sid) - - def __call__(self, sid: str) -> KeyContext: - """ - Constructs a KeyContext - - :param sid: Provides a 34 character string that uniquely identifies the requested Key credential resource. - """ - return KeyContext(self._version, fleet_sid=self._solution["fleet_sid"], sid=sid) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/taskrouter/v1/workspace/task/__init__.py b/twilio/rest/taskrouter/v1/workspace/task/__init__.py index 631b8f8bd..ed25dc71d 100644 --- a/twilio/rest/taskrouter/v1/workspace/task/__init__.py +++ b/twilio/rest/taskrouter/v1/workspace/task/__init__.py @@ -193,7 +193,7 @@ def update( :param reason: The reason that the Task was canceled or completed. This parameter is required only if the Task is canceled or completed. Setting this value queues the task for deletion and logs the reason. :param priority: The Task's new priority value. When supplied, the Task takes on the specified priority unless it matches a Workflow Target with a Priority set. Value can be 0 to 2^31^ (2,147,483,647). :param task_channel: When MultiTasking is enabled, specify the TaskChannel with the task to update. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. - :param virtual_start_time: The task's new virtual start time value. When supplied, the Task takes on the specified virtual start time. Value can't be in the future. + :param virtual_start_time: The task's new virtual start time value. When supplied, the Task takes on the specified virtual start time. Value can't be in the future or before the year of 1900. :returns: The updated TaskInstance """ @@ -226,7 +226,7 @@ async def update_async( :param reason: The reason that the Task was canceled or completed. This parameter is required only if the Task is canceled or completed. Setting this value queues the task for deletion and logs the reason. :param priority: The Task's new priority value. When supplied, the Task takes on the specified priority unless it matches a Workflow Target with a Priority set. Value can be 0 to 2^31^ (2,147,483,647). :param task_channel: When MultiTasking is enabled, specify the TaskChannel with the task to update. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. - :param virtual_start_time: The task's new virtual start time value. When supplied, the Task takes on the specified virtual start time. Value can't be in the future. + :param virtual_start_time: The task's new virtual start time value. When supplied, the Task takes on the specified virtual start time. Value can't be in the future or before the year of 1900. :returns: The updated TaskInstance """ @@ -371,7 +371,7 @@ def update( :param reason: The reason that the Task was canceled or completed. This parameter is required only if the Task is canceled or completed. Setting this value queues the task for deletion and logs the reason. :param priority: The Task's new priority value. When supplied, the Task takes on the specified priority unless it matches a Workflow Target with a Priority set. Value can be 0 to 2^31^ (2,147,483,647). :param task_channel: When MultiTasking is enabled, specify the TaskChannel with the task to update. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. - :param virtual_start_time: The task's new virtual start time value. When supplied, the Task takes on the specified virtual start time. Value can't be in the future. + :param virtual_start_time: The task's new virtual start time value. When supplied, the Task takes on the specified virtual start time. Value can't be in the future or before the year of 1900. :returns: The updated TaskInstance """ @@ -421,7 +421,7 @@ async def update_async( :param reason: The reason that the Task was canceled or completed. This parameter is required only if the Task is canceled or completed. Setting this value queues the task for deletion and logs the reason. :param priority: The Task's new priority value. When supplied, the Task takes on the specified priority unless it matches a Workflow Target with a Priority set. Value can be 0 to 2^31^ (2,147,483,647). :param task_channel: When MultiTasking is enabled, specify the TaskChannel with the task to update. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. - :param virtual_start_time: The task's new virtual start time value. When supplied, the Task takes on the specified virtual start time. Value can't be in the future. + :param virtual_start_time: The task's new virtual start time value. When supplied, the Task takes on the specified virtual start time. Value can't be in the future or before the year of 1900. :returns: The updated TaskInstance """ @@ -534,7 +534,7 @@ def create( :param task_channel: When MultiTasking is enabled, specify the TaskChannel by passing either its `unique_name` or `sid`. Default value is `default`. :param workflow_sid: The SID of the Workflow that you would like to handle routing for the new Task. If there is only one Workflow defined for the Workspace that you are posting the new task to, this parameter is optional. :param attributes: A URL-encoded JSON string with the attributes of the new task. This value is passed to the Workflow's `assignment_callback_url` when the Task is assigned to a Worker. For example: `{ \\\"task_type\\\": \\\"call\\\", \\\"twilio_call_sid\\\": \\\"CAxxx\\\", \\\"customer_ticket_number\\\": \\\"12345\\\" }`. - :param virtual_start_time: The virtual start time to assign the new task and override the default. When supplied, the new task will have this virtual start time. When not supplied, the new task will have the virtual start time equal to `date_created`. Value can't be in the future. + :param virtual_start_time: The virtual start time to assign the new task and override the default. When supplied, the new task will have this virtual start time. When not supplied, the new task will have the virtual start time equal to `date_created`. Value can't be in the future or before the year of 1900. :param routing_target: A SID of a Worker, Queue, or Workflow to route a Task to :param ignore_capacity: A boolean that indicates if the Task should respect a Worker's capacity and availability during assignment. This field can only be used when the `RoutingTarget` field is set to a Worker SID. By setting `IgnoreCapacity` to a value of `true`, `1`, or `yes`, the Task will be routed to the Worker without respecting their capacity and availability. Any other value will enforce the Worker's capacity and availability. The default value of `IgnoreCapacity` is `true` when the `RoutingTarget` is set to a Worker SID. :param task_queue_sid: The SID of the TaskQueue in which the Task belongs @@ -585,7 +585,7 @@ async def create_async( :param task_channel: When MultiTasking is enabled, specify the TaskChannel by passing either its `unique_name` or `sid`. Default value is `default`. :param workflow_sid: The SID of the Workflow that you would like to handle routing for the new Task. If there is only one Workflow defined for the Workspace that you are posting the new task to, this parameter is optional. :param attributes: A URL-encoded JSON string with the attributes of the new task. This value is passed to the Workflow's `assignment_callback_url` when the Task is assigned to a Worker. For example: `{ \\\"task_type\\\": \\\"call\\\", \\\"twilio_call_sid\\\": \\\"CAxxx\\\", \\\"customer_ticket_number\\\": \\\"12345\\\" }`. - :param virtual_start_time: The virtual start time to assign the new task and override the default. When supplied, the new task will have this virtual start time. When not supplied, the new task will have the virtual start time equal to `date_created`. Value can't be in the future. + :param virtual_start_time: The virtual start time to assign the new task and override the default. When supplied, the new task will have this virtual start time. When not supplied, the new task will have the virtual start time equal to `date_created`. Value can't be in the future or before the year of 1900. :param routing_target: A SID of a Worker, Queue, or Workflow to route a Task to :param ignore_capacity: A boolean that indicates if the Task should respect a Worker's capacity and availability during assignment. This field can only be used when the `RoutingTarget` field is set to a Worker SID. By setting `IgnoreCapacity` to a value of `true`, `1`, or `yes`, the Task will be routed to the Worker without respecting their capacity and availability. Any other value will enforce the Worker's capacity and availability. The default value of `IgnoreCapacity` is `true` when the `RoutingTarget` is set to a Worker SID. :param task_queue_sid: The SID of the TaskQueue in which the Task belongs diff --git a/twilio/rest/verify/v2/service/verification.py b/twilio/rest/verify/v2/service/verification.py index c8deef535..23a956b65 100644 --- a/twilio/rest/verify/v2/service/verification.py +++ b/twilio/rest/verify/v2/service/verification.py @@ -325,6 +325,7 @@ def create( template_sid: Union[str, object] = values.unset, template_custom_substitutions: Union[str, object] = values.unset, device_ip: Union[str, object] = values.unset, + enable_sna_client_token: Union[bool, object] = values.unset, risk_check: Union["VerificationInstance.RiskCheck", object] = values.unset, tags: Union[str, object] = values.unset, ) -> VerificationInstance: @@ -346,6 +347,7 @@ def create( :param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. :param template_custom_substitutions: A stringified JSON object in which the keys are the template's special variables and the values are the variables substitutions. :param device_ip: Strongly encouraged if using the auto channel. The IP address of the client's device. If provided, it has to be a valid IPv4 or IPv6 address. + :param enable_sna_client_token: An optional Boolean value to indicate the requirement of sna client token in the SNA URL invocation response for added security. This token must match in the Verification Check request to confirm phone number verification. :param risk_check: :param tags: A string containing a JSON map of key value pairs of tags to be recorded as metadata for the message. The object may contain up to 10 tags. Keys and values can each be up to 128 characters in length. @@ -369,6 +371,9 @@ def create( "TemplateSid": template_sid, "TemplateCustomSubstitutions": template_custom_substitutions, "DeviceIp": device_ip, + "EnableSnaClientToken": serialize.boolean_to_string( + enable_sna_client_token + ), "RiskCheck": risk_check, "Tags": tags, } @@ -400,6 +405,7 @@ async def create_async( template_sid: Union[str, object] = values.unset, template_custom_substitutions: Union[str, object] = values.unset, device_ip: Union[str, object] = values.unset, + enable_sna_client_token: Union[bool, object] = values.unset, risk_check: Union["VerificationInstance.RiskCheck", object] = values.unset, tags: Union[str, object] = values.unset, ) -> VerificationInstance: @@ -421,6 +427,7 @@ async def create_async( :param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. :param template_custom_substitutions: A stringified JSON object in which the keys are the template's special variables and the values are the variables substitutions. :param device_ip: Strongly encouraged if using the auto channel. The IP address of the client's device. If provided, it has to be a valid IPv4 or IPv6 address. + :param enable_sna_client_token: An optional Boolean value to indicate the requirement of sna client token in the SNA URL invocation response for added security. This token must match in the Verification Check request to confirm phone number verification. :param risk_check: :param tags: A string containing a JSON map of key value pairs of tags to be recorded as metadata for the message. The object may contain up to 10 tags. Keys and values can each be up to 128 characters in length. @@ -444,6 +451,9 @@ async def create_async( "TemplateSid": template_sid, "TemplateCustomSubstitutions": template_custom_substitutions, "DeviceIp": device_ip, + "EnableSnaClientToken": serialize.boolean_to_string( + enable_sna_client_token + ), "RiskCheck": risk_check, "Tags": tags, } diff --git a/twilio/rest/verify/v2/service/verification_check.py b/twilio/rest/verify/v2/service/verification_check.py index af216a39f..fd1b3f897 100644 --- a/twilio/rest/verify/v2/service/verification_check.py +++ b/twilio/rest/verify/v2/service/verification_check.py @@ -108,6 +108,7 @@ def create( verification_sid: Union[str, object] = values.unset, amount: Union[str, object] = values.unset, payee: Union[str, object] = values.unset, + sna_client_token: Union[str, object] = values.unset, ) -> VerificationCheckInstance: """ Create the VerificationCheckInstance @@ -117,6 +118,7 @@ def create( :param verification_sid: A SID that uniquely identifies the Verification Check. Either this parameter or the `to` phone number/[email](https://www.twilio.com/docs/verify/email) must be specified. :param amount: The amount of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled. :param payee: The payee of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled. + :param sna_client_token: A sna client token received in sna url invocation response needs to be passed in Verification Check request and should match to get successful response. :returns: The created VerificationCheckInstance """ @@ -128,6 +130,7 @@ def create( "VerificationSid": verification_sid, "Amount": amount, "Payee": payee, + "SnaClientToken": sna_client_token, } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) @@ -147,6 +150,7 @@ async def create_async( verification_sid: Union[str, object] = values.unset, amount: Union[str, object] = values.unset, payee: Union[str, object] = values.unset, + sna_client_token: Union[str, object] = values.unset, ) -> VerificationCheckInstance: """ Asynchronously create the VerificationCheckInstance @@ -156,6 +160,7 @@ async def create_async( :param verification_sid: A SID that uniquely identifies the Verification Check. Either this parameter or the `to` phone number/[email](https://www.twilio.com/docs/verify/email) must be specified. :param amount: The amount of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled. :param payee: The payee of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled. + :param sna_client_token: A sna client token received in sna url invocation response needs to be passed in Verification Check request and should match to get successful response. :returns: The created VerificationCheckInstance """ @@ -167,6 +172,7 @@ async def create_async( "VerificationSid": verification_sid, "Amount": amount, "Payee": payee, + "SnaClientToken": sna_client_token, } ) headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) From 69b9ae8b978aef665c56ff4e3ab09004d505a679 Mon Sep 17 00:00:00 2001 From: Twilio Date: Thu, 3 Oct 2024 15:43:07 +0000 Subject: [PATCH 36/37] Release 9.3.3 --- setup.py | 2 +- twilio/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index be0c82e70..911ec6d8a 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setup( name="twilio", - version="9.3.2", + version="9.3.3", 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 9c85cf3a4..e5ba728ee 100644 --- a/twilio/__init__.py +++ b/twilio/__init__.py @@ -1,2 +1,2 @@ -__version_info__ = ("9", "3", "2") +__version_info__ = ("9", "3", "3") __version__ = ".".join(__version_info__) From 35b5015909953ee62871e8ce03036fae647ee4df Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Sun, 6 Oct 2024 14:11:11 +0530 Subject: [PATCH 37/37] Uptake of review comments --- twilio/auth_strategy/token_auth_strategy.py | 27 ++++++++++++------- twilio/base/client_base.py | 9 +++++-- twilio/credential/orgs_credential_provider.py | 6 +++-- twilio/http/http_client.py | 6 +---- twilio/rest/__init__.py | 1 + 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/twilio/auth_strategy/token_auth_strategy.py b/twilio/auth_strategy/token_auth_strategy.py index 88b0d787f..a21ea44be 100644 --- a/twilio/auth_strategy/token_auth_strategy.py +++ b/twilio/auth_strategy/token_auth_strategy.py @@ -18,8 +18,7 @@ def __init__(self, token_manager: TokenManager): self.logger = logging.getLogger(__name__) def get_auth_string(self) -> str: - if self.token is None: - self.fetch_token() + self.fetch_token() return f"Bearer {self.token}" def requires_authentication(self) -> bool: @@ -28,15 +27,23 @@ def requires_authentication(self) -> bool: def fetch_token(self): self.logger.info("New token fetched for accessing organization API") if self.token is None or self.token == "" or self.is_token_expired(self.token): - with self.lock: + with self.lock: if self.token is None or self.token == "" or self.is_token_expired(self.token): self.token = self.token_manager.fetch_access_token() def is_token_expired(self, token): - print(f'token is {token}') - decoded_jwt = jwt.decode(token, options={"verify_signature": True}, algorithms=["RS256"]) - expires_at = decoded_jwt.get("exp") - # Add a buffer of 30 seconds - buffer_seconds = 30 - buffer_expires_at = expires_at - buffer_seconds - return buffer_expires_at < datetime.datetime.now().timestamp() \ No newline at end of file + try: + decoded = jwt.decode(token, options={"verify_signature": False}) + exp = decoded.get('exp') + + if exp is None: + return True # No expiration time present, consider it expired + + # Check if the expiration time has passed + return datetime.fromtimestamp(exp) < datetime.utcnow() + + except jwt.DecodeError: + return True # Token is invalid + except Exception as e: + print(f"An error occurred: {e}") + return True \ No newline at end of file diff --git a/twilio/base/client_base.py b/twilio/base/client_base.py index 1fdc689ea..8526bdd33 100644 --- a/twilio/base/client_base.py +++ b/twilio/base/client_base.py @@ -96,8 +96,10 @@ def request( if self.credential_provider: auth_strategy = self.credential_provider.to_auth_strategy() headers["Authorization"] = auth_strategy.get_auth_string() - else: + elif self.username is not None and self.password is not None: auth = self.get_auth(auth) + else: + auth = None uri = self.get_hostname(uri) @@ -150,11 +152,14 @@ async def request_async( ##If credential provider is provided by user, get the associated auth strategy ##Using the auth strategy, fetch the auth string and set it to authorization header + if self.credential_provider: auth_strategy = self.credential_provider.to_auth_strategy() headers["Authorization"] = auth_strategy.get_auth_string() - else: + elif self.username is not None and self.password is not None: auth = self.get_auth(auth) + else: + auth = None uri = self.get_hostname(uri) diff --git a/twilio/credential/orgs_credential_provider.py b/twilio/credential/orgs_credential_provider.py index 4e58271a9..6ec31441e 100644 --- a/twilio/credential/orgs_credential_provider.py +++ b/twilio/credential/orgs_credential_provider.py @@ -18,9 +18,11 @@ def __init__(self, client_id: str, client_secret: str, token_manager=None): self.client_id = client_id self.client_secret = client_secret self.token_manager = token_manager + self.auth_strategy = None def to_auth_strategy(self): if self.token_manager is None: self.token_manager = OrgTokenManager(self.grant_type, self.client_id, self.client_secret) - - return TokenAuthStrategy(self.token_manager) + if self.auth_strategy is None: + self.auth_strategy = TokenAuthStrategy(self.token_manager) + return self.auth_strategy diff --git a/twilio/http/http_client.py b/twilio/http/http_client.py index 0e3e7638f..27617fb7a 100644 --- a/twilio/http/http_client.py +++ b/twilio/http/http_client.py @@ -78,11 +78,6 @@ def request( elif timeout <= 0: raise ValueError(timeout) - if headers: - if "Requires-Authentication" in headers: - headers.pop("Requires-Authentication", None) - auth = None - kwargs = { "method": method.upper(), "url": url, @@ -96,6 +91,7 @@ def request( else: kwargs["data"] = data self.log_request(kwargs) + print(f'args : {kwargs}') self._test_only_last_response = None session = self.session or Session() request = Request(**kwargs) diff --git a/twilio/rest/__init__.py b/twilio/rest/__init__.py index 458168fa2..7874236a2 100644 --- a/twilio/rest/__init__.py +++ b/twilio/rest/__init__.py @@ -136,6 +136,7 @@ def __init__( self._events: Optional["Events"] = None self._flex_api: Optional["FlexApi"] = None self._frontline_api: Optional["FrontlineApi"] = None + self._iam: Optional["Iam"] = None self._preview_iam: Optional["PreviewIam"] = None self._insights: Optional["Insights"] = None self._intelligence: Optional["Intelligence"] = None